| 96 |
return NULL; |
return NULL; |
| 97 |
} |
} |
| 98 |
|
|
| 99 |
p_editor_data->display_line_total = split_data_lines(p_data, SCREEN_COLS, line_offsets, MAX_EDITOR_DATA_LINES + 1); |
p_editor_data->display_line_total = split_data_lines(p_data, SCREEN_COLS, line_offsets, MAX_EDITOR_DATA_LINES + 1, 0); |
| 100 |
|
|
| 101 |
for (i = 0; i < p_editor_data->display_line_total; i++) |
for (i = 0; i < p_editor_data->display_line_total; i++) |
| 102 |
{ |
{ |
| 362 |
} |
} |
| 363 |
|
|
| 364 |
// Split current data line since beginning of current display line |
// Split current data line since beginning of current display line |
| 365 |
split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total); |
split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total, 0); |
| 366 |
|
|
| 367 |
for (i = 0; i < split_line_total; i++) |
for (i = 0; i < split_line_total; i++) |
| 368 |
{ |
{ |
| 375 |
// Terminate prior display line with \n, to avoid error on cleanup |
// Terminate prior display line with \n, to avoid error on cleanup |
| 376 |
if (display_line + i - 1 >= 0 && p_editor_data->display_line_lengths[display_line + i - 1] > 0) |
if (display_line + i - 1 >= 0 && p_editor_data->display_line_lengths[display_line + i - 1] > 0) |
| 377 |
{ |
{ |
| 378 |
len = split_line(p_editor_data->p_display_lines[display_line + i - 1], SCREEN_COLS - 1, &eol, &display_len); |
len = split_line(p_editor_data->p_display_lines[display_line + i - 1], SCREEN_COLS - 1, &eol, &display_len, 0); |
| 379 |
p_editor_data->p_display_lines[display_line + i - 1][len] = '\n'; |
p_editor_data->p_display_lines[display_line + i - 1][len] = '\n'; |
| 380 |
p_editor_data->p_display_lines[display_line + i - 1][len + 1] = '\0'; |
p_editor_data->p_display_lines[display_line + i - 1][len + 1] = '\0'; |
| 381 |
p_editor_data->display_line_lengths[display_line + i - 1] = len + 1; |
p_editor_data->display_line_lengths[display_line + i - 1] = len + 1; |
| 422 |
// Prevent the last display line from being over-length |
// Prevent the last display line from being over-length |
| 423 |
if (p_editor_data->display_line_total == MAX_EDITOR_DATA_LINES) |
if (p_editor_data->display_line_total == MAX_EDITOR_DATA_LINES) |
| 424 |
{ |
{ |
| 425 |
len = split_line(p_editor_data->p_display_lines[p_editor_data->display_line_total - 1], SCREEN_COLS - 1, &eol, &display_len); |
len = split_line(p_editor_data->p_display_lines[p_editor_data->display_line_total - 1], SCREEN_COLS - 1, &eol, &display_len, 0); |
| 426 |
p_editor_data->p_display_lines[p_editor_data->display_line_total - 1][len] = '\0'; |
p_editor_data->p_display_lines[p_editor_data->display_line_total - 1][len] = '\0'; |
| 427 |
p_editor_data->display_line_lengths[p_editor_data->display_line_total - 1] = len; |
p_editor_data->display_line_lengths[p_editor_data->display_line_total - 1] = len; |
| 428 |
if (*p_display_line + 1 >= p_editor_data->display_line_total) |
if (*p_display_line + 1 >= p_editor_data->display_line_total) |
| 564 |
split_line_total = last_display_line - display_line + 2; |
split_line_total = last_display_line - display_line + 2; |
| 565 |
|
|
| 566 |
// Split current data line since beginning of current display line |
// Split current data line since beginning of current display line |
| 567 |
split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total); |
split_line_total = split_data_lines(p_data_line, SCREEN_COLS, line_offsets, split_line_total, 0); |
| 568 |
|
|
| 569 |
for (i = 0; i < split_line_total; i++) |
for (i = 0; i < split_line_total; i++) |
| 570 |
{ |
{ |
| 611 |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
| 612 |
"| 退出[\033[32mCtrl-W\033[33m] | 帮助[\033[32mh\033[33m] |"); |
"| 退出[\033[32mCtrl-W\033[33m] | 帮助[\033[32mh\033[33m] |"); |
| 613 |
break; |
break; |
| 614 |
|
case KEY_CSI: |
| 615 |
|
*p_key = KEY_ESC; |
| 616 |
|
break; |
| 617 |
} |
} |
| 618 |
|
|
| 619 |
return 0; |
return 0; |
| 666 |
"%s", |
"%s", |
| 667 |
row_pos, col_pos, |
row_pos, col_pos, |
| 668 |
ctx.line_cursor, p_editor_data->display_line_total, |
ctx.line_cursor, p_editor_data->display_line_total, |
| 669 |
key_insert ? "插入" : "改写", |
key_insert ? "插入" : "替换", |
| 670 |
ctx.msg); |
ctx.msg); |
| 671 |
|
|
| 672 |
len = split_line(buffer, SCREEN_COLS, &eol, &display_len); |
len = split_line(buffer, SCREEN_COLS, &eol, &display_len, 1); |
| 673 |
for (; display_len < SCREEN_COLS; display_len++) |
for (; display_len < SCREEN_COLS; display_len++) |
| 674 |
{ |
{ |
| 675 |
buffer[len++] = ' '; |
buffer[len++] = ' '; |