Permalink
Browse files

geanyextrasel - added "Toggle Rectangular/Stream"

  • Loading branch information...
1 parent 1da79ca commit 23ce0cd4dc74d0bebba38aec827d50dbbcb9d5cd @zhekov zhekov committed Mar 19, 2013
Showing with 44 additions and 9 deletions.
  1. +5 −2 geanyextrasel/ChangeLog
  2. +11 −6 geanyextrasel/README
  3. +28 −1 geanyextrasel/src/extrasel.c
View
@@ -1,15 +1,18 @@
-2012-06-13 Dimitar Zhekov <dimitar.zhekov@gmail.com>
+2013-03-19 Dimitar Zhekov <dimitar.zhekov@gmail.com>
* src/extrasel.c:
+ Added "Toggle Rectangular/Stream".
+
+2012-06-13 Dimitar Zhekov <dimitar.zhekov@gmail.com>
+ * src/extrasel.c:
Fixed the prototype of on_column_mode_toggled().
Partially restored ignore_callback to avoid delay on document
activation.
2012-06-13 Dimitar Zhekov <dimitar.zhekov@gmail.com>
* src/extrasel.c:
-
Fixed on_settings_change() prototype.
Fixed on settings changed to reassign the selection keys for all
documents, not the current document only.
View
@@ -3,12 +3,15 @@ Extra Selection Plugin
About
-----
-The Extra Selection adds the following functions:
+The Extra Selection plugin adds the following functions to Geany:
Goto matching brace and select (Select to Matching Brace).
Goto line and select (Select to Line).
+Toggle the current selection type between stream and rectangular
+(without changing column mode, can be invoked while drag-selecting).
+
Ctrl-Shift-Alt-Left/Right/Home/End keys - same as Ctrl-Shift, but for
rectangular selection.
@@ -17,6 +20,8 @@ selection instead of stream.
Selection with anchor instead of the Shift-movement keys.
+--
+
"Movement keys" refers to the arrows, Home, End, Page Up and Page Down.
For more information, see the Usage section below.
@@ -35,11 +40,11 @@ See the README file of that package.
Usage
-----
-Under Tools -> Extra Selection, there are 6 new items: "Column Mode",
-"Select to Line" and "Select to Matching Brace", "Set Anchor", "Select to
-Anchor" and "Rectangle Select to Anchor". Normally these should be bound
-to keys, for example Alt-C, Alt-Shift-L, Ctrl-Shift-B, F12, Shift-F12 and
-Alt-Shift-F12. Now:
+Under Tools -> Extra Selection, there are 7 new items: "Column Mode",
+"Select to Line", "Select to Matching Brace", "Toggle Rectangular/Stream",
+"Set Anchor", "Select to Anchor" and "Rectangle Select to Anchor".
+Normally these should be bound to keys, for example Alt-C, Alt-Shift-L,
+Ctrl-Shift-B, Ctrl+2, F12, Shift-F12 and Alt-Shift-F12. Now:
1. Position the cursor on an opening brace and invoke "Select to Matching
Brace". The cursor will move to the closing brace, and the braced area
@@ -40,6 +40,7 @@ enum
COLUMN_MODE_KB,
GOTO_LINE_EXTEND_KB,
BRACE_MATCH_EXTEND_KB,
+ CONVERT_SELECTION_KB,
SET_ANCHOR_KB,
ANCHOR_EXTEND_KB,
ANCHOR_RECTEXTEND_KB,
@@ -193,7 +194,7 @@ static gboolean on_key_press_event(GtkWidget *widget, GdkEventKey *event,
if (sci && sci_has_selection(sci) && sci_rectangle_selection(sci) &&
gtk_window_get_focus(GTK_WINDOW(widget)) == GTK_WIDGET(sci))
{
- /* not exactly a bug, yet... */
+ /* not exactly a bug, but... */
convert_selection(sci, FALSE);
}
break;
@@ -372,6 +373,20 @@ static void on_brace_match_key(G_GNUC_UNUSED guint key_id)
on_brace_match_activate(NULL, NULL);
}
+static void on_convert_selection_activate(G_GNUC_UNUSED GtkMenuItem *menuitem,
+ G_GNUC_UNUSED gpointer gdata)
+{
+ ScintillaObject *sci = scintilla_get_current();
+
+ if (sci)
+ convert_selection(sci, !sci_rectangle_selection(sci));
+}
+
+static void on_convert_selection_key(G_GNUC_UNUSED guint key_id)
+{
+ on_convert_selection_activate(NULL, NULL);
+}
+
/* Set anchor / select to anchor */
static void save_selection(ScintillaObject *sci)
@@ -472,6 +487,11 @@ PluginCallback plugin_callbacks[] =
{ NULL, NULL, FALSE, NULL }
};
+static void on_extra_select_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, gpointer gdata)
+{
+ gtk_widget_set_sensitive(GTK_WIDGET(gdata), sci_has_selection(scintilla_get_current()));
+}
+
void plugin_init(G_GNUC_UNUSED GeanyData *data)
{
GtkContainer *menu;
@@ -505,6 +525,13 @@ void plugin_init(G_GNUC_UNUSED GeanyData *data)
keybindings_set_item(plugin_key_group, BRACE_MATCH_EXTEND_KB, on_brace_match_key, 0, 0,
"brace_match_extend", _("Select to matching brace"), item);
+ item = gtk_menu_item_new_with_mnemonic(_("_Toggle Stream/Rectangular"));
+ gtk_container_add(menu, item);
+ g_signal_connect(item, "activate", G_CALLBACK(on_convert_selection_activate), NULL);
+ keybindings_set_item(plugin_key_group, CONVERT_SELECTION_KB, on_convert_selection_key,
+ 0, 0, "convert_selection", _("Convert selection"), item);
+ g_signal_connect(main_menu_item, "activate", G_CALLBACK(on_extra_select_activate), item);
+
gtk_container_add(menu, gtk_separator_menu_item_new());
item = gtk_menu_item_new_with_mnemonic(_("_Set Anchor"));

0 comments on commit 23ce0cd

Please sign in to comment.