[gedit] Added additional input type (selection, with default to document)



commit 1ccfc978ed02522509a0d907bdfe9e91709c58ed
Author: Jesse van den Kieboom <jvanden grijpc10 epfl ch>
Date:   Fri May 22 09:55:52 2009 +0200

    Added additional input type (selection, with default to document)
    
    This fixes bug #331222.
---
 plugins/externaltools/tools/functions.py |   16 ++++++++++++----
 plugins/externaltools/tools/tools.ui     |    4 ++++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/plugins/externaltools/tools/functions.py b/plugins/externaltools/tools/functions.py
index bafcf59..8d09c7f 100644
--- a/plugins/externaltools/tools/functions.py
+++ b/plugins/externaltools/tools/functions.py
@@ -90,13 +90,21 @@ def run_external_tool(window, node):
     if input_type != 'nothing' and view is not None:
         if input_type == 'document':
             start, end = document.get_bounds()
-        elif input_type == 'selection':
+        elif input_type == 'selection' or input_type == 'selection-document':
             try:
                 start, end = document.get_selection_bounds()
+                
+                print start, end
             except ValueError:
-                start, end = document.get_bounds()
-                if output_type == 'replace-selection':
-                    document.select_range(start, end)
+                if input_type == 'selection-document':
+                    start, end = document.get_bounds()
+
+                    if output_type == 'replace-selection':
+                        document.select_range(start, end)
+                else:
+                    start = document.get_iter_at_mark(document.get_insert())
+                    end = start.copy()
+                    
         elif input_type == 'line':
             start = document.get_iter_at_mark(document.get_insert())
             end = start.copy()
diff --git a/plugins/externaltools/tools/tools.ui b/plugins/externaltools/tools/tools.ui
index 9046479..dff7d19 100644
--- a/plugins/externaltools/tools/tools.ui
+++ b/plugins/externaltools/tools/tools.ui
@@ -41,6 +41,10 @@
         <col id="1">selection</col>
       </row>
       <row>
+        <col id="0" translatable="yes">Current selection (default to document)</col>
+        <col id="1">selection-document</col>
+      </row>
+      <row>
         <col id="0" translatable="yes">Current line</col>
         <col id="1">line</col>
       </row>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]