From f0fe44f35504788edc241e347252384517a33087 Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Sun, 6 Sep 2020 20:40:29 -0400 Subject: Add C-r, C-s for basic scrollback search --- ui.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ui.c') diff --git a/ui.c b/ui.c index 4178d8f..676f969 100644 --- a/ui.c +++ b/ui.c @@ -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; static void notify(uint id, const char *str) { if (!uiNotifyUtil.argc) return; @@ -877,6 +888,8 @@ static void keyCtrl(wchar_t ch) { break; case L'L': clearok(curscr, true); break; case L'N': 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'U': edit(id, EditDeleteHead, 0); break; case L'V': windowScrollPage(window, -1); -- cgit 1.4.1-2-gfad0