summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dalos-textbuffer.lua32
-rw-r--r--dalos.lua1
2 files changed, 33 insertions, 0 deletions
diff --git a/dalos-textbuffer.lua b/dalos-textbuffer.lua
new file mode 100644
index 0000000..b1e3c03
--- /dev/null
+++ b/dalos-textbuffer.lua
@@ -0,0 +1,32 @@
+dalosp.textbuffer = {
+ get_settings = function (self)
+ return { text = extra.text }
+ end,
+
+ activate = function (self)
+ local text = self.extra.text or ""
+ text = iup.GetText(self.name, text)
+ if text then
+ self.extra.text = text
+ local b = Buffer(true)
+ b:write(text)
+ self.set_houtput(b)
+ end
+ end,
+
+ create = function (d, tab, settings)
+ tab.ninputs = 0
+ tab.noutputs = 1
+ tab.otype = dalos.objtype.HANDLE
+ tab.activate = dalosp.textbuffer.activate
+ tab.default_name = "Text Buffer"
+ tab.get_settings = dalosp.textbuffer.get_settings
+ local extra = { }
+ if settings then extra.text = settings.text end
+
+ local obj = dalos.object(d, tab, extra)
+ end,
+}
+
+dalos.textbuffer = dalosp.textbuffer.create
+dalos:register_obj("Text Buffer", dalos.textbuffer)
diff --git a/dalos.lua b/dalos.lua
index c2279db..5d13283 100644
--- a/dalos.lua
+++ b/dalos.lua
@@ -679,6 +679,7 @@ load "dalos-luahandle.lua"
load "dalos-hexview.lua"
load "dalos-binaryops.lua"
load "dalos-limiter.lua"
+load "dalos-textbuffer.lua"
----------------