diff options
Diffstat (limited to 'src/core-commands.c')
| -rw-r--r-- | src/core-commands.c | 126 |
1 files changed, 65 insertions, 61 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index cd9a8fa..d2c8b9d 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -1739,8 +1739,10 @@ TECO_DEFINE_STATE(teco_state_ascii, /*$ ^[^[ ^[$ $$ ^C terminate return * [a1,a2,...]$$ -- Terminate command line or return from macro + * -$$ * [a1,a2,...]^[$ * [a1,a2,...]^C + * -^C * * Returns from the current macro invocation. * This will pass control to the calling macro immediately @@ -1754,6 +1756,8 @@ TECO_DEFINE_STATE(teco_state_ascii, * All braces opened in the current macro invocation will * be closed and their values discarded. * Only the direct arguments to \fB$$\fP will be kept. + * If the prefix sign is set (\(lq-\fB$$\fP\(rq) the command + * will always leave -1 on the stack. * * Returning from the top-level macro in batch mode * will exit the program or start up interactive mode depending @@ -1806,6 +1810,9 @@ teco_return(teco_machine_main_t *ctx, GError **error) ctx->parent.current = &teco_state_start; if (!teco_expressions_eval(FALSE, error)) return NULL; + if (teco_num_sign < 0) + /* only if you wrote -$$ */ + teco_expressions_push(1); teco_error_return_set(error, teco_expressions_args()); return NULL; } @@ -1873,6 +1880,18 @@ TECO_DEFINE_STATE_START(teco_state_escape, .end_of_macro_cb = teco_state_escape_end_of_macro ); +static gboolean +teco_state_ctlc_initial(teco_machine_main_t *ctx, GError **error) +{ + if (G_UNLIKELY(ctx == &teco_cmdline.machine)) { + g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED, + "<^C> is not allowed to terminate command-lines"); + return FALSE; + } + + return TRUE; +} + /* * Just like ^[, ^C actually implements a lookahead, * so a ^C itself does nothing. @@ -1892,20 +1911,20 @@ teco_state_ctlc_input(teco_machine_main_t *ctx, gunichar chr, GError **error) } static gboolean -teco_state_ctlc_initial(teco_machine_main_t *ctx, GError **error) +teco_state_ctlc_end_of_macro(teco_machine_main_t *ctx, GError **error) { - if (G_UNLIKELY(ctx == &teco_cmdline.machine)) { - g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED, - "<^C> is not allowed to terminate command-lines"); - return FALSE; - } - + if (ctx->flags.mode > TECO_MODE_NORMAL) + return TRUE; + if (teco_num_sign < 0) + /* only if you wrote -^C */ + teco_expressions_push(1); return TRUE; } TECO_DEFINE_STATE_START(teco_state_ctlc, .initial_cb = (teco_state_initial_cb_t)teco_state_ctlc_initial, - .input_cb = (teco_state_input_cb_t)teco_state_ctlc_input + .input_cb = (teco_state_input_cb_t)teco_state_ctlc_input, + .end_of_macro_cb = (teco_state_end_of_macro_cb_t)teco_state_ctlc_end_of_macro ); static teco_state_t * @@ -2117,46 +2136,35 @@ teco_state_ecommand_flags(teco_machine_main_t *ctx, GError **error) * first. * Memory limiting is enabled by default. * .IP 3: - * This \fBwrite-only\fP property allows redefining the - * first 16 entries of the terminal color palette \(em a - * feature required by some - * color schemes when using the Curses user interface. - * When setting this property, you are making a request - * to define the terminal \fIcolor\fP as the Scintilla-compatible - * RGB color value given in the \fIrgb\fP parameter. - * \fIcolor\fP must be a value between 0 and 15 - * corresponding to black, red, green, yellow, blue, magenta, - * cyan, white, bright black, bright red, etc. in that order. - * The \fIrgb\fP value has the format 0xBBGGRR, i.e. the red - * component is the least-significant byte and all other bytes - * are ignored. - * Note that on curses, RGB color values sent to Scintilla - * are actually mapped to these 16 colors by the Scinterm port - * and may represent colors with no resemblance to the \(lqRGB\(rq - * value used (depending on the current palette) \(em they should - * instead be viewed as placeholders for 16 standard terminal - * color codes. - * Please refer to the Scinterm manual for details on the allowed - * \(lqRGB\(rq values and how they map to terminal colors. - * This command provides a crude way to request exact RGB colors - * for the first 16 terminal colors. - * The color definition may be queued or be completely ignored - * on other user interfaces and no feedback is given - * if it fails. In fact feedback cannot be given reliably anyway. - * Note that on 8 color terminals, only the first 8 colors - * can be redefined (if you are lucky). - * Note that due to restrictions of most terminal emulators - * and some curses implementations, this command simply will not - * restore the original palette entry or request - * when rubbed out and should generally only be used in - * \fIbatch-mode\fP \(em typically when loading a color scheme. - * For the same reasons \(em even though \*(ST tries hard to - * restore the original palette on exit \(em palette changes may - * persist after \*(ST terminates on most terminal emulators on Unix. - * The only emulator which will restore their default palette - * on exit the author is aware of is \fBxterm\fP(1) and - * the Linux console driver. - * You have been warned. Good luck. + * This \fBwrite-only\fP property allows disabling use of + * the 16 color palette of default colors when using + * the Curses user interface. + * By default, when working with RGB values in Scintilla + * messages (and \*(ST color schemes for that matter) + * the 16 \(lqdefault\(rq colors are represented by + * special RGB placeholders (e.g. 0x000080 for \fICOLOR_RED\fP) + * as documented in the Scinterm manual. + * Any other RGB values will be automatically allocated + * in the terminal emulator if supported, giving the illusion + * of true color support, even though the actual number of + * concurrent colors on screen may be limited by the terminal + * emulator (see \fImax_colors\fP and \fImax_pairs\fP + * .B terminfo (1) + * capabilities) and other factors. + * \*(ST tries to avoid the first 16 color ids so as not to + * interfer with other terminal-based applications. + * The default palette however may be overwritten when requesting + * new colors in terminals restricted to 16 colors. + * In this case the original palette might not be restored properly on + * program termination and affect other terminal applications. + * The 16 predefined colors do not map to exact RGB values, + * though, but point into a palette at the terminal emulator. + * \*(ST therefore allows you to disable the 16 RGB placeholders + * by calling \(lq0,3EJ\(rq so that all colors are freshly initialized + * and will represent their exact RGB values. + * It has no effect when using the GTK interface. + * You are recommended to add \(lq0,3EJ\(rq to all color + * schemes that rely on exact RGB values. * .IP 4: * The column after the last horizontal movement. * This is only used by \fBfnkeys.tes\fP and is similar to the Scintilla-internal @@ -2169,12 +2177,14 @@ teco_state_ecommand_flags(teco_machine_main_t *ctx, GError **error) * .IP 6: * .SCITECO_TOPIC recovery * Interval in seconds for the creation of recovery files - * or 0 if those dumps are disabled (the default is 300 seconds). + * or 0 if those dumps are disabled (the default is 120 seconds). * When enabled all dirty buffers are dumped to files with hash * signs around the original basename (\fB#\fIfilename\fB#\fR). * They are removed automatically when no longer required, * but may be left around when the \*(ST crashes or terminates * unexpectedly. + * During graceful shutdowns (\fBSIGTERM\fP etc.) recovery + * files may be dumped immediately even before the interval expires. * After changing the interval, the new value may become * active only after the previous interval expires. * Recovery files are not dumped in batch mode. @@ -2229,7 +2239,7 @@ teco_state_ecommand_properties(teco_machine_main_t *ctx, GError **error) EJ_USER_INTERFACE = 0, EJ_BUFFERS, EJ_MEMORY_LIMIT, - EJ_INIT_COLOR, + EJ_PALETTE, EJ_CARETX, EJ_CMDLINE_HEIGHT, EJ_RECOVERY_INTERVAL @@ -2253,19 +2263,13 @@ teco_state_ecommand_properties(teco_machine_main_t *ctx, GError **error) return; break; - case EJ_INIT_COLOR: - if (value < 0 || value >= 16) { - g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED, - "Invalid color code %" TECO_INT_FORMAT " " - "specified for <EJ>", value); - return; - } - if (!teco_expressions_args()) { - teco_error_argexpected_set(error, "EJ"); + case EJ_PALETTE: + if (teco_is_success(value)) { + g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED, + "Default color palette can only be disabled"); return; } - teco_interface_init_color((guint)value, - (guint32)teco_expressions_pop_num(0)); + teco_interface_disable_palette(); break; case EJ_CARETX: |
