From a8c573a17409a7b0803b9534bd8d32b794be8130 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 2 Sep 2006 18:58:24 +0300 Subject: [PATCH] viewer: Document some members of struct form_state. The new comments describe how the members were apparently intended to be used. However, the implementation does not actually work when CONFIG_UTF_8 is defined, and the current semantics do not even allow an efficient implementation of long (mostly scrolled out) strings. --- src/viewer/text/form.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/viewer/text/form.h b/src/viewer/text/form.h index b813d77a..ed6164c8 100644 --- a/src/viewer/text/form.h +++ b/src/viewer/text/form.h @@ -37,11 +37,31 @@ struct form_state { int position; enum form_type type; + /* For FC_TEXT, FC_PASSWORD, and FC_FILE, @value is the text + * string that the user can edit. The string is null-terminated; + * its length is not stored separately. The size of the buffer + * is not stored anywhere; extending the string always requires + * calling realloc(). The string is not normally allowed to grow + * past @form_control.maxlength bytes (not counting the null), + * but there may be ways to get longer strings. */ unsigned char *value; + /* For FC_TEXT, FC_PASSWORD, and FC_FILE, @state is the byte + * position of the insertion point in @value. + * For FC_CHECKBOX and FC_RADIO, @state is 1 or 0. + * For FC_SELECT, @state is the index of the selected item + * in @form_control.labels. */ int state; #ifdef CONFIG_UTF_8 + /* For FC_TEXT, FC_PASSWORD, and FC_FILE, @state_cell is the + * number of cells needed for the text before the insertion + * point. (For FC_PASSWORD, each character is one cell.) + * When CONFIG_UTF_8 is not defined, @state_cell is assumed + * to be the same as @state. */ int state_cell; #endif /* CONFIG_UTF_8 */ + /* For FC_TEXT, FC_PASSWORD, and FC_FILE, @vpos is the number + * of cells that scrolling has hidden at the left. Thus, the + * X offset of the cursor is @state_cell - @vpos. */ int vpos; int vypos;