SF.net SVN: geany:[4354] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Oct 22 11:29:00 UTC 2009


Revision: 4354
          http://geany.svn.sourceforge.net/geany/?rev=4354&view=rev
Author:   ntrel
Date:     2009-10-22 11:28:59 +0000 (Thu, 22 Oct 2009)

Log Message:
-----------
Add 'Move line(s) up/down' keybindings.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/geany.html
    trunk/doc/geany.txt
    trunk/src/keybindings.c
    trunk/src/keybindings.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-10-22 11:04:45 UTC (rev 4353)
+++ trunk/ChangeLog	2009-10-22 11:28:59 UTC (rev 4354)
@@ -1,3 +1,9 @@
+2009-10-22  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/keybindings.c, src/keybindings.h, doc/geany.txt, doc/geany.html:
+   Add 'Move line(s) up/down' keybindings.
+
+
 2009-10-22  Lex Trotman  <elextr.at.gmail.dot.com>
 
  * src/build.c, src/build.h, src/filetypes.h:

Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html	2009-10-22 11:04:45 UTC (rev 4353)
+++ trunk/doc/geany.html	2009-10-22 11:28:59 UTC (rev 4354)
@@ -6,7 +6,7 @@
 <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
 <title>Geany</title>
 <meta name="authors" content="Enrico Tröger  Nick Treleaven  Frank Lanitz" />
-<meta name="date" content="2009-10-20" />
+<meta name="date" content="2009-10-22" />
 <style type="text/css">
 
 /*
@@ -139,7 +139,7 @@
 <br />Nick Treleaven
 <br />Frank Lanitz</td></tr>
 <tr><th class="docinfo-name">Date:</th>
-<td>2009-10-20</td></tr>
+<td>2009-10-22</td></tr>
 <tr><th class="docinfo-name">Version:</th>
 <td>0.19</td></tr>
 </tbody>
@@ -2843,8 +2843,8 @@
 filetype.xxx file in
 ~/.config/geany/filedefs</p>
 <p class="last">Saves To:
-geany.conf file in
-~/.config/geany</p>
+filetype.xxx file in
+~/.config/geany/filedefs</p>
 </td>
 <td><p class="first">Loads From:
 filetype.xxx in
@@ -2870,9 +2870,9 @@
 <li>(Non-Filetype, System Filetype) - although conceptually strange, defining
 non-filetype commands in a filetype file, this provides the ability to
 define filetype dependent default menu items.</li>
-<li>(Execute, Project File) and (Execute, Preferences) - the filetype based execute
-configuration can only be set by hand editing the appropriate file, see
-<cite>Preferences File Format</cite> and <cite>Project File Format</cite>.</li>
+<li>(Execute, Project File) and (Execute, Preferences) - the project filetype based execute
+configuration and preferences non-filetype based execute can only be set by hand editing the
+appropriate file, see <cite>Preferences File Format</cite> and <cite>Project File Format</cite>.</li>
 </ul>
 </div>
 <div class="section">
@@ -3240,6 +3240,16 @@
 the currently selected item up to the next word
 part.</td>
 </tr>
+<tr><td>Move line(s) up</td>
+<td> </td>
+<td>Move the current line or selected lines up by
+one line.</td>
+</tr>
+<tr><td>Move line(s) down</td>
+<td> </td>
+<td>Move the current line or selected lines down by
+one line.</td>
+</tr>
 </tbody>
 </table>
 </div>
@@ -5792,7 +5802,7 @@
 <div class="footer">
 <hr class="footer" />
 <a class="reference" href="geany.txt">View document source</a>.
-Generated on: 2009-10-20 16:54 UTC.
+Generated on: 2009-10-22 11:20 UTC.
 Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
 
 </div>

Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt	2009-10-22 11:04:45 UTC (rev 4353)
+++ trunk/doc/geany.txt	2009-10-22 11:28:59 UTC (rev 4354)
@@ -2609,8 +2609,8 @@
   non-filetype commands in a filetype file, this provides the ability to
   define filetype dependent default menu items.
 
-* (Execute, Project File) and (Execute, Preferences) - the project filetype based execute 
-  configuration and preferences non-filetype based execute can only be set by hand editing the 
+* (Execute, Project File) and (Execute, Preferences) - the project filetype based execute
+  configuration and preferences non-filetype based execute can only be set by hand editing the
   appropriate file, see `Preferences File Format` and `Project File Format`.
 
 Build Menu Commands Dialog
@@ -2921,6 +2921,12 @@
 Word part completion            Tab                       When the autocompletion list is visible, complete
                                                           the currently selected item up to the next word
                                                           part.
+
+Move line(s) up                                           Move the current line or selected lines up by
+                                                          one line.
+
+Move line(s) down                                         Move the current line or selected lines down by
+                                                          one line.
 =============================== ========================= ==================================================
 
 

Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c	2009-10-22 11:04:45 UTC (rev 4353)
+++ trunk/src/keybindings.c	2009-10-22 11:28:59 UTC (rev 4354)
@@ -287,6 +287,10 @@
 		GDK_Return, GDK_CONTROL_MASK, "edit_macrolist", _("Show macro list"), NULL);
 	keybindings_set_item(group, GEANY_KEYS_EDITOR_WORDPARTCOMPLETION, NULL,
 		GDK_Tab, 0, "edit_wordpartcompletion", _("Word part completion"), NULL);
+	keybindings_set_item(group, GEANY_KEYS_EDITOR_MOVELINEUP, NULL,
+		0, 0, "edit_movelineup", _("Move line(s) up"), NULL);
+	keybindings_set_item(group, GEANY_KEYS_EDITOR_MOVELINEDOWN, NULL,
+		0, 0, "edit_movelinedown", _("Move line(s) down"), NULL);
 
 	group = ADD_KB_GROUP(CLIPBOARD, _("Clipboard"), cb_func_clipboard_action);
 
@@ -1963,6 +1967,37 @@
 }
 
 
+static void move_lines(GeanyEditor *editor, gboolean down)
+{
+	ScintillaObject *sci = editor->sci;
+	gchar *text;
+	gint pos, line, len;
+
+	sci_start_undo_action(sci);
+	editor_select_lines(editor, TRUE);
+	len = sci_get_selected_text_length(sci);
+
+	pos = sci_get_selection_start(sci);
+	line = sci_get_line_from_position(sci, pos);
+	if (down)
+		line++;
+	else
+		line--;
+
+	text = sci_get_selection_contents(sci);
+	sci_clear(sci);
+
+	pos = sci_get_position_from_line(sci, line);
+	sci_insert_text(sci, pos, text);
+	g_free(text);
+
+	sci_set_current_position(sci, pos, TRUE);
+	sci_set_selection_end(sci, pos + len - 2);
+
+	sci_end_undo_action(sci);
+}
+
+
 /* common function for editor keybindings, only valid when scintilla has focus. */
 static gboolean cb_func_editor_action(guint key_id)
 {
@@ -2043,6 +2078,13 @@
 		}
 		case GEANY_KEYS_EDITOR_WORDPARTCOMPLETION:
 			return editor_complete_word_part(doc->editor);
+
+		case GEANY_KEYS_EDITOR_MOVELINEUP:
+			move_lines(doc->editor, FALSE);
+			break;
+		case GEANY_KEYS_EDITOR_MOVELINEDOWN:
+			move_lines(doc->editor, TRUE);
+			break;
 	}
 	return TRUE;
 }

Modified: trunk/src/keybindings.h
===================================================================
--- trunk/src/keybindings.h	2009-10-22 11:04:45 UTC (rev 4353)
+++ trunk/src/keybindings.h	2009-10-22 11:28:59 UTC (rev 4354)
@@ -149,6 +149,8 @@
 	GEANY_KEYS_EDITOR_MACROLIST,
 	GEANY_KEYS_EDITOR_DELETELINETOEND,
 	GEANY_KEYS_EDITOR_WORDPARTCOMPLETION,
+	GEANY_KEYS_EDITOR_MOVELINEUP,
+	GEANY_KEYS_EDITOR_MOVELINEDOWN,
 	GEANY_KEYS_EDITOR_COUNT
 };
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list