aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core-commands.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-26 02:00:18 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-26 02:00:18 +0200
commit282fa65c0d547c89eac6cd4c7e91496a280bece7 (patch)
treea66ff298a5ec0d14e8bbc836e4e0bcbbd437a44d /src/core-commands.c
parentcdcbab03107fd74855cfd201161bd116b2eebba8 (diff)
Curses: support arbitrary RGB colorsHEADmaster-fmsbw-cimaster
* Instead of supporting only 16 predefined RGB placeholder values in Scintilla messages and styles, you can now use arbitrary RGB values and colors are allocated via the terminal on the fly. You no longer need to call 3EJ to change the default color palette. * The placeholder RGB values are still available. Since you will usually want exact RGB values when using anything outside of the range of 16 default colors and the RGB placeholders will not always exactly correspond to their RGB value, you can now call `0,3EJ` to ignore the default palette and allocate all colors dynamically. * Allows for more than 16 colors on the screen simultaneously. Also simplifies the solarized.tes color scheme. Since both Scinterm and SciTECO try not to touch the 16 default colors, you also no longer have to deal with restoring the palette after program termination (which was never reliable anyway). * Color schemes with non-default colors (solarized.tes) may now be broken on TERM=linux-16color (Linux VT) since Scinterm will get only 8 colors, but solarized.tes needs 16.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r--src/core-commands.c87
1 files changed, 35 insertions, 52 deletions
diff --git a/src/core-commands.c b/src/core-commands.c
index 2dc1da7..d2c8b9d 100644
--- a/src/core-commands.c
+++ b/src/core-commands.c
@@ -2136,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
@@ -2250,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
@@ -2274,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: