Revision: 1741 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1741&view=re... Author: sheckley Date: 2010-11-11 17:41:03 +0000 (Thu, 11 Nov 2010)
Log Message: ----------- smart home selection synced with Geany Camel Cased E_xtra selection, _Column mode fixed a small compilation warning
Modified Paths: -------------- trunk/geany-plugins/geanyextrasel/ChangeLog trunk/geany-plugins/geanyextrasel/src/extrasel.c
Modified: trunk/geany-plugins/geanyextrasel/ChangeLog =================================================================== --- trunk/geany-plugins/geanyextrasel/ChangeLog 2010-11-11 15:48:55 UTC (rev 1740) +++ trunk/geany-plugins/geanyextrasel/ChangeLog 2010-11-11 17:41:03 UTC (rev 1741) @@ -1,14 +1,20 @@ +2010-11-11 Dimitar Zhekov dimitar.zhekov@gmail.com + + * src/extrasel.c: + Respect 'Smart' home key (Geany does now). + Camel Cased "Extra selection" and "Column mode" menu items. + 2010-05-31 Dimitar Zhekov dimitar.zhekov@gmail.com
* src/extrasel.c: - Fixed "Goto line and select" with the toolbar visible. - + Fixed "Select to Line" with the toolbar visible. + 2010-05-22 Dimitar Zhekov hamster@mbox.contact.bg
* src/extrasel.c: Fixed crash in plugin_cleanup() - patch by Colomban Wendling, thanks. Use documents_foreach() if foreach_document() is not available. - + 2010-05-21 Dimitar Zhekov hamster@mbox.contact.bg
* src/extrasel.c:
Modified: trunk/geany-plugins/geanyextrasel/src/extrasel.c =================================================================== --- trunk/geany-plugins/geanyextrasel/src/extrasel.c 2010-11-11 15:48:55 UTC (rev 1740) +++ trunk/geany-plugins/geanyextrasel/src/extrasel.c 2010-11-11 17:41:03 UTC (rev 1741) @@ -28,7 +28,7 @@ PLUGIN_VERSION_CHECK(150)
PLUGIN_SET_INFO(_("Extra Selection"), _("Column mode, select to line / matching brace."), - "0.1", "Dimitar Toshkov Zhekov dimitar.zhekov@gmail.com"); + "0.2", "Dimitar Toshkov Zhekov dimitar.zhekov@gmail.com");
/* Keybinding(s) */ enum @@ -58,12 +58,12 @@
static const command_key command_keys[] = { + { GDK_Up, GDK_KP_Up, SCI_PARAUP }, + { GDK_Down, GDK_KP_Down, SCI_PARADOWN }, { GDK_Left, GDK_KP_Left, SCI_WORDLEFT }, { GDK_Right, GDK_KP_Right, SCI_WORDRIGHTEND }, { GDK_Home, GDK_KP_Home, SCI_DOCUMENTSTART }, { GDK_End, GDK_KP_End, SCI_DOCUMENTEND }, - { GDK_Up, GDK_KP_Up, SCI_PARAUP }, - { GDK_Down, GDK_KP_Down, SCI_PARADOWN }, { 0, 0, 0 } };
@@ -104,13 +104,13 @@ { ScintillaObject *sci = doc->editor->sci;
- if (gtk_window_get_focus(GTK_WINDOW(widget)) == sci) + if (gtk_window_get_focus(GTK_WINDOW(widget)) == GTK_WIDGET(sci)) { column_mode_command(sci, ck->command); return TRUE; } } - /* no document or not focused */ + break; } } @@ -126,54 +126,85 @@ gint rectangle; } select_key;
-static const select_key select_keys[] = +/* not #defined in 0.18 */ +#define sci_clear_cmdkey(sci, key) scintilla_send_message((sci), SCI_CLEARCMDKEY, (key), 0) +#define sci_assign_cmdkey(sci, key, command) \ + scintilla_send_message((sci), SCI_ASSIGNCMDKEY, (key), (command)) + +static void assign_select_key(ScintillaObject *sci, const select_key *sk) { + if (column_mode) + { + sci_clear_cmdkey(sci, sk->key | (SCMOD_ALT << 16)); + sci_assign_cmdkey(sci, sk->key, sk->rectangle); + } + else + { + sci_assign_cmdkey(sci, sk->key, sk->stream); + sci_assign_cmdkey(sci, sk->key | (SCMOD_ALT << 16), sk->rectangle); + } +} + +static select_key select_keys[] = +{ + { SCK_HOME | (SCMOD_SHIFT << 16), SCI_NULL, SCI_NULL }, + { SCK_UP | (SCMOD_SHIFT << 16), SCI_LINEUPEXTEND, SCI_LINEUPRECTEXTEND }, { SCK_DOWN | (SCMOD_SHIFT << 16), SCI_LINEDOWNEXTEND, SCI_LINEDOWNRECTEXTEND }, - { SCK_UP | (SCMOD_SHIFT << 16), SCI_LINEUPEXTEND, SCI_LINEUPRECTEXTEND }, { SCK_LEFT | (SCMOD_SHIFT << 16), SCI_CHARLEFTEXTEND, SCI_CHARLEFTRECTEXTEND }, { SCK_RIGHT | (SCMOD_SHIFT << 16), SCI_CHARRIGHTEXTEND, SCI_CHARRIGHTRECTEXTEND }, - { SCK_HOME | (SCMOD_SHIFT << 16), SCI_VCHOMEEXTEND, SCI_VCHOMERECTEXTEND }, { SCK_END | (SCMOD_SHIFT << 16), SCI_LINEENDEXTEND, SCI_LINEENDRECTEXTEND }, { SCK_PRIOR | (SCMOD_SHIFT << 16), SCI_PAGEUPEXTEND, SCI_PAGEUPRECTEXTEND }, { SCK_NEXT | (SCMOD_SHIFT << 16), SCI_PAGEDOWNEXTEND, SCI_PAGEDOWNRECTEXTEND }, { 0, 0, 0 } };
-/* not #defined in 0.18 */ -#define sci_clear_cmdkey(sci, key) scintilla_send_message((sci), SCI_CLEARCMDKEY, (key), 0) -#define sci_assign_cmdkey(sci, key, command) \ - scintilla_send_message((sci), SCI_ASSIGNCMDKEY, (key), (command)) - -static void assign_column_keys(ScintillaObject *sci) +static void assign_select_keys(ScintillaObject *sci) { const select_key *sk;
for (sk = select_keys; sk->key; sk++) - { - if (column_mode) - { - sci_clear_cmdkey(sci, sk->key | (SCMOD_ALT << 16)); - sci_assign_cmdkey(sci, sk->key, sk->rectangle); - } - else - { - sci_assign_cmdkey(sci, sk->key, sk->stream); - sci_assign_cmdkey(sci, sk->key | (SCMOD_ALT << 16), sk->rectangle); - } - } + assign_select_key(sci, sk); }
static void on_document_switch(G_GNUC_UNUSED GObject *obj, GeanyDocument *doc, G_GNUC_UNUSED gpointer user_data) { - assign_column_keys(doc->editor->sci); + assign_select_keys(doc->editor->sci); }
+static void update_home_key(void) +{ + if (geany_data->editor_prefs->smart_home_key) + { + select_keys->stream = SCI_VCHOMEEXTEND; + select_keys->rectangle = SCI_VCHOMERECTEXTEND; + } + else + { + select_keys->stream = SCI_HOMEEXTEND; + select_keys->rectangle = SCI_HOMERECTEXTEND; + } +} + +static void on_settings_change(G_GNUC_UNUSED GKeyFile *config) +{ + update_home_key(); + + if (column_mode) + { + GeanyDocument *doc = document_get_current(); + + if (doc) + assign_select_key(doc->editor->sci, select_keys); + } +} + PluginCallback plugin_callbacks[] = { { "document-new", (GCallback) &on_document_switch, FALSE, NULL }, { "document-open", (GCallback) &on_document_switch, FALSE, NULL }, { "document-activate", (GCallback) &on_document_switch, FALSE, NULL }, + { "save-settings", (GCallback) &on_settings_change, FALSE, NULL }, { NULL, NULL, FALSE, NULL } };
@@ -197,7 +228,7 @@ int anchor = sci_get_anchor(sci); int cursor = sci_get_current_position(sci);
- assign_column_keys(sci); + assign_select_keys(sci); if (column_mode && select_mode == SC_SEL_STREAM) { sci_set_selection_mode(sci, SC_SEL_RECTANGLE); @@ -273,13 +304,13 @@
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
- main_menu_item = gtk_menu_item_new_with_mnemonic(_("E_xtra selection")); + main_menu_item = gtk_menu_item_new_with_mnemonic(_("E_xtra Selection")); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), main_menu_item); g_signal_connect(main_menu_item, "activate", G_CALLBACK(on_extra_select_activate), NULL); extra_select_menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(main_menu_item), extra_select_menu);
- column_mode_item = gtk_check_menu_item_new_with_mnemonic(_("_Column mode")); + column_mode_item = gtk_check_menu_item_new_with_mnemonic(_("_Column Mode")); gtk_container_add(GTK_CONTAINER(extra_select_menu), column_mode_item); g_signal_connect(column_mode_item, "toggled", G_CALLBACK(on_column_mode_toggled), NULL); keybindings_set_item(plugin_key_group, COLUMN_MODE_KB, on_column_mode_key, 0, 0, @@ -303,6 +334,8 @@ go_to_line1_item = g_object_get_data((gpointer) geany->main_widgets->window, "go_to_line1");
+ update_home_key(); + plugin_signal_connect(geany_plugin, G_OBJECT(geany->main_widgets->window), "key-press-event", FALSE, G_CALLBACK(on_key_press_event), NULL); } @@ -318,6 +351,6 @@
column_mode = FALSE; foreach_document (i) - assign_column_keys(documents[i]->editor->sci); + assign_select_keys(documents[i]->editor->sci); gtk_widget_destroy(main_menu_item); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.