| 647 |
EDITOR_CTX ctx; |
EDITOR_CTX ctx; |
| 648 |
int ch = 0; |
int ch = 0; |
| 649 |
char input_str[5]; |
char input_str[5]; |
| 650 |
|
int str_len = 0; |
| 651 |
wchar_t wcs[2]; |
wchar_t wcs[2]; |
| 652 |
|
int wc_len; |
| 653 |
char c; |
char c; |
|
int str_len = 0; |
|
| 654 |
int input_ok; |
int input_ok; |
| 655 |
const int screen_begin_row = 1; |
const int screen_begin_row = 1; |
| 656 |
const int screen_row_total = SCREEN_ROWS - screen_begin_row; |
const int screen_row_total = SCREEN_ROWS - screen_begin_row; |
| 1026 |
offset_in = split_line(p_editor_data->p_display_lines[line_current - output_current_row + row_pos], |
offset_in = split_line(p_editor_data->p_display_lines[line_current - output_current_row + row_pos], |
| 1027 |
(int)col_pos - 1, &eol, &display_len, 0); |
(int)col_pos - 1, &eol, &display_len, 0); |
| 1028 |
col_pos = display_len; |
col_pos = display_len; |
| 1029 |
if (offset_in >= 1 && p_editor_data->p_display_lines[line_current - output_current_row + row_pos][offset_in - 1] < 0) // UTF8 |
if (offset_in > 0) |
| 1030 |
{ |
{ |
| 1031 |
split_line(p_editor_data->p_display_lines[line_current - output_current_row + row_pos], |
str_len = 1; |
| 1032 |
(int)col_pos - 1, &eol, &display_len, 0); |
offset_in--; |
| 1033 |
if (display_len == col_pos - 2) |
if (p_editor_data->p_display_lines[line_current - output_current_row + row_pos][offset_in] < 0 || |
| 1034 |
|
p_editor_data->p_display_lines[line_current - output_current_row + row_pos][offset_in] > 127) // UTF8 |
| 1035 |
{ |
{ |
| 1036 |
col_pos--; |
while (offset_in > 0 && |
| 1037 |
|
(p_editor_data->p_display_lines[line_current - output_current_row + row_pos][offset_in] & 0xc0) != 0xc0) |
| 1038 |
|
{ |
| 1039 |
|
str_len++; |
| 1040 |
|
offset_in--; |
| 1041 |
|
} |
| 1042 |
|
|
| 1043 |
|
if (str_len > 4) |
| 1044 |
|
{ |
| 1045 |
|
log_error("Invalid UTF-8 data detected: str_len > 4\n"); |
| 1046 |
|
} |
| 1047 |
|
|
| 1048 |
|
if (mbstowcs(wcs, p_editor_data->p_display_lines[line_current - output_current_row + row_pos] + offset_in, 1) == |
| 1049 |
|
(size_t)-1) |
| 1050 |
|
{ |
| 1051 |
|
log_error("mbstowcs() error\n"); |
| 1052 |
|
} |
| 1053 |
|
wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0])); |
| 1054 |
|
|
| 1055 |
|
if (wc_len == 2) |
| 1056 |
|
{ |
| 1057 |
|
col_pos--; |
| 1058 |
|
} |
| 1059 |
} |
} |
| 1060 |
} |
} |
| 1061 |
if (col_pos >= 1) |
if (col_pos >= 1) |
| 1086 |
offset_in = split_line(p_editor_data->p_display_lines[line_current - output_current_row + row_pos], |
offset_in = split_line(p_editor_data->p_display_lines[line_current - output_current_row + row_pos], |
| 1087 |
(int)col_pos - 1, &eol, &display_len, 0); |
(int)col_pos - 1, &eol, &display_len, 0); |
| 1088 |
col_pos = display_len + 2; |
col_pos = display_len + 2; |
| 1089 |
if (offset_in < p_editor_data->display_line_lengths[line_current - output_current_row + row_pos] && |
if (offset_in < p_editor_data->display_line_lengths[line_current - output_current_row + row_pos]) |
|
p_editor_data->p_display_lines[line_current - output_current_row + row_pos][offset_in] < 0) // UTF8 |
|
| 1090 |
{ |
{ |
| 1091 |
split_line(p_editor_data->p_display_lines[line_current - output_current_row + row_pos] + offset_in, |
str_len = 0; |
| 1092 |
1, &eol, &display_len, 0); |
if ((p_editor_data->p_display_lines[line_current - output_current_row + row_pos][offset_in] & 0x80) == |
| 1093 |
if (display_len == 0) |
0x80) // head of multi-byte character |
| 1094 |
|
{ |
| 1095 |
|
c = (char)(p_editor_data->p_display_lines[line_current - output_current_row + row_pos][offset_in] & 0xf0); |
| 1096 |
|
while (c & 0x80) |
| 1097 |
|
{ |
| 1098 |
|
str_len++; |
| 1099 |
|
c = (c & 0x7f) << 1; |
| 1100 |
|
} |
| 1101 |
|
|
| 1102 |
|
if (str_len > 4) |
| 1103 |
|
{ |
| 1104 |
|
log_error("Invalid UTF-8 data detected: str_len > 4\n"); |
| 1105 |
|
} |
| 1106 |
|
|
| 1107 |
|
if (mbstowcs(wcs, p_editor_data->p_display_lines[line_current - output_current_row + row_pos] + offset_in, 1) == |
| 1108 |
|
(size_t)-1) |
| 1109 |
|
{ |
| 1110 |
|
log_error("mbstowcs() error\n"); |
| 1111 |
|
} |
| 1112 |
|
wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0])); |
| 1113 |
|
|
| 1114 |
|
if (wc_len == 2) |
| 1115 |
|
{ |
| 1116 |
|
col_pos++; |
| 1117 |
|
} |
| 1118 |
|
} |
| 1119 |
|
else |
| 1120 |
{ |
{ |
| 1121 |
col_pos++; |
str_len = 1; |
| 1122 |
} |
} |
| 1123 |
|
offset_in += str_len; |
| 1124 |
} |
} |
| 1125 |
if (col_pos <= p_editor_data->display_line_widths[line_current - output_current_row + row_pos]) |
if (col_pos <= p_editor_data->display_line_widths[line_current - output_current_row + row_pos]) |
| 1126 |
{ |
{ |