diff options
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/sslcert.c | 24 | ||||
-rw-r--r-- | riscos/textarea.c | 128 | ||||
-rw-r--r-- | riscos/textarea.h | 20 | ||||
-rw-r--r-- | riscos/treeview.c | 16 |
4 files changed, 96 insertions, 92 deletions
diff --git a/riscos/sslcert.c b/riscos/sslcert.c index 7e9e8557c..9db500486 100644 --- a/riscos/sslcert.c +++ b/riscos/sslcert.c @@ -338,8 +338,8 @@ void ro_gui_cert_open(struct tree *tree, struct node *node) return; } if (session->issuer) - textarea_destroy(session->issuer); - session->issuer = textarea_create(w, ICON_CERT_ISSUER, + ro_textarea_destroy(session->issuer); + session->issuer = ro_textarea_create(w, ICON_CERT_ISSUER, TEXTAREA_MULTILINE | TEXTAREA_READONLY, ro_gui_desktop_font_family, ro_gui_desktop_font_size, ro_gui_desktop_font_style); @@ -348,28 +348,28 @@ void ro_gui_cert_open(struct tree *tree, struct node *node) warn_user("NoMemory", 0); return; } - if (!textarea_set_text(session->issuer, session->issuer_t)) { - textarea_destroy(session->issuer); + if (!ro_textarea_set_text(session->issuer, session->issuer_t)) { + ro_textarea_destroy(session->issuer); xwimp_delete_window(w); warn_user("NoMemory", 0); return; } if (session->subject) - textarea_destroy(session->subject); - session->subject = textarea_create(w, ICON_CERT_SUBJECT, + ro_textarea_destroy(session->subject); + session->subject = ro_textarea_create(w, ICON_CERT_SUBJECT, TEXTAREA_MULTILINE | TEXTAREA_READONLY, ro_gui_desktop_font_family, ro_gui_desktop_font_size, ro_gui_desktop_font_style); if (!session->subject) { - textarea_destroy(session->issuer); + ro_textarea_destroy(session->issuer); xwimp_delete_window(w); warn_user("NoMemory", 0); return; } - if (!textarea_set_text(session->subject, session->subject_t)) { - textarea_destroy(session->subject); - textarea_destroy(session->issuer); + if (!ro_textarea_set_text(session->subject, session->subject_t)) { + ro_textarea_destroy(session->subject); + ro_textarea_destroy(session->issuer); xwimp_delete_window(w); warn_user("NoMemory", 0); return; @@ -392,9 +392,9 @@ void ro_gui_cert_close(wimp_w w) for (i = 0; i < data->num; i++) { if (data->certs[i].subject) - textarea_destroy(data->certs[i].subject); + ro_textarea_destroy(data->certs[i].subject); if (data->certs[i].issuer) - textarea_destroy(data->certs[i].issuer); + ro_textarea_destroy(data->certs[i].issuer); } free(data->certs); free(data->url); 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; diff --git a/riscos/textarea.h b/riscos/textarea.h index ac766d1c8..c726a0e78 100644 --- a/riscos/textarea.h +++ b/riscos/textarea.h @@ -31,20 +31,20 @@ #define TEXTAREA_MULTILINE 0x01 /**< Text area is multiline */ #define TEXTAREA_READONLY 0x02 /**< Text area is read only */ -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); -bool textarea_update(uintptr_t self); -void textarea_destroy(uintptr_t self); -bool textarea_set_text(uintptr_t self, const char *text); -int textarea_get_text(uintptr_t self, char *buf, unsigned int len); -void textarea_insert_text(uintptr_t self, unsigned int index, +bool ro_textarea_update(uintptr_t self); +void ro_textarea_destroy(uintptr_t self); +bool ro_textarea_set_text(uintptr_t self, const char *text); +int ro_textarea_get_text(uintptr_t self, char *buf, unsigned int len); +void ro_textarea_insert_text(uintptr_t self, unsigned int index, const char *text); -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); -void textarea_set_caret(uintptr_t self, unsigned int caret); -void textarea_set_caret_xy(uintptr_t self, int x, int y); -unsigned int textarea_get_caret(uintptr_t self); +void ro_textarea_set_caret(uintptr_t self, unsigned int caret); +void ro_textarea_set_caret_xy(uintptr_t self, int x, int y); +unsigned int ro_textarea_get_caret(uintptr_t self); #endif diff --git a/riscos/treeview.c b/riscos/treeview.c index 5f826e865..ef23c5e3e 100644 --- a/riscos/treeview.c +++ b/riscos/treeview.c @@ -1080,7 +1080,7 @@ void ro_gui_tree_start_edit(struct tree *tree, struct node_element *element, LOG(("xwimp_create_icon: 0x%x: %s", error->errnum, error->errmess)); - tree->textarea_handle = textarea_create((wimp_w)tree->handle, + tree->textarea_handle = ro_textarea_create((wimp_w)tree->handle, (wimp_i)tree->edit_handle, 0, ro_gui_desktop_font_family, ro_gui_desktop_font_size, ro_gui_desktop_font_style); @@ -1088,12 +1088,13 @@ void ro_gui_tree_start_edit(struct tree *tree, struct node_element *element, ro_gui_tree_stop_edit(tree); return; } - textarea_set_text(tree->textarea_handle, element->text); + ro_textarea_set_text(tree->textarea_handle, element->text); if (pointer) - textarea_set_caret_xy(tree->textarea_handle, + ro_textarea_set_caret_xy(tree->textarea_handle, pointer->pos.x, pointer->pos.y); else - textarea_set_caret(tree->textarea_handle, strlen(element->text)); + ro_textarea_set_caret(tree->textarea_handle, + strlen(element->text)); tree_handle_node_element_changed(tree, element); ro_gui_tree_scroll_visible(tree, element); @@ -1114,7 +1115,7 @@ void ro_gui_tree_stop_edit(struct tree *tree) if (!tree->editing) return; if (tree->textarea_handle) { - textarea_destroy(tree->textarea_handle); + ro_textarea_destroy(tree->textarea_handle); tree->textarea_handle = 0; } error = xwimp_delete_icon((wimp_w)tree->handle, (wimp_i)tree->edit_handle); @@ -1308,7 +1309,8 @@ bool ro_gui_tree_keypress(wimp_key *key) return true; case wimp_KEY_RETURN: if ((tree->editing) && (tree->textarea_handle)) { - strlen = textarea_get_text(tree->textarea_handle, + strlen = ro_textarea_get_text( + tree->textarea_handle, NULL, 0); if (strlen == -1) { ro_gui_tree_stop_edit(tree); @@ -1321,7 +1323,7 @@ bool ro_gui_tree_keypress(wimp_key *key) warn_user("NoMemory", 0); return true; } - textarea_get_text(tree->textarea_handle, + ro_textarea_get_text(tree->textarea_handle, new_string, strlen); free((void *)tree->editing->text); tree->editing->text = new_string; |