2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
#ifndef EL__VIEWER_TEXT_FORM_H
|
|
|
|
#define EL__VIEWER_TEXT_FORM_H
|
|
|
|
|
|
|
|
#include "document/forms.h"
|
|
|
|
#include "util/lists.h" /* LIST_HEAD */
|
|
|
|
#include "viewer/action.h"
|
|
|
|
|
|
|
|
struct document;
|
|
|
|
struct document_view;
|
|
|
|
struct link;
|
|
|
|
struct session;
|
|
|
|
struct term_event;
|
|
|
|
struct terminal;
|
|
|
|
|
2007-07-27 07:13:27 -04:00
|
|
|
/*! This struct looks a little embarrassing, yeah. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct form_view {
|
|
|
|
LIST_HEAD(struct form_view);
|
|
|
|
|
2007-07-27 07:13:27 -04:00
|
|
|
/** The corresponding form.form_num within the document.
|
|
|
|
* We can't just reference to struct form since we can potentially
|
|
|
|
* live much longer than that.
|
|
|
|
* @see find_form_by_form_view() */
|
2005-09-15 09:58:31 -04:00
|
|
|
int form_num;
|
|
|
|
|
|
|
|
#ifdef CONFIG_ECMASCRIPT
|
2007-07-27 07:13:27 -04:00
|
|
|
/** This holds the ECMAScript object attached to this structure. It can
|
2005-09-15 09:58:31 -04:00
|
|
|
* be NULL since the object is created on-demand at the first time some
|
|
|
|
* ECMAScript code accesses it. It is freed automatically by the
|
|
|
|
* garbage-collecting code when the ECMAScript context is over (usually
|
|
|
|
* when the document is destroyed). */
|
|
|
|
void *ecmascript_obj;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct form_state {
|
|
|
|
struct form_view *form_view;
|
|
|
|
int g_ctrl_num;
|
|
|
|
int position;
|
|
|
|
enum form_type type;
|
|
|
|
|
2007-07-27 07:13:27 -04:00
|
|
|
/* Editable string.
|
|
|
|
* - For ::FC_TEXT, ::FC_PASSWORD, ::FC_FILE, and
|
|
|
|
* ::FC_TEXTAREA, @c 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. The
|
|
|
|
* string is in the charset of the terminal (which can be
|
|
|
|
* UTF-8 only if CONFIG_UTF8 is defined, and is assumed to
|
|
|
|
* be unibyte otherwise). The charset of the document and
|
|
|
|
* the UTF-8 I/O option have no effect here. */
|
2005-09-15 09:58:31 -04:00
|
|
|
unsigned char *value;
|
2007-07-27 07:13:27 -04:00
|
|
|
/** Position in #value, or an editable integer.
|
|
|
|
* - For ::FC_TEXT, ::FC_PASSWORD, and ::FC_FILE, @c state is
|
|
|
|
* the byte position of the insertion point in #value.
|
|
|
|
* - For ::FC_CHECKBOX and ::FC_RADIO, @c state is 1 or 0.
|
|
|
|
* - For ::FC_SELECT, @c state is the index of the selected item
|
|
|
|
* in form_control.labels. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int state;
|
2006-09-17 09:12:47 -04:00
|
|
|
#ifdef CONFIG_UTF8
|
2007-07-27 07:13:27 -04:00
|
|
|
/** Position in the screen.
|
|
|
|
* - For ::FC_TEXT, ::FC_PASSWORD, and ::FC_FILE, @c
|
|
|
|
* state_cell is not used. */
|
2006-05-06 14:50:59 -04:00
|
|
|
int state_cell;
|
2006-09-17 09:12:47 -04:00
|
|
|
#endif /* CONFIG_UTF8 */
|
2007-07-27 07:13:27 -04:00
|
|
|
/** Horizontal scrolling.
|
|
|
|
* - For ::FC_TEXT, ::FC_PASSWORD, and ::FC_FILE, @c vpos is
|
|
|
|
* the index of the first displayed byte in #value. It
|
|
|
|
* should never be in the middle of a character. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int vpos;
|
2007-07-27 07:13:27 -04:00
|
|
|
/** Vertical scrolling. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int vypos;
|
|
|
|
|
|
|
|
#ifdef CONFIG_ECMASCRIPT
|
2007-07-27 07:13:27 -04:00
|
|
|
/** This holds the ECMAScript object attached to this structure. It can
|
2005-09-15 09:58:31 -04:00
|
|
|
* be NULL since the object is created on-demand at the first time some
|
|
|
|
* ECMAScript code accesses it. It is freed automatically by the
|
|
|
|
* garbage-collecting code when the ECMAScript context is over (usually
|
|
|
|
* when the document is destroyed). */
|
|
|
|
void *ecmascript_obj;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct submitted_value {
|
|
|
|
LIST_HEAD(struct submitted_value);
|
|
|
|
|
|
|
|
unsigned char *name;
|
|
|
|
unsigned char *value;
|
|
|
|
|
|
|
|
struct form_control *form_control;
|
|
|
|
|
|
|
|
enum form_type type;
|
|
|
|
int position;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct submitted_value *init_submitted_value(unsigned char *name, unsigned char *value, enum form_type type, struct form_control *fc, int position);
|
|
|
|
void done_submitted_value(struct submitted_value *sv);
|
2007-07-26 15:39:08 -04:00
|
|
|
void done_submitted_value_list(LIST_OF(struct submitted_value) *list);
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
struct uri *get_form_uri(struct session *ses, struct document_view *doc_view, struct form_control *fc);
|
|
|
|
|
|
|
|
unsigned char *get_form_info(struct session *ses, struct document_view *doc_view);
|
|
|
|
|
|
|
|
void selected_item(struct terminal *term, void *item_, void *ses_);
|
|
|
|
int get_current_state(struct session *ses);
|
|
|
|
|
|
|
|
struct form_state *find_form_state(struct document_view *doc_view, struct form_control *fc);
|
|
|
|
struct form_control *find_form_control(struct document *document, struct form_state *fs);
|
|
|
|
struct form_view *find_form_view_in_vs(struct view_state *vs, int form_num);
|
|
|
|
struct form_view *find_form_view(struct document_view *doc_view, struct form *form);
|
|
|
|
struct form *find_form_by_form_view(struct document *document, struct form_view *fv);
|
|
|
|
|
2008-07-18 12:16:34 -04:00
|
|
|
void done_form_state(struct form_state *);
|
2008-07-18 12:43:30 -04:00
|
|
|
void done_form_view(struct form_view *);
|
2008-07-18 12:16:34 -04:00
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
enum frame_event_status field_op(struct session *ses, struct document_view *doc_view, struct link *link, struct term_event *ev);
|
|
|
|
|
|
|
|
void draw_form_entry(struct terminal *term, struct document_view *doc_view, struct link *link);
|
|
|
|
void draw_forms(struct terminal *term, struct document_view *doc_view);
|
|
|
|
|
|
|
|
enum frame_event_status reset_form(struct session *ses, struct document_view *doc_view, int a);
|
|
|
|
enum frame_event_status submit_form(struct session *ses, struct document_view *doc_view, int do_reload);
|
2006-01-28 05:17:22 -05:00
|
|
|
void submit_given_form(struct session *ses, struct document_view *doc_view, struct form *form, int do_reload);
|
2005-09-15 09:58:31 -04:00
|
|
|
void auto_submit_form(struct session *ses);
|
|
|
|
void do_reset_form(struct document_view *doc_view, struct form *form);
|
|
|
|
|
2005-12-26 16:28:38 -05:00
|
|
|
void link_form_menu(struct session *ses);
|
2005-12-25 19:27:44 -05:00
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
#endif
|