From 9f1ac34671b0446c8eb8855e0aca62d5b69840b0 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Thu, 7 Feb 2002 10:22:59 +0000 Subject: Bumped the version number to 0.19.99.5. 2002-02-07 Christopher James Lahey * configure.in: Bumped the version number to 0.19.99.5. * gal/Makefile.am (libgal_la_LIBADD): Added menus/gal-view-instance-save-as-dialog.lo. * gal/e-text/e-text.c (next_word): Contains refactored code from the E_TEP_FORWARD_WORD case of e_text_command. (e_text_command): Implemented E_TEP_CAPS. From gal/menus/ChangeLog: 2002-02-07 Christopher James Lahey * Makefile.am (glade_DATA): Added gal-view-instance-save-as-dialog.glade. (libgalmenus_la_SOURCES): Added gal-view-instance-save-as-dialog.c. (libgalmenusinclude_HEADERS): Added gal-view-instance-save-as-dialog.h. * gal-view-collection.c, gal-view-collection.h (gal_view_collection_append_with_title): Added this new version of the append function that sets the title and returns the new id as well. (gal_view_collection_set_nth_view): Added this function to save over another view. (gal_view_collection_get_default_view, gal_view_collection_set_default_view): Added the concept of a default view for GalViewCollections. * gal-view-etable.c, gal-view-etable.h (gal_view_etable_attach_table, gal_view_etable_attach_tree, gal_view_etable_detach): Added functions to set the state of a table or tree and then send GalView "changed" signals whenever that state changes. (gal_view_etable_set_state): New function to set the ETableState of a GalViewETable. * gal-view-instance-save-as-dialog.c, gal-view-instance-save-as-dialog.glade, gal-view-instance-save-as-dialog.h: New dialog to save the current custom view as a named view. * gal-view-instance.c, gal-view-instance.h (gal_view_instance_set_custom_view): New function to set the state of an instance to custom view and set the custom view to a particular GalView. (gal_view_instance_exists): New function to check if this particular instance has ever been opened before. Use before gal_view_instance_load. (gal_view_instance_save_as): New function to open a save as dialog. (gal_view_instance_load): Added this function which used to be part of _construct. This function can be called multiple times, and those extra times will be ignored. This is so you can set a default view before loading. (gal_view_instance_get_default_view, gal_view_instance_set_default_view): Set the default view for this instance. If unset, this falls back to the default view for the corresponding GalViewCollection. svn path=/trunk/; revision=15590 --- widgets/text/e-text.c | 101 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 22 deletions(-) (limited to 'widgets/text') diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index 4439a3e9bf..2dc03d9a25 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -3298,6 +3298,31 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event) /* fixme: */ +static int +next_word (EText *text, int start) +{ + char *p; + int length; + + length = strlen (text->text); + + if (start >= length) { + return length; + } else { + p = g_utf8_next_char (text->text + start); + + while (p && *p && g_unichar_validate (g_utf8_get_char (p))) { + gunichar unival = g_utf8_get_char (p); + if (g_unichar_isspace (unival)) { + return p - text->text; + } else + p = g_utf8_next_char (p); + } + } + + return p - text->text; +} + static int _get_position(EText *text, ETextEventProcessorCommand *command) { @@ -3393,28 +3418,7 @@ _get_position(EText *text, ETextEventProcessorCommand *command) break; case E_TEP_FORWARD_WORD: - new_pos = -1; - length = strlen (text->text); - - if (text->selection_end >= length) { - new_pos = length; - } else { - - p = g_utf8_next_char (text->text + text->selection_end); - - while (p && *p && g_unichar_validate (g_utf8_get_char (p))) { - unival = g_utf8_get_char (p); - if (g_unichar_isspace (unival)) { - new_pos = p - text->text; - p = NULL; - } else - p = g_utf8_next_char (p); - } - } - - if (new_pos == -1) - new_pos = p - text->text; - + new_pos = next_word (text, text->selection_end); break; case E_TEP_BACKWARD_WORD: @@ -3585,6 +3589,50 @@ _insert(EText *text, char *string, int value) } } +static void +capitalize (EText *text, int start, int end, ETextEventProcessorCaps type) +{ + gboolean first = TRUE; + const char *p = text->text + start; + const char *text_end = text->text + end; + char *new_text = g_new0 (char, g_utf8_strlen (text->text + start, start - end) * 6); + char *output = new_text; + + while (p && *p && p < text_end && g_unichar_validate (g_utf8_get_char (p))) { + gunichar unival = g_utf8_get_char (p); + gunichar newval = unival; + + switch (type) { + case E_TEP_CAPS_UPPER: + newval = g_unichar_toupper (unival); + break; + case E_TEP_CAPS_LOWER: + newval = g_unichar_tolower (unival); + break; + case E_TEP_CAPS_TITLE: + if (g_unichar_isalpha (unival)) { + if (first) + newval = g_unichar_totitle (unival); + else + newval = g_unichar_tolower (unival); + first = FALSE; + } else { + first = TRUE; + } + break; + } + g_unichar_to_utf8 (newval, output); + output = g_utf8_next_char (output); + + p = g_utf8_next_char (p); + } + *output = 0; + + e_text_model_delete (text->model, start, end - start); + e_text_model_insert (text->model, start, new_text); + g_free (new_text); +} + static void e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data) { @@ -3678,6 +3726,15 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM(text), command->time); scroll = FALSE; break; + case E_TEP_CAPS: + if (text->selection_start == text->selection_end) { + capitalize (text, text->selection_start, next_word (text, text->selection_start), command->value); + } else { + int selection_start = MIN (text->selection_start, text->selection_end); + int selection_end = text->selection_start + text->selection_end - selection_start; /* Slightly faster than MAX */ + capitalize (text, selection_start, selection_end, command->value); + } + break; case E_TEP_NOP: scroll = FALSE; break; -- cgit v1.2.3