Add C-r, C-s for basic scrollback search

weechat-hashes
C. McEnroe 2020-09-06 20:40:29 -04:00
parent 49e626b2f3
commit f0fe44f355
2 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,4 @@
.Dd September 3, 2020 .Dd September 6, 2020
.Dt CATGIRL 1 .Dt CATGIRL 1
.Os .Os
. .
@ -459,6 +459,10 @@ Redraw the UI.
Switch to next window. Switch to next window.
.It Ic C-p .It Ic C-p
Switch to previous window. Switch to previous window.
.It Ic C-r
Scroll to previous line matching input.
.It Ic C-s
Scroll to next line matching input.
.It Ic C-v .It Ic C-v
Scroll down a page. Scroll down a page.
.It Ic M-- .It Ic M--

13
ui.c
View File

@ -518,6 +518,17 @@ static void windowScrollHot(struct Window *window, int dir) {
} }
} }
static void
windowScrollSearch(struct Window *window, const char *str, int dir) {
size_t from = BufferCap - window->scroll - MAIN_LINES + MarkerLines + dir;
for (size_t i = from; i < BufferCap; i += dir) {
const struct Line *line = bufferHard(window->buffer, i);
if (!line || !strcasestr(line->str, str)) continue;
windowScrollTo(window, BufferCap - i);
break;
}
}
struct Util uiNotifyUtil; struct Util uiNotifyUtil;
static void notify(uint id, const char *str) { static void notify(uint id, const char *str) {
if (!uiNotifyUtil.argc) return; if (!uiNotifyUtil.argc) return;
@ -877,6 +888,8 @@ static void keyCtrl(wchar_t ch) {
break; case L'L': clearok(curscr, true); break; case L'L': clearok(curscr, true);
break; case L'N': uiShowNum(windows.show + 1); break; case L'N': uiShowNum(windows.show + 1);
break; case L'P': uiShowNum(windows.show - 1); break; case L'P': uiShowNum(windows.show - 1);
break; case L'R': windowScrollSearch(window, editBuffer(NULL), -1);
break; case L'S': windowScrollSearch(window, editBuffer(NULL), +1);
break; case L'T': edit(id, EditTranspose, 0); break; case L'T': edit(id, EditTranspose, 0);
break; case L'U': edit(id, EditDeleteHead, 0); break; case L'U': edit(id, EditDeleteHead, 0);
break; case L'V': windowScrollPage(window, -1); break; case L'V': windowScrollPage(window, -1);