top: if line editing, account for invisible characters <=== port of newlib b0adacf1
______________________________ original newlib message If we're deleting a character or operating in overtype mode, we must account for the potential of 'invisible' characters. When one follows any character about to be deleted or replaced both multi-byte sequences must go. Without this change, there exists the possibility that top might report some error where no error is apparent to the user. For example, with 'other filtering' (o/O) the user could see "unrecognized field name 'COMMAND'" where the quoted column name appears perfectly normal. Or maybe a sequences like the 'combining acute accent' gets applied to an existing character instead of being deleted as one expects when its parent was eliminated. So, henceforth whenever any character is being deleted we will now check for a following 'invisible' sequence then eliminate it along with that preceding character. [ admittedly, these scenarios are very rare yet they ] [ may occur, especially when recalling some previous ] [ multi-byte strings for editing. and, since we will ] [ be interacting with a user, performance won't be a ] [ factor so extra checks for a zero wcwidth is fine. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
aa6a792bf9
commit
be7e171597
@ -1337,6 +1337,7 @@ static char *ioline (const char *prompt) {
|
|||||||
#define chkCUR { if (cur < 0) cur = 0; if (cur > len) cur = len; }
|
#define chkCUR { if (cur < 0) cur = 0; if (cur > len) cur = len; }
|
||||||
// thank goodness ol' memmove will safely allow strings to overlap
|
// thank goodness ol' memmove will safely allow strings to overlap
|
||||||
#define sqzSTR { i = utfTOT(pos); while (i < 0) i = utfTOT(--pos); \
|
#define sqzSTR { i = utfTOT(pos); while (i < 0) i = utfTOT(--pos); \
|
||||||
|
if (!utfCOL(pos + i)) i += utfTOT(pos + i); \
|
||||||
memmove(&buf[pos], &buf[pos + i], bufMAX-(pos + i)); \
|
memmove(&buf[pos], &buf[pos + i], bufMAX-(pos + i)); \
|
||||||
memset(&buf[bufMAX - i], '\0', i); }
|
memset(&buf[bufMAX - i], '\0', i); }
|
||||||
#define expSTR(X) if (bufNXT < bufMAX && scrNXT < Screen_cols) { \
|
#define expSTR(X) if (bufNXT < bufMAX && scrNXT < Screen_cols) { \
|
||||||
|
Loading…
Reference in New Issue
Block a user