1
0
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:
Pavol Babincak 2006-05-06 20:50:59 +02:00 committed by Pavol Babincak
parent 9d1008c523
commit f515f14e08
4 changed files with 22 additions and 22 deletions

View File

@ -169,7 +169,7 @@ init_form_state(struct form_control *fc, struct form_state *fs)
fs->state = strlen(fc->default_value);
#ifdef CONFIG_UTF_8
text = fs->value;
fs->utf8_pos = strlen_utf8(&text);
fs->state_cell = strlen_utf8(&text);
#endif /* CONFIG_UTF_8 */
fs->vpos = 0;
break;
@ -177,7 +177,7 @@ init_form_state(struct form_control *fc, struct form_state *fs)
fs->value = stracpy("");
fs->state = 0;
#ifdef CONFIG_UTF_8
fs->utf8_pos = 0;
fs->state_cell = 0;
#endif /* CONFIG_UTF_8 */
fs->vpos = 0;
break;
@ -381,7 +381,7 @@ draw_form_entry(struct terminal *term, struct document_view *doc_view,
utf_8:
text = fs->value;
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;
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);
fs->state = (int)(text - fs->value);
if (old != fs->state) fs->utf8_pos--;
if (old != fs->state) fs->state_cell--;
} else
#endif /* CONFIG_UTF_8 */
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);
fs->state = (int)(text - fs->value);
if (old != fs->state) fs->utf8_pos++;
if (old != fs->state) fs->state_cell++;
} else
#endif /* CONFIG_UTF_8 */
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 {
fs->state = 0;
#ifdef CONFIG_UTF_8
fs->utf8_pos = 0;
fs->state_cell = 0;
#endif /* CONFIG_UTF_8 */
}
break;
@ -1357,7 +1357,7 @@ field_op(struct session *ses, struct document_view *doc_view,
if (utf8) {
unsigned char *text = fs->value;
fs->utf8_pos = strlen_utf8(&text);
fs->state_cell = strlen_utf8(&text);
}
#endif /* CONFIG_UTF_8 */
}
@ -1372,7 +1372,7 @@ field_op(struct session *ses, struct document_view *doc_view,
} else {
fs->state = 0;
#ifdef CONFIG_UTF_8
fs->utf8_pos = 0;
fs->state_cell = 0;
#endif /* CONFIG_UTF_8 */
}
break;
@ -1389,7 +1389,7 @@ field_op(struct session *ses, struct document_view *doc_view,
if (utf8) {
unsigned char *text = fs->value;
fs->utf8_pos = strlen_utf8(&text);
fs->state_cell = strlen_utf8(&text);
}
#endif /* CONFIG_UTF_8 */
}
@ -1410,7 +1410,7 @@ field_op(struct session *ses, struct document_view *doc_view,
fs->value[0] = 0;
fs->state = 0;
#ifdef CONFIG_UTF_8
fs->utf8_pos = 0;
fs->state_cell = 0;
#endif /* CONFIG_UTF_8 */
break;
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) {
unsigned char *text = fs->value;
fs->utf8_pos = strlen_utf8(&text);
fs->state_cell = strlen_utf8(&text);
}
#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 *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);
length = strlen(end) + 1;
memmove(text, end, length);
fs->state = (int)(text - fs->value);
fs->utf8_pos--;
fs->state_cell--;
break;
}
#endif /* CONFIG_UTF_8 */
@ -1548,7 +1548,7 @@ field_op(struct session *ses, struct document_view *doc_view,
if (utf8 && fc->type != FC_TEXTAREA) {
unsigned char *text = fs->value;
fs->utf8_pos = strlen_utf8(&text);
fs->state_cell = strlen_utf8(&text);
}
#endif /* CONFIG_UTF_8 */
break;
@ -1630,7 +1630,7 @@ field_op(struct session *ses, struct document_view *doc_view,
return FRAME_EVENT_OK;
}
fs->state += i;
fs->utf8_pos++;
fs->state_cell++;
i = 0;
break;
}

View File

@ -40,7 +40,7 @@ struct form_state {
unsigned char *value;
int state;
#ifdef CONFIG_UTF_8
int utf8_pos;
int state_cell;
#endif /* CONFIG_UTF_8 */
int vpos;
int vypos;

View File

@ -128,7 +128,7 @@ get_link_cursor_offset(struct document_view *doc_view, struct link *link)
fs = find_form_state(doc_view, fc);
#ifdef CONFIG_UTF_8
if (utf8) {
return fs ? fs->utf8_pos - fs->vpos : 0;
return fs ? fs->state_cell - fs->vpos : 0;
} else
#endif /* CONFIG_UTF_8 */
return fs ? fs->state - fs->vpos : 0;

View File

@ -64,7 +64,7 @@ format_textutf8(unsigned char *text, int width, enum form_wrap wrap, int format)
int pos = 0;
int skip;
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);
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') {
skip = 1;
} else if (wrap == FORM_WRAP_NONE || char_cnt < width) {
} else if (wrap == FORM_WRAP_NONE || chars_cells < width) {
pos += utf8charlen(&text[pos]);
char_cnt++;
chars_cells++;
continue;
} else {
@ -96,7 +96,7 @@ format_textutf8(unsigned char *text, int width, enum form_wrap wrap, int format)
}
skip = !!wrappos;
}
char_cnt = 0;
chars_cells = 0;
wrappos = NULL;
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];
fs->value[fs->state] = '\0';
fs->utf8_pos = strlen_utf8(&text);
fs->state_cell = strlen_utf8(&text);
text = fs->value + line[y].start;
x = strlen_utf8(&text);