44#define CARET_COLOR 0x0000FF
45#define TA_ALLOC_STEP 512
118#define PASSWORD_REPLACEMENT "\xe2\x80\xa2"
119#define PASSWORD_REPLACEMENT_W (sizeof(PASSWORD_REPLACEMENT) - 1)
140#define LINE_CHUNK_SIZE 32
167 unsigned int b_start,
unsigned int b_len)
176 for (index = 0; index < b_len; index++) {
178 if (b_start + index + 1 <=
ta->
text.
len &&
194 if (!multi && (
ta->
text.
data[b_start + index] ==
'\n'))
259 bool scrolled =
false;
361 bool scrolled =
false;
363 if (caret_b != -1 && caret_b > (
signed)(
ta->
show->
len - 1))
464 ((ta->
bar_y == NULL) ?
467 ((ta->
bar_x == NULL) ?
507 bool pre_existing_selection = (ta->
sel_start != -1);
510 if (b_start == b_end) {
516 if (b_start > b_end) {
539 unsigned int b_low, b_high;
540 int line_start = 0, line_end = 0;
542 if (!pre_existing_selection) {
576 for (line_end = 0; line_end <
ta->
line_count - 1; line_end++)
578 line_start = line_end;
600 if (!pre_existing_selection &&
ta->
sel_start != -1) {
631 size_t sel_start, sel_end;
634 static const char *sep =
" /:.\r\n";
646 for (sel_start = (caret_pos > 0 ? caret_pos - 1 : caret_pos);
647 sel_start > 0; sel_start--) {
649 if (strchr(sep,
ta->
show->
data[sel_start]) != NULL) {
658 for (sel_end = caret_pos; sel_end <
ta->
show->
len - 1; sel_end++) {
659 if (strchr(sep,
ta->
show->
data[sel_end]) != NULL) {
664 if (sel_start < sel_end) {
682 size_t sel_start, sel_end;
690 for (sel_start = (caret_pos > 0 ? caret_pos - 1 : caret_pos);
691 sel_start > 0; sel_start--) {
701 for (sel_end = caret_pos; sel_end <
ta->
show->
len - 1; sel_end++) {
707 if (sel_start < sel_end) {
725 switch(scrollbar_data->
msg) {
751 ((ta->
bar_y == NULL) ?
754 ((ta->
bar_x == NULL) ?
761 if ((x >= cr.
x0 && x < cr.
x1) &&
762 (y + h >= cr.
y0 && y < cr.
y1)) {
821 int retained_width = 0;
827 if (ta->
lines == NULL) {
830 if (ta->
lines == NULL) {
831 NSLOG(netsurf, INFO,
"malloc failed");
855 NSLOG(netsurf, INFO,
"realloc failed");
864 for (c = 0; c < b_len; c += rep_len) {
865 for (b = 0; b < rep_len; b++) {
882 b_off, &retained_width);
889 r->
x0 =
max(r->
x0, retained_width + shift - 1);
917 const size_t b_start,
const int b_length,
struct rect *r)
923 size_t b_start_line_end;
925 char *space, *para_end;
927 unsigned int scroll_lines;
931 bool restart =
false;
932 bool skip_line =
false;
936 if (ta->
lines == NULL) {
938 if (ta->
lines == NULL) {
940 "Failed to allocate memory for textarea lines");
947 for (start = 0; (signed) start < ta->line_count - 1; start++)
982 h_extent = avail_width;
997 for (i = 0; i <
line; i++) {
1014 for (; len > 0; len -= b_off,
text += b_off) {
1016 for (para_end =
text; para_end <
text + len;
1018 if (*para_end ==
'\n')
1024 avail_width, &b_off, &x);
1030 if (x > avail_width && ta->
bar_x == NULL) {
1038 if (ta->
bar_y != NULL)
1057 NSLOG(netsurf, INFO,
"realloc failed");
1066 if (para_end ==
text + b_off && *para_end ==
'\n') {
1076 if (len - b_off == 0) {
1085 if (
line > scroll_lines && ta->
bar_y == NULL)
1090 }
else if (len - b_off > 0) {
1092 for (space =
text + b_off; space >
text;
1099 b_off = space + 1 -
text;
1106 if (
line > scroll_lines && ta->
bar_y == NULL)
1110 if (h_extent <= avail_width && ta->bar_x != NULL) {
1122 if (
line > scroll_lines && ta->
bar_y == NULL) {
1130 if (ta->
bar_x != NULL)
1136 }
else if (line <= scroll_lines && ta->bar_y != NULL) {
1151 if (ta->
bar_x != NULL) {
1158 if (ta->
bar_y != NULL) {
1178 if (b_start_line_end <
b_start && restart ==
false) {
1188 if ((skip_line || start == 0) &&
1194 if (*
text ==
'\0' || *
text ==
'\n') {
1202 int retained_width = 0;
1208 retain_end, &retained_width);
1312 size_t b_off,
size_t b_len,
int *byte_delta,
struct rect *r)
1315 const size_t show_b_off = b_off;
1338 NSLOG(netsurf, INFO,
"realloc failed");
1365 *byte_delta = ta->
text.
len - *byte_delta;
1391 unsigned int start,
unsigned int end,
1392 size_t *
b_start,
size_t *b_end)
1394 size_t diff = end - start;
1396 for (*
b_start = 0; start-- > 0;
1402 for (*b_end = *
b_start; diff-- > 0;
1425 size_t b_end,
const char *rep,
size_t rep_len,
1426 bool add_to_clipboard,
int *byte_delta,
struct rect *r)
1429 const size_t show_b_off =
b_start;
1433 !(rep == NULL && rep_len == 0 && add_to_clipboard))
1439 if (b_end > ta->
show->
len - 1)
1451 if (
b_start == b_end && rep != NULL)
1459 if (add_to_clipboard) {
1472 size_t c_start, c_end;
1484 char *temp = realloc(ta->
text.
data,
1488 NSLOG(netsurf, INFO,
"realloc failed");
1517 *byte_delta = ta->
text.
len - *byte_delta;
1544 size_t b_start,
size_t b_end,
size_t rep_len)
1548 unsigned int len = b_end - b_start;
1558 len = len > rep_len ? len : rep_len;
1560 if (b_offset + len >= undo->
text.
alloc) {
1562 char *temp = realloc(undo->
text.
data,
1565 NSLOG(netsurf, INFO,
"realloc failed");
1579 NSLOG(netsurf, INFO,
"realloc failed");
1619 size_t b_end,
const char *rep,
size_t rep_len,
1620 bool add_to_clipboard,
int *byte_delta,
struct rect *r)
1622 if (!(
b_start !=
b_end && rep == NULL && add_to_clipboard) &&
1633 add_to_clipboard, byte_delta, r) ==
false) {
1637 if (!(
b_start !=
b_end && rep == NULL && add_to_clipboard) &&
1642 b_end + *byte_delta;
1661 unsigned int *caret,
struct rect *r)
1663 unsigned int detail_n;
1667 unsigned int b_text_len;
1697 temp = malloc(b_text_len);
1710 false, &byte_delta, r);
1804 int text_y_offset, text_y_offset_baseline;
1814 text_y_offset_baseline +=
1820 text_y_offset_baseline +=
1857 struct rect r = {0, 0, 0, 0};
1863 if (callback == NULL) {
1864 NSLOG(netsurf, INFO,
"no callback provided");
1868 ret = malloc(
sizeof(
struct textarea));
1870 NSLOG(netsurf, INFO,
"malloc failed");
1916 NSLOG(netsurf, INFO,
"malloc failed");
1928 NSLOG(netsurf, INFO,
"malloc failed");
1949 ret->
line_height = FIXTOINT(FMUL(FLTTOFIX(1.3), FDIV(FMUL(
1997 unsigned int len = strlen(
text) + 1;
1998 struct rect r = {0, 0, 0, 0};
2003 NSLOG(netsurf, INFO,
"realloc failed");
2037 unsigned int caret_pos;
2050 text, text_length,
false, &byte_delta, &r))
2057 text, text_length,
false, &byte_delta, &r))
2061 caret_pos += byte_delta;
2080 if (buf == NULL && len == 0) {
2084 }
else if (buf == NULL) {
2089 if (len < ta->
text.len) {
2090 NSLOG(netsurf, INFO,
"buffer too small");
2118 }
else if (caret == 0) {
2134 int line0, line1,
line, left, right, line_y;
2135 int text_y_offset, text_y_offset_baseline;
2136 unsigned int b_pos, b_len, b_len_part, b_end;
2137 unsigned int sel_start, sel_end;
2141 bool selected =
false;
2156 if (r.
x1 < x || r.
y1 < y)
2167 if (ta->
lines == NULL)
2257 text_y_offset *= scale;
2258 text_y_offset_baseline *= scale;
2292 sel_end < ta->lines[
line].b_start ||
2297 fstyle.
size = fsize;
2302 y + line_y + text_y_offset_baseline,
2310 if (sel_end <= b_pos || sel_start > b_pos + b_len) {
2316 }
else if (sel_start <= b_pos &&
2317 sel_end > b_pos + b_len) {
2323 }
else if (sel_start > b_pos) {
2326 b_len_part = sel_start - b_pos;
2329 }
else if (sel_end > b_pos) {
2332 b_len_part = sel_end - b_pos;
2338 fstyle.
size = fsize;
2343 b_end += b_len_part;
2347 if (b_len_part != b_len) {
2361 if (s.
x1 <= left || s.
x0 > right) {
2363 b_pos += b_len_part;
2364 b_len -= b_len_part;
2374 if (right <= left) {
2376 b_pos += b_len_part;
2377 b_len -= b_len_part;
2386 rect.
y0 = y + line_y + text_y_offset;
2396 y + line_y + text_y_offset_baseline,
2400 b_pos += b_len_part;
2401 b_len -= b_len_part;
2403 }
while (b_pos < b_pos + b_len);
2406 if (line < ta->line_count - 1 &&
2431 if (ta->
bar_x != NULL) {
2439 if (ta->
bar_y != NULL) {
2455 unsigned int caret, caret_copy, length, b_off, b_len;
2461 bool redraw =
false;
2463 bool bar_x = ta->
bar_x;
2464 bool bar_y = ta->
bar_y;
2467 static const char *sep =
" .\n";
2473 if (!(key <= 0x001F || (0x007F <= key && key <= 0x009F))) {
2476 utf8[length] =
'\0';
2481 length,
false, &byte_delta, &r))
2489 utf8, length,
false, &byte_delta, &r))
2493 caret += byte_delta;
2495 }
else switch (key) {
2503 NULL, 0,
true, &byte_delta, &r))
2513 "", 0,
false, &byte_delta, &r))
2519 }
else if (caret > 0) {
2522 "", 0,
false, &byte_delta, &r))
2526 caret += byte_delta;
2534 "", 0,
false, &byte_delta, &r))
2540 }
else if (caret < ta->show->len - 1) {
2544 "", 0,
false, &byte_delta, &r))
2549 caret += byte_delta;
2573 caret += byte_delta;
2578 size_t clipboard_length;
2591 false, &byte_delta, &r))
2601 false, &byte_delta, &r))
2605 caret += byte_delta;
2616 "", 0,
true, &byte_delta, &r))
2621 caret += byte_delta;
2641 if (caret < ta->show->len - 1)
2752 while (strchr(sep, ta->
show->
data[caret]) != NULL &&
2755 for (; caret > 0; caret--) {
2756 if (strchr(sep, ta->
show->
data[caret])
2786 while (strchr(sep, ta->
show->
data[caret]) != NULL &&
2791 for (; caret > 0; caret--) {
2792 if (strchr(sep, ta->
show->
data[caret]) !=
2802 "", 0,
false, &byte_delta, &r))
2813 if (caret == ta->
show->
len - 1)
2815 if (strchr(sep, ta->
show->
data[caret]) != NULL &&
2816 caret < ta->show->len - 1) {
2817 while (strchr(sep, ta->
show->
data[caret]) !=
2819 caret < ta->show->len - 1) {
2824 for (; caret < ta->
show->
len - 1; caret++) {
2825 if (strchr(sep, ta->
show->
data[caret]) != NULL)
2828 while (strchr(sep, ta->
show->
data[caret]) != NULL &&
2829 caret < ta->show->len - 1)
2849 if (caret == ta->
show->
len - 1)
2854 while (strchr(sep, ta->
show->
data[caret_copy]) != NULL
2855 && caret_copy < ta->show->len - 1)
2860 for (; caret_copy < ta->
show->
len - 1; caret_copy++) {
2861 if (strchr(sep, ta->
show->
data[caret_copy]) !=
2870 "", 0,
false, &byte_delta, &r))
2881 "", 0,
false, &byte_delta, &r))
2892 caret + b_len,
"", 0,
2893 false, &byte_delta, &r))
2895 caret = caret + b_len;
2896 }
else if (caret < ta->show->len - 1) {
2899 caret, caret + 1,
"", 0,
2900 false, &byte_delta, &r))
2906 caret += byte_delta;
2914 "", 0,
false, &byte_delta, &r))
2923 "", 0,
false, &byte_delta, &r))
2928 caret += byte_delta;
2936 "", 0,
false, &byte_delta, &r))
2944 caret,
"", 0,
false,
2949 caret += byte_delta;
2983 if (bar_x != (ta->
bar_x != NULL) || bar_y != (ta->
bar_y != NULL) ||
2992 }
else if (redraw) {
3131 b_start = ((
unsigned)b_start > b_off) ?
3166 bool need_redraw =
false;
3178 if (x < ta->border_width)
3183 if (y < ta->border_width)
3208 int line_end, line_start = 0;
3215 for (line_end = 0; line_end <
ta->
line_count - 1; line_end++)
3217 line_start = line_end;
3256 ((ta->
bar_y == NULL) ?
3259 ((ta->
bar_x == NULL) ?
3281 size_t b_start, b_end, b_len;
3289 b_len = b_end - b_start;
3295 ret = malloc(b_len + 1);
3300 memcpy(ret, ta->
show->
data + b_start, b_len);
3320 struct rect r = {0, 0, 0, 0};
3341 int bottom,
int left)
3343 struct rect r = {0, 0, 0, 0};
3369 bool handled_scroll =
false;
3373 if (ta->
bar_x != NULL && scrx != 0 &&
3375 handled_scroll =
true;
3376 if (ta->
bar_y != NULL && scry != 0 &&
3378 handled_scroll =
true;
3395 handled_scroll =
true;
3399 return handled_scroll;
Browser window creation and manipulation interface.
static int line_height(const css_unit_ctx *unit_len_ctx, const css_computed_style *style)
Calculate line height from a style.
css_fixed nscss_screen_dpi
Screen DPI in fixed point units: defaults to 90, which RISC OS uses.
static void textarea_setup_text_offsets(struct textarea *ta)
Setup text offsets after height / border / padding change.
static size_t textarea_get_b_off_xy(struct textarea *ta, int x, int y, bool visible)
get byte offset from the beginning of the text for some coordinates
static bool textarea_insert_text(struct textarea *ta, const char *text, size_t b_off, size_t b_len, int *byte_delta, struct rect *r)
Insert text into the textarea.
#define PASSWORD_REPLACEMENT_W
static bool textarea_replace_text(struct textarea *ta, size_t b_start, size_t b_end, const char *rep, size_t rep_len, bool add_to_clipboard, int *byte_delta, struct rect *r)
Replace text in a textarea, updating undo buffer.
static void textarea_reset_selection(struct textarea *ta)
Reset the selection (no redraw)
static plot_style_t pstyle_stroke_caret
bool textarea_scroll(struct textarea *ta, int scrx, int scry)
Scroll a textarea by an amount.
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.
void textarea_set_dimensions(struct textarea *ta, int width, int height)
Set the dimensions of a textarea.
static void textarea_normalise_text(struct textarea *ta, unsigned int b_start, unsigned int b_len)
Normalises any line endings within the text, replacing CRLF or CR with LF as necessary.
static bool textarea_drag_end(struct textarea *ta, browser_mouse_state mouse, int x, int y)
Handles the end of a drag operation.
static bool textarea_reflow_singleline(struct textarea *ta, size_t b_off, struct rect *r)
Reflow a single line textarea.
static bool textarea_select_paragraph(struct textarea *ta)
Selects paragraph, at current caret position.
struct textarea * textarea_create(const textarea_flags flags, const textarea_setup *setup, textarea_client_callback callback, void *data)
Create a text area.
bool textarea_clear_selection(struct textarea *ta)
Clear any selection in the textarea.
#define PASSWORD_REPLACEMENT
static void textarea_scrollbar_callback(void *client_data, struct scrollbar_msg_data *scrollbar_data)
Callback for scrollbar widget.
void textarea_destroy(struct textarea *ta)
Destroy a text area.
bool textarea_set_caret(struct textarea *ta, int caret)
Set the caret's position.
static bool textarea_undo(struct textarea *ta, bool forward, unsigned int *caret, struct rect *r)
Undo or redo previous change.
static bool textarea_select(struct textarea *ta, int b_start, int b_end, bool force_redraw)
Selects a character range in the textarea and redraws it.
bool textarea_set_text(struct textarea *ta, const char *text)
Set the text in a text area, discarding any current text.
int textarea_get_text(struct textarea *ta, char *buf, unsigned int len)
Extract the text from a text area.
const char * textarea_data(struct textarea *ta, unsigned int *len)
Access text data in a text area.
static int textarea_get_caret(struct textarea *ta)
Get the caret's position.
static textarea_mouse_status textarea_mouse_scrollbar_action(struct textarea *ta, browser_mouse_state mouse, int x, int y)
static bool textarea_select_fragment(struct textarea *ta)
Selects a text fragment, relative to current caret position.
textarea_mouse_status textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
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.
char * textarea_get_selection(struct textarea *ta)
Get selected text.
void textarea_get_dimensions(struct textarea *ta, int *width, int *height)
Gets the dimensions of a textarea.
static bool textarea_copy_to_undo_buffer(struct textarea *ta, size_t b_start, size_t b_end, size_t rep_len)
Update undo buffer by adding any text to be replaced, and allocating space as appropriate.
static void textarea_char_to_byte_offset(struct textarea_utf8 *text, unsigned int start, unsigned int end, size_t *b_start, size_t *b_end)
Helper for replace_text function converts character offset to byte offset.
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.
static void textarea_set_text_style(struct textarea *ta, const plot_font_style_t *fstyle, colour selected_text, colour selected_bg)
Set font styles up for a textarea.
static bool textarea_set_caret_xy(struct textarea *ta, int x, int y, bool visible)
Set the caret's position.
static bool textarea_replace_text_internal(struct textarea *ta, size_t b_start, size_t b_end, const char *rep, size_t rep_len, bool add_to_clipboard, int *byte_delta, struct rect *r)
Perform actual text replacment in a textarea.
static bool textarea_set_caret_internal(struct textarea *ta, int caret_b)
Set the caret position.
bool textarea_keypress(struct textarea *ta, uint32_t key)
Key press handling for text areas.
static bool textarea_reflow_multiline(struct textarea *ta, const size_t b_start, const int b_length, struct rect *r)
Reflow a multiline textarea from the given line onwards.
static bool textarea_scroll_visible(struct textarea *ta)
Scrolls a textarea to make the caret visible (doesn't perform a redraw)
Single/Multi-line UTF-8 text area interface.
void(* textarea_client_callback)(void *data, struct textarea_msg *msg)
Client callback for the textarea.
textarea_flags
Text area flags.
@ TEXTAREA_INTERNAL_CARET
Render own caret.
@ TEXTAREA_PASSWORD
Obscured display.
@ TEXTAREA_READONLY
Non-editable.
@ TEXTAREA_MULTILINE
Multiline area.
textarea_mouse_status
Text area mouse input status flags.
@ TEXTAREA_MOUSE_SCR_USED
Scrollbar action.
@ TEXTAREA_MOUSE_USED
Took action with input.
@ TEXTAREA_MOUSE_SELECTION
Hover: selection.
@ TEXTAREA_MOUSE_NONE
Not relevant.
@ TEXTAREA_MOUSE_EDITOR
Hover: caret pointer.
textarea_drag_type
Textarea drag status.
@ TEXTAREA_DRAG_SCROLLBAR
@ TEXTAREA_DRAG_SELECTION
@ TEXTAREA_MSG_SELECTION_REPORT
Textarea text selection presence.
@ TEXTAREA_MSG_TEXT_MODIFIED
Textarea text modified.
@ TEXTAREA_MSG_DRAG_REPORT
Textarea drag start/end report.
@ TEXTAREA_MSG_REDRAW_REQUEST
Textarea redraw request.
@ TEXTAREA_MSG_CARET_UPDATE
Textarea caret.
static GtkClipboard * clipboard
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
Interface to platform-specific clipboard operations.
Interface to platform-specific layout operation table.
Core mouse and pointer states.
browser_mouse_state
Mouse state: 1 is primary mouse button.
@ BROWSER_MOUSE_PRESS_1
primary button pressed
@ BROWSER_MOUSE_PRESS_2
auxillary button pressed
@ BROWSER_MOUSE_HOVER
No mouse buttons pressed, May be used to indicate hover or end of drag.
@ BROWSER_MOUSE_TRIPLE_CLICK
button triple clicked
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
@ BROWSER_MOUSE_HOLDING_2
during button 2 drag
@ BROWSER_MOUSE_HOLDING_1
during button 1 drag
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Target independent plotting interface.
Interface to key press operations.
@ NS_KEY_DELETE_WORD_RIGHT
@ NS_KEY_DELETE_LINE_START
@ NS_KEY_DELETE_WORD_LEFT
#define NSLOG(catname, level, logmsg, args...)
#define plot_style_int_to_fixed(v)
@ PLOT_OP_TYPE_NONE
No operation.
@ PLOT_OP_TYPE_SOLID
Solid colour.
#define NS_TRANSPARENT
Transparent colour value.
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
Interface to utility string handling.
void(* get)(char **buffer, size_t *length)
Core asks front end for clipboard contents.
void(* set)(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles)
Core tells front end to put given text in clipboard.
nserror(* position)(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
Find the position in a string where an x coordinate falls.
nserror(* width)(const struct plot_font_style *fstyle, const char *string, size_t length, int *width)
Measure the width of a string.
nserror(* split)(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
Find where to split a string to make it fit a width.
unsigned int b_start
Byte offset of line start.
unsigned int b_length
Byte length of line.
int width
Width in pixels of line.
struct gui_clipboard_table * clipboard
Clipboard table.
struct gui_layout_table * layout
Layout table.
colour foreground
Colour of text.
plot_style_fixed size
Font size, in pt.
colour background
Background colour to blend to, if appropriate.
Plot style for stroke/fill plotters.
colour fill_colour
Colour of fill.
plot_operation_type_t stroke_type
Stroke plot type.
nserror(* line)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *line)
Plots a line.
nserror(* text)(const struct redraw_context *ctx, const plot_font_style_t *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
nserror(* clip)(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
const struct plotter_table * plot
Current plot operation table.
union textarea_drag::@77 data
struct scrollbar * scrollbar
struct textarea_msg::@79::@81 caret
With _CARET_UPDATE.
unsigned int len
Byte length of text.
struct textarea_msg::@79::@80 selection
With _SELECTION_REPORT.
struct textarea_msg::@79::@81::@84 pos
With _CARET_SET_POS.
bool read_only
Selection can't be cut.
struct textarea * ta
The textarea widget.
const char * text
UTF8 text.
textarea_msg_type type
Indicates message data type.
struct rect redraw
With _REDRAW_REQUEST.
@ TEXTAREA_CARET_HIDE
Hide.
struct textarea_msg::@79::@82 modified
With _TEXT_MODIFIED.
union textarea_msg::@79 data
Depends on msg type.
bool have_selection
Selection exists.
textarea_drag_type drag
With _DRAG_REPORT.
struct rect * clip
Caret clip rect.
textarea setup parameters
int pad_top
Textarea top padding.
colour border_col
Textarea border colour.
int height
Textarea height.
int border_width
Textarea border width.
int pad_right
Textarea right padding.
int pad_left
Textarea left padding.
plot_font_style_t text
Textarea background colour and font.
int pad_bottom
Textarea bottom padding.
colour selected_text
Textarea selected text colour.
colour selected_bg
Textarea selection background colour.
unsigned int b_text_end
End of textarea text (exclusive)
unsigned int b_limit
End of detail space (exclusive)
unsigned int b_text_start
Start of textarea text.
unsigned int b_start
Offset to detail's text in undo buffer.
unsigned int b_end
End of text (exclusive)
struct textarea_utf8 text
unsigned int last_detail
Last detail used.
struct textarea_undo_detail * details
Array of undo details.
unsigned int details_alloc
Details allocated for.
unsigned int next_detail
Next detail pos.
unsigned int utf8_len
Length of text, in characters without trailing NULL.
unsigned int len
Length of text, in bytes.
unsigned int alloc
Size of allocated text.
int caret_y
cached Y coordinate of the caret
int line
Line caret is on.
int sel_end
Character index of sel end (exclusive)
int pad_right
Right padding, inside border, in pixels.
int byte_off
Character index of caret on line.
plot_font_style_t fstyle
Text style, inc.
unsigned int lines_alloc_size
Number of LINE_CHUNK_SIZEs.
int h_extent
Width of content in px.
int vis_height
Visible height, in pixels.
unsigned int flags
Textarea flags.
struct textarea_utf8 text
Textarea text content.
textarea_client_callback callback
Callback function for messages to client.
int pad_left
Left padding, inside border, in pixels.
int border_width
Border width, in pixels.
int text_y_offset_baseline
Vertical dist to 1st baseline.
void * data
Client data for callback.
plot_font_style_t sel_fstyle
Selected text style.
int pad_bottom
Bottom padding, inside border, in pixels.
int line_count
Count of lines.
int vis_width
Visible width, in pixels.
colour border_col
Border colour.
struct scrollbar * bar_x
Horizontal scroll.
int drag_start
Byte offset of drag start (in ta->show)
struct textarea_utf8 * show
Points at .text or .password.
struct textarea_undo undo
Undo/redo information.
struct scrollbar * bar_y
Vertical scroll.
struct textarea_utf8 password
Text for obscured display.
int text_y_offset
Vertical dist to 1st line top.
struct line_info * lines
Line info array.
struct textarea_drag drag_info
Drag information.
int scroll_y
scroll offsets for the textarea
int v_extent
Height of content in px.
struct textarea::@78 caret_pos
int sel_start
Character index of sel start (inclusive)
int pad_top
Top padding, inside border, in pixels.
int line_height
Line height obtained from style.
int caret_x
cached X coordinate of the caret
uint32_t colour
Colour type: XBGR.
size_t utf8_prev(const char *s, size_t o)
Find previous legal UTF-8 char in string.
size_t utf8_from_ucs4(uint32_t c, char *s)
Convert a single UCS4 character into a UTF-8 multibyte sequence.
size_t utf8_next(const char *s, size_t l, size_t o)
Find next legal UTF-8 char in string.
size_t utf8_bounded_length(const char *s, size_t l)
Calculated the length (in characters) of a bounded UTF-8 string.
size_t utf8_length(const char *s)
Calculate the length (in characters) of a NULL-terminated UTF-8 string.
size_t utf8_bounded_byte_length(const char *s, size_t l, size_t c)
Calculate the length (in bytes) of a bounded UTF-8 string.
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.