[bim] redraw INSERT when scrolling insert mode

This commit is contained in:
K. Lange 2018-08-16 13:30:46 +09:00
parent 2d8c538b71
commit 317a500bd6
1 changed files with 21 additions and 12 deletions

View File

@ -572,6 +572,12 @@ void render_error(char * message) {
fflush(stdout); fflush(stdout);
} }
void redraw_modeline() {
set_bold();
printf("-- INSERT --");
reset();
}
void show_cursor() { void show_cursor() {
fprintf(stdout, "\033[?25h"); fprintf(stdout, "\033[?25h");
fflush(stdout); fflush(stdout);
@ -836,7 +842,7 @@ void close_buffer() {
redraw_all(); redraw_all();
} }
void cursor_down(void) { void cursor_down(int insert_mode) {
if (env->line_no < env->line_count) { if (env->line_no < env->line_count) {
env->line_no += 1; env->line_no += 1;
if (env->col_no > env->lines[env->line_no-1]->actual) { if (env->col_no > env->lines[env->line_no-1]->actual) {
@ -867,6 +873,9 @@ void cursor_down(void) {
redraw_tabbar(); redraw_tabbar();
redraw_statusbar(); redraw_statusbar();
redraw_commandline(); redraw_commandline();
if (insert_mode) {
redraw_modeline();
}
place_cursor_actual(); place_cursor_actual();
return; return;
} else if (redraw == 1) { } else if (redraw == 1) {
@ -877,7 +886,7 @@ void cursor_down(void) {
} }
} }
void cursor_up(void) { void cursor_up(int insert_mode) {
if (env->line_no > 1) { if (env->line_no > 1) {
env->line_no -= 1; env->line_no -= 1;
if (env->col_no > env->lines[env->line_no-1]->actual) { if (env->col_no > env->lines[env->line_no-1]->actual) {
@ -900,8 +909,10 @@ void cursor_up(void) {
redraw_tabbar(); redraw_tabbar();
redraw_statusbar(); redraw_statusbar();
redraw_commandline(); redraw_commandline();
if (insert_mode) {
redraw_modeline();
}
place_cursor_actual(); place_cursor_actual();
return; return;
} else if (redraw) { } else if (redraw) {
redraw_text(); redraw_text();
@ -1056,9 +1067,7 @@ void insert_mode() {
int cin; int cin;
uint32_t c; uint32_t c;
redraw_commandline(); redraw_commandline();
set_bold(); redraw_modeline();
printf("-- INSERT --");
reset();
place_cursor_actual(); place_cursor_actual();
set_colors(COLOR_FG, COLOR_BG); set_colors(COLOR_FG, COLOR_BG);
int timeout = 0; int timeout = 0;
@ -1134,10 +1143,10 @@ void insert_mode() {
if (timeout == 2 && this_buf[0] == '\033' && this_buf[1] == '[') { if (timeout == 2 && this_buf[0] == '\033' && this_buf[1] == '[') {
switch (c) { switch (c) {
case 'A': // up case 'A': // up
cursor_up(); cursor_up(1);
break; break;
case 'B': // down case 'B': // down
cursor_down(); cursor_down(1);
break; break;
case 'C': // right case 'C': // right
cursor_right(1); cursor_right(1);
@ -1209,10 +1218,10 @@ int main(int argc, char * argv[]) {
command_mode(); command_mode();
break; break;
case 'j': case 'j':
cursor_down(); cursor_down(0);
break; break;
case 'k': case 'k':
cursor_up(); cursor_up(0);
break; break;
case 'h': case 'h':
cursor_left(); cursor_left();
@ -1280,10 +1289,10 @@ _insert:
if (timeout == 2 && this_buf[0] == '\033' && this_buf[1] == '[') { if (timeout == 2 && this_buf[0] == '\033' && this_buf[1] == '[') {
switch (c) { switch (c) {
case 'A': // up case 'A': // up
cursor_up(); cursor_up(0);
break; break;
case 'B': // down case 'B': // down
cursor_down(); cursor_down(0);
break; break;
case 'C': // right case 'C': // right
cursor_right(0); cursor_right(0);