diff options
author | Adrian Lees <adrian@aemulor.com> | 2006-02-15 23:09:55 +0000 |
---|---|---|
committer | Adrian Lees <adrian@aemulor.com> | 2006-02-15 23:09:55 +0000 |
commit | dbfdafdf1820a95995c3b260e147c55125468874 (patch) | |
tree | 8ef69f8cbc4733490f82b462edeb167c0ee08fb8 /desktop/textinput.c | |
parent | 07d55db910095415d15cc2b6509fd44efa79a875 (diff) | |
download | netsurf-dbfdafdf1820a95995c3b260e147c55125468874.tar.gz netsurf-dbfdafdf1820a95995c3b260e147c55125468874.tar.bz2 |
[project @ 2006-02-15 23:09:53 by adrianl]
Extend text selection, copying, saving and searching code to handle textplain contents; modified textplain code to accept other line terminators
svn path=/import/netsurf/; revision=2081
Diffstat (limited to 'desktop/textinput.c')
-rw-r--r-- | desktop/textinput.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/desktop/textinput.c b/desktop/textinput.c index b2232e6bd..a941cc86b 100644 --- a/desktop/textinput.c +++ b/desktop/textinput.c @@ -75,6 +75,60 @@ static bool word_right(const char *text, int len, int *poffset, int *pchars); /** + * Remove the given text caret from the window by invalidating it + * and causing its former position to be redrawn. + * + * \param c structure describing text caret + */ + +void caret_remove(struct caret *c) +{ + if (c->defined) { + int w = (c->height + 7) / 8; + int xc = c->x; + c->defined = false; + browser_window_redraw_rect(c->bw, xc - w, c->y, 2 * w, c->height); + } +} + + +/** + * Set the given text caret's position within the window (text box + * and byte/pixel offsets within the UTF-8 content of that text box) + * and draw it. + * + * \param c structure describing text caret + * \param bw browser window containing caret + * \param box INLINE box containing caret + * \param char_offset byte offset within UTF-8 representation + * \param pixel_offset from left side of box + */ + +void caret_set_position(struct caret *c, struct browser_window *bw, + struct box *text_box, int char_offset, int pixel_offset) +{ + struct rect r; + int xc; + int w; + + box_bounds(text_box, &r); + + c->bw = bw; + c->text_box = text_box; + c->char_offset = char_offset; + + c->x = xc = r.x0 + pixel_offset; + c->y = r.y0; + c->height = r.y1 - r.y0; + w = (c->height + 7) / 8; + + c->defined = true; + + browser_window_redraw_rect(c->bw, xc - w, c->y, w * 2, c->height); +} + + +/** * Given the x,y co-ordinates of a point within a textarea, return the * INLINE box pointer, and the character and pixel offsets within that * box at which the caret should be positioned. (eg. for mouse clicks, |