diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-09-14 23:22:13 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-09-14 23:22:13 +0100 |
commit | b96222d8571237919bbfc7d85d43a2d46cfe262f (patch) | |
tree | 7a5bc24273d2394a076256308267829e115525b3 /desktop/textarea.c | |
parent | 951ad51cd45ba2e5f49fab169ccbabc8f98a5185 (diff) | |
download | netsurf-b96222d8571237919bbfc7d85d43a2d46cfe262f.tar.gz netsurf-b96222d8571237919bbfc7d85d43a2d46cfe262f.tar.bz2 |
We return client data, not node.
Diffstat (limited to 'desktop/textarea.c')
-rw-r--r-- | desktop/textarea.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c index 7c967b6cd..65f0c53e5 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -63,6 +63,18 @@ struct textarea_utf8 { * trailing NULL */ }; +struct textarea_undo_detail { + unsigned int offset; /**< Offset to detail's text in undo.text */ + unsigned int len; /**< Length of detail's text */ +}; + +struct textarea_undo { + unsigned int next_detail; + struct textarea_undo_detail *details; + + struct textarea_utf8 text; +}; + struct textarea { int scroll_x, scroll_y; /**< scroll offsets for the textarea */ @@ -1337,7 +1349,7 @@ static inline void textarea_char_to_byte_offset(struct textarea_utf8 *text, /** - * Replace text in a textarea + * Perform actual text replacment in a textarea * * \param ta Textarea widget * \param b_start Start byte index of replaced section (inclusive) @@ -1352,7 +1364,7 @@ static inline void textarea_char_to_byte_offset(struct textarea_utf8 *text, * Note, b_start and b_end must be the byte offsets in ta->show, so in the * password textarea case, they are for ta->password. */ -static bool textarea_replace_text(struct textarea *ta, size_t b_start, +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) { @@ -1462,6 +1474,47 @@ static bool textarea_replace_text(struct textarea *ta, size_t b_start, /** + * Replace text in a textarea, updating undo buffer. + * + * \param ta Textarea widget + * \param b_start Start byte index of replaced section (inclusive) + * \param b_end End byte index of replaced section (exclusive) + * \param rep Replacement UTF-8 text to insert + * \param rep_len Byte length of replacement UTF-8 text + * \param add_to_clipboard True iff replaced text to be added to clipboard + * \param byte_delta Updated to change in byte count in textarea (ta->show) + * \param r Updated to area where redraw is required + * \return false on memory exhaustion, true otherwise + * + * Note, b_start and b_end must be the byte offsets in ta->show, so in the + * password textarea case, they are for ta->password. + */ +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) +{ + /* TODO: Make copy of any replaced text */ + if (b_start != b_end) { + } + + /* Replace the text in the textarea, and reflow it */ + if (textarea_replace_text_internal(ta, b_start, b_end, rep, rep_len, + add_to_clipboard, byte_delta, r) == false) { + return false; + } + + if (b_start == b_end && rep_len == 0) { + /* Nothing changed at all */ + return true; + } + + /* TODO: Update UNDO buffer */ + + return true; +} + + +/** * Handles the end of a drag operation * * \param ta Text area |