summaryrefslogtreecommitdiff
path: root/desktop/browser.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2003-10-08 20:48:46 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2003-10-08 20:48:46 +0000
commit16746b0151b6623c8d1403acc1f84036758ac2ae (patch)
tree67d5b0a5c9b726aa1ffa0fa0c31b03b77be290b5 /desktop/browser.c
parentec15724bc3bc16ed4dcd59bf5c31734c3440fc8a (diff)
downloadnetsurf-16746b0151b6623c8d1403acc1f84036758ac2ae.tar.gz
netsurf-16746b0151b6623c8d1403acc1f84036758ac2ae.tar.bz2
[project @ 2003-10-08 20:48:46 by jmb]
Make cursor keys work in text areas svn path=/import/netsurf/; revision=352
Diffstat (limited to 'desktop/browser.c')
-rw-r--r--desktop/browser.c63
1 files changed, 55 insertions, 8 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index b408d38ae..b94a35958 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -819,20 +819,67 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void
text_box->width = UNKNOWN_WIDTH;
char_offset--;
}
- } else if (key == 28 && char_offset != text_box->length) {
+ } else if (key == 28) {
/* Right cursor -> */
- char_offset++;
- } else if (key == 29 && char_offset != 0) {
+ if (char_offset == text_box->length &&
+ inline_container->next) {
+ if (inline_container->next->children) {
+ /* move to start of next box (if it exists) */
+ text_box = inline_container->next->children;
+ }
+ char_offset = 0;
+ inline_container=inline_container->next;
+ }
+ else if (char_offset != text_box->length) {
+ char_offset++;
+ }
+ else {
+ return;
+ }
+ } else if (key == 29) {
/* Left cursor <- */
- char_offset--;
+ if (char_offset == 0 && inline_container->prev) {
+ if (inline_container->prev->children) {
+ /* move to end of previous box */
+ text_box = inline_container->prev->children;
+ }
+ inline_container=inline_container->prev;
+ char_offset = text_box->length;
+ }
+ else if (char_offset != 0) {
+ char_offset--;
+ }
+ else {
+ return;
+ }
} else if (key == 30) {
/* Up Cursor */
- /* TODO */
- return;
+ if (inline_container->prev) {
+ if (inline_container->prev->children) {
+ text_box = inline_container->prev->children;
+ }
+ inline_container = inline_container->prev;
+ if (char_offset > text_box->length) {
+ char_offset = text_box->length;
+ }
+ }
+ else {
+ return;
+ }
} else if (key == 31) {
/* Down cursor */
- /* TODO */
- return;
+ if (inline_container->next) {
+ if (inline_container->next->children) {
+ text_box = inline_container->next->children;
+ }
+ inline_container = inline_container->next;
+ if (char_offset > text_box->length) {
+ char_offset = text_box->length;
+ }
+ }
+ else {
+ return;
+ }
} else {
return;
}