mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Renamed variables utf8_pos to state_cell and char_cnt to chars_cells.
This commit is contained in:
parent
9d1008c523
commit
f515f14e08
@ -169,7 +169,7 @@ init_form_state(struct form_control *fc, struct form_state *fs)
|
|||||||
fs->state = strlen(fc->default_value);
|
fs->state = strlen(fc->default_value);
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
text = fs->value;
|
text = fs->value;
|
||||||
fs->utf8_pos = strlen_utf8(&text);
|
fs->state_cell = strlen_utf8(&text);
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
fs->vpos = 0;
|
fs->vpos = 0;
|
||||||
break;
|
break;
|
||||||
@ -177,7 +177,7 @@ init_form_state(struct form_control *fc, struct form_state *fs)
|
|||||||
fs->value = stracpy("");
|
fs->value = stracpy("");
|
||||||
fs->state = 0;
|
fs->state = 0;
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
fs->utf8_pos = 0;
|
fs->state_cell = 0;
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
fs->vpos = 0;
|
fs->vpos = 0;
|
||||||
break;
|
break;
|
||||||
@ -381,7 +381,7 @@ draw_form_entry(struct terminal *term, struct document_view *doc_view,
|
|||||||
utf_8:
|
utf_8:
|
||||||
text = fs->value;
|
text = fs->value;
|
||||||
end = strchr(text, '\0');
|
end = strchr(text, '\0');
|
||||||
int_bounds(&fs->vpos, fs->utf8_pos - fc->size + 1, fs->utf8_pos);
|
int_bounds(&fs->vpos, fs->state_cell - fc->size + 1, fs->state_cell);
|
||||||
if (!link->npoints) break;
|
if (!link->npoints) break;
|
||||||
|
|
||||||
y = link->points[0].y + dy;
|
y = link->points[0].y + dy;
|
||||||
@ -1291,7 +1291,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
|
|
||||||
while (utf_8_to_unicode(&text, end) != UCS_NO_CHAR);
|
while (utf_8_to_unicode(&text, end) != UCS_NO_CHAR);
|
||||||
fs->state = (int)(text - fs->value);
|
fs->state = (int)(text - fs->value);
|
||||||
if (old != fs->state) fs->utf8_pos--;
|
if (old != fs->state) fs->state_cell--;
|
||||||
} else
|
} else
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
fs->state = int_max(fs->state - 1, 0);
|
fs->state = int_max(fs->state - 1, 0);
|
||||||
@ -1305,7 +1305,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
|
|
||||||
utf_8_to_unicode(&text, end);
|
utf_8_to_unicode(&text, end);
|
||||||
fs->state = (int)(text - fs->value);
|
fs->state = (int)(text - fs->value);
|
||||||
if (old != fs->state) fs->utf8_pos++;
|
if (old != fs->state) fs->state_cell++;
|
||||||
} else
|
} else
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
fs->state = int_min(fs->state + 1, strlen(fs->value));
|
fs->state = int_min(fs->state + 1, strlen(fs->value));
|
||||||
@ -1320,7 +1320,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
} else {
|
} else {
|
||||||
fs->state = 0;
|
fs->state = 0;
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
fs->utf8_pos = 0;
|
fs->state_cell = 0;
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1357,7 +1357,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
if (utf8) {
|
if (utf8) {
|
||||||
unsigned char *text = fs->value;
|
unsigned char *text = fs->value;
|
||||||
|
|
||||||
fs->utf8_pos = strlen_utf8(&text);
|
fs->state_cell = strlen_utf8(&text);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
}
|
}
|
||||||
@ -1372,7 +1372,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
} else {
|
} else {
|
||||||
fs->state = 0;
|
fs->state = 0;
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
fs->utf8_pos = 0;
|
fs->state_cell = 0;
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1389,7 +1389,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
if (utf8) {
|
if (utf8) {
|
||||||
unsigned char *text = fs->value;
|
unsigned char *text = fs->value;
|
||||||
|
|
||||||
fs->utf8_pos = strlen_utf8(&text);
|
fs->state_cell = strlen_utf8(&text);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
}
|
}
|
||||||
@ -1410,7 +1410,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
fs->value[0] = 0;
|
fs->value[0] = 0;
|
||||||
fs->state = 0;
|
fs->state = 0;
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
fs->utf8_pos = 0;
|
fs->state_cell = 0;
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
break;
|
break;
|
||||||
case ACT_EDIT_PASTE_CLIPBOARD:
|
case ACT_EDIT_PASTE_CLIPBOARD:
|
||||||
@ -1431,7 +1431,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
if (utf8 && fc->type != FC_TEXTAREA) {
|
if (utf8 && fc->type != FC_TEXTAREA) {
|
||||||
unsigned char *text = fs->value;
|
unsigned char *text = fs->value;
|
||||||
|
|
||||||
fs->utf8_pos = strlen_utf8(&text);
|
fs->state_cell = strlen_utf8(&text);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
}
|
}
|
||||||
@ -1475,12 +1475,12 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
unsigned char *text = fs->value;
|
unsigned char *text = fs->value;
|
||||||
unsigned char *end = fs->value + fs->state;
|
unsigned char *end = fs->value + fs->state;
|
||||||
|
|
||||||
for (i = 0; i < fs->utf8_pos - 1; i++)
|
for (i = 0; i < fs->state_cell - 1; i++)
|
||||||
utf_8_to_unicode(&text, end);
|
utf_8_to_unicode(&text, end);
|
||||||
length = strlen(end) + 1;
|
length = strlen(end) + 1;
|
||||||
memmove(text, end, length);
|
memmove(text, end, length);
|
||||||
fs->state = (int)(text - fs->value);
|
fs->state = (int)(text - fs->value);
|
||||||
fs->utf8_pos--;
|
fs->state_cell--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
@ -1548,7 +1548,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
if (utf8 && fc->type != FC_TEXTAREA) {
|
if (utf8 && fc->type != FC_TEXTAREA) {
|
||||||
unsigned char *text = fs->value;
|
unsigned char *text = fs->value;
|
||||||
|
|
||||||
fs->utf8_pos = strlen_utf8(&text);
|
fs->state_cell = strlen_utf8(&text);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
break;
|
break;
|
||||||
@ -1630,7 +1630,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
|||||||
return FRAME_EVENT_OK;
|
return FRAME_EVENT_OK;
|
||||||
}
|
}
|
||||||
fs->state += i;
|
fs->state += i;
|
||||||
fs->utf8_pos++;
|
fs->state_cell++;
|
||||||
i = 0;
|
i = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ struct form_state {
|
|||||||
unsigned char *value;
|
unsigned char *value;
|
||||||
int state;
|
int state;
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
int utf8_pos;
|
int state_cell;
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
int vpos;
|
int vpos;
|
||||||
int vypos;
|
int vypos;
|
||||||
|
@ -128,7 +128,7 @@ get_link_cursor_offset(struct document_view *doc_view, struct link *link)
|
|||||||
fs = find_form_state(doc_view, fc);
|
fs = find_form_state(doc_view, fc);
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
if (utf8) {
|
if (utf8) {
|
||||||
return fs ? fs->utf8_pos - fs->vpos : 0;
|
return fs ? fs->state_cell - fs->vpos : 0;
|
||||||
} else
|
} else
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
return fs ? fs->state - fs->vpos : 0;
|
return fs ? fs->state - fs->vpos : 0;
|
||||||
|
@ -64,7 +64,7 @@ format_textutf8(unsigned char *text, int width, enum form_wrap wrap, int format)
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
int skip;
|
int skip;
|
||||||
unsigned char *wrappos=NULL;
|
unsigned char *wrappos=NULL;
|
||||||
int char_cnt=0; /* Number of console chars on line */
|
int chars_cells=0; /* Number of console chars on line */
|
||||||
|
|
||||||
assert(text);
|
assert(text);
|
||||||
if_assert_failed return NULL;
|
if_assert_failed return NULL;
|
||||||
@ -81,9 +81,9 @@ format_textutf8(unsigned char *text, int width, enum form_wrap wrap, int format)
|
|||||||
if (text[pos] == '\n') {
|
if (text[pos] == '\n') {
|
||||||
skip = 1;
|
skip = 1;
|
||||||
|
|
||||||
} else if (wrap == FORM_WRAP_NONE || char_cnt < width) {
|
} else if (wrap == FORM_WRAP_NONE || chars_cells < width) {
|
||||||
pos += utf8charlen(&text[pos]);
|
pos += utf8charlen(&text[pos]);
|
||||||
char_cnt++;
|
chars_cells++;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -96,7 +96,7 @@ format_textutf8(unsigned char *text, int width, enum form_wrap wrap, int format)
|
|||||||
}
|
}
|
||||||
skip = !!wrappos;
|
skip = !!wrappos;
|
||||||
}
|
}
|
||||||
char_cnt = 0;
|
chars_cells = 0;
|
||||||
wrappos = NULL;
|
wrappos = NULL;
|
||||||
|
|
||||||
if (!realloc_line_info(&line, line_number)) {
|
if (!realloc_line_info(&line, line_number)) {
|
||||||
@ -242,7 +242,7 @@ area_cursor(struct form_control *fc, struct form_state *fs)
|
|||||||
unsigned char tmp = fs->value[fs->state];
|
unsigned char tmp = fs->value[fs->state];
|
||||||
|
|
||||||
fs->value[fs->state] = '\0';
|
fs->value[fs->state] = '\0';
|
||||||
fs->utf8_pos = strlen_utf8(&text);
|
fs->state_cell = strlen_utf8(&text);
|
||||||
|
|
||||||
text = fs->value + line[y].start;
|
text = fs->value + line[y].start;
|
||||||
x = strlen_utf8(&text);
|
x = strlen_utf8(&text);
|
||||||
|
Loading…
Reference in New Issue
Block a user