Text files redone to use lightbars

This commit is contained in:
Andrew Pamment 2018-02-05 19:26:06 +10:00
parent c2e2319a1c
commit 6468040826
5 changed files with 138 additions and 30 deletions

View File

@ -46,3 +46,23 @@ NEWSTRING: "\r\n\r\n\e[1;37mReset \e[1;31mALL\e[1;37m pointers in \e[1;31mALL \e
LINE 167 MODIFIED LINE 167 MODIFIED
OLDSTRING: "\r\nWhat is your login name: " OLDSTRING: "\r\nWhat is your login name: "
NEWSTRING: "\r\n\e[0mWhat is your login name: " NEWSTRING: "\r\n\e[0mWhat is your login name: "
LINE 144 MODIFIED
OLDSTRING: "\r\n\e[1;32mText Files Collection\r\n"
NEWSTRING: "\e[1;37;44mChoose a Text file to view\e[K"
LINE 145 MODIFIED
OLDSTRING: "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"
NEWSTRING: "\e[24;1H\e[1;37;44mUp / Down to Select, Enter to View, Q to Quit\e[K"
LINE 146 CLEARED
OLDSTRING: "\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%s\r\n"
NEWSTRING: ""
LINE 147 CLEARED
OLDSTRING: "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"
NEWSTRING: ""
LINE 148 CLEARED
OLDSTRING: "Enter the number of a text file to display or Q to quit:"
NEWSTRING: ""

Binary file not shown.

10
dist/magicka.strings vendored
View File

@ -141,11 +141,11 @@ Enter the area number:
\r\n\e[1;32m%d. %s\e[0m\r\n \r\n\e[1;32m%d. %s\e[0m\r\n
\e[1;37m --> %d. %s (%d new)\e[0m\r\n \e[1;37m --> %d. %s (%d new)\e[0m\r\n
\r\n\e[0mTL: %dm :> \r\n\e[0mTL: %dm :>
\r\n\e[1;32mText Files Collection\r\n \e[1;37;44mChoose a Text file to view\e[K
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n \e[24;1H\e[1;37;44mUp / Down to Select, Enter to View, Q to Quit\e[K
\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;37m%s\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
Enter the number of a text file to display or Q to quit:
\r\nSorry, there are no text files to display\r\n \r\nSorry, there are no text files to display\r\n
\e[2J\e[1;1H\e[1;32mYour Settings\r\n \e[2J\e[1;1H\e[1;32mYour Settings\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n \e[1;30m-------------------------------------------------------------------------------\e[0m\r\n

View File

@ -20,7 +20,7 @@ end
while(true) do while(true) do
if file_exists(bulletin_path .. "/bulletin" .. string.format("%d", i) .. ".ans") then if file_exists(bulletin_path .. "/bulletin" .. string.format("%d", i) .. ".ans") then
bbs_write_string("\027[2J\027[1;1H"); bbs_write_string("\027[2J\027[1;1H");
bbs_display_ansi("bulletin" .. string.format("%d", i)); bbs_display_ansi_pause("bulletin" .. string.format("%d", i));
bbs_write_string("\027[1;37mPress any key to continue...\027[0m"); bbs_write_string("\027[1;37mPress any key to continue...\027[0m");
bbs_read_char(); bbs_read_char();
else else

View File

@ -86,36 +86,124 @@ void send_node_msg() {
void display_textfiles() { void display_textfiles() {
int i; int i;
char buffer[5]; int redraw = 1;
int start = 0;
int selected = 0;
char c;
if (conf.text_file_count > 0) { if (conf.text_file_count == 0) {
s_printf("\e[2J\e[1;1H");
s_printf(get_string(148));
s_printf(get_string(185));
s_getc();
s_printf("\r\n");
return;
}
while(1) { while (1) {
if (redraw) {
s_printf("\e[2J\e[1;1H");
s_printf(get_string(143)); s_printf(get_string(143));
s_printf(get_string(144)); s_printf(get_string(144));
for (i=start;i<start+22 && i < conf.text_file_count;i++) {
for (i=0;i<conf.text_file_count;i++) { if (i == selected) {
s_printf(get_string(145), i, conf.text_files[i]->name); s_printf(get_string(249), i - start + 2, i, conf.text_files[i]->name);
} } else {
s_printf(get_string(146)); s_printf(get_string(250), i - start + 2, i, conf.text_files[i]->name);
s_printf(get_string(147));
s_readstring(buffer, 4);
if (tolower(buffer[0]) != 'q') {
i = atoi(buffer);
if (i >= 0 && i < conf.text_file_count) {
s_printf("\r\n");
s_displayansi_p(conf.text_files[i]->path);
s_printf(get_string(6));
s_getc();
s_printf("\r\n");
} }
} else {
break;
} }
s_printf("\e[%d;5H", selected - start + 2);
redraw = 0;
}
c = s_getchar();
if (tolower(c) == 'q') {
break;
} else if (c == 27) {
c = s_getchar();
if (c == 91) {
c = s_getchar();
if (c == 66) {
// down
if (selected + 1 >= start + 22) {
start += 22;
if (start >= conf.text_file_count) {
start = conf.text_file_count - 22;
}
redraw = 1;
}
selected++;
if (selected >= conf.text_file_count) {
selected = conf.text_file_count - 1;
} else {
if (!redraw) {
s_printf(get_string(250), selected - start + 1, selected - 1, conf.text_files[selected - 1]->name);
s_printf(get_string(249), selected - start + 2, selected, conf.text_files[selected]->name);
s_printf("\e[%d;5H", selected - start + 2);
}
}
} else if (c == 65) {
// up
if (selected - 1 < start) {
start -= 22;
if (start < 0) {
start = 0;
}
redraw = 1;
}
selected--;
if (selected < 0) {
selected = 0;
} else {
if (!redraw) {
s_printf(get_string(249), selected - start + 2, selected, conf.text_files[selected]->name);
s_printf(get_string(250), selected - start + 3, selected + 1, conf.text_files[selected + 1]->name);
s_printf("\e[%d;5H", selected - start + 2);
}
}
} else if (c == 75) {
// END KEY
selected = conf.text_file_count - 1;
start = conf.text_file_count - 22;
if (start < 0) {
start = 0;
}
redraw = 1;
} else if (c == 72) {
// HOME KEY
selected = 0;
start = 0;
redraw = 1;
} else if (c == 86 || c == '5') {
if (c == '5') {
s_getchar();
}
// PAGE UP
selected = selected - 22;
if (selected < 0) {
selected = 0;
}
start = selected;
redraw = 1;
} else if (c == 85 || c == '6') {
if (c == '6') {
s_getchar();
}
// PAGE DOWN
selected = selected + 22;
if (selected >= conf.text_file_count) {
selected = conf.text_file_count -1;
}
start = selected;
redraw = 1;
}
}
} else if (c == 13) {
s_printf("\e[2J\e[1;1H");
s_displayansi_p(conf.text_files[selected]->path);
s_printf(get_string(185));
s_getc();
s_printf("\r\n");
redraw = 1;
} }
} else {
s_printf(get_string(148));
s_printf(get_string(6));
s_getc();
} }
} }