Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 01eae0574d42e5c90069f682d4edfa4248d6c5d1 0 parents
@kemayo kemayo authored
1  .gitignore
@@ -0,0 +1 @@
+*.pyc
9 Default (OSX).sublime-keymap
@@ -0,0 +1,9 @@
+[
+ { "keys": ["super+c"], "command": "clipboard_copy",
+ "context": [{"key": "clipboardcopy_fake", "operator":"equal", "operand":true}]
+ },
+ { "keys": ["super+x"], "command": "clipboard_copy", "args": {"cut": true},
+ "context": [{"key": "clipboardcopy_fake", "operator":"equal", "operand":true}]
+ },
+ { "keys": ["ctrl+alt+command+v"], "command": "clipboard_display" }
+]
6 Default.sublime-commands
@@ -0,0 +1,6 @@
+[
+ {
+ "caption": "Clipboard History",
+ "command": "clipboard_display"
+ }
+]
52 clipboard.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+import sublime
+import sublime_plugin
+
+clipboard_history = []
+
+
+class ClipboardDisplayCommand(sublime_plugin.TextCommand):
+ def run(self, edit):
+ print clipboard_history
+ if not clipboard_history:
+ print "no history"
+ return
+ self.view.window().show_quick_panel(clipboard_history, self.panel_done)
+
+ def panel_done(self, picked):
+ if 0 > picked > len(clipboard_history):
+ return
+ print picked
+ text = clipboard_history[picked]
+ edit = self.view.begin_edit()
+ new_regions = []
+ for region in self.view.sel():
+ self.view.replace(edit, region, text)
+ new_regions.append(sublime.Region(region.begin() + len(text), region.end() + len(text)))
+ self.view.sel().clear()
+ for region in new_regions:
+ self.view.sel().add(region)
+ self.view.end_edit(edit)
+
+ sublime.set_clipboard(text)
+
+
+# Here we see a cunning plan. We listen for a key, but never say we
+# support it. This lets us respond to ctrl-c and ctrl-x, without having
+# to re-implement the copy and cut commands. (Important, since
+# run_command("copy") doesn't do anything.)
+class ClipboardListner(sublime_plugin.EventListener):
+ def on_query_context(self, view, key, *args):
+ if key != "clipboardcopy_fake":
+ return None
+ selected = view.sel()[0]
+ if selected.empty():
+ selected = view.line(selected)
+
+ text = view.substr(selected)
+
+ if not clipboard_history or clipboard_history[-1] != text:
+ clipboard_history.insert(0, text)
+
+ return None
Please sign in to comment.
Something went wrong with that request. Please try again.