From 16746b0151b6623c8d1403acc1f84036758ac2ae Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 8 Oct 2003 20:48:46 +0000 Subject: [project @ 2003-10-08 20:48:46 by jmb] Make cursor keys work in text areas svn path=/import/netsurf/; revision=352 --- desktop/browser.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 8 deletions(-) (limited to 'desktop') 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; } -- cgit v1.2.3