From ee965f2133c9b34d1c2519467da6b1df3320a23a Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" <rob@synchro.net> Date: Fri, 31 Jan 2025 12:14:19 -0800 Subject: [PATCH] Add K_CHANGED mode flag for uifc.input() Used in combination with K_EDIT, if the string isn't actually changed, return -1 (same as abort/ESC). This allows the elimination of some save/compare/copy code in SCFG where we only care to even look at the string if it was changed from its existing value. --- src/uifc/uifc.h | 1 + src/uifc/uifc32.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/uifc/uifc.h b/src/uifc/uifc.h index 7de1b6b8de..2b04533725 100644 --- a/src/uifc/uifc.h +++ b/src/uifc/uifc.h @@ -201,6 +201,7 @@ typedef int64_t uifc_winmode_t; #define K_FIND (1 << 17) /* Don't set the "changes" flag */ #define K_TRIM (1 << 23) /* Don't allow leading or trailing wsp */ #define K_NOSPACE (1 << 26) /* Don't allow any wsp chars */ +#define K_CHANGED (1 << 28) /* Return -1 if string was not changed (w/K_EDIT) */ /* Extra exit flags */ diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c index 2d2709c9e7..9c6bdfac7a 100644 --- a/src/uifc/uifc32.c +++ b/src/uifc/uifc32.c @@ -2541,6 +2541,8 @@ int ugetstr(int left, int top, int width, char *outstr, int max, long mode, int { if (!(mode & K_FIND) && strcmp(outstr, str)) api->changes = 1; + else if (mode & K_CHANGED) + j = -1; } else { -- GitLab