summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/ui.c b/ui.c
index 643d627..1273028 100644
--- a/ui.c
+++ b/ui.c
@@ -76,6 +76,15 @@ static void windowAppend(struct Window *win) {
 	windows.tag[win->tag.id] = win;
 }
 
+static void windowInsert(struct Window *win, struct Window *next) {
+	win->prev = next->prev;
+	win->next = next;
+	if (win->prev) win->prev->next = win;
+	win->next->prev = win;
+	if (!win->prev) windows.head = win;
+	windows.tag[win->tag.id] = win;
+}
+
 static void windowRemove(struct Window *win) {
 	windows.tag[win->tag.id] = NULL;
 	if (win->prev) win->prev->next = win->next;
@@ -365,6 +374,17 @@ void uiShowTag(struct Tag tag) {
 	uiShowWindow(windowFor(tag));
 }
 
+static void uiShowAuto(void) {
+	struct Window *unread = NULL;
+	struct Window *hot;
+	for (hot = windows.head; hot; hot = hot->next) {
+		if (hot->hot) break;
+		if (!unread && hot->unread) unread = hot;
+	}
+	if (!hot && !unread) return;
+	uiShowWindow(hot ? hot : unread);
+}
+
 void uiShowNum(int num, bool relative) {
 	struct Window *win = (relative ? windows.active : windows.head);
 	if (num < 0) {
@@ -375,15 +395,18 @@ void uiShowNum(int num, bool relative) {
 	if (win) uiShowWindow(win);
 }
 
-static void uiShowAuto(void) {
-	struct Window *unread = NULL;
-	struct Window *hot;
-	for (hot = windows.head; hot; hot = hot->next) {
-		if (hot->hot) break;
-		if (!unread && hot->unread) unread = hot;
+void uiMoveTag(struct Tag tag, int num, bool relative) {
+	struct Window *win = windowFor(tag);
+	windowRemove(win);
+	struct Window *ins = (relative ? win : windows.head);
+	if (num < 0) {
+		for (; ins; ins = ins->prev) if (!num++) break;
+	} else {
+		if (relative) ins = ins->next;
+		for (; ins; ins = ins->next) if (!num--) break;
 	}
-	if (!hot && !unread) return;
-	uiShowWindow(hot ? hot : unread);
+	ins ? windowInsert(win, ins) : windowAppend(win);
+	uiStatus();
 }
 
 void uiCloseTag(struct Tag tag) {
td>Add first working version of imboxJune McEnroe 2019-12-20Respect mailmap in gl pretty formatJune McEnroe 2019-12-20Set LANG in cgit filtersJune McEnroe ttpre needs to know about UTF-8 too so it can bold/italic non-ASCII chars. 2019-12-20Source .editrc before applying -v or -eJune McEnroe Otherwise a bind -v in .editrc will take precedence and overwrite the ^I binding for sh-complete. 2019-12-20Disable signing commitsJune McEnroe Why did I ever turn this on? This gets me nothing but inconvenience. RIP to all the wasted bytes in my git repos. 2019-12-19Ignore about-filterJune McEnroe 2019-12-19Fix matching make tags with no sourcesJune McEnroe 2019-12-19Avoid matching := assignments as tagsJune McEnroe 2019-12-18Hide line numbers when rendering mdocJune McEnroe Hack: output an extra <td> after rendering mdoc so that line numbers can be hidden based on there being three. This required splitting source-filter and about-filter since on about pages there is no table. 2019-12-18Customize cgit CSSJune McEnroe 2019-12-18Use :target rather than :focus pseudo-classJune McEnroe :target persists after you click on something else. 2019-12-18Copy cgit auxiliary binaries properlyJune McEnroe 2019-12-18Add git.causal.agency cgit configJune McEnroe 2019-12-18Bail from hi if input is binaryJune McEnroe NULs in the input cause an infinite loop in htmlEscape, not to mention regexes obviously not working, etc. 2019-12-16Post "cgit setup"June McEnroe