Revision: 1648 http://svn.sourceforge.net/geany/?rev=1648&view=rev Author: eht16 Date: 2007-06-27 12:07:03 -0700 (Wed, 27 Jun 2007)
Log Message: ----------- Replace existing selection with chosen colour.
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-27 18:43:23 UTC (rev 1647) +++ trunk/ChangeLog 2007-06-27 19:07:03 UTC (rev 1648) @@ -3,6 +3,7 @@ * src/callbacks.c, src/dialogs.c: Add palette to Colour Chooser Dialog. Fix picking colours starting with '#'. + Replace existing selection with chosen colour.
2007-06-27 Nick Treleaven nick.treleaven@btinternet.com
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2007-06-27 18:43:23 UTC (rev 1647) +++ trunk/src/callbacks.c 2007-06-27 19:07:03 UTC (rev 1648) @@ -994,7 +994,27 @@ GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(app->open_colorsel)->colorsel), &color);
hex = utils_get_hex_from_color(&color); - sci_add_text(doc_list[idx].sci, hex); + // add the selected colour into the doc, prefer #... format unless there is a selection + // starting with 0x... + if (sci_can_copy(doc_list[idx].sci)) + { + gint start = sci_get_selection_start(doc_list[idx].sci); + gchar *replacement = hex; + + if (sci_get_char_at(doc_list[idx].sci, start) == '0' && + sci_get_char_at(doc_list[idx].sci, start + 1) == 'x') + { + sci_set_selection_start(doc_list[idx].sci, start + 2); + replacement++; // skip the leading '#' + } + else if (sci_get_char_at(doc_list[idx].sci, start - 1) == '#') + { // double clicking something like #00ffff may only select 00ffff because of wordchars + replacement++; // so skip the '#' to only replace the colour value + } + sci_replace_sel(doc_list[idx].sci, replacement); + } + else + sci_add_text(doc_list[idx].sci, hex); g_free(hex); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.