Fixes for ctrl-y

This commit is contained in:
Andrew Pamment 2017-09-03 17:49:25 +10:00
parent e1c7d7ed47
commit 3d1f083e24

View File

@ -579,13 +579,13 @@ char *message_editor() {
body_lines[i] = body_lines[i+1]; body_lines[i] = body_lines[i+1];
} }
body_line_count--; body_line_count--;
body_lines = (char **)realloc(body_lines, sizeof(char *) * (body_line_count)); body_lines = (char **)realloc(body_lines, sizeof(char *) * (body_line_count + 1));
} else { } else {
if (body_line_count > 0) { if (body_line_count > 0) {
memcpy(line, body_lines[body_line_count -1], 81); memcpy(line, body_lines[body_line_count -1], 81);
free(body_lines[body_line_count - 1]); free(body_lines[body_line_count - 1]);
body_line_count--; body_line_count--;
body_lines = (char **)realloc(body_lines, sizeof(char *) * (body_line_count)); body_lines = (char **)realloc(body_lines, sizeof(char *) * (body_line_count + 1));
position_y--; position_y--;
} else { } else {
memset(line, 0, 81); memset(line, 0, 81);
@ -594,12 +594,17 @@ char *message_editor() {
// refresh screen; // refresh screen;
position_x = 0; position_x = 0;
if (position_y < body_line_count) {
for (i = body_line_count;i < top_of_screen + 17;i++) { for (i=position_y; i<= body_line_count && i < top_of_screen + 17;i++) {
od_set_cursor(i - top_of_screen + 6, 1); od_set_cursor(i - top_of_screen + 5, 1);
od_printf("%s", body_lines[i]);
od_clr_line();
}
}
for (;i< top_of_screen + 17;i++) {
od_set_cursor(i - top_of_screen + 5, 1);
od_clr_line(); od_clr_line();
} }
} else if (ch.chKeyPress == 26) { } else if (ch.chKeyPress == 26) {
// save // save