[bim] Add word delete and fix up horizontal scrolling on backspace

This commit is contained in:
K. Lange 2018-09-13 18:39:27 +09:00
parent b747ab7935
commit e9f886715f

View File

@ -4537,6 +4537,7 @@ void delete_at_cursor(void) {
if (env->col_no > 1) {
line_delete(env->lines[env->line_no - 1], env->col_no - 1, env->line_no - 1);
env->col_no -= 1;
if (env->coffset > 0) env->coffset--;
redraw_line(env->line_no - env->offset - 1, env->line_no-1);
set_modified();
redraw_statusbar();
@ -4553,6 +4554,25 @@ void delete_at_cursor(void) {
}
}
void delete_word(void) {
if (!env->lines[env->line_no-1]) return;
if (env->col_no > 1) {
do {
if (env->col_no > 1) {
line_delete(env->lines[env->line_no - 1], env->col_no - 1, env->line_no - 1);
env->col_no -= 1;
if (env->coffset > 0) env->coffset--;
}
} while (env->col_no > 1 && env->lines[env->line_no - 1]->text[env->col_no - 2].codepoint != ' ');
redraw_text();
set_modified();
redraw_statusbar();
place_cursor_actual();
}
}
/**
* Break the current line in two at the current cursor position.
*/
@ -5317,6 +5337,9 @@ void insert_mode(void) {
case ENTER_KEY:
insert_line_feed();
break;
case 23: /* ^W */
delete_word();
break;
case '\t':
if (env->tabs) {
insert_char('\t');