NetSurf
|
Single/Multi-line UTF-8 text area interface. More...
Go to the source code of this file.
Data Structures | |
struct | textarea_msg |
textarea message More... | |
struct | textarea_setup |
textarea setup parameters More... | |
Typedefs | |
typedef struct textarea_setup | textarea_setup |
textarea setup parameters More... | |
typedef void(* | textarea_client_callback) (void *data, struct textarea_msg *msg) |
Client callback for the textarea. More... | |
Functions | |
struct textarea * | textarea_create (const textarea_flags flags, const textarea_setup *setup, textarea_client_callback callback, void *data) |
Create a text area. More... | |
void | textarea_destroy (struct textarea *ta) |
Destroy a text area. More... | |
bool | textarea_set_text (struct textarea *ta, const char *text) |
Set the text in a text area, discarding any current text. More... | |
bool | textarea_drop_text (struct textarea *ta, const char *text, size_t text_length) |
Insert the text in a text area at the caret, replacing any selection. More... | |
int | textarea_get_text (struct textarea *ta, char *buf, unsigned int len) |
Extract the text from a text area. More... | |
const char * | textarea_data (struct textarea *ta, unsigned int *len) |
Access text data in a text area. More... | |
bool | textarea_set_caret (struct textarea *ta, int caret) |
Set the caret's position. More... | |
void | textarea_redraw (struct textarea *ta, int x, int y, colour bg, float scale, const struct rect *clip, const struct redraw_context *ctx) |
Handle redraw requests for text areas. More... | |
bool | textarea_keypress (struct textarea *ta, uint32_t key) |
Key press handling for text areas. More... | |
textarea_mouse_status | textarea_mouse_action (struct textarea *ta, browser_mouse_state mouse, int x, int y) |
Handles all kinds of mouse action. More... | |
bool | textarea_clear_selection (struct textarea *ta) |
Clear any selection in the textarea. More... | |
char * | textarea_get_selection (struct textarea *ta) |
Get selected text. More... | |
void | textarea_get_dimensions (struct textarea *ta, int *width, int *height) |
Gets the dimensions of a textarea. More... | |
void | textarea_set_dimensions (struct textarea *ta, int width, int height) |
Set the dimensions of a textarea. More... | |
void | textarea_set_layout (struct textarea *ta, const plot_font_style_t *fstyle, int width, int height, int top, int right, int bottom, int left) |
Set the dimensions and padding of a textarea. More... | |
bool | textarea_scroll (struct textarea *ta, int scrx, int scry) |
Scroll a textarea by an amount. More... | |
Single/Multi-line UTF-8 text area interface.
Definition in file textarea.h.
typedef void(* textarea_client_callback) (void *data, struct textarea_msg *msg) |
Client callback for the textarea.
data | user data passed at textarea creation |
msg | textarea message data |
Definition at line 156 of file textarea.h.
typedef struct textarea_setup textarea_setup |
textarea setup parameters
enum textarea_drag_type |
Textarea drag status.
Enumerator | |
---|---|
TEXTAREA_DRAG_NONE | |
TEXTAREA_DRAG_SCROLLBAR | |
TEXTAREA_DRAG_SELECTION |
Definition at line 52 of file textarea.h.
enum textarea_flags |
Text area flags.
Enumerator | |
---|---|
TEXTAREA_DEFAULT | Standard input. |
TEXTAREA_MULTILINE | Multiline area. |
TEXTAREA_READONLY | Non-editable. |
TEXTAREA_INTERNAL_CARET | Render own caret. |
TEXTAREA_PASSWORD | Obscured display. |
Definition at line 40 of file textarea.h.
Text area mouse input status flags.
Definition at line 130 of file textarea.h.
enum textarea_msg_type |
textarea message types
Definition at line 62 of file textarea.h.
bool textarea_clear_selection | ( | struct textarea * | ta | ) |
Clear any selection in the textarea.
ta | textarea widget |
Definition at line 3205 of file textarea.c.
References line_info::b_start, textarea::bar_x, textarea::bar_y, textarea::border_width, textarea::callback, textarea_msg::caret, textarea::caret_x, textarea::caret_y, textarea_msg::clip, textarea::data, textarea_msg::data, textarea::flags, textarea_msg::have_selection, textarea_msg::height, textarea::line_count, textarea::line_height, textarea::lines, max, min, textarea_msg::pos, textarea_msg::read_only, textarea_msg::redraw, textarea::scroll_x, textarea::scroll_y, SCROLLBAR_WIDTH, textarea::sel_end, textarea::sel_start, textarea_msg::selection, textarea_msg::ta, textarea::text_y_offset, TEXTAREA_INTERNAL_CARET, TEXTAREA_MSG_CARET_UPDATE, TEXTAREA_MSG_REDRAW_REQUEST, TEXTAREA_MSG_SELECTION_REPORT, TEXTAREA_READONLY, textarea_reset_selection(), textarea_msg::type, textarea::vis_height, textarea::vis_width, textarea_msg::x, rect::x0, rect::x1, textarea_msg::y, rect::y0, and rect::y1.
Referenced by html_clear_selection(), html_set_selection(), textarea_keypress(), textarea_mouse_action(), and textarea_select().
struct textarea * textarea_create | ( | const textarea_flags | flags, |
const textarea_setup * | setup, | ||
textarea_client_callback | callback, | ||
void * | data | ||
) |
Create a text area.
flags | flags controlling the text area creation |
setup | textarea settings and style |
callback | will be called when textarea wants to redraw |
data | user specified data which will be passed to callbacks |
Definition at line 1852 of file textarea.c.
References textarea_utf8::alloc, textarea::bar_x, textarea::bar_y, textarea::border_col, textarea_setup::border_col, textarea::border_width, textarea_setup::border_width, textarea::byte_off, textarea::callback, textarea::caret_pos, textarea::caret_x, textarea::caret_y, textarea_utf8::data, textarea::data, textarea_undo::details, textarea_undo::details_alloc, textarea::drag_info, textarea::drag_start, textarea::flags, textarea::h_extent, textarea_setup::height, textarea_undo::last_detail, textarea_utf8::len, textarea::line, textarea::line_count, textarea::line_height, textarea::lines, textarea::lines_alloc_size, textarea_undo::next_detail, nscss_screen_dpi, NSLOG, textarea::pad_bottom, textarea_setup::pad_bottom, textarea::pad_left, textarea_setup::pad_left, textarea::pad_right, textarea_setup::pad_right, textarea::pad_top, textarea_setup::pad_top, textarea::password, PLOT_STYLE_SCALE, textarea::scroll_x, textarea::scroll_y, textarea::sel_end, textarea::sel_start, textarea_setup::selected_bg, textarea_setup::selected_text, textarea::show, plot_font_style::size, TA_ALLOC_STEP, textarea_undo::text, textarea::text, textarea_setup::text, TEXTAREA_DRAG_NONE, TEXTAREA_MULTILINE, TEXTAREA_PASSWORD, textarea_reflow_multiline(), textarea_reflow_singleline(), textarea_set_text_style(), textarea_setup_text_offsets(), textarea_drag::type, textarea::undo, textarea_utf8::utf8_len, textarea::v_extent, textarea::vis_height, textarea::vis_width, and textarea_setup::width.
Referenced by box_textarea_create_textarea(), toolbar_create(), and treeview__create_textarea().
const char * textarea_data | ( | struct textarea * | ta, |
unsigned int * | len | ||
) |
Access text data in a text area.
[in] | ta | Text area |
[out] | len | Returns byte length of returned text, if passed non-NULL. |
Definition at line 2101 of file textarea.c.
References textarea_utf8::data, textarea_utf8::len, and textarea::text.
Referenced by treeview__search_update_display().
void textarea_destroy | ( | struct textarea * | ta | ) |
Destroy a text area.
ta | Text area to destroy |
Definition at line 1975 of file textarea.c.
References textarea::bar_x, textarea::bar_y, textarea_utf8::data, textarea_undo::details, textarea::flags, textarea::lines, textarea::password, scrollbar_destroy(), textarea_undo::text, textarea::text, TEXTAREA_PASSWORD, and textarea::undo.
Referenced by form_free_control(), toolbar_destroy(), treeview_destroy(), treeview_edit_cancel(), and treeview_edit_node_at_point().
bool textarea_drop_text | ( | struct textarea * | ta, |
const char * | text, | ||
size_t | text_length | ||
) |
Insert the text in a text area at the caret, replacing any selection.
ta | Text area |
text | UTF-8 text to set text area's contents to |
text_length | length of text. |
< Redraw rectangle
Definition at line 2032 of file textarea.c.
References textarea::callback, textarea::data, textarea_msg::data, textarea::flags, textarea_msg::redraw, textarea::sel_end, textarea::sel_start, textarea_msg::ta, text(), textarea_get_caret(), TEXTAREA_MSG_REDRAW_REQUEST, TEXTAREA_READONLY, textarea_replace_text(), textarea_set_caret_internal(), textarea_msg::type, textarea::vis_height, textarea::vis_width, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by html_drop_file_at_point().
void textarea_get_dimensions | ( | struct textarea * | ta, |
int * | width, | ||
int * | height | ||
) |
Gets the dimensions of a textarea.
ta | textarea widget |
width | if not NULL, gets updated to the width of the textarea |
height | if not NULL, gets updated to the height of the textarea |
Definition at line 3308 of file textarea.c.
References height, textarea::vis_height, textarea::vis_width, and width.
char * textarea_get_selection | ( | struct textarea * | ta | ) |
Get selected text.
ownership of the returned string is passed to caller which needs to free it.
ta | Textarea widget |
Definition at line 3278 of file textarea.c.
References textarea_utf8::data, textarea::sel_end, textarea::sel_start, and textarea::show.
Referenced by html_get_selection().
int textarea_get_text | ( | struct textarea * | ta, |
char * | buf, | ||
unsigned int | len | ||
) |
Extract the text from a text area.
ta | Text area |
buf | Pointer to buffer to receive data, or NULL to read length required (includes trailing '\0') |
len | Length (bytes) of buffer pointed to by buf, or 0 to read length |
Definition at line 2078 of file textarea.c.
References textarea_utf8::data, textarea_utf8::len, NSLOG, textarea::text, and text().
Referenced by toolbar_get_url(), toolbar_key_input(), treeview__search_cancel(), and treeview_edit_done().
bool textarea_keypress | ( | struct textarea * | ta, |
uint32_t | key | ||
) |
Key press handling for text areas.
ta | The text area which got the keypress |
key | The ucs4 character codepoint |
< Redraw rectangle
Definition at line 2450 of file textarea.c.
References line_info::b_length, line_info::b_start, textarea::bar_x, textarea::bar_y, textarea::border_width, textarea::byte_off, textarea::callback, textarea::caret_pos, textarea::caret_x, netsurf_table::clipboard, clipboard, textarea_utf8::data, textarea::data, textarea_msg::data, textarea::flags, gui_clipboard_table::get, guit, textarea::h_extent, textarea_utf8::len, textarea::line, line(), textarea::line_count, textarea::line_height, textarea::lines, NS_KEY_CLEAR_SELECTION, NS_KEY_COPY_SELECTION, NS_KEY_CR, NS_KEY_CUT_SELECTION, NS_KEY_DELETE_LEFT, NS_KEY_DELETE_LINE, NS_KEY_DELETE_LINE_END, NS_KEY_DELETE_LINE_START, NS_KEY_DELETE_RIGHT, NS_KEY_DELETE_WORD_LEFT, NS_KEY_DELETE_WORD_RIGHT, NS_KEY_DOWN, NS_KEY_ESCAPE, NS_KEY_LEFT, NS_KEY_LINE_END, NS_KEY_LINE_START, NS_KEY_NL, NS_KEY_PAGE_DOWN, NS_KEY_PAGE_UP, NS_KEY_PASTE, NS_KEY_REDO, NS_KEY_RIGHT, NS_KEY_SELECT_ALL, NS_KEY_TEXT_END, NS_KEY_TEXT_START, NS_KEY_UNDO, NS_KEY_UP, NS_KEY_WORD_LEFT, NS_KEY_WORD_RIGHT, textarea::pad_bottom, textarea::pad_top, textarea_msg::redraw, textarea::sel_end, textarea::sel_start, textarea::show, textarea_msg::ta, textarea::text, textarea::text_y_offset_baseline, textarea_clear_selection(), textarea_get_caret(), TEXTAREA_MSG_REDRAW_REQUEST, TEXTAREA_MULTILINE, TEXTAREA_PASSWORD, TEXTAREA_READONLY, textarea_replace_text(), textarea_reset_selection(), textarea_scroll(), textarea_select(), textarea_set_caret_internal(), textarea_set_caret_xy(), textarea_undo(), textarea_msg::type, utf8_from_ucs4(), utf8_next(), utf8_prev(), textarea::v_extent, textarea::vis_height, textarea::vis_width, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by box_textarea_keypress(), toolbar_key_input(), and treeview_keypress().
textarea_mouse_status textarea_mouse_action | ( | struct textarea * | ta, |
browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handles all kinds of mouse action.
ta | Text area |
mouse | the mouse state at action moment |
x | X coordinate |
y | Y coordinate |
Definition at line 3069 of file textarea.c.
References textarea::bar_x, textarea::bar_y, textarea::border_width, BROWSER_MOUSE_DOUBLE_CLICK, BROWSER_MOUSE_DRAG_1, BROWSER_MOUSE_DRAG_2, BROWSER_MOUSE_HOLDING_1, BROWSER_MOUSE_HOLDING_2, BROWSER_MOUSE_HOVER, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, BROWSER_MOUSE_TRIPLE_CLICK, textarea::callback, textarea::data, textarea_msg::data, textarea_msg::drag, textarea::drag_info, textarea::drag_start, textarea::flags, SCROLLBAR_WIDTH, textarea::sel_end, textarea::sel_start, textarea_msg::ta, textarea_clear_selection(), textarea_drag_end(), TEXTAREA_DRAG_NONE, TEXTAREA_DRAG_SELECTION, textarea_get_b_off_xy(), textarea_get_caret(), TEXTAREA_MOUSE_EDITOR, TEXTAREA_MOUSE_NONE, textarea_mouse_scrollbar_action(), TEXTAREA_MOUSE_SELECTION, TEXTAREA_MOUSE_USED, TEXTAREA_MSG_DRAG_REPORT, TEXTAREA_MULTILINE, textarea_scroll(), textarea_select(), textarea_select_fragment(), textarea_select_paragraph(), textarea_set_caret_internal(), textarea_set_caret_xy(), textarea_drag::type, textarea_msg::type, textarea::vis_height, textarea::vis_width, textarea_msg::x, and textarea_msg::y.
Referenced by gadget_mouse_action(), html_drop_file_at_point(), mouse_action_drag_textarea(), toolbar_mouse_input(), treeview_edit_node_at_point(), and treeview_mouse_action().
void textarea_redraw | ( | struct textarea * | ta, |
int | x, | ||
int | y, | ||
colour | bg, | ||
float | scale, | ||
const struct rect * | clip, | ||
const struct redraw_context * | ctx | ||
) |
Handle redraw requests for text areas.
ta | textarea to render |
x | x coordinate of textarea top |
y | y coordinate of textarea left |
bg | background colour under textarea |
scale | scale to render at |
clip | clip rectangle |
ctx | current redraw context |
Definition at line 2131 of file textarea.c.
References line_info::b_length, line_info::b_start, plot_font_style::background, textarea::bar_x, textarea::bar_y, textarea::border_col, textarea::border_width, textarea::byte_off, textarea::caret_pos, textarea::caret_x, textarea::caret_y, clip(), plotter_table::clip, textarea_utf8::data, plot_style_s::fill_colour, textarea::flags, textarea::fstyle, guit, netsurf_table::layout, line(), plotter_table::line, textarea::line_count, line_height(), textarea::line_height, textarea::lines, NS_TRANSPARENT, textarea::pad_left, redraw_context::plot, PLOT_OP_TYPE_NONE, PLOT_OP_TYPE_SOLID, pstyle_stroke_caret, plotter_table::rectangle, textarea::scroll_x, textarea::scroll_y, scrollbar_redraw(), SCROLLBAR_WIDTH, textarea::sel_end, textarea::sel_fstyle, textarea::sel_start, textarea::show, plot_font_style::size, plot_style_s::stroke_type, plotter_table::text, textarea::text_y_offset, textarea::text_y_offset_baseline, TEXTAREA_INTERNAL_CARET, textarea::vis_height, textarea::vis_width, line_info::width, gui_layout_table::width, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by html_redraw_box(), toolbar_redraw(), and treeview_redraw().
bool textarea_scroll | ( | struct textarea * | ta, |
int | scrx, | ||
int | scry | ||
) |
Scroll a textarea by an amount.
Only does anything if multi-line textarea has scrollbars. If it scrolls, it will emit a redraw request.
ta | textarea widget |
scrx | number of px try to scroll in x direction |
scry | number of px try to scroll in y direction |
Definition at line 3367 of file textarea.c.
References textarea::bar_x, textarea::bar_y, textarea::border_width, textarea::flags, textarea::h_extent, textarea::scroll_x, scrollbar_scroll(), TEXTAREA_MULTILINE, and textarea::vis_width.
Referenced by html_scroll_at_point(), textarea_keypress(), and textarea_mouse_action().
bool textarea_set_caret | ( | struct textarea * | ta, |
int | caret | ||
) |
Set the caret's position.
ta | Text area |
caret | 0-based character index to place caret at, -1 removes the caret |
Definition at line 2112 of file textarea.c.
References textarea_utf8::data, textarea_utf8::len, textarea::show, textarea_set_caret_internal(), and utf8_bounded_byte_length().
Referenced by box_textarea_keypress(), textarea_get_caret(), treeview__search_cancel(), and treeview_mouse_action().
void textarea_set_dimensions | ( | struct textarea * | ta, |
int | width, | ||
int | height | ||
) |
Set the dimensions of a textarea.
This causes a reflow of the text and does not emit a redraw request. Up to client to call textarea_redraw.
ta | textarea widget |
width | the new width of the textarea |
height | the new height of the textarea |
Definition at line 3318 of file textarea.c.
References textarea::flags, height, textarea_utf8::len, textarea::show, TEXTAREA_MULTILINE, textarea_reflow_multiline(), textarea_reflow_singleline(), textarea_setup_text_offsets(), textarea::vis_height, textarea::vis_width, and width.
Referenced by toolbar_set_dimensions(), and toolbar_set_width().
void textarea_set_layout | ( | struct textarea * | ta, |
const plot_font_style_t * | fstyle, | ||
int | width, | ||
int | height, | ||
int | top, | ||
int | right, | ||
int | bottom, | ||
int | left | ||
) |
Set the dimensions and padding of a textarea.
This causes a reflow of the text. Does not emit a redraw request. Up to client to call textarea_redraw.
ta | textarea widget |
width | the new width of the textarea |
height | the new height of the textarea |
top | the new top padding of the textarea |
right | the new right padding of the textarea |
bottom | the new bottom padding of the textarea |
left | the new left padding of the textarea |
Definition at line 3336 of file textarea.c.
References plot_font_style::background, textarea::bar_x, textarea::bar_y, textarea::flags, plot_font_style::foreground, height, textarea_utf8::len, textarea::pad_bottom, textarea::pad_left, textarea::pad_right, textarea::pad_top, SCROLLBAR_WIDTH, textarea::sel_fstyle, textarea::show, TEXTAREA_MULTILINE, textarea_reflow_multiline(), textarea_reflow_singleline(), textarea_set_text_style(), textarea_setup_text_offsets(), textarea::vis_height, textarea::vis_width, and width.
Referenced by layout_block_context().
bool textarea_set_text | ( | struct textarea * | ta, |
const char * | text | ||
) |
Set the text in a text area, discarding any current text.
ta | Text area |
text | UTF-8 text to set text area's contents to |
Definition at line 1995 of file textarea.c.
References textarea_utf8::alloc, textarea_utf8::data, textarea::flags, textarea_undo::last_detail, textarea_utf8::len, textarea_undo::next_detail, NSLOG, TA_ALLOC_STEP, textarea::text, text(), TEXTAREA_MULTILINE, textarea_normalise_text(), textarea_reflow_multiline(), textarea_reflow_singleline(), textarea::undo, textarea_utf8::utf8_len, and utf8_length().
Referenced by box_textarea_create_textarea(), form_gadget_sync_with_dom(), toolbar_set_url(), treeview__search_cancel(), treeview_edit_node_at_point(), and treeview_set_search_string().