]> git.neil.brown.name Git - edlib.git/commitdiff
render-lines: initial support for multi-line renders.
authorNeilBrown <neil@brown.name>
Sat, 29 Apr 2023 10:11:44 +0000 (20:11 +1000)
committerNeilBrown <neil@brown.name>
Sat, 29 Apr 2023 10:14:00 +0000 (20:14 +1000)
An image will soon appear as multiple lines so that the cursor can
appear at locations within it.

Moving down always goes to start of line.  Moving up goes to top of
image.
These aren't ideal, but better than nothing for now.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
render-lines.c

index 2a54f26cdb222e6bbe2868917b5e3fb4ec73fbfd..d795e0d50405c541c5de48b5b965605ffe1f17e3 100644 (file)
@@ -438,6 +438,9 @@ Module features
 
 ### render-lines
 
+- [ ] improve Move-line in multi-line renders (images). prev
+      must only move up one line, and moving down should start
+     in column
 - [X] improve 'margin' to permit cursor in margin at start of file
 - [X] improve 'margin' to honour previous view of doc
 - [X] update_line_height should handle TAB (and any control) - cannot expect
index 95c0d8399ca5cb2bbb1dfc9492563342c825444c..a35b16573db3a8ba818cb64f22366e556a8ce73e 100644 (file)
@@ -1514,6 +1514,11 @@ DEF_CMD(render_lines_move_line)
        /* We are at the start of the target line.  We might
         * like to find the target_x column, but if anything
         * goes wrong it isn't a failure.
+        * Need to ensure there is a vmark here. call_render_line_prev()
+        * wil only move the mark if it is in a multi-line rendering,
+        * such as an image which acts as though it is multiple lines.
+        * It will check if there is already a mark at the target location.
+        * It will free the mark passed in unless it returns it.
         */
        start = vmark_new(focus, rl->typenum, p);
 
@@ -1556,6 +1561,20 @@ DEF_CMD(render_lines_move_line)
        m2 = call_render_line_offset(focus, start, xypos);
        if (!m2)
                goto done;
+
+       if (!mark_same(start, m)) {
+               /* This is a multi-line render and we aren't on
+                * the first line.  We might need a larger 'y'.
+                * For now, ensure that we move in the right
+                * direction.
+                * FIXME this loses target_x and can move up
+                * too far.  How to fix??
+                */
+               if (num > 0 && mark_ordered_not_same(m2, m))
+                       mark_to_mark(m2, m);
+               if (num < 0 && mark_ordered_not_same(m, m2))
+                       mark_to_mark(m2, m);
+       }
        mark_to_mark(m, m2);
 
        mark_free(m2);