From 6ad8b25cc0288224d305e8b5c8fdb496bb1593ff Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 8 Oct 2003 22:01:20 +0000 Subject: [project @ 2003-10-08 22:01:20 by jmb] Allow cursor movement between lines in paragraphs svn path=/import/netsurf/; revision=356 --- desktop/browser.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'desktop/browser.c') diff --git a/desktop/browser.c b/desktop/browser.c index b94a35958..3aea8f8d4 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -822,7 +822,8 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void } else if (key == 28) { /* Right cursor -> */ if (char_offset == text_box->length && - inline_container->next) { + text_box == inline_container->last && + inline_container->next) { if (inline_container->next->children) { /* move to start of next box (if it exists) */ text_box = inline_container->next->children; @@ -830,6 +831,10 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void char_offset = 0; inline_container=inline_container->next; } + else if (char_offset == text_box->length && text_box->next) { + text_box = text_box->next; + char_offset == 0; + } else if (char_offset != text_box->length) { char_offset++; } @@ -838,7 +843,9 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void } } else if (key == 29) { /* Left cursor <- */ - if (char_offset == 0 && inline_container->prev) { + if (char_offset == 0 && + text_box == inline_container->children && + inline_container->prev) { if (inline_container->prev->children) { /* move to end of previous box */ text_box = inline_container->prev->children; @@ -846,6 +853,10 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void inline_container=inline_container->prev; char_offset = text_box->length; } + else if (char_offset == 0 && text_box->next) { + text_box = text_box->next; + char_offset = text_box->length; + } else if (char_offset != 0) { char_offset--; } @@ -854,7 +865,8 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void } } else if (key == 30) { /* Up Cursor */ - if (inline_container->prev) { + if (text_box == inline_container->children && + inline_container->prev) { if (inline_container->prev->children) { text_box = inline_container->prev->children; } @@ -863,12 +875,19 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void char_offset = text_box->length; } } + else if (text_box->prev) { + text_box = text_box->prev; + if (char_offset > text_box->length) { + char_offset = text_box->length; + } + } else { return; } } else if (key == 31) { /* Down cursor */ - if (inline_container->next) { + if (text_box == inline_container->last && + inline_container->next) { if (inline_container->next->children) { text_box = inline_container->next->children; } @@ -877,6 +896,12 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void char_offset = text_box->length; } } + else if (text_box->next) { + text_box = text_box->next; + if (char_offset > text_box->length) { + char_offset = text_box->length; + } + } else { return; } -- cgit v1.2.3