aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-03-12 19:52:18 +0100
committerThomas White <taw@bitwiz.org.uk>2014-03-12 19:52:18 +0100
commitdc6118b49b3f5858732ba5a48751a552eedafa11 (patch)
tree29367ce300acc601997ba3755341abaf263a50d4
parentcd5b7c2b8905619e2c66959178c92fc41a712eb7 (diff)
Cursor advance stuff
-rw-r--r--src/mainwindow.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 7c850cd..482ef1c 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1601,18 +1601,33 @@ static void move_cursor(struct presentation *p, signed int x, signed int y)
{
struct wrap_line *line = &p->cursor_frame->lines[p->cursor_line];
struct wrap_box *box = &line->boxes[p->cursor_box];
+ signed int cp, cb, cl;
/* FIXME: Advance past images etc */
- p->cursor_pos += x;
+ /* FIXME: use g_utf8_find_next_char() or .._prev_char() */
+ cp = p->cursor_pos + x;
+ cb = p->cursor_box;
+ cl = p->cursor_line;
- if ( p->cursor_pos < 0 ) {
- p->cursor_pos = 0;
- }
+ if ( cp < 0 ) cp = 0;
+
+ printf("pos=%i, length=%i\n", cp, g_utf8_strlen(box->text, -1));
- if ( p->cursor_pos > g_utf8_strlen(box->text, -1) ) {
- p->cursor_pos = 0;
+ if ( cp > g_utf8_strlen(box->text, -1) ) {
+ cp = 0;
+ cb++;
+ if ( cb >= line->n_boxes ) {
+ cl++;
+ if ( cl >= p->cursor_frame->n_lines ) {
+ cl = p->cursor_frame->n_lines-1;
+ }
+ }
}
+
+ p->cursor_pos = cp;
+ p->cursor_box = cb;
+ p->cursor_line = cl;
}