From e3f7362241a82d2089a45d119b86109c9d89ec8f Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 7 Apr 2020 10:48:44 -0400 Subject: Add M-q to collapse whitespace --- catgirl.1 | 4 +++- chat.h | 1 + edit.c | 13 +++++++++++++ ui.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/catgirl.1 b/catgirl.1 index 5ec8db1..a7c096c 100644 --- a/catgirl.1 +++ b/catgirl.1 @@ -1,4 +1,4 @@ -.Dd April 6, 2020 +.Dd April 7, 2020 .Dt CATGIRL 1 .Os . @@ -429,6 +429,8 @@ Move to previous word. Delete next word. .It Ic M-f Move to next word. +.It Ic M-q +Collapse all whitespace. .It Ic Tab Complete nick, channel, command or macro. .El diff --git a/chat.h b/chat.h index 7bcac3b..764f8ec 100644 --- a/chat.h +++ b/chat.h @@ -234,6 +234,7 @@ enum Edit { EditDeleteNextWord, EditPaste, EditTranspose, + EditCollapse, EditInsert, EditComplete, EditExpand, diff --git a/edit.c b/edit.c index 1b23737..a37a3e4 100644 --- a/edit.c +++ b/edit.c @@ -232,6 +232,19 @@ void edit(uint id, enum Edit op, wchar_t ch) { buf[pos - 1] = buf[pos]; buf[pos++] = t; } + break; case EditCollapse: { + size_t ws; + for (pos = 0; pos < len;) { + for (; pos < len && !iswspace(buf[pos]); ++pos); + for (ws = pos; ws < len && iswspace(buf[ws]); ++ws); + if (pos && ws < len) { + delete(false, pos, ws - pos - 1); + buf[pos++] = L' '; + } else { + delete(false, pos, ws - pos); + } + } + } break; case EditInsert: { if (reserve(pos, 1)) { diff --git a/ui.c b/ui.c index 03fa776..da6cd18 100644 --- a/ui.c +++ b/ui.c @@ -211,6 +211,7 @@ static short colorPair(short fg, short bg) { X(KeyMetaF, "\33f", NULL) \ X(KeyMetaL, "\33l", NULL) \ X(KeyMetaM, "\33m", NULL) \ + X(KeyMetaQ, "\33q", NULL) \ X(KeyMetaU, "\33u", NULL) \ X(KeyMetaV, "\33v", NULL) \ X(KeyMetaEnter, "\33\r", "\33\n") \ @@ -911,6 +912,7 @@ static void keyCode(int code) { break; case KeyMetaF: edit(id, EditNextWord, 0); break; case KeyMetaL: bufferList(&window->buffer); break; case KeyMetaM: waddch(window->pad, '\n'); + break; case KeyMetaQ: edit(id, EditCollapse, 0); break; case KeyMetaU: windowScrollUnread(window); break; case KeyMetaV: windowScroll(window, +(PAGE_LINES - 2)); -- cgit 1.4.1 low=1'>gfx (unfollow)
Commit message (Collapse)Author
2018-04-03Ignore c and txtJune McEnroe
2018-04-03Move home bins to ~/.local/binJune McEnroe
Also replaced ~/.cargo/bin with a symlink to ~/.local/bin to avoid having to have that in $path as well.
2018-04-02Highlight Special as NormalJune McEnroe
Special characters in strings are more like normal code than keywords.
2018-04-02Use size_t for iterating in schemeJune McEnroe
2018-04-02Modulo H and saturate S, V in schemeJune McEnroe
2018-04-02Rewrite scheme in a more sensible orderJune McEnroe
2018-04-02Use function pointers in schemeJune McEnroe
2018-04-02Use union for scheme gen functionsJune McEnroe
2018-04-02Use uint32_t for len in schemeJune McEnroe
There are potentially 256 colours.
2018-04-01Add HSV output to schemeJune McEnroe
2018-03-31Output Linux console escapes from schemeJune McEnroe
2018-03-31Add scheme to READMEJune McEnroe
2018-03-31Brighten color schemeJune McEnroe
2018-03-31Set Dark terminal to schemeJune McEnroe
2018-03-31Lighten cursor colorJune McEnroe
2018-03-31Tweak cyan furtherJune McEnroe
It's actually green at this point.
2018-03-31Tweak colors in schemeJune McEnroe
2018-03-31Add scheme.png targetJune McEnroe
2018-03-31Generate Terminal.app color schemeJune McEnroe
Colors still very much WIP, but coming along.
2018-03-31Generate basic ANSI color schemeJune McEnroe
2018-03-31Add hex output to schemeJune McEnroe
2018-03-31Add color scheme PNG generatorJune McEnroe
2018-03-31Simplify gfxx palette generationJune McEnroe
2018-03-31Switch to HSV for gfxx palette generationJune McEnroe
2018-03-30Generate default palette in gfxxJune McEnroe
2018-03-30Ignore build and cloneJune McEnroe
2018-03-30Set g:clipboard to pb{copy,paste} alwaysJune McEnroe
Previously neovim would use these automatically if it found them, but now it only checks for them on macOS. pbd continues to work well.
2018-03-28Add d-_-b crateJune McEnroe