From e475ceb3958775ba1d6291a24f09217e1f571a09 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Sun, 26 Mar 2017 20:24:41 +1000 Subject: [PATCH] changes to magiedit --- utils/magiedit/main.c | 116 +++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 48 deletions(-) diff --git a/utils/magiedit/main.c b/utils/magiedit/main.c index b5e73d9..e07566e 100644 --- a/utils/magiedit/main.c +++ b/utils/magiedit/main.c @@ -44,6 +44,7 @@ char *message_editor() { int q_unquote; int z; int redraw; + int old_top_of_screen = 0; position_x = 0; position_y = 0; @@ -87,23 +88,25 @@ char *message_editor() { top_of_screen--; } - od_set_cursor(3, 1); + if (old_top_of_screen != top_of_screen) { + od_set_cursor(3, 1); - for (i=top_of_screen;i= 73) { + if (strlen(line) >= 73 && ch.chKeyPress != '\r') { if (position_x == strlen(line)) { strncat(line, &ch.chKeyPress, 1); z = 1; @@ -538,22 +543,24 @@ char *message_editor() { } - od_set_cursor(3, 1); + if (old_top_of_screen != top_of_screen) { + od_set_cursor(3, 1); - for (i=top_of_screen;i 20) { - od_set_cursor(23, 1); - od_clr_line(); + if (position_x > 1) { + if (position_y > 20) { + od_set_cursor(23, position_x - 1); + od_clr_line(); + } else { + od_set_cursor(position_y + 3, position_x - 1); + od_clr_line(); + } + + for (i = position_x - 2; i < position_x; i++) { + od_printf("%c", line[i]); + } } else { - od_set_cursor(position_y + 3, 1); - od_clr_line(); - } + if (position_y > 20) { + od_set_cursor(23, 1); + od_clr_line(); + } else { + od_set_cursor(position_y + 3, 1); + od_clr_line(); + } - for (i = 0; i < position_x; i++) { - od_printf("%c", line[i]); + for (i = 0; i < position_x; i++) { + od_printf("%c", line[i]); + } } - if (position_x < strlen(line) ) { for (i = position_x; i < strlen(line); i++) { od_printf("%c", line[i]);