diff options
| author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-18 16:24:32 +0200 |
|---|---|---|
| committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-22 04:05:02 +0200 |
| commit | 8101cec729c07fd5bdeda70c12dbb43a2383cbe8 (patch) | |
| tree | 41b212abb27bfe432e9de526425651c35652577a /src/qregisters.cpp | |
| parent | 5cc4daf4d51c4f17a824bd8a3ce04257e865f02c (diff) | |
major Curses UI revision: initialize curses as late as possible
* relies on a patched version of Scinterm that allows you to
construct Scintilla objects, send messages etc. before Curses
is initialized.
The Scintilla and Scinterm submodules have been updated.
* This once and for all fixes batch mode and stdio redirections
in batch mode on all Curses platforms and operating systems.
* Fixes the ^C-does-not-interrupt bug on ncurses/UNIX.
See #4.
* On ncurses/UNIX we will still do a newterm()-initialization.
This allows us to keep stdout/stderr alone in case they are
redirected. This effectively allows redirecting SciTECO's
output into a file even in interactive mode.
ncurses/UNIX now behaves like, e.g. PDCurses/win32a and GTK+
in this regard.
* Curses environment variable handling fixed.
The environment registers are exported into the process environment
so that Curses environment variables can be set/modified by the
SciTECO profile.
* Use term.h for accessing terminfo now.
Explained set_window_title() limitations.
* fixed interruption via SIGINT. If the UI is waiting for user
input, SIGINT is effectively ignored instead of letting the
next character fail always.
* Updated sciteco(1) and sciteco(7): More options, environment variables
and signals documented. Also rewritten DESCRIPTION section
(different modes of operation).
Diffstat (limited to 'src/qregisters.cpp')
| -rw-r--r-- | src/qregisters.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/qregisters.cpp b/src/qregisters.cpp index 22d7300..ef47627 100644 --- a/src/qregisters.cpp +++ b/src/qregisters.cpp @@ -529,6 +529,16 @@ QRegisterTable::edit(QRegister *reg) QRegisters::current = reg; } +/** + * Import process environment into table + * by setting environment registers for every + * environment variable. + * It is assumed that the table does not yet + * contain any environment register. + * + * In general this method is only safe to call + * at startup. + */ void QRegisterTable::set_environ(void) { @@ -553,6 +563,13 @@ QRegisterTable::set_environ(void) g_strfreev(env); } +/** + * Export environment registers as a list of environment + * variables compatible with `g_get_environ()`. + * + * @return Zero-terminated list of strings in the form + * `NAME=VALUE`. Should be freed with `g_strfreev()`. + */ gchar ** QRegisterTable::get_environ(void) { @@ -601,6 +618,40 @@ QRegisterTable::get_environ(void) } /** + * Update process environment with environment registers + * using `g_setenv()`. + * It does not try to unset environment variables that + * are no longer in the Q-Register table. + * + * This method may be dangerous in a multi-threaded environment + * but may be necessary for libraries that access important + * environment variables internally without providing alternative + * APIs. + */ +void +QRegisterTable::update_environ(void) +{ + for (QRegister *cur = nfind("$"); + cur && cur->name[0] == '$'; + cur = (QRegister *)cur->next()) { + gchar *value; + + /* + * Ignore the "$" register (not an environment + * variable register) and registers whose + * name contains "=" (not allowed in environment + * variable names). + */ + if (!cur->name[1] || strchr(cur->name+1, '=')) + continue; + + value = cur->get_string(); + g_setenv(cur->name+1, value, TRUE); + g_free(value); + } +} + +/** * Free resources associated with table. * * This is similar to RBTree::clear() but |
