110 if (offset < old_start) {
139 if (offset < old_end) {
197 size_t new_length = sel_string->
length + length + (space ? 1 : 0) + 1;
204 assert(sel_string->
length == 0);
207 new_styles = realloc(sel_string->
styles,
210 if (new_styles == NULL) {
214 sel_string->
styles = new_styles;
225 size_t new_alloc = new_length + (new_length / 4);
228 new_buff = realloc(sel_string->
buffer, new_alloc);
229 if (new_buff == NULL) {
233 sel_string->
buffer = new_buff;
239 sel_string->
length += length;
256 sel = calloc(1,
sizeof(
struct selection));
348 }
else if (!modkeys) {
495 if (s == NULL || !s->
defined) {
520 int old_start, old_end;
533 if (redraw && was_defined) {
574 if ((end <= s->start_idx) ||
Browser window private structure.
struct browser_window * browser_window_get_root(struct browser_window *bw)
Get the root level browser window.
Browser window creation and manipulation interface.
Protected interface to Content handling.
void selection_drag_end(struct selection *s)
Handles completion of a drag operation.
bool selection_click(struct selection *s, struct browser_window *top, browser_mouse_state mouse, unsigned idx)
Handles mouse clicks (including drag starts) in or near a selection.
void selection_reinit(struct selection *s)
Initialise the selection object to use the given box subtree as its root, ie.
bool selection_highlighted(const struct selection *s, unsigned start, unsigned end, unsigned *start_idx, unsigned *end_idx)
Tests whether a text range lies partially within the selection, if there is a selection defined,...
bool selection_clear(struct selection *s, bool redraw)
Clears the current selection, optionally causing the screen to be updated.
struct selection * selection_create(struct content *c)
Creates a new selection object associated with a browser window.
bool selection_string_append(const char *text, size_t length, bool space, plot_font_style_t *style, struct selection_string *sel_string)
Append text to selection string.
void selection_init(struct selection *s)
Initialise the selection object to use the given box subtree as its root, ie.
static nserror selection_redraw(struct selection *s, unsigned start_idx, unsigned end_idx)
Redraws the given range of text.
bool selection_copy_to_clipboard(struct selection *s)
Copy the selected contents to the clipboard.
bool selection_dragging_start(struct selection *s)
void selection_track(struct selection *s, browser_mouse_state mouse, unsigned idx)
Handles movements related to the selection, eg.
static void selection_set_end(struct selection *s, unsigned offset)
Set the end position of the current selection, updating the screen.
bool selection_active(struct selection *s)
determine if a selecion is active
bool selection_dragging(struct selection *s)
void selection_set_position(struct selection *s, unsigned start, unsigned end)
Set the position of the current selection, updating the screen.
void selection_destroy(struct selection *s)
Destroys a selection object clearing it if nesessary.
static bool selection_copy(struct selection *s, struct selection_string *selstr)
Traverse the current selection, calling the handler function (with its handle) for all boxes that lie...
void selection_select_all(struct selection *s)
Selects all the text within the box subtree controlled by this selection object, updating the screen ...
static void selection_set_start(struct selection *s, unsigned offset)
Set the start position of the current selection, updating the screen.
char * selection_get_copy(struct selection *s)
Get copy of selection as string.
Text selection within browser windows (interface).
nserror
Enumeration of error codes.
@ NSERROR_NOT_IMPLEMENTED
Functionality is not implemented.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
Interface to platform-specific clipboard operations.
browser_mouse_state
Mouse state: 1 is primary mouse button.
@ BROWSER_MOUSE_PRESS_1
primary button pressed
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Interface to platform-specific graphical user interface window operations.
@ GW_EVENT_START_SELECTION
selection started
Interface to utility string handling.
struct gui_window * window
Platform specific window data only valid at top level.
nserror(* textselection_copy)(struct content *c, unsigned start_idx, unsigned end_idx, struct selection_string *selstr)
copy selected text into selection string possibly with formatting
nserror(* textselection_get_end)(struct content *c, unsigned *end_idx)
get maximum index of text section.
nserror(* textselection_redraw)(struct content *c, unsigned start_idx, unsigned end_idx)
redraw an area of selected text
Content which corresponds to a single URL.
const struct content_handler * handler
Handler for content.
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(* event)(struct gui_window *gw, enum gui_window_event event)
Miscellaneous event occurred for a window.
void(* drag_save_selection)(struct gui_window *gw, const char *selection)
drag selection save
struct gui_clipboard_table * clipboard
Clipboard table.
struct gui_window_table * window
Window table.
size_t start
Start of run.
plot_font_style_t style
Style to give text run.
nsclipboard_styles * styles
seln_drag_state drag_state
Interface to a number of general purpose functionality.
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.