NetSurf
|
implementation of text selection for a HTML content. More...
#include <stdlib.h>
#include "utils/errors.h"
#include "utils/utils.h"
#include "netsurf/types.h"
#include "netsurf/plot_style.h"
#include "desktop/selection.h"
#include "desktop/save_text.h"
#include "html/private.h"
#include "html/box.h"
#include "html/box_inspect.h"
#include "html/font.h"
#include "html/textselection.h"
Go to the source code of this file.
Data Structures | |
struct | rdw_info |
Macros | |
#define | SPACE_LEN(b) ((b->space == 0) ? 0 : 1) |
Functions | |
static bool | selected_part (struct box *box, unsigned start_idx, unsigned end_idx, unsigned *start_offset, unsigned *end_offset) |
Tests whether a text box lies partially within the given range of byte offsets, returning the start and end indexes of the bytes that are enclosed. More... | |
static nserror | coords_from_range (struct box *box, unsigned start_idx, unsigned end_idx, struct rdw_info *rdwi, bool do_marker) |
Traverse the given box subtree adding the boxes inside the selection to the coordinate range. More... | |
static nserror | selection_copy_box (const char *text, size_t length, struct box *box, const css_unit_ctx *unit_len_ctx, struct selection_string *handle, const char *whitespace_text, size_t whitespace_length) |
Append the contents of a box to a selection along with style information. More... | |
static nserror | selection_copy (struct box *box, const css_unit_ctx *unit_len_ctx, unsigned start_idx, unsigned end_idx, struct selection_string *selstr, save_text_whitespace *before, bool *first, bool do_marker) |
Traverse the given box subtree, calling selection copy for all boxes that lie (partially) within the given range. More... | |
static unsigned | selection_label_subtree (struct box *box, unsigned idx) |
Label each text box in the given box subtree with its position in a textual representation of the content. More... | |
nserror | html_textselection_redraw (struct content *c, unsigned start_idx, unsigned end_idx) |
nserror | html_textselection_copy (struct content *c, unsigned start_idx, unsigned end_idx, struct selection_string *selstr) |
nserror | html_textselection_get_end (struct content *c, unsigned *end_idx) |
get maximum index of text section. More... | |
implementation of text selection for a HTML content.
Definition in file textselection.c.
#define SPACE_LEN | ( | b | ) | ((b->space == 0) ? 0 : 1) |
Definition at line 39 of file textselection.c.
|
static |
Traverse the given box subtree adding the boxes inside the selection to the coordinate range.
box | box subtree |
start_idx | start of range within textual representation (bytes) |
end_idx | end of range |
rdwi | redraw range to fill in |
do_marker | whether deal enter any marker box |
Definition at line 114 of file textselection.c.
References BOTTOM, BOX_BR, box_coords(), BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, BOX_TEXT, box::byte_offset, box::children, coords_from_range(), box::height, height, rdw_info::inited, LEFT, box::list_marker, box::next, NSERROR_OK, box::padding, box::parent, rdw_info::r, RIGHT, selected_part(), box::space, box::text, TOP, box::type, box::width, width, box::x, rect::x0, rect::x1, box::y, rect::y0, and rect::y1.
Referenced by coords_from_range(), and html_textselection_redraw().
nserror html_textselection_copy | ( | struct content * | c, |
unsigned | start_idx, | ||
unsigned | end_idx, | ||
struct selection_string * | selstr | ||
) |
Definition at line 507 of file textselection.c.
References html_content::layout, NSERROR_INVALID, selection_copy(), html_content::unit_len_ctx, and WHITESPACE_NONE.
get maximum index of text section.
[in] | c | The content to measure |
[out] | end_idx | pointer to value to recive result |
Definition at line 533 of file textselection.c.
References html_content::layout, NSERROR_INVALID, NSERROR_OK, and selection_label_subtree().
Definition at line 474 of file textselection.c.
References content__request_redraw(), coords_from_range(), rdw_info::inited, html_content::layout, NSERROR_INVALID, NSERROR_OK, rdw_info::r, rect::x0, rect::x1, rect::y0, and rect::y1.
|
static |
Tests whether a text box lies partially within the given range of byte offsets, returning the start and end indexes of the bytes that are enclosed.
box | box to be tested |
start_idx | byte offset of start of range |
end_idx | byte offset of end of range |
start_offset | receives the start offset of the selected part |
end_offset | receives the end offset of the selected part |
Definition at line 60 of file textselection.c.
References box::byte_offset, box::length, and SPACE_LEN.
Referenced by coords_from_range(), and selection_copy().
|
static |
Traverse the given box subtree, calling selection copy for all boxes that lie (partially) within the given range.
box | box subtree |
unit_len_ctx | Length conversion context. |
start_idx | start of range within textual representation (bytes) |
end_idx | end of range |
handler | handler function to call |
handle | handle to pass |
before | type of whitespace to place before next encountered text |
first | whether this is the first box with text |
do_marker | whether deal enter any marker box |
Definition at line 314 of file textselection.c.
References BOX_BR, BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, box::byte_offset, box::children, box::length, box::list_marker, min, box::next, NSERROR_OK, box::parent, save_text_solve_whitespace(), selected_part(), selection_copy(), selection_copy_box(), box::text, box::type, and WHITESPACE_NONE.
Referenced by html_textselection_copy(), and selection_copy().
|
static |
Append the contents of a box to a selection along with style information.
text | pointer to text being added, or NULL for newline |
length | length of text to be appended (bytes) |
box | pointer to text box, or NULL if from textplain |
unit_len_ctx | Length conversion context |
handle | selection string to append to |
whitespace_text | whitespace to place before text for formatting may be NULL |
whitespace_length | length of whitespace_text |
Definition at line 251 of file textselection.c.
References font_plot_style_from_css(), box::length, NSERROR_NOMEM, NSERROR_OK, selection_string_append(), box::space, box::style, box::text, and text().
Referenced by selection_copy().
|
static |
Label each text box in the given box subtree with its position in a textual representation of the content.
box | The box at root of subtree |
idx | current position within textual representation |
Definition at line 445 of file textselection.c.
References box::byte_offset, box::children, box::length, box::list_marker, box::next, selection_label_subtree(), SPACE_LEN, and box::text.
Referenced by html_textselection_get_end(), and selection_label_subtree().