From 229512ea95752a6d424666c1608caf054c056b3d Mon Sep 17 00:00:00 2001 From: ANSI TV Admin Date: Wed, 11 Nov 2026 13:22:44 -0800 Subject: [PATCH 19/24] Exclusive border: the 15 DOS colours, from the active palette "Exclusive Border Colour" now offers the 15 visible DOS colours by name, in DOS order (Blue ... White; Black left out), picked from a list. The frame's colour is looked up in the active palette each frame (bitmap_attr_rgb), so a custom palette or theme still matches. The default is DOS Cyan (colour 3, 00A8A8 in the stock palette) instead of the bright cyan (00FFFF) the first version drew, which was too bright. Stored as ExclusiveMouseBorderDOSColour; a test3 ExclusiveMouseBorderColour value is carried over to the nearest DOS colour (its default, Cyan, becomes DOS Cyan) and the old key is dropped on the next save. Co-Authored-By: Claude Opus 5.5 --- src/conio/bitmap_con.c | 10 ++++++ src/conio/bitmap_con.h | 2 ++ src/conio/ciolib.h | 9 +++--- src/conio/sdl_con.c | 17 ++++++---- src/syncterm/menu_settings.c | 3 +- src/syncterm/scripts/menu_settings_ui.wren | 19 ++++++++--- src/syncterm/syncterm.c | 37 ++++++++++------------ src/syncterm/syncterm.h | 2 +- src/syncterm/wren_bind_menu_settings.c | 2 +- 9 files changed, 62 insertions(+), 39 deletions(-) diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c index b205a304..a85a65cb 100644 --- a/src/conio/bitmap_con.c +++ b/src/conio/bitmap_con.c @@ -3197,6 +3197,16 @@ int bitmap_drv_init(void (*drawrect_cb) (struct rectlist *data) return(0); } +uint32_t bitmap_attr_rgb(int attr) +{ + uint32_t rgb; + + assert_rwlock_rdlock(&vstatlock); + rgb = color_value(vstat.palette[attr & 15]); + assert_rwlock_unlock(&vstatlock); + return rgb; +} + void bitmap_drv_request_pixels(void) { assert_pthread_mutex_lock(&screenlock); diff --git a/src/conio/bitmap_con.h b/src/conio/bitmap_con.h index 6ab2d97a..a4b685a0 100644 --- a/src/conio/bitmap_con.h +++ b/src/conio/bitmap_con.h @@ -30,6 +30,8 @@ int bitmap_drv_init_mode(int mode, int *width, int *height, int maxwidth, int ma int bitmap_drv_init(void (*drawrect_cb) (struct rectlist *data) ,void (*flush) (void)); void bitmap_drv_request_pixels(void); +/* RGB (0xRRGGBB) of text attribute colour 0-15 in the active palette. */ +uint32_t bitmap_attr_rgb(int attr); void bitmap_drv_request_some_pixels(int x, int y, int width, int height); void bitmap_drv_free_rect(struct rectlist *rect); void bitmap_snap(bool grow, int maxwidth, int maxheight); diff --git a/src/conio/ciolib.h b/src/conio/ciolib.h index a4e9fa70..1afb9841 100644 --- a/src/conio/ciolib.h +++ b/src/conio/ciolib.h @@ -926,9 +926,10 @@ CIOLIBEXPORT int ciolib_set_mouse_exclusive(int on); CIOLIBEXPORT void ciolib_set_mouse_edge_motion(int on); /* A coloured frame round the picture while the mouse is captured * (exclusive mode) and the window has focus: width in window pixels - * (0 = off) and colour as 0xRRGGBB. Program Settings "Exclusive Mouse - * Border". The picture is never covered: it keeps its size when the - * window margin has room, else shrinks just enough to clear the frame. */ -CIOLIBEXPORT void ciolib_set_exclusive_border(int px, uint32_t rgb); + * (0 = off) and colour as a text attribute colour 1-15, looked up in the + * active palette when drawn. Program Settings "Exclusive Mouse Border". + * The picture is never covered: it keeps its size when the window margin + * has room, else shrinks just enough to clear the frame. */ +CIOLIBEXPORT void ciolib_set_exclusive_border(int px, int attr); #endif /* Do not add anything after this line */ diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index 48335b0d..06df9a39 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -94,7 +94,7 @@ static int sdl_last_x = 0, sdl_last_y = 0; /* last real pointer position */ * Event thread only, except the settings, which are plain ints. */ static int sdl_xborder_px = 4; /* configured width, 0 = off */ -static uint32_t sdl_xborder_rgb = 0x00FFFF; /* configured colour */ +static int sdl_xborder_attr = 3; /* configured colour: DOS attribute 1-15 */ static int sdl_focused = 1; /* window has keyboard focus */ static int sdl_xborder_cur = 0; /* width in force */ @@ -968,7 +968,7 @@ sdl_xborder_refresh(void) } CIOLIBEXPORT void -ciolib_set_exclusive_border(int px, uint32_t rgb) +ciolib_set_exclusive_border(int px, int attr) { int recolour; @@ -976,9 +976,11 @@ ciolib_set_exclusive_border(int px, uint32_t rgb) px = 0; if (px > 32) px = 32; - recolour = (sdl_xborder_rgb != (rgb & 0xFFFFFF)); + if (attr < 1 || attr > 15) + attr = 3; + recolour = (sdl_xborder_attr != attr); sdl_xborder_px = px; - sdl_xborder_rgb = rgb & 0xFFFFFF; + sdl_xborder_attr = attr; sdl_xborder_refresh(); if (recolour && sdl_xborder_cur > 0) bitmap_drv_request_pixels(); @@ -1029,6 +1031,7 @@ sdl_draw_xborder(int winw, int winh, int pw, int ph) { int b = sdl_xborder_cur; int x, y, w, h; + uint32_t rgb; Uint8 or, og, ob, oa; SDL_Rect r[4]; @@ -1061,8 +1064,10 @@ sdl_draw_xborder(int winw, int winh, int pw, int ph) or = og = ob = 0; oa = 255; } - sdl.SetRenderDrawColor(renderer, (sdl_xborder_rgb >> 16) & 0xFF, - (sdl_xborder_rgb >> 8) & 0xFF, sdl_xborder_rgb & 0xFF, 255); + /* Looked up per frame, so a custom palette or theme still matches. */ + rgb = bitmap_attr_rgb(sdl_xborder_attr); + sdl.SetRenderDrawColor(renderer, (rgb >> 16) & 0xFF, + (rgb >> 8) & 0xFF, rgb & 0xFF, 255); sdl.RenderFillRects(renderer, r, 4); /* RenderClear uses the draw colour: put it back for the next frame. */ sdl.SetRenderDrawColor(renderer, or, og, ob, oa); diff --git a/src/syncterm/menu_settings.c b/src/syncterm/menu_settings.c index a54cef1e..740163a0 100644 --- a/src/syncterm/menu_settings.c +++ b/src/syncterm/menu_settings.c @@ -107,8 +107,9 @@ set_ini_values(str_list_t *ini, const struct syncterm_settings *set) &ini_style); iniSetInteger(ini, "SyncTERM", "ExclusiveMouseBorder", set->exclusive_border, &ini_style); - iniSetInteger(ini, "SyncTERM", "ExclusiveMouseBorderColour", + iniSetInteger(ini, "SyncTERM", "ExclusiveMouseBorderDOSColour", set->exclusive_border_colour, &ini_style); + iniRemoveKey(ini, "SyncTERM", "ExclusiveMouseBorderColour"); /* test3 key */ iniSetBool(ini, "SyncTERM", "InvertMouseWheel", set->invert_wheel, &ini_style); iniSetString(ini, "SyncTERM", "KeyDerivationIterations", diff --git a/src/syncterm/scripts/menu_settings_ui.wren b/src/syncterm/scripts/menu_settings_ui.wren index a146c769..05091a3f 100644 --- a/src/syncterm/scripts/menu_settings_ui.wren +++ b/src/syncterm/scripts/menu_settings_ui.wren @@ -460,9 +460,11 @@ class SettingsMenu { static yesNo_(value) { value ? "Yes" : "No" } - // Same order as exclusive_border_colours[] in syncterm.c. + // DOS colours 1-15 (Black left out); item i is colour i + 1. static borderColours_ { - return ["Cyan", "Magenta", "Yellow", "Green", "Orange", "Red", "White", "Blue"] + return ["Blue", "Green", "Cyan", "Red", "Magenta", "Brown", "Light Gray", + "Dark Gray", "Light Blue", "Light Green", "Light Cyan", "Light Red", + "Light Magenta", "Yellow", "White"] } static audioSummary_(s) { @@ -508,7 +510,7 @@ class SettingsMenu { "Let a game (e.g. /quake) capture the mouse and keep turning past the window edges; Ctrl+Alt releases") + helpItem_("Exclusive Mouse Border", "A coloured frame round the screen while the mouse is captured; Off, 2, 4, 6 or 8 pixels") + - helpItem_("Exclusive Border Colour", "The colour of that frame") + + helpItem_("Exclusive Border Colour", "The frame's colour: any of the 15 DOS colours, from the active palette") + helpItem_("Exclusive Mouse Mode", "Capture the mouse in every session; press Ctrl+Alt together to release it to the OS, click to take it back") + helpItem_("Key Derivation Shift", "The scrypt cost used for list encryption") + @@ -758,7 +760,7 @@ class SettingsMenu { rows.add([25, settingsLine_("Exclusive Mouse Border", s.exclusiveBorder == 0 ? "Off" : "%(s.exclusiveBorder) px")]) rows.add([26, settingsLine_("Exclusive Border Colour", - borderColours_[s.exclusiveBorderColour])]) + borderColours_[s.exclusiveBorderColour - 1])]) rows.add([17, settingsLine_("Key Derivation Shift", s.kdfShift)]) rows.add([18, "Classic Theme Colours"]) if (!connected) rows.add([19, "Custom Screen Mode"]) @@ -841,7 +843,14 @@ class SettingsMenu { var i = widths.indexOf(s.exclusiveBorder) s.exclusiveBorder = widths[(i + 1) % widths.count] } else if (value == 26) { - s.exclusiveBorderColour = (s.exclusiveBorderColour + 1) % borderColours_.count + var colourRows = [] + for (i in 0...borderColours_.count) colourRows.add([i + 1, borderColours_[i]]) + var c = MenuUi.choice(app, "Exclusive Border Colour", colourRows, + s.exclusiveBorderColour, + "# Exclusive Border Colour\n\nThe colour of the frame shown " + + "while the mouse is captured: one of the 15 DOS colours, " + + "taken from the active palette.") + if (c != null) s.exclusiveBorderColour = c } else if (value == 17) { var next = MenuUi.integer(app, "Key Derivation Work Factor", "Exponent N for scrypt-Nn", s.kdfShift, 8, 20, kdfHelp_()) diff --git a/src/syncterm/syncterm.c b/src/syncterm/syncterm.c index e2096558..1d770abc 100644 --- a/src/syncterm/syncterm.c +++ b/src/syncterm/syncterm.c @@ -1943,9 +1943,19 @@ load_settings(struct syncterm_settings *set) set->exclusive_border = iniReadInteger(inifile, "SyncTERM", "ExclusiveMouseBorder", 4); if (set->exclusive_border < 0 || set->exclusive_border > 16) set->exclusive_border = 4; - set->exclusive_border_colour = iniReadInteger(inifile, "SyncTERM", "ExclusiveMouseBorderColour", 0); - if (set->exclusive_border_colour < 0 || set->exclusive_border_colour > 7) - set->exclusive_border_colour = 0; + /* DOS colour 1-15 (default 3, Cyan). test3 builds stored an index + * into an eight-colour list under ExclusiveMouseBorderColour; carry + * that over to the nearest DOS colour (its default, Cyan, becomes + * the new default, the darker DOS Cyan). */ + set->exclusive_border_colour = iniReadInteger(inifile, "SyncTERM", + "ExclusiveMouseBorderDOSColour", -1); + if (set->exclusive_border_colour == -1) { + static const int from_test3[8] = {3, 13, 14, 10, 6, 12, 15, 9}; + int old = iniReadInteger(inifile, "SyncTERM", "ExclusiveMouseBorderColour", -1); + set->exclusive_border_colour = (old >= 0 && old <= 7) ? from_test3[old] : 3; + } + if (set->exclusive_border_colour < 1 || set->exclusive_border_colour > 15) + set->exclusive_border_colour = 3; set->invert_wheel = iniReadBool(inifile, "SyncTERM", "InvertMouseWheel", false); set->defaultCursor = iniReadEnum(inifile, "SyncTERM", "DefaultCursor", cursor_enum, ST_CT_DEFAULT); @@ -2929,28 +2939,13 @@ USAGE: return 0; } -/* Program Settings "Exclusive Mouse Border" colours, in the order the - * settings menu lists them (menu_settings_ui.wren borderColours_). */ -static const uint32_t exclusive_border_colours[8] = { - 0x00FFFF, /* Cyan */ - 0xFF00FF, /* Magenta */ - 0xFFFF00, /* Yellow */ - 0x00FF00, /* Green */ - 0xFF8000, /* Orange */ - 0xFF0000, /* Red */ - 0xFFFFFF, /* White */ - 0x3070FF, /* Blue */ -}; - +/* Program Settings "Exclusive Mouse Border": the colour is a DOS text + * colour 1-15, drawn from the active palette (ciolib looks it up). */ void apply_exclusive_border(void) { - int c = settings.exclusive_border_colour; - - if (c < 0 || c > 7) - c = 0; ciolib_set_exclusive_border(settings.exclusive_border, - exclusive_border_colours[c]); + settings.exclusive_border_colour); } int diff --git a/src/syncterm/syncterm.h b/src/syncterm/syncterm.h index 7daefba4..7670d183 100644 --- a/src/syncterm/syncterm.h +++ b/src/syncterm/syncterm.h @@ -95,7 +95,7 @@ struct syncterm_settings { bool exclusive_mouse; bool mouse_edge_motion; int exclusive_border; /* frame px while mouse captured, 0 = off */ - int exclusive_border_colour; /* index into exclusive_border_rgb() */ + int exclusive_border_colour; /* DOS colour 1-15 */ uint audio_output_modes; bool invert_wheel; bool webgetUserList; diff --git a/src/syncterm/wren_bind_menu_settings.c b/src/syncterm/wren_bind_menu_settings.c index 3449310d..8086492d 100644 --- a/src/syncterm/wren_bind_menu_settings.c +++ b/src/syncterm/wren_bind_menu_settings.c @@ -216,7 +216,7 @@ SETTINGS_BOOL_PROPERTY(gpuAccelerated, gpu_accel) SETTINGS_BOOL_PROPERTY(exclusiveMouse, exclusive_mouse) SETTINGS_BOOL_PROPERTY(mouseEdgeMotion, mouse_edge_motion) SETTINGS_NUM_PROPERTY(exclusiveBorder, exclusive_border, 0, 16) -SETTINGS_NUM_PROPERTY(exclusiveBorderColour, exclusive_border_colour, 0, 7) +SETTINGS_NUM_PROPERTY(exclusiveBorderColour, exclusive_border_colour, 1, 15) SETTINGS_STRING_PROPERTY(modemDevice, mdm.device_name) SETTINGS_STRING_PROPERTY(modemInit, mdm.init_string) SETTINGS_STRING_PROPERTY(modemDial, mdm.dial_string) -- 2.47.3