From 4c446797d83a6851bc09ded057b065608454de17 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Thu, 18 Jan 2018 08:58:32 +1000 Subject: [PATCH] Tweaks to file area chooser --- magicka.strings | 4 ++-- src/files.c | 10 ++++++++-- src/mail_menu.c | 10 ++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/magicka.strings b/magicka.strings index 6580bdf..723d2bf 100644 --- a/magicka.strings +++ b/magicka.strings @@ -247,8 +247,8 @@ File exists!\r\n \e[0;36mT. \e[1;37mToggle Auto-Signature (\e[1;33m%s\e[1;37m)\r\n \e[1;37;44mChoose a Conference\e[K \e[24;1H\e[1;37;44mUp / Down to Select, Enter to Confirm\e[K -\e[%d;1H\e[1;30;40m[\e[1;34;44m%.4d\e[1;30;40m] \e[1;37m%s\e[K -\e[%d;1H\e[1;30;40m[\e[1;34m%.4d\e[1;30;40m] \e[1;37m%s\e[K +\e[%d;1H\e[1;30;40m[\e[1;34;44m%4d\e[1;30;40m] \e[1;37m%s\e[K +\e[%d;1H\e[1;30;40m[\e[1;34m%4d\e[1;30;40m] \e[1;37m%s\e[K \e[1;37;44mChoose an Area in %s\e[K \e[1;37;44mChoose an Subdir in %s\e[K \e[1;37;44mChoose a Directory\e[K diff --git a/src/files.c b/src/files.c index 8c1e872..a4e46aa 100644 --- a/src/files.c +++ b/src/files.c @@ -1382,6 +1382,7 @@ void choose_subdir() { s_printf(get_string(250), i - start + 2, sub_tmp[i]->index, sub_tmp[i]->sub->name); } } + s_printf("\e[%d;5H", selected - start + 2); redraw = 0; } c = s_getchar(); @@ -1393,7 +1394,7 @@ void choose_subdir() { c = s_getchar(); if (c == 66) { // down - if (selected + 1 > start + 22) { + if (selected + 1 >= start + 22) { start += 22; if (start >= list_tmp) { start = list_tmp - 22; @@ -1407,6 +1408,7 @@ void choose_subdir() { if (!redraw) { s_printf(get_string(250), selected - start + 1, sub_tmp[selected - 1]->index, sub_tmp[selected - 1]->sub->name); s_printf(get_string(249), selected - start + 2, sub_tmp[selected]->index, sub_tmp[selected]->sub->name); + s_printf("\e[%d;5H", selected - start + 2); } } } else if (c == 65) { @@ -1425,6 +1427,7 @@ void choose_subdir() { if (!redraw) { s_printf(get_string(249), selected - start + 2, sub_tmp[selected]->index, sub_tmp[selected]->sub->name); s_printf(get_string(250), selected - start + 3, sub_tmp[selected + 1]->index, sub_tmp[selected + 1]->sub->name); + s_printf("\e[%d;5H", selected - start + 2); } } } @@ -1482,6 +1485,7 @@ void choose_directory() { s_printf(get_string(250), i - start + 2, dir_tmp[i]->index, dir_tmp[i]->dir->name); } } + s_printf("\e[%d;5H", selected - start + 2); redraw = 0; } c = s_getchar(); @@ -1493,7 +1497,7 @@ void choose_directory() { c = s_getchar(); if (c == 66) { // down - if (selected + 1 > start + 22) { + if (selected + 1 >= start + 22) { start += 22; if (start >= list_tmp) { start = list_tmp - 22; @@ -1507,6 +1511,7 @@ void choose_directory() { if (!redraw) { s_printf(get_string(250), selected - start + 1, dir_tmp[selected - 1]->index, dir_tmp[selected - 1]->dir->name); s_printf(get_string(249), selected - start + 2, dir_tmp[selected]->index, dir_tmp[selected]->dir->name); + s_printf("\e[%d;5H", selected - start + 2); } } } else if (c == 65) { @@ -1525,6 +1530,7 @@ void choose_directory() { if (!redraw) { s_printf(get_string(249), selected - start + 2, dir_tmp[selected]->index, dir_tmp[selected]->dir->name); s_printf(get_string(250), selected - start + 3, dir_tmp[selected + 1]->index, dir_tmp[selected + 1]->dir->name); + s_printf("\e[%d;5H", selected - start + 2); } } } diff --git a/src/mail_menu.c b/src/mail_menu.c index 634867b..69f954e 100644 --- a/src/mail_menu.c +++ b/src/mail_menu.c @@ -2595,6 +2595,7 @@ void choose_conference() { s_printf(get_string(250), i - start + 2, conf_tmp[i]->index, conf_tmp[i]->conference->name); } } + s_printf("\e[%d;5H", selected - start + 2); redraw = 0; } c = s_getchar(); @@ -2606,7 +2607,7 @@ void choose_conference() { c = s_getchar(); if (c == 66) { // down - if (selected + 1 > start + 22) { + if (selected + 1 >= start + 22) { start += 22; if (start >= list_tmp) { start = list_tmp - 22; @@ -2620,6 +2621,7 @@ void choose_conference() { if (!redraw) { s_printf(get_string(250), selected - start + 1, conf_tmp[selected - 1]->index, conf_tmp[selected - 1]->conference->name); s_printf(get_string(249), selected - start + 2, conf_tmp[selected]->index, conf_tmp[selected]->conference->name); + s_printf("\e[%d;5H", selected - start + 2); } } } else if (c == 65) { @@ -2638,6 +2640,7 @@ void choose_conference() { if (!redraw) { s_printf(get_string(249), selected - start + 2, conf_tmp[selected]->index, conf_tmp[selected]->conference->name); s_printf(get_string(250), selected - start + 3, conf_tmp[selected + 1]->index, conf_tmp[selected + 1]->conference->name); + s_printf("\e[%d;5H", selected - start + 2); } } } @@ -2696,6 +2699,7 @@ void choose_area() { s_printf(get_string(250), i - start + 2, area_tmp[i]->index, area_tmp[i]->area->name); } } + s_printf("\e[%d;5H", selected - start + 2); redraw = 0; } c = s_getchar(); @@ -2707,7 +2711,7 @@ void choose_area() { c = s_getchar(); if (c == 66) { // down - if (selected + 1 > start + 22) { + if (selected + 1 >= start + 22) { start += 22; if (start >= list_tmp) { start = list_tmp - 22; @@ -2721,6 +2725,7 @@ void choose_area() { if (!redraw) { s_printf(get_string(250), selected - start + 1, area_tmp[selected - 1]->index, area_tmp[selected - 1]->area->name); s_printf(get_string(249), selected - start + 2, area_tmp[selected]->index, area_tmp[selected]->area->name); + s_printf("\e[%d;5H", selected - start + 2); } } } else if (c == 65) { @@ -2739,6 +2744,7 @@ void choose_area() { if (!redraw) { s_printf(get_string(249), selected - start + 2, area_tmp[selected]->index, area_tmp[selected]->area->name); s_printf(get_string(250), selected - start + 3, area_tmp[selected + 1]->index, area_tmp[selected + 1]->area->name); + s_printf("\e[%d;5H", selected - start + 2); } } }