From 6ff93ed7d8ba6aa3bf3cc4a2987c363d686641e9 Mon Sep 17 00:00:00 2001 From: gamemanj Date: Thu, 27 Oct 2016 21:20:27 +0100 Subject: [PATCH] Finished some missing bits of Omniterm One-line history (for spam) and a basic root Lua terminal, since that's the thing everybody uses for testing components. --- apps/omniterm.lua | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/omniterm.lua b/apps/omniterm.lua index bd0eb0a..cd25ec5 100644 --- a/apps/omniterm.lua +++ b/apps/omniterm.lua @@ -16,15 +16,17 @@ if not consoleBuffer then "rpc: |RPC", "tun: |Linked Card", "net::|Net.Card", - --Allows talking with everybody on a network. + --Broadcast (hopefully obvious?) "net: |Net.Card-BC", --Allows talking with MineOS Chat... in theory... "moschat: |MineOS Chat", "componentlist|Components.", + "lua |Lua console", "Exit with Ctrl-W." } end +local prevLine = "" local lineBuffer = "" local function incomingSubLine(txt) for i = 1, #consoleBuffer - 1 do @@ -170,7 +172,7 @@ local drivers = { end, -- componentlist -- Used to list components - -- Useful because OpenComputers stupidly cuts off text, + -- Useful because OpenComputers cuts off text, -- which is really bad when you need the *whole* ID... -- >.< like when doing anything involving networking. componentlist = function (id) @@ -183,6 +185,18 @@ local drivers = { end end end + end, + lua = function (id) + local root = A.request("root") + incomingLine("Lua Console") + outgoingLine = function (txt) + local r, re = pcall(function () + local f, fe = load(txt, nil, root) + if not f then error(fe) end + return f() + end) + incomingLine(tostring(re)) + end end } local hasDriver = false @@ -247,8 +261,13 @@ function app.key(ka, kc, down) return false end if down then + if kc == 200 then + lineBuffer = prevLine + return true + end if ka ~= 0 then if ka == 13 then + prevLine = lineBuffer typedLine(lineBuffer) lineBuffer = "" return true