[geany/geany-plugins] 23ce0c: geanyextrasel - added "Toggle Rectangular/Stream"

Dimitar Zhekov git-noreply at xxxxx
Tue Mar 19 18:03:43 UTC 2013


Branch:      refs/heads/master
Author:      Dimitar Zhekov <dimitar.zhekov at gmail.com>
Committer:   Dimitar Zhekov <dimitar.zhekov at gmail.com>
Date:        Tue, 19 Mar 2013 18:03:43 UTC
Commit:      23ce0cd4dc74d0bebba38aec827d50dbbcb9d5cd
             https://github.com/geany/geany-plugins/commit/23ce0cd4dc74d0bebba38aec827d50dbbcb9d5cd

Log Message:
-----------
geanyextrasel - added "Toggle Rectangular/Stream"


Modified Paths:
--------------
    geanyextrasel/ChangeLog
    geanyextrasel/README
    geanyextrasel/src/extrasel.c

Modified: geanyextrasel/ChangeLog
7 files changed, 5 insertions(+), 2 deletions(-)
===================================================================
@@ -1,7 +1,11 @@
-2012-06-13  Dimitar Zhekov  <dimitar.zhekov at gmail.com>
+2013-03-19  Dimitar Zhekov  <dimitar.zhekov at gmail.com>
 
  * src/extrasel.c:
+   Added "Toggle Rectangular/Stream".
+
+2012-06-13  Dimitar Zhekov  <dimitar.zhekov at gmail.com>
 
+ * src/extrasel.c:
    Fixed the prototype of on_column_mode_toggled().
    Partially restored ignore_callback to avoid delay on document
    activation.
@@ -9,7 +13,6 @@
 2012-06-13  Dimitar Zhekov  <dimitar.zhekov at 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.


Modified: geanyextrasel/README
17 files changed, 11 insertions(+), 6 deletions(-)
===================================================================
@@ -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


Modified: geanyextrasel/src/extrasel.c
29 files changed, 28 insertions(+), 1 deletions(-)
===================================================================
@@ -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 @@ static void on_select_rectangle_key(G_GNUC_UNUSED guint key_id)
 	{ 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"));



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list