summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-09-06 20:40:29 -0400
committerJune McEnroe <june@causal.agency>2020-09-06 20:40:29 -0400
commitf0fe44f35504788edc241e347252384517a33087 (patch)
treec64fb5fc70b25e557ab8390290f8cc6a5ef5c701 /ui.c
parentAdd M-n, M-p to jump to highlights (diff)
downloadcatgirl-f0fe44f35504788edc241e347252384517a33087.tar.gz
catgirl-f0fe44f35504788edc241e347252384517a33087.zip
Add C-r, C-s for basic scrollback search
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c13
1 files changed, 13 insertions, 0 deletions
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);
d>June McEnroe I have no idea why I did this. 2018-09-13Rewrite UI againJune McEnroe The persistent topic is gone and the status line is now at the top. The status formatting still needs to be reworked. I also want to try showing the nick in the input window so it really looks like your next message. 2018-09-12Add note about C-oJune McEnroe Why are there so few well usable ctrl key bindings? 2018-09-12Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe Ridiculous. 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe