[kupfer] core: Add 'Last Command' object



commit e1e3efaa42bd72adbf85addb1a3b3aeefaf8894a
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sat Jan 9 03:16:28 2010 +0100

    core: Add 'Last Command' object

 kupfer/plugin/core/__init__.py |    3 ++-
 kupfer/plugin/core/internal.py |   31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/plugin/core/__init__.py b/kupfer/plugin/core/__init__.py
index 7dd2149..fa3116a 100644
--- a/kupfer/plugin/core/__init__.py
+++ b/kupfer/plugin/core/__init__.py
@@ -34,11 +34,12 @@ def register_subplugin(module):
 		globals()[attr] += object_names
 		globals().update((sym, getattr(module, sym)) for sym in object_names)
 
-from kupfer.plugin.core import contents, selection, text
+from kupfer.plugin.core import contents, selection, text, internal
 
 register_subplugin(contents)
 register_subplugin(selection)
 register_subplugin(text)
+register_subplugin(internal)
 
 if _is_debug():
 	from kupfer.plugin.core import debug
diff --git a/kupfer/plugin/core/internal.py b/kupfer/plugin/core/internal.py
new file mode 100644
index 0000000..8b9ef73
--- /dev/null
+++ b/kupfer/plugin/core/internal.py
@@ -0,0 +1,31 @@
+
+from kupfer.objects import Source
+from kupfer.objects import RunnableLeaf
+from kupfer import commandexec
+
+__kupfer_sources__ = ("KupferInterals", )
+__author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
+
+class LastCommand (RunnableLeaf):
+	"Represented object is the command tuple to run"
+	qf_id = "lastcommand"
+	def __init__(self, obj):
+		RunnableLeaf.__init__(self, obj, _("Last Command"))
+
+	def run(self):
+		ctx = commandexec.DefaultActionExecutionContext()
+		obj, action, iobj = self.object
+		return ctx.run(obj, action, iobj, delegate=True)
+
+class KupferInterals (Source):
+	def __init__(self):
+		Source.__init__(self, _("Internal Kupfer Objects"))
+	def is_dynamic(self):
+		return True
+	def get_items(self):
+		ctx = commandexec.DefaultActionExecutionContext()
+		if ctx.last_command is None:
+			return
+		yield LastCommand(ctx.last_command)
+	def provides(self):
+		yield LastCommand



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