summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2012-06-27 23:48:24 +0200
committerKevin Chabowski <kevin@kch42.de>2012-06-27 23:48:24 +0200
commit3978d3d574ad0f1483aa1b76e904eeb8b43d7eef (patch)
tree0f4e3abaa1f1433b9771f47b46f05d737be0d878
downloadClipboardStack-3978d3d574ad0f1483aa1b76e904eeb8b43d7eef.tar.gz
ClipboardStack-3978d3d574ad0f1483aa1b76e904eeb8b43d7eef.tar.bz2
ClipboardStack-3978d3d574ad0f1483aa1b76e904eeb8b43d7eef.zip
Initial Commit.
-rw-r--r--.gitignore1
-rw-r--r--COPYING13
-rw-r--r--ClipboardStack.py49
-rw-r--r--ClipboardStackCommands.sublime-commands6
-rw-r--r--README.markdown27
5 files changed, 96 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7e99e36
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.pyc \ No newline at end of file
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..8e63045
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,13 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar
+ 14 rue de Plaisance, 75014 Paris, France
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO. \ No newline at end of file
diff --git a/ClipboardStack.py b/ClipboardStack.py
new file mode 100644
index 0000000..7b37901
--- /dev/null
+++ b/ClipboardStack.py
@@ -0,0 +1,49 @@
+import sublime, sublime_plugin
+
+clipboard_stack = []
+
+class ClipboardStackPushCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ global clipboard_stack
+ clipcontent = sublime.get_clipboard()
+ clipboard_stack.append(clipcontent)
+ r = repr(clipcontent)[1:-1]
+ sublime.status_message("\'{content}{ellipsis}\' pushed to stack ({num} elements total).".format(content=r[:10], ellipsis="..." if len(r) > 10 else "", num=len(clipboard_stack)))
+
+class ClipboardStackPopCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ global clipboard_stack
+ if len(clipboard_stack) == 0:
+ sublime.status_message("Error: Clipboard stack is empty, can not pop.")
+ else:
+ el = clipboard_stack.pop()
+ r = repr(el)[1:-1]
+ sublime.set_clipboard(el)
+ sublime.status_message("Clipboard is now '{content}{ellipsis}', stack has now {num} elements.".format(content=r[:10], ellipsis="..." if len(r) > 10 else "", num=len(clipboard_stack)))
+
+class ClipboardStackSelectCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ global clipboard_stack
+ if len(clipboard_stack) == 0:
+ sublime.status_message("Stack is empty.")
+
+ self.window.show_quick_panel([ repr(x)[1:-1] for x in clipboard_stack[::-1] ], self.qp_response)
+
+ def qp_response(self, idx):
+ global clipboard_stack
+ if idx == -1:
+ return
+
+ addr = -(idx+1)
+
+ el = clipboard_stack[addr]
+ r = repr(el)[1:-1]
+ clipboard_stack = clipboard_stack[:addr] + clipboard_stack[addr+1:]
+ sublime.set_clipboard(el)
+ sublime.status_message("Clipboard is now '{content}{ellipsis}', stack has now {num} elements.".format(content=r[:10], ellipsis="..." if len(r) > 10 else "", num=len(clipboard_stack)))
+
+class ClipboardStackClearCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ global clipboard_stack
+ clipboard_stack = []
+ sublime.status_message("Clipboard stack is now empty.") \ No newline at end of file
diff --git a/ClipboardStackCommands.sublime-commands b/ClipboardStackCommands.sublime-commands
new file mode 100644
index 0000000..2460c5a
--- /dev/null
+++ b/ClipboardStackCommands.sublime-commands
@@ -0,0 +1,6 @@
+[
+ {"caption": "Clipboard Stack: Push clipboard content on stack", "command": "clipboard_stack_push"},
+ {"caption": "Clipboard Stack: Pop content from stack to clipboard", "command": "clipboard_stack_pop"},
+ {"caption": "Clipboard Stack: Select an element from the stack", "command": "clipboard_stack_select"},
+ {"caption": "Clipboard Stack: Clear Stack", "command": "clipboard_stack_clear"}
+] \ No newline at end of file
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..ccde68a
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1,27 @@
+ClipboardStack
+==============
+
+A Plugin for [Sublime Text 2](http://www.sublimetext.com) to organize your clipboard.
+
+Need more than one clipboard? Push your current clipboard on a stack and retrieve it later by pop it from the top of the stack or selecting an arbitrary stack element.
+
+Install
+-------
+
+Clone this repository into your *Packages* directory:
+
+ $ cd ~/.config/sublime-text-2/Packages/
+ $ git clone https://github.com/kch42/ClipboardStack.git
+
+Commands
+--------
+
+Here is a list of implemented commands:
+
+* `clipboard_stack_push` - Push clipboard content on stack
+* `clipboard_stack_pop` - Pop content from stack to clipboard
+* `clipboard_stack_select` - Select an element from the stack
+* `clipboard_stack_clear` - Clear Stack
+
+You can reach the commands from the **Command Palette** (`Ctrl+Shift+P`) and searching for `Clipboard Stack:`.
+