summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Mackus <michaelmackus@gmail.com>2018-07-18 14:54:22 -0700
committerMichael Mackus <michaelmackus@gmail.com>2018-07-18 14:54:22 -0700
commit4a8ee545c2f001a9d59ce1c7cafd9aa156f1976e (patch)
treee5c358f2d1a65c02d6fd96a4c49170c6ca342e86 /src
parent2697c02618d908e5bdcae93ab4815b04c49bd25e (diff)
Add support for underlining selected item
Diffstat (limited to 'src')
-rw-r--r--src/tty.c4
-rw-r--r--src/tty.h1
-rw-r--r--src/tty_interface.c4
3 files changed, 9 insertions, 0 deletions
diff --git a/src/tty.c b/src/tty.c
index ed951b3..7271307 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -110,6 +110,10 @@ void tty_setinvert(tty_t *tty) {
tty_sgr(tty, 7);
}
+void tty_setunderline(tty_t *tty) {
+ tty_sgr(tty, 4);
+}
+
void tty_setnormal(tty_t *tty) {
tty_sgr(tty, 0);
tty->fgcolor = 9;
diff --git a/src/tty.h b/src/tty.h
index 28c5cad..b949a46 100644
--- a/src/tty.h
+++ b/src/tty.h
@@ -21,6 +21,7 @@ int tty_input_ready(tty_t *tty);
void tty_setfg(tty_t *tty, int fg);
void tty_setinvert(tty_t *tty);
+void tty_setunderline(tty_t *tty);
void tty_setnormal(tty_t *tty);
#define TTY_COLOR_BLACK 0
diff --git a/src/tty_interface.c b/src/tty_interface.c
index 1af647c..4d4d52f 100644
--- a/src/tty_interface.c
+++ b/src/tty_interface.c
@@ -46,7 +46,11 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected)
}
if (selected)
+#ifdef TTY_SELECTION_UNDERLINE
+ tty_setunderline(tty);
+#else
tty_setinvert(tty);
+#endif
for (size_t i = 0, p = 0; choice[i] != '\0'; i++) {
if (i + 1 < maxwidth) {