Modified quoting to stop redrawing every keypress

This commit is contained in:
Andrew Pamment 2017-03-24 16:28:31 +10:00
parent ca5f4cb4c6
commit 6ed9f934b6

View File

@ -43,6 +43,7 @@ char *message_editor() {
int q_line_count; int q_line_count;
int q_unquote; int q_unquote;
int z; int z;
int redraw;
position_x = 0; position_x = 0;
position_y = 0; position_y = 0;
@ -189,6 +190,7 @@ char *message_editor() {
} else if (strcasecmp(line, "/Q") == 0) { } else if (strcasecmp(line, "/Q") == 0) {
// quote // quote
if (quote_line_count > 0) { if (quote_line_count > 0) {
redraw = 1;
od_clr_scr(); od_clr_scr();
od_set_cursor(1, 1); od_set_cursor(1, 1);
od_set_color(L_WHITE, D_BLUE); od_set_color(L_WHITE, D_BLUE);
@ -206,24 +208,27 @@ char *message_editor() {
q_done = 0; q_done = 0;
q_marker = ' '; q_marker = ' ';
while (!q_done) { while (!q_done) {
for (i=q_start;i<q_start + 21 && i < quote_line_count;i++) { if (redraw) {
q_marker = ' '; for (i=q_start;i<q_start + 21 && i < quote_line_count;i++) {
for (j=0;j<q_line_count;j++) { q_marker = ' ';
if (q_lines[j] == i) { for (j=0;j<q_line_count;j++) {
q_marker = '+'; if (q_lines[j] == i) {
break; q_marker = '+';
break;
}
}
od_set_cursor(i - q_start + 3, 1);
if (i == q_position) {
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`black green`%s", q_marker, quote_lines[i]);
od_clr_line();
} else {
od_set_color(L_WHITE, D_BLACK);
od_printf("`bright yellow`%c`bright white`%s", q_marker, quote_lines[i]);
od_clr_line();
} }
} }
od_set_cursor(i - q_start + 3, 1); redraw = 0;
if (i == q_position) {
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`black green`%s", q_marker, quote_lines[i]);
od_clr_line();
} else {
od_set_color(L_WHITE, D_BLACK);
od_printf("`bright yellow`%c`bright white`%s", q_marker, quote_lines[i]);
od_clr_line();
}
} }
od_get_input(&ch, OD_NO_TIMEOUT, GETIN_NORMAL); od_get_input(&ch, OD_NO_TIMEOUT, GETIN_NORMAL);
if (ch.EventType == EVENT_EXTENDED_KEY) { if (ch.EventType == EVENT_EXTENDED_KEY) {
@ -237,6 +242,33 @@ char *message_editor() {
if (q_start < 0) { if (q_start < 0) {
q_start = 0; q_start = 0;
} }
redraw = 1;
}
if (!redraw) {
q_marker = ' ';
for (j=0;j<q_line_count;j++) {
if (q_lines[j] == q_position) {
q_marker = '+';
break;
}
}
od_set_cursor(q_position - q_start + 3, 1);
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`black green`%s", q_marker, quote_lines[q_position]);
od_clr_line();
q_marker = ' ';
for (j=0;j<q_line_count;j++) {
if (q_lines[j] == q_position + 1) {
q_marker = '+';
break;
}
}
od_set_cursor(q_position + 1 - q_start + 3, 1);
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`bright white`%s", q_marker, quote_lines[q_position + 1]);
od_clr_line();
} }
} else if (ch.chKeyPress == OD_KEY_DOWN) { } else if (ch.chKeyPress == OD_KEY_DOWN) {
q_position++; q_position++;
@ -249,6 +281,31 @@ char *message_editor() {
if (q_start + 21 >= quote_line_count) { if (q_start + 21 >= quote_line_count) {
q_start = quote_line_count - 21; q_start = quote_line_count - 21;
} }
redraw = 1;
}
if (!redraw) {
q_marker = ' ';
for (j=0;j<q_line_count;j++) {
if (q_lines[j] == q_position) {
q_marker = '+';
break;
}
}
od_set_cursor(q_position - q_start + 3, 1);
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`black green`%s", q_marker, quote_lines[q_position]);
od_clr_line();
q_marker = ' ';
for (j=0;j<q_line_count;j++) {
if (q_lines[j] == q_position - 1) {
q_marker = '+';
break;
}
}
od_set_cursor(q_position - 1 - q_start + 3, 1);
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`bright white`%s", q_marker, quote_lines[q_position + 1]);
od_clr_line();
} }
} }
} else if (ch.EventType == EVENT_CHARACTER) { } else if (ch.EventType == EVENT_CHARACTER) {
@ -280,7 +337,18 @@ char *message_editor() {
q_lines[q_line_count] = q_position; q_lines[q_line_count] = q_position;
q_line_count++; q_line_count++;
od_set_cursor(q_position - q_start + 3, 1);
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`black green`%s", ' ', quote_lines[q_position]);
od_clr_line();
} else {
od_set_cursor(q_position - q_start + 3, 1);
od_set_color(D_BLACK, D_GREEN);
od_printf("`bright yellow`%c`black green`%s", '+', quote_lines[q_position]);
od_clr_line();
} }
} else if (tolower(ch.chKeyPress) == 'q') { } else if (tolower(ch.chKeyPress) == 'q') {
for (i=0;i<q_line_count;i++) { for (i=0;i<q_line_count;i++) {
if (body_line_count == 0) { if (body_line_count == 0) {
@ -544,10 +612,10 @@ char *message_editor() {
} }
} }
if (position_y > 20) { if (position_y > 20) {
od_set_cursor(23, position_x + 1); od_set_cursor(23, position_x + 1);
} else { } else {
od_set_cursor(position_y - top_of_screen + 3, position_x + 1); od_set_cursor(position_y - top_of_screen + 3, position_x + 1);
} }
} }
} }
@ -571,6 +639,9 @@ int main(int argc, char **argv)
FILE *fptr; FILE *fptr;
char *body; char *body;
int i; int i;
msgpath = NULL;
#if _MSC_VER #if _MSC_VER
int j; int j;
@ -598,6 +669,11 @@ int main(int argc, char **argv)
path_sep = '/'; path_sep = '/';
#endif #endif
if (msgpath == NULL) {
fprintf(stderr, "No MSGTMP switch specified!\n");
exit(0);
}
od_init(); od_init();
msgtmp = (char *)malloc(strlen(msgpath) + 8); msgtmp = (char *)malloc(strlen(msgpath) + 8);