summaryrefslogtreecommitdiff
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
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
-rw-r--r--!NetSurf/Resources/CSS,f792
-rw-r--r--desktop/browser.c63
2 files changed, 56 insertions, 9 deletions
diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79
index 96480100a..6a9db5a95 100644
--- a/!NetSurf/Resources/CSS,f79
+++ b/!NetSurf/Resources/CSS,f79
@@ -39,7 +39,7 @@ center { text-align: center; }
small { font-size: smaller; }
big { font-size: larger; }
select, input { background-color: #eeb; color: #000; width: 10em; height: 2em; }
-textarea { background-color: #eeb; color: #000; }
+textarea { background-color: #eeb; color: #000; text-align: left; }
input[type=button], input[type=image], input[type=reset], input[type=submit],
button { background-color: #ddd; color: #000; width: auto;
height: auto; }
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;
}