Commit Graph

188 Commits

Author SHA1 Message Date
Michael Drake
e2bcc5f5eb Tidy up pointer beyond scrollbars. 2013-03-27 11:43:10 +00:00
Michael Drake
9a73da6347 Reduce multi-line textarea a bit more. When redrawing only one line, don't redraw unchanged text at the start of the line. 2013-03-26 14:07:08 +00:00
Michael Drake
0bb9543293 Further reduce redraw region for multi-line textareas when editing. 2013-03-26 12:54:19 +00:00
Michael Drake
53962009da Trivial redraw optimisation for multiline textareas. Only redraw the line that was changed and below. 2013-03-25 12:37:18 +00:00
Michael Drake
cc4411c0c7 Remove some spaces. 2013-03-25 12:03:53 +00:00
Michael Drake
70fbca3606 Reduce redraw area for selection set/change/clear. 2013-03-22 18:14:42 +00:00
Michael Drake
b603cafbaa Move line start calc into reflow handler. 2013-03-22 18:14:42 +00:00
Michael Drake
ad53da023d Optimise redraw of single line textarea. When single line textarea is unscrolled, only the changed area is redrawn after edits. 2013-03-21 18:47:38 +00:00
Michael Drake
948f2dbed6 Split reflow into two functions for single or multi line textareas. 2013-03-21 14:15:36 +00:00
Michael Drake
8e360ff040 Robust detection of scroll changes. 2013-03-20 19:52:10 +00:00
Michael Drake
c568a9626b Avoid double redraw when edit causes scroll. 2013-03-20 19:24:53 +00:00
Michael Drake
50efd110b8 Use cached line length to avoid some nsfont_width calls for selection rendering in redraw. 2013-03-20 18:09:52 +00:00
Michael Drake
3403891f63 Avoid redraw of scrollbars when they've not changed. 2013-03-20 17:53:38 +00:00
Michael Drake
71392160d0 Cache line widths. Fixes scrollbar issue introduced with partial reflow enablement. Will also be used for future redraw optimisations. 2013-03-20 17:32:18 +00:00
Michael Drake
8cfa964cdf Start reflow on line before change in text, rather than always reflowing the entire textarea. 2013-03-20 12:41:06 +00:00
Michael Drake
0bcbdba424 Comment fixes. 2013-03-19 17:29:55 +00:00
Michael Drake
b1082c09e7 Fix warnings. 2013-03-19 16:28:05 +00:00
Michael Drake
2ad0d23915 Start reducing unnecessary redraws: when only start OR end of selection has changed, only redraw the lines affected. (Reduces redraw of vertical regions only. Still redraw full width for changed lines.) 2013-03-19 16:22:24 +00:00
Michael Drake
8d0c1f9207 Loads of changes including fixes, new functionality, and optimisation.
+ Refactor internals to be byte, rather than character based.
    + Don't need to hammer utf8_* functions everywhere
    + Optimises:
        + Redraw (lots)
        + Editing (insertion, replacement, removal)
        + Caret placement
        + Selection
+ Early avoid of zero length autoscroll during selection drag.
+ Optimised redraw to avoid nsfont_width when:
    + There's no selection at all.
    + We're on last part of line, and it's unselected.
+ Implemented WORD_LEFT and WORD_RIGHT keys (shift + cursor left/right)
+ Fixed UP and DOWN (cursor up/down) keys to handle non-monospace fonts.
  (Now based on 'x' offset on line, rather than character offset on line.)
+ Fixed PAGE_UP and PAGE_DOWN to scroll without moving the caret.
+ Fixed redraw bug in text selection edge case.
+ Changed textarea_replace_text and textarea_insert_text to return
  a byte delta for caret position changes.
+ Coordinate to text offset function handles global and viewport coords.
+ Many small improvements and tidying.
2013-03-17 22:06:48 +00:00
Michael Drake
2af4b5be01 Make textarea_get_caret private. 2013-03-13 11:23:07 +00:00
Michael Drake
41e4928e25 Fix pointer shape and status bar messages for textareas and their scrollbars. 2013-03-11 12:57:33 +00:00
Michael Drake
490de208d0 Make autoscroll start at inside edge of border or scrollbar. 2013-03-06 21:31:20 +00:00
Michael Drake
e3cb0ba450 Pull scrollbar mouse handling out into helper function. 2013-03-06 15:41:51 +00:00
Michael Drake
5b7643634f Textarea sends caret hide msg if caret completely outside visible area. 2013-03-06 14:28:34 +00:00
Michael Drake
951a584705 Don't show caret if there's a selection. 2013-03-06 13:10:37 +00:00
Michael Drake
e8950dee22 Propagate native caret clip rect through core. 2013-03-05 22:54:51 +00:00
Michael Drake
bba74b7a0b Handle readonly attribute for text inputs and textareas. 2013-02-23 17:44:20 +00:00
Michael Drake
ffe3ce2615 Don't need initial caret pos now. 2013-02-22 22:26:03 +00:00
Michael Drake
c034fb87ad No point in setting caret there. 2013-02-22 22:16:26 +00:00
Michael Drake
48bd5e1f10 Always set caret. 2013-02-22 16:41:35 +00:00
Michael Drake
04ca082416 Shove allocation step size into #define. 2013-02-22 16:16:10 +00:00
Michael Drake
00eb142661 Increase allocation increment step size. 2013-02-22 16:12:48 +00:00
Michael Drake
d48f3e3f49 Textarea tweaks for caret placement after selection removal. 2013-02-22 16:04:31 +00:00
Michael Drake
59fdbae1bc Fix setting of empty selections. 2013-02-22 15:23:36 +00:00
Michael Drake
c2a718075a A load of refactoring of how content selection and input work.
Keypresses now go via content interface.
Contents don't shove the selection object into browser windows any more.
Contents report selection existence by sending message.
HTML content keeps track of where selections in it exist.
Contents report whether they have input focus via caret setting msg.
Caret can be hidden (can still input/paste) or removed.
Consolidate textarea selection handling.
Make textarea report its selection status changes to client.
Various textarea fixes.
Changed how we decide when to clear selections, and give focus.
2013-02-22 12:19:35 +00:00
Michael Drake
553c55b07a Move selection clearing into a function, and expose it in the header file. 2013-02-13 13:37:46 +00:00
Michael Drake
08a229161b Calculate and store text offsets only when they change, rather than recalculating on every redraw and caret placement. Also ensures that caret placement and redraw get the same text offset values. 2013-02-13 13:08:05 +00:00
Michael Drake
2c64e89641 Implement selection modification. Clicks and drags with button 2 alter the nearest end of the selection. Button 2 when there is no selection selects from caret pos to click pos. 2013-02-12 18:20:06 +00:00
Michael Drake
eccf590616 Triple click selects paragraph in textarea widget. 2013-02-12 12:58:12 +00:00
Michael Drake
97f0a22a8b Tidy textarea-handled mouse action. 2013-02-12 12:09:49 +00:00
Michael Drake
19f09dcc61 Init clipboard to NULL, just in case front end implementation of gui_get_clipboard fails to set it on empty clipboard. 2013-02-12 11:15:37 +00:00
Michael Drake
c39a3d7263 When reqesting redraaw to remove internal caret, make sure caret is already removed as the redraw may be serviced immediatley. 2013-02-12 10:13:55 +00:00
Michael Drake
515cef8444 Don't include '\0' in single-line nsfont_width call. 2013-02-11 18:42:51 +00:00
Michael Drake
fe7b71edbf Selection autoscroll of scrollbarless textareas (single line). 2013-02-11 17:55:36 +00:00
Michael Drake
99cab8389a Early detection of regions outside the visible. 2013-02-11 17:05:42 +00:00
Michael Drake
fc430dba75 Clip native caret render so it can't overwrite border. Slight simplification. 2013-02-11 16:47:11 +00:00
Michael Drake
e6bf51c3ba Single line textareas don't have scrollbars, so they don't get the scroll redraw request from the scrollbar callback. 2013-02-11 16:31:06 +00:00
Michael Drake
3bcc79ccf0 Don't need to redraw for caret removal if using a native caret. 2013-02-11 16:10:19 +00:00
Michael Drake
fa2d5cf62c Fix internal caret redraw bounds. 2013-02-11 14:30:26 +00:00
Michael Drake
18444f261a Fix delete-to-line-end. 2013-02-11 13:39:56 +00:00
Michael Drake
7af0614202 Make delete line key enum value name less missleading. (Doesn't cut to clipboard.) 2013-02-11 10:34:06 +00:00
Michael Drake
b38520da99 Implement delete line. (Ctrl+U on RISC OS.) 2013-02-10 23:22:46 +00:00
Michael Drake
10edbc45bd If a character is replaced by a character of different width, the caret needs to move. Checking change in character index isn't enough, so move caret if redraw was required too. 2013-02-09 18:41:23 +00:00
Michael Drake
32e9602126 When updating textarea layout settings, remember scrollbar status. 2013-02-09 18:21:10 +00:00
Michael Drake
1be54d7b10 If restarting reflow for scrollbar change, need to start at line 0. 2013-02-09 16:50:30 +00:00
Michael Drake
56cfa93531 Empty textarea has one line. 2013-02-09 16:28:00 +00:00
Michael Drake
25b036418e Stop it from using past the end of lines data allocation. (It could add up to 2 lines per pass, but assumed 1 for allocation.) 2013-02-09 15:26:20 +00:00
Michael Drake
8c3e0cf81a [Return] will replace selection. 2013-02-09 14:43:21 +00:00
Michael Drake
b4609f41bc Support front ends that pass CR for [return], as well as those that pass NL. 2013-02-09 14:19:38 +00:00
Michael Drake
eb1113e4c3 Fix handling of empty textarea. 2013-02-09 14:18:17 +00:00
Michael Drake
048b344a43 Take account of scrollbar-occupied regions. 2013-02-09 13:34:28 +00:00
Michael Drake
f848de3dd0 Fix use of x values when y is required. 2013-02-09 13:18:16 +00:00
Michael Drake
2bd0d13817 Take account of caret height when scrolling to show caret. 2013-02-09 11:54:13 +00:00
Michael Drake
688e1b0e4f Slight selection auto-scroll optimisation. 2013-02-09 11:24:44 +00:00
Michael Drake
363d02b8ad Pedantic wrap. 2013-02-08 23:39:41 +00:00
Michael Drake
50c52408f5 Fix seg fault when moving cursor up onto empty top line. 2013-02-08 23:38:05 +00:00
Michael Drake
6fee220c52 Adjust code to reduce indentation. 2013-02-08 23:35:42 +00:00
Michael Drake
0d831c4ab6 Scaled textarea rendering support. Ugly. 2013-02-08 23:25:40 +00:00
Michael Drake
586e02e915 Implement text selection auto-scroll. 2013-02-08 20:03:44 +00:00
Michael Drake
7a397d29c6 Improve scroll-to-caret behaviour. 2013-02-08 19:46:35 +00:00
Michael Drake
59d24187f7 Support dropping text file on textarea widget. 2013-02-08 16:05:44 +00:00
Michael Drake
698f391289 Add scrollwheel support to textareas. 2013-02-08 15:26:24 +00:00
Michael Drake
9ec663f3a9 Tweak selection rendering. Adjusting layout doesn't emit redraw request. Client must redraw when it wants it. 2013-02-08 13:16:24 +00:00
Michael Drake
76b0e59b18 Don't lose fractional part of text pt size to rounding. 2013-02-07 15:03:35 +00:00
Michael Drake
94be5edbfa Native caret not now set in redraw. Prevents endless redraw when textarea has caret. 2013-02-07 13:58:43 +00:00
Michael Drake
008cdb42d7 Fix empty textarea reflow. Fix empty line (just \n) redraw. Add set layout function to set size and padding. 2013-02-06 22:30:32 +00:00
Michael Drake
442218cb80 Pull flags out of textarea_setup. 2013-02-02 22:58:35 +00:00
Michael Drake
97bc1d0189 Add support for password text inputs.
+ Text display obscured.
  + Cut/Copy put the obscured version on the clipboard.
2013-02-01 18:29:27 +00:00
Michael Drake
663191791e Add move caret msg. Add flag to choose internal caret or caret move msgs. 2013-01-30 18:01:01 +00:00
Michael Drake
5eb417fff4 Create textarea_msg struct on stack, rather than using global. 2013-01-29 22:52:21 +00:00
Michael Drake
af7a5d2d67 Don't redraw if selection is unchanged. 2013-01-29 20:28:10 +00:00
Michael Drake
93cc123200 Update textarea to inform client what it's doing with drags.
Now single callback for both redraw requests and drag reports.
Update treeview to use new textarea API.
Update Atari URL bar to use new textarea API.  (Ignores drag reports, currently.)
Minor textarea fixes.
2013-01-29 17:34:08 +00:00
François Revol
2f94b0a949 textarea: C89 2013-01-20 17:59:55 +01:00
Michael Drake
9995ef583f Early scrollbar mouse handling. 2013-01-18 23:32:53 +00:00
Michael Drake
d252896953 Ensure we know for sure if scrollbar widget will want to scroll us. Avoid double xy to offset conversion. 2013-01-15 21:05:54 +00:00
Michael Drake
7a0b347563 Add parentheses. 2013-01-15 19:50:36 +00:00
Michael Drake
348e9789a4 Add scrollbars to textarea, and improve scrolling to try to keep caret in centre. Currently the scrollbars are mostly decoration, although they show accuratly where you are scrolled to in the area. TODO: Pass mouse input to scrollbars. 2013-01-15 19:40:32 +00:00
Michael Drake
96264ca71e Use right padding. Thanks jmb. 2013-01-14 12:01:23 +00:00
Michael Drake
700aea8b08 Fix caret removal redraw to take account of border width. Fix scroll_visible to take account of border width in vertical scroll. 2013-01-14 11:46:56 +00:00
Michael Drake
2b7bc02961 Implement most of the styling needed for HTML. Allow caret to be hidden. 2013-01-13 23:01:29 +00:00
Michael Drake
740559ab52 Rewrite redraw to handle selection properly. (Now text can change colour inside selection, rather than just rendering a rectangle under the normal line of text. This removes colour restrictions, allowing e.g. inversion for selected text.) 2013-01-13 14:51:26 +00:00
Michael Drake
c7a37392e4 Add background colour to textarea_redraw API. Add source comments. 2013-01-12 20:59:32 +00:00
Michael Drake
5124b8a02a Add textarea_setup struct to textarea_create API. 2013-01-12 20:46:01 +00:00
Michael Drake
ac03806a50 Fix redraw of caret when scroll offsets are non-zero, only caret has moved, and we're not getting a full textarea redraw. 2013-01-10 23:21:47 +00:00
Michael Drake
ac89e52109 Simplify routine to scroll ta so that caret is visible. 2013-01-10 23:20:42 +00:00
Michael Drake
ab5d165659 More wrap behaviour improvement. 2013-01-10 19:43:22 +00:00
Michael Drake
694c1e7eea Fix silly. 2013-01-10 18:42:56 +00:00
Michael Drake
d3973b2991 Fix previous caret position redraw. 2013-01-10 18:36:25 +00:00
Michael Drake
2158ef60a8 Improve reflow in multiline textareas. 2013-01-10 17:42:43 +00:00
Michael Drake
eddb0f17d1 Simplfy caret placement and redraw. 2013-01-10 15:06:05 +00:00