| 445 |
} |
} |
| 446 |
|
|
| 447 |
int editor_data_delete(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset, |
int editor_data_delete(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset, |
| 448 |
long *p_last_updated_line) |
long *p_last_updated_line, int del_line) |
| 449 |
{ |
{ |
| 450 |
long display_line = *p_display_line; |
long display_line = *p_display_line; |
| 451 |
long offset = *p_offset; |
long offset = *p_offset; |
| 500 |
} |
} |
| 501 |
|
|
| 502 |
// Check str to be deleted |
// Check str to be deleted |
| 503 |
if (p_data_line[offset_data_line] > 0 && p_data_line[offset_data_line] < 127) |
if (del_line) |
| 504 |
|
{ |
| 505 |
|
str_len = (int)(p_editor_data->display_line_lengths[display_line] - offset); |
| 506 |
|
} |
| 507 |
|
else if (p_data_line[offset_data_line] > 0 && p_data_line[offset_data_line] < 127) |
| 508 |
{ |
{ |
| 509 |
str_len = 1; |
str_len = 1; |
| 510 |
} |
} |
| 527 |
|
|
| 528 |
// Current display line is (almost) empty |
// Current display line is (almost) empty |
| 529 |
if (offset_data_line + str_len > len_data_line || |
if (offset_data_line + str_len > len_data_line || |
| 530 |
(offset_data_line + str_len == len_data_line && p_data_line[offset_data_line] == '\n')) |
(offset_data_line + str_len == len_data_line && |
| 531 |
|
p_data_line[del_line ? len_data_line - 1 : offset_data_line] == '\n')) |
| 532 |
{ |
{ |
| 533 |
if (display_line + 1 >= p_editor_data->display_line_total) // No additional display line (data line) |
if (display_line + 1 >= p_editor_data->display_line_total) // No additional display line (data line) |
| 534 |
{ |
{ |
| 668 |
int key_insert = 1; |
int key_insert = 1; |
| 669 |
int i, j; |
int i, j; |
| 670 |
char *p_str; |
char *p_str; |
| 671 |
|
int del_line; |
| 672 |
|
|
| 673 |
clrline(output_current_row, SCREEN_ROWS); |
clrline(output_current_row, SCREEN_ROWS); |
| 674 |
|
|
| 775 |
if (!key_insert) // overwrite |
if (!key_insert) // overwrite |
| 776 |
{ |
{ |
| 777 |
if (editor_data_delete(p_editor_data, &display_line_out, &offset_out, |
if (editor_data_delete(p_editor_data, &display_line_out, &offset_out, |
| 778 |
&last_updated_line) < 0) |
&last_updated_line, 0) < 0) |
| 779 |
{ |
{ |
| 780 |
log_error("editor_data_delete() error\n"); |
log_error("editor_data_delete() error\n"); |
| 781 |
} |
} |
| 844 |
str_len = 0; |
str_len = 0; |
| 845 |
continue; |
continue; |
| 846 |
} |
} |
| 847 |
else if (ch == KEY_DEL || ch == BACKSPACE) // Del |
else if (ch == KEY_DEL || ch == BACKSPACE || ch == Ctrl('K') || ch == Ctrl('Y')) // Del |
| 848 |
{ |
{ |
| 849 |
// Refresh current action while user input |
// Refresh current action while user input |
| 850 |
if (user_online_update(NULL) < 0) |
if (user_online_update(NULL) < 0) |
| 852 |
log_error("user_online_update(NULL) error\n"); |
log_error("user_online_update(NULL) error\n"); |
| 853 |
} |
} |
| 854 |
|
|
| 855 |
|
del_line = 0; |
| 856 |
|
|
| 857 |
if (ch == BACKSPACE) |
if (ch == BACKSPACE) |
| 858 |
{ |
{ |
| 859 |
if (line_current - output_current_row + row_pos <= 0 && col_pos <= 1) // Forbidden |
if (line_current - output_current_row + row_pos <= 0 && col_pos <= 1) // Forbidden |
| 878 |
col_pos = MAX(1, p_editor_data->display_line_widths[line_current - output_current_row + row_pos]); |
col_pos = MAX(1, p_editor_data->display_line_widths[line_current - output_current_row + row_pos]); |
| 879 |
} |
} |
| 880 |
} |
} |
| 881 |
|
else if (ch == Ctrl('K')) |
| 882 |
|
{ |
| 883 |
|
del_line = 1; |
| 884 |
|
} |
| 885 |
|
else if (ch == Ctrl('Y')) |
| 886 |
|
{ |
| 887 |
|
col_pos = 1; |
| 888 |
|
del_line = 1; |
| 889 |
|
} |
| 890 |
|
|
| 891 |
display_line_in = line_current - output_current_row + row_pos; |
display_line_in = line_current - output_current_row + row_pos; |
| 892 |
offset_in = split_line(p_editor_data->p_display_lines[display_line_in], (int)col_pos - 1, &eol, &display_len, 0); |
offset_in = split_line(p_editor_data->p_display_lines[display_line_in], (int)col_pos - 1, &eol, &display_len, 0); |
| 894 |
offset_out = offset_in; |
offset_out = offset_in; |
| 895 |
|
|
| 896 |
if ((str_len = editor_data_delete(p_editor_data, &display_line_out, &offset_out, |
if ((str_len = editor_data_delete(p_editor_data, &display_line_out, &offset_out, |
| 897 |
&last_updated_line)) < 0) |
&last_updated_line, del_line)) < 0) |
| 898 |
{ |
{ |
| 899 |
log_error("editor_data_delete() error\n"); |
log_error("editor_data_delete() error: %d\n", str_len); |
| 900 |
} |
} |
| 901 |
else |
else |
| 902 |
{ |
{ |