Commits

Tobias Berling committed c6698a4

Added the paste2 gedit-commander module.

Comments (0)

Files changed (2)

gedit-commander-module/README

+Copy paste2.py to ~/.gnome2/gedit/commander/modules and have fun.

gedit-commander-module/paste2.py

+import urllib
+import gtk
+
+import commander.commands as commands
+import commander.commands.completion
+import commander.commands.result
+import commander.commands.exceptions
+
+__commander_module__ = True
+
+def __default__(view, entry):
+    """paste2: paste selection or hole file"""
+    buf = view.get_buffer()
+    bounds = buf.get_selection_bounds()
+
+    # nothing selected -> select all
+    if not bounds:
+        bounds = buf.get_bounds()
+
+    text = bounds[0].get_text(bounds[1])
+ 
+    params = urllib.urlencode({'content': text})
+    f = urllib.urlopen("http://p2.karottika.de/", params)
+    url = f.read().strip()
+
+    lang = buf.get_language()
+    if lang:
+        url += '?%s' % lang.get_id()
+
+    prret = (yield commands.result.Prompt("Copy URL to Clipboard? [Y/n]", ('yes','no')))
+    if prret[0].strip().lower() in ['y', 'ye', 'yes', '']:
+        clipboard = gtk.Clipboard(selection='CLIPBOARD')
+        clipboard.set_text(url, len(url))
+       
+    entry.info_show('<u>%s</u>' % url, True)
+    yield commands.result.DONE
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.