mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 13:26:37 +00:00
make Ctrl+w in xreadline similar to readline's
when there's multiple spaces, the previous logic didn't erase them, e.g: a word | < before a word | < after Ctrl-w this patch brings the behavior closer to readline's: a word | < before a | < after Ctrl-w this also slightly changes the behavior since '/' is no longer considered a boundary.
This commit is contained in:
parent
d6b1b80e40
commit
942afdf445
15
src/nnn.c
15
src/nnn.c
|
@ -180,6 +180,7 @@
|
|||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#define ISODD(x) ((x) & 1)
|
||||
#define ISBLANK(x) ((x) == ' ' || (x) == '\t')
|
||||
#define ISSPACE(x) (ISBLANK(x) || (x) == '\n' || (x) == '\r' || (x) == '\f' || (x) == '\v')
|
||||
#define TOUPPER(ch) (((ch) >= 'a' && (ch) <= 'z') ? ((ch) - 'a' + 'A') : (ch))
|
||||
#define TOLOWER(ch) (((ch) >= 'A' && (ch) <= 'Z') ? ((ch) - 'A' + 'a') : (ch))
|
||||
#define ISUPPER_(ch) ((ch) >= 'A' && (ch) <= 'Z')
|
||||
|
@ -3717,13 +3718,13 @@ static char *xreadline(const char *prefill, const char *prompt)
|
|||
continue;
|
||||
case CONTROL('W'):
|
||||
printmsg(prompt);
|
||||
do {
|
||||
if (pos == 0)
|
||||
break;
|
||||
memmove(buf + pos - 1, buf + pos,
|
||||
(len - pos) * WCHAR_T_WIDTH);
|
||||
--pos, --len;
|
||||
} while (buf[pos - 1] != ' ' && buf[pos - 1] != '/'); // NOLINT
|
||||
lpos = pos;
|
||||
while (pos > 0 && ISSPACE(buf[pos-1]))
|
||||
--pos;
|
||||
while (pos > 0 && !ISSPACE(buf[pos-1]))
|
||||
--pos;
|
||||
memmove(buf + pos, buf + lpos, (len - lpos) * WCHAR_T_WIDTH);
|
||||
len -= lpos - pos;
|
||||
continue;
|
||||
case CONTROL('K'):
|
||||
printmsg(prompt);
|
||||
|
|
Loading…
Reference in a new issue