NetSurf
|
Single/Multi-line UTF-8 text area (interface) More...
#include <stdbool.h>
#include <stdint.h>
#include "rufl.h"
#include "oslib/wimp.h"
Go to the source code of this file.
Macros | |
#define | TEXTAREA_MULTILINE 0x01 |
Text area is multiline. More... | |
#define | TEXTAREA_READONLY 0x02 |
Text area is read only. More... | |
Functions | |
uintptr_t | ro_textarea_create (wimp_w parent, wimp_i icon, unsigned int flags, const char *font_family, unsigned int font_size, rufl_style font_style) |
Create a text area. More... | |
bool | ro_textarea_update (uintptr_t self) |
Update the a text area following a change in the parent icon. More... | |
void | ro_textarea_destroy (uintptr_t self) |
Destroy a text area. More... | |
bool | ro_textarea_set_text (uintptr_t self, const char *text) |
Set the text in a text area, discarding any current text. More... | |
int | ro_textarea_get_text (uintptr_t self, char *buf, unsigned int len) |
Extract the text from a text area. More... | |
void | ro_textarea_insert_text (uintptr_t self, unsigned int index, const char *text) |
Insert text into the text area. More... | |
void | ro_textarea_replace_text (uintptr_t self, unsigned int start, unsigned int end, const char *text) |
Replace text in a text area. More... | |
void | ro_textarea_set_caret (uintptr_t self, unsigned int caret) |
Set the caret's position. More... | |
void | ro_textarea_set_caret_xy (uintptr_t self, int x, int y) |
Set the caret's position. More... | |
unsigned int | ro_textarea_get_caret (uintptr_t self) |
Get the caret's position. More... | |
Single/Multi-line UTF-8 text area (interface)
Definition in file textarea.h.
#define TEXTAREA_MULTILINE 0x01 |
Text area is multiline.
Definition at line 31 of file textarea.h.
#define TEXTAREA_READONLY 0x02 |
Text area is read only.
Definition at line 32 of file textarea.h.
uintptr_t ro_textarea_create | ( | wimp_w | parent, |
wimp_i | icon, | ||
unsigned int | flags, | ||
const char * | font_family, | ||
unsigned int | font_size, | ||
rufl_style | font_style | ||
) |
Create a text area.
parent | Parent window |
icon | Icon in parent window to replace |
flags | Text area flags |
font_family | RUfl font family to use, or NULL for default |
font_size | Font size to use (pt * 16), or 0 for default |
font_style | Font style to use, or 0 for default |
Definition at line 133 of file textarea.c.
References text_area::caret_pos, text_area::char_off, text_area::flags, text_area::font_family, text_area::font_size, text_area::font_style, text_area::icon, text_area::line, text_area::line_count, text_area::line_height, text_area::line_spacing, text_area::lines, MAGIC, text_area::magic, NSLOG, parent, text_area::parent, ro_gui_wimp_event_register_keypress(), ro_gui_wimp_event_register_mouse_click(), ro_gui_wimp_event_register_open_window(), ro_gui_wimp_event_register_redraw_window(), ro_gui_wimp_event_set_user_data(), ro_textarea_destroy(), ro_textarea_key_press(), ro_textarea_mouse_click(), ro_textarea_open(), ro_textarea_redraw(), ro_textarea_update(), text_area::text, text_area::text_alloc, text_area_definition, text_area::text_len, TEXTAREA_READONLY, and text_area::window.
void ro_textarea_destroy | ( | uintptr_t | self | ) |
Destroy a text area.
self | Text area to destroy |
Definition at line 305 of file textarea.c.
References text_area::font_family, MAGIC, text_area::magic, NSLOG, ro_gui_wimp_event_finalise(), text_area::text, and text_area::window.
Referenced by ro_textarea_create().
unsigned int ro_textarea_get_caret | ( | uintptr_t | self | ) |
Get the caret's position.
self | Text area |
Definition at line 677 of file textarea.c.
References line_info::b_start, text_area::caret_pos, text_area::char_off, text_area::line, text_area::lines, MAGIC, text_area::magic, NSLOG, text_area::text, text_area::text_len, and utf8_next().
Referenced by ro_textarea_key_press(), and ro_textarea_set_caret().
int ro_textarea_get_text | ( | uintptr_t | self, |
char * | buf, | ||
unsigned int | len | ||
) |
Extract the text from a text area.
self | Text area |
buf | Pointer to buffer to receive data, or NULL to read length required |
len | Length (bytes) of buffer pointed to by buf, or 0 to read length |
Definition at line 372 of file textarea.c.
References MAGIC, text_area::magic, NSLOG, text_area::text, and text_area::text_len.
void ro_textarea_insert_text | ( | uintptr_t | self, |
unsigned int | index, | ||
const char * | text | ||
) |
Insert text into the text area.
self | Text area |
index | 0-based character index to insert at |
text | UTF-8 text to insert |
Definition at line 404 of file textarea.c.
References MAGIC, text_area::magic, NSLOG, ro_textarea_reflow(), text_area::text, text(), text_area::text_alloc, text_area::text_len, utf8_length(), and utf8_next().
Referenced by ro_textarea_key_press(), and ro_textarea_replace_text().
void ro_textarea_replace_text | ( | uintptr_t | self, |
unsigned int | start, | ||
unsigned int | end, | ||
const char * | text | ||
) |
Replace text in a text area.
self | Text area |
start | Start character index of replaced section (inclusive) |
end | End character index of replaced section (exclusive) |
text | UTF-8 text to insert |
Definition at line 458 of file textarea.c.
References MAGIC, text_area::magic, NSLOG, ro_textarea_insert_text(), ro_textarea_reflow(), text_area::text, text(), text_area::text_alloc, text_area::text_len, utf8_length(), and utf8_next().
Referenced by ro_textarea_key_press().
void ro_textarea_set_caret | ( | uintptr_t | self, |
unsigned int | caret | ||
) |
Set the caret's position.
self | Text area |
caret | 0-based character index to place caret at |
Definition at line 529 of file textarea.c.
References line_info::b_length, line_info::b_start, text_area::caret_pos, text_area::char_off, text_area::font_family, text_area::font_size, text_area::font_style, text_area::line, text_area::line_count, text_area::line_height, text_area::line_spacing, text_area::lines, MAGIC, text_area::magic, MARGIN_LEFT, NSLOG, ro_convert_pixels_to_os_units(), ro_textarea_get_caret(), text_area::text, text_area::text_len, utf8_length(), utf8_next(), and text_area::window.
Referenced by ro_textarea_key_press(), and ro_textarea_set_caret_xy().
void ro_textarea_set_caret_xy | ( | uintptr_t | self, |
int | x, | ||
int | y | ||
) |
Set the caret's position.
self | Text area |
x | X position of caret on the screen |
y | Y position of caret on the screen |
Definition at line 609 of file textarea.c.
References line_info::b_length, line_info::b_start, text_area::flags, text_area::font_family, text_area::font_size, text_area::font_style, line(), text_area::line_count, text_area::line_height, text_area::line_spacing, text_area::lines, MAGIC, text_area::magic, MARGIN_LEFT, NSLOG, ro_convert_pixels_to_os_units(), ro_textarea_set_caret(), text_area::text, text_area::text_len, TEXTAREA_READONLY, utf8_next(), and text_area::window.
Referenced by ro_textarea_mouse_click().
bool ro_textarea_set_text | ( | uintptr_t | self, |
const char * | text | ||
) |
Set the text in a text area, discarding any current text.
self | Text area |
text | UTF-8 text to set text area's contents to |
Definition at line 334 of file textarea.c.
References MAGIC, text_area::magic, NSLOG, ro_textarea_reflow(), text_area::text, text(), text_area::text_alloc, and text_area::text_len.
Referenced by ro_textarea_key_press().
bool ro_textarea_update | ( | uintptr_t | self | ) |
Update the a text area following a change in the parent icon.
self | Text area to update |
Definition at line 218 of file textarea.c.
References text_area::flags, text_area::icon, MAGIC, text_area::magic, NSLOG, text_area::parent, PTR_WIMP_OPEN, ro_get_hscroll_height(), ro_get_vscroll_width(), ro_textarea_reflow(), TEXTAREA_READONLY, text_area::vis_height, text_area::vis_width, and text_area::window.
Referenced by ro_textarea_create().