Browse code

Add support for underlining selected item

Michael Mackus authored on 18/07/2018 21:54:22
Showing 3 changed files

... ...
@@ -110,6 +110,10 @@ void tty_setinvert(tty_t *tty) {
110 110
 	tty_sgr(tty, 7);
111 111
 }
112 112
 
113
+void tty_setunderline(tty_t *tty) {
114
+	tty_sgr(tty, 4);
115
+}
116
+
113 117
 void tty_setnormal(tty_t *tty) {
114 118
 	tty_sgr(tty, 0);
115 119
 	tty->fgcolor = 9;
... ...
@@ -21,6 +21,7 @@ int tty_input_ready(tty_t *tty);
21 21
 
22 22
 void tty_setfg(tty_t *tty, int fg);
23 23
 void tty_setinvert(tty_t *tty);
24
+void tty_setunderline(tty_t *tty);
24 25
 void tty_setnormal(tty_t *tty);
25 26
 
26 27
 #define TTY_COLOR_BLACK 0
... ...
@@ -46,7 +46,11 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected)
46 46
 	}
47 47
 
48 48
 	if (selected)
49
+#ifdef TTY_SELECTION_UNDERLINE
50
+		tty_setunderline(tty);
51
+#else
49 52
 		tty_setinvert(tty);
53
+#endif
50 54
 
51 55
 	for (size_t i = 0, p = 0; choice[i] != '\0'; i++) {
52 56
 		if (i + 1 < maxwidth) {