From ca96353d9fac049057535ed7fdff19e43ac79666 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 27 Jun 2009 13:59:25 +0000 Subject: Merged revisions 7764-7977,7979-8058 via svnmerge from svn://svn.netsurf-browser.org/branches/paulblokus/textinput ........ r7769 | paulblokus | 2009-06-11 22:26:16 +0100 (Thu, 11 Jun 2009) | 4 lines replace global history window with an empty window for future tests add the necessary files first lines ported ........ r7771 | paulblokus | 2009-06-11 23:51:46 +0100 (Thu, 11 Jun 2009) | 1 line more functions ........ r7772 | paulblokus | 2009-06-12 02:07:36 +0100 (Fri, 12 Jun 2009) | 1 line redraw working ........ r7777 | paulblokus | 2009-06-12 11:35:45 +0100 (Fri, 12 Jun 2009) | 3 lines plotter fix make use of the provided clipping rectangle ........ r7781 | paulblokus | 2009-06-12 16:26:51 +0100 (Fri, 12 Jun 2009) | 3 lines callbacks for taxtarea to request a [caret]redraw basic caret handling drawing ........ r7782 | paulblokus | 2009-06-12 22:36:50 +0100 (Fri, 12 Jun 2009) | 1 line single character insertion ........ r7783 | paulblokus | 2009-06-12 22:41:37 +0100 (Fri, 12 Jun 2009) | 1 line single character insertion ........ r7784 | paulblokus | 2009-06-12 23:55:40 +0100 (Fri, 12 Jun 2009) | 3 lines fixed caret clipping arrows, delete and backspace ........ r7812 | paulblokus | 2009-06-16 14:55:41 +0100 (Tue, 16 Jun 2009) | 1 line remove bug causing NS hang on \n in textarea ........ r7816 | paulblokus | 2009-06-16 16:29:48 +0100 (Tue, 16 Jun 2009) | 1 line Enter, Home, End keys ........ r7817 | paulblokus | 2009-06-16 16:56:16 +0100 (Tue, 16 Jun 2009) | 1 line Ctrl + Home/End ........ r7818 | paulblokus | 2009-06-16 17:16:51 +0100 (Tue, 16 Jun 2009) | 1 line redraw caret only on caret moves ........ r7821 | paulblokus | 2009-06-16 20:18:30 +0100 (Tue, 16 Jun 2009) | 1 line line end/start delete ........ r7822 | paulblokus | 2009-06-16 23:43:42 +0100 (Tue, 16 Jun 2009) | 1 line selection drawing + select all ........ r7823 | paulblokus | 2009-06-17 02:31:07 +0100 (Wed, 17 Jun 2009) | 3 lines auto scrolling on caret moves clear selection ........ r7845 | paulblokus | 2009-06-18 17:35:03 +0100 (Thu, 18 Jun 2009) | 1 line page up/down ........ r7846 | paulblokus | 2009-06-18 17:38:45 +0100 (Thu, 18 Jun 2009) | 1 line remove unnecessary fix ........ r7847 | paulblokus | 2009-06-18 18:00:16 +0100 (Thu, 18 Jun 2009) | 1 line clipping fixes ........ r7849 | paulblokus | 2009-06-18 18:21:02 +0100 (Thu, 18 Jun 2009) | 1 line scroll fix ........ r7850 | paulblokus | 2009-06-18 18:45:13 +0100 (Thu, 18 Jun 2009) | 1 line simplified redraw request logic ........ r7855 | paulblokus | 2009-06-18 19:56:24 +0100 (Thu, 18 Jun 2009) | 1 line front end passing mouse events ........ r7858 | paulblokus | 2009-06-18 22:18:39 +0100 (Thu, 18 Jun 2009) | 3 lines drag selection bug fixes ........ r7860 | paulblokus | 2009-06-18 23:32:39 +0100 (Thu, 18 Jun 2009) | 3 lines take selection into account on keypress of different types a few bugs fixed ........ r7876 | paulblokus | 2009-06-19 13:43:07 +0100 (Fri, 19 Jun 2009) | 3 lines pango nsfont_split fix a few textarea fixes ........ r7879 | paulblokus | 2009-06-19 17:33:10 +0100 (Fri, 19 Jun 2009) | 4 lines newline handling seems to work this way clear selection on mouse click more bug fixes ........ r7880 | paulblokus | 2009-06-19 18:16:27 +0100 (Fri, 19 Jun 2009) | 3 lines no caret option selection follows drag ........ r7883 | paulblokus | 2009-06-19 19:08:44 +0100 (Fri, 19 Jun 2009) | 3 lines o width selection bug fix caret at correct side of drag selection ........ r7918 | paulblokus | 2009-06-22 21:01:28 +0100 (Mon, 22 Jun 2009) | 3 lines fix caret positioning at line end CR removal in input methods ........ r7919 | paulblokus | 2009-06-22 21:34:39 +0100 (Mon, 22 Jun 2009) | 1 line fix crash on 0 length text ........ r7926 | paulblokus | 2009-06-23 09:53:56 +0100 (Tue, 23 Jun 2009) | 3 lines change LF into spaces for single line widget text normalisation at one place ........ r7931 | paulblokus | 2009-06-23 10:51:25 +0100 (Tue, 23 Jun 2009) | 1 line cleanup ........ r7933 | paulblokus | 2009-06-23 11:17:22 +0100 (Tue, 23 Jun 2009) | 1 line fix selection draw ........ r7935 | paulblokus | 2009-06-23 11:41:30 +0100 (Tue, 23 Jun 2009) | 1 line guard readonly ........ r7942 | paulblokus | 2009-06-24 08:19:39 +0100 (Wed, 24 Jun 2009) | 1 line applied changes suggested by jmb ........ r7943 | paulblokus | 2009-06-24 09:04:49 +0100 (Wed, 24 Jun 2009) | 1 line little fixes ........ r7945 | paulblokus | 2009-06-24 12:50:14 +0100 (Wed, 24 Jun 2009) | 1 line correct line length and wrapping ........ r7947 | paulblokus | 2009-06-24 14:32:36 +0100 (Wed, 24 Jun 2009) | 3 lines fixed page up/down broken in last commit changed logic for caret positioning on soft breaks ........ r7949 | paulblokus | 2009-06-24 16:31:42 +0100 (Wed, 24 Jun 2009) | 1 line remove temporary/test code ........ r7975 | paulblokus | 2009-06-25 16:00:46 +0100 (Thu, 25 Jun 2009) | 1 line changes suggested by jmb ........ r7976 | paulblokus | 2009-06-25 16:33:23 +0100 (Thu, 25 Jun 2009) | 1 line added ro_ prefix to RISC OS textarea code ........ svn path=/trunk/netsurf/; revision=8060 --- riscos/textarea.c | 128 +++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 63 deletions(-) (limited to 'riscos/textarea.c') diff --git a/riscos/textarea.c b/riscos/textarea.c index 365aa17a8..86774fad4 100644 --- a/riscos/textarea.c +++ b/riscos/textarea.c @@ -110,12 +110,12 @@ static wimp_window text_area_definition = { {} }; -static void textarea_reflow(struct text_area *ta, unsigned int line); -static bool textarea_mouse_click(wimp_pointer *pointer); -static bool textarea_key_press(wimp_key *key); -static void textarea_redraw(wimp_draw *redraw); -static void textarea_redraw_internal(wimp_draw *redraw, bool update); -static void textarea_open(wimp_open *open); +static void ro_textarea_reflow(struct text_area *ta, unsigned int line); +static bool ro_textarea_mouse_click(wimp_pointer *pointer); +static bool ro_textarea_key_press(wimp_key *key); +static void ro_textarea_redraw(wimp_draw *redraw); +static void ro_textarea_redraw_internal(wimp_draw *redraw, bool update); +static void ro_textarea_open(wimp_open *open); /** * Create a text area @@ -128,7 +128,7 @@ static void textarea_open(wimp_open *open); * \param font_style Font style to use, or 0 for default * \return Opaque handle for textarea or 0 on error */ -uintptr_t textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, +uintptr_t ro_textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, const char *font_family, unsigned int font_size, rufl_style font_style) { @@ -189,21 +189,21 @@ uintptr_t textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, } /* set the window dimensions */ - if (!textarea_update((uintptr_t)ret)) { - textarea_destroy((uintptr_t)ret); + if (!ro_textarea_update((uintptr_t)ret)) { + ro_textarea_destroy((uintptr_t)ret); return 0; } /* and register our event handlers */ ro_gui_wimp_event_set_user_data(ret->window, ret); ro_gui_wimp_event_register_mouse_click(ret->window, - textarea_mouse_click); + ro_textarea_mouse_click); ro_gui_wimp_event_register_keypress(ret->window, - textarea_key_press); + ro_textarea_key_press); ro_gui_wimp_event_register_redraw_window(ret->window, - textarea_redraw); + ro_textarea_redraw); ro_gui_wimp_event_register_open_window(ret->window, - textarea_open); + ro_textarea_open); return (uintptr_t)ret; } @@ -213,7 +213,7 @@ uintptr_t textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, * * \param self Text area to update */ -bool textarea_update(uintptr_t self) +bool ro_textarea_update(uintptr_t self) { struct text_area *ta; wimp_window_state state; @@ -291,7 +291,7 @@ bool textarea_update(uintptr_t self) } /* reflow the text */ - textarea_reflow(ta, 0); + ro_textarea_reflow(ta, 0); return true; } @@ -300,7 +300,7 @@ bool textarea_update(uintptr_t self) * * \param self Text area to destroy */ -void textarea_destroy(uintptr_t self) +void ro_textarea_destroy(uintptr_t self) { struct text_area *ta; os_error *error; @@ -329,7 +329,7 @@ void textarea_destroy(uintptr_t self) * \param text UTF-8 text to set text area's contents to * \return true on success, false on memory exhaustion */ -bool textarea_set_text(uintptr_t self, const char *text) +bool ro_textarea_set_text(uintptr_t self, const char *text) { struct text_area *ta; unsigned int len = strlen(text) + 1; @@ -353,7 +353,7 @@ bool textarea_set_text(uintptr_t self, const char *text) memcpy(ta->text, text, len); ta->text_len = len; - textarea_reflow(ta, 0); + ro_textarea_reflow(ta, 0); return true; } @@ -367,7 +367,7 @@ bool textarea_set_text(uintptr_t self, const char *text) * \param len Length (bytes) of buffer pointed to by buf, or 0 to read length * \return Length (bytes) written/required or -1 on error */ -int textarea_get_text(uintptr_t self, char *buf, unsigned int len) +int ro_textarea_get_text(uintptr_t self, char *buf, unsigned int len) { struct text_area *ta; @@ -399,7 +399,7 @@ int textarea_get_text(uintptr_t self, char *buf, unsigned int len) * \param index 0-based character index to insert at * \param text UTF-8 text to insert */ -void textarea_insert_text(uintptr_t self, unsigned int index, +void ro_textarea_insert_text(uintptr_t self, unsigned int index, const char *text) { struct text_area *ta; @@ -442,7 +442,7 @@ void textarea_insert_text(uintptr_t self, unsigned int index, ta->text_len += b_len; /** \todo calculate line to reflow from */ - textarea_reflow(ta, 0); + ro_textarea_reflow(ta, 0); } /** @@ -453,7 +453,7 @@ void textarea_insert_text(uintptr_t self, unsigned int index, * \param end End character index of replaced section (exclusive) * \param text UTF-8 text to insert */ -void textarea_replace_text(uintptr_t self, unsigned int start, +void ro_textarea_replace_text(uintptr_t self, unsigned int start, unsigned int end, const char *text) { struct text_area *ta; @@ -474,7 +474,7 @@ void textarea_replace_text(uintptr_t self, unsigned int start, end = c_len; if (start == end) - return textarea_insert_text(self, start, text); + return ro_textarea_insert_text(self, start, text); if (start > end) { int temp = end; @@ -515,7 +515,7 @@ void textarea_replace_text(uintptr_t self, unsigned int start, ta->text_len += b_len - (b_end - b_start); /** \todo calculate line to reflow from */ - textarea_reflow(ta, 0); + ro_textarea_reflow(ta, 0); } /** @@ -524,7 +524,7 @@ void textarea_replace_text(uintptr_t self, unsigned int start, * \param self Text area * \param caret 0-based character index to place caret at */ -void textarea_set_caret(uintptr_t self, unsigned int caret) +void ro_textarea_set_caret(uintptr_t self, unsigned int caret) { struct text_area *ta; size_t c_len, b_off; @@ -566,7 +566,7 @@ void textarea_set_caret(uintptr_t self, unsigned int caret) /* Finally, redraw the WIMP caret */ - index = textarea_get_caret(self); + index = ro_textarea_get_caret(self); os_line_height.x = 0; os_line_height.y = (int)((float)(ta->line_height - ta->line_spacing) * 0.62) + 1; ro_convert_pixels_to_os_units(&os_line_height, (os_mode)-1); @@ -605,7 +605,7 @@ void textarea_set_caret(uintptr_t self, unsigned int caret) * \param x X position of caret on the screen * \param y Y position of caret on the screen */ -void textarea_set_caret_xy(uintptr_t self, int x, int y) +void ro_textarea_set_caret_xy(uintptr_t self, int x, int y) { struct text_area *ta; wimp_window_state state; @@ -665,7 +665,7 @@ void textarea_set_caret_xy(uintptr_t self, int x, int y) temp = utf8_next(ta->text, ta->text_len, temp)) c_off++; - textarea_set_caret((uintptr_t)ta, c_off); + ro_textarea_set_caret((uintptr_t)ta, c_off); } /** @@ -674,7 +674,7 @@ void textarea_set_caret_xy(uintptr_t self, int x, int y) * \param self Text area * \return 0-based character index of caret location, or -1 on error */ -unsigned int textarea_get_caret(uintptr_t self) +unsigned int ro_textarea_get_caret(uintptr_t self) { struct text_area *ta; size_t c_off = 0, b_off; @@ -701,7 +701,7 @@ unsigned int textarea_get_caret(uintptr_t self) * \param ta Text area to reflow * \param line Line number to begin reflow on */ -void textarea_reflow(struct text_area *ta, unsigned int line) +void ro_textarea_reflow(struct text_area *ta, unsigned int line) { rufl_code code; char *text; @@ -846,7 +846,8 @@ void textarea_reflow(struct text_area *ta, unsigned int line) } /* Now, attempt to create vertical scrollbar */ - ro_gui_wimp_update_window_furniture(ta->window, wimp_WINDOW_VSCROLL, + ro_gui_wimp_update_window_furniture(ta->window, + wimp_WINDOW_VSCROLL, wimp_WINDOW_VSCROLL); /* Get new window state */ @@ -877,7 +878,7 @@ void textarea_reflow(struct text_area *ta, unsigned int line) ta->vis_width -= vscroll_width; /* Now we've done that, we have to reflow the text area */ - textarea_reflow(ta, 0); + ro_textarea_reflow(ta, 0); } } @@ -887,13 +888,13 @@ void textarea_reflow(struct text_area *ta, unsigned int line) * \param pointer Mouse click state block * \return true if click handled, false otherwise */ -bool textarea_mouse_click(wimp_pointer *pointer) +bool ro_textarea_mouse_click(wimp_pointer *pointer) { struct text_area *ta; ta = (struct text_area *)ro_gui_wimp_event_get_user_data(pointer->w); - textarea_set_caret_xy((uintptr_t)ta, pointer->pos.x, pointer->pos.y); + ro_textarea_set_caret_xy((uintptr_t)ta, pointer->pos.x, pointer->pos.y); return true; } @@ -903,7 +904,7 @@ bool textarea_mouse_click(wimp_pointer *pointer) * \param key Key pressed state block * \param true if press handled, false otherwise */ -bool textarea_key_press(wimp_key *key) +bool ro_textarea_key_press(wimp_key *key) { uint32_t c = (uint32_t) key->c; wimp_key keypress; @@ -925,49 +926,49 @@ bool textarea_key_press(wimp_key *key) utf8_len = utf8_from_ucs4(c, utf8); utf8[utf8_len] = '\0'; - c_pos = textarea_get_caret((uintptr_t)ta); - textarea_insert_text((uintptr_t)ta, c_pos, utf8); - textarea_set_caret((uintptr_t)ta, ++c_pos); + c_pos = ro_textarea_get_caret((uintptr_t)ta); + ro_textarea_insert_text((uintptr_t)ta, c_pos, utf8); + ro_textarea_set_caret((uintptr_t)ta, ++c_pos); redraw = true; } else { /** \todo handle command keys */ switch (c & ~IS_WIMP_KEY) { case 8: /* Backspace */ - c_pos = textarea_get_caret((uintptr_t)ta); + c_pos = ro_textarea_get_caret((uintptr_t)ta); if (c_pos > 0) { - textarea_replace_text((uintptr_t)ta, + ro_textarea_replace_text((uintptr_t)ta, c_pos - 1, c_pos, ""); - textarea_set_caret((uintptr_t)ta, c_pos - 1); + ro_textarea_set_caret((uintptr_t)ta, c_pos - 1); redraw = true; } break; case 21: /* Ctrl + U */ - textarea_set_text((uintptr_t)ta, ""); - textarea_set_caret((uintptr_t)ta, 0); + ro_textarea_set_text((uintptr_t)ta, ""); + ro_textarea_set_caret((uintptr_t)ta, 0); redraw = true; break; case wimp_KEY_DELETE: - c_pos = textarea_get_caret((uintptr_t)ta); + c_pos = ro_textarea_get_caret((uintptr_t)ta); if (os_version < RISCOS5 && c_pos > 0) { - textarea_replace_text((uintptr_t)ta, + ro_textarea_replace_text((uintptr_t)ta, c_pos - 1, c_pos, ""); - textarea_set_caret((uintptr_t)ta, c_pos - 1); + ro_textarea_set_caret((uintptr_t)ta, c_pos - 1); } else { - textarea_replace_text((uintptr_t)ta, c_pos, + ro_textarea_replace_text((uintptr_t)ta, c_pos, c_pos + 1, ""); } redraw = true; break; case wimp_KEY_LEFT: - c_pos = textarea_get_caret((uintptr_t)ta); + c_pos = ro_textarea_get_caret((uintptr_t)ta); if (c_pos > 0) - textarea_set_caret((uintptr_t)ta, c_pos - 1); + ro_textarea_set_caret((uintptr_t)ta, c_pos - 1); break; case wimp_KEY_RIGHT: - c_pos = textarea_get_caret((uintptr_t)ta); - textarea_set_caret((uintptr_t)ta, c_pos + 1); + c_pos = ro_textarea_get_caret((uintptr_t)ta); + ro_textarea_set_caret((uintptr_t)ta, c_pos + 1); break; case wimp_KEY_UP: /** \todo Move caret up a line */ @@ -984,16 +985,17 @@ bool textarea_key_press(wimp_key *key) /** \todo line end */ break; case wimp_KEY_CONTROL | wimp_KEY_UP: - textarea_set_caret((uintptr_t)ta, 0); + ro_textarea_set_caret((uintptr_t)ta, 0); break; case wimp_KEY_CONTROL | wimp_KEY_DOWN: - textarea_set_caret((uintptr_t)ta, utf8_length(ta->text)); + ro_textarea_set_caret((uintptr_t)ta, + utf8_length(ta->text)); break; case wimp_KEY_COPY: if (os_version < RISCOS5) { - c_pos = textarea_get_caret((uintptr_t)ta); - textarea_replace_text((uintptr_t)ta, c_pos, + c_pos = ro_textarea_get_caret((uintptr_t)ta); + ro_textarea_replace_text((uintptr_t)ta, c_pos, c_pos + 1, ""); } else { /** \todo line end */ @@ -1004,10 +1006,10 @@ bool textarea_key_press(wimp_key *key) case wimp_KEY_RETURN: if (ta->flags & TEXTAREA_MULTILINE) { /* Insert newline */ - c_pos = textarea_get_caret((uintptr_t)ta); - textarea_insert_text((uintptr_t)ta, c_pos, + c_pos = ro_textarea_get_caret((uintptr_t)ta); + ro_textarea_insert_text((uintptr_t)ta, c_pos, "\n"); - textarea_set_caret((uintptr_t)ta, ++c_pos); + ro_textarea_set_caret((uintptr_t)ta, ++c_pos); redraw = true; @@ -1038,7 +1040,7 @@ bool textarea_key_press(wimp_key *key) update.box.y1 = 0; update.box.x1 = ta->vis_width; update.box.y0 = -ta->line_height * (ta->line_count + 1); - textarea_redraw_internal(&update, true); + ro_textarea_redraw_internal(&update, true); } return true; @@ -1049,9 +1051,9 @@ bool textarea_key_press(wimp_key *key) * * \param redraw Redraw request block */ -void textarea_redraw(wimp_draw *redraw) +void ro_textarea_redraw(wimp_draw *redraw) { - textarea_redraw_internal(redraw, false); + ro_textarea_redraw_internal(redraw, false); } /** @@ -1060,7 +1062,7 @@ void textarea_redraw(wimp_draw *redraw) * \param redraw Redraw/update request block * \param update True if update, false if full redraw */ -void textarea_redraw_internal(wimp_draw *redraw, bool update) +void ro_textarea_redraw_internal(wimp_draw *redraw, bool update) { struct text_area *ta; int clip_x0, clip_y0, clip_x1, clip_y1; @@ -1170,7 +1172,7 @@ void textarea_redraw_internal(wimp_draw *redraw, bool update) * * \param open OpenWindow block */ -void textarea_open(wimp_open *open) +void ro_textarea_open(wimp_open *open) { os_error *error; -- cgit v1.2.3