From 195dbd365aa8113511200c7359adacaa5339dce7 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Fri, 8 Feb 2019 21:02:41 -0500 Subject: [PATCH] check for recursive requires + Lua update --- sys/apis/injector.lua | 9 ++++- sys/apps/Lua.lua | 70 +++++++++++++++++++----------------- sys/apps/system/requires.lua | 2 +- 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/sys/apis/injector.lua b/sys/apis/injector.lua index 7f6fc37..2eb14dc 100644 --- a/sys/apis/injector.lua +++ b/sys/apis/injector.lua @@ -89,14 +89,21 @@ return function(env) end local function loadedSearcher(modname) - if env.package.loaded[modname] then + if env.package.loaded[modname] then return function() return env.package.loaded[modname] end end end + local sentinel = { } + local function pathSearcher(modname) + if env.package.loaded[modname] == sentinel then + error("loop or previous error loading module '" .. modname .. "'", 0) + end + env.package.loaded[modname] = sentinel + local fname = modname:gsub('%.', '/') for pattern in string.gmatch(env.package.path, "[^;]+") do diff --git a/sys/apps/Lua.lua b/sys/apps/Lua.lua index 4414475..dd50147 100644 --- a/sys/apps/Lua.lua +++ b/sys/apps/Lua.lua @@ -45,28 +45,33 @@ local page = UI.Page { [ 'control-space' ] = 'autocomplete', }, }, - grid = UI.ScrollingGrid { - y = 3, ey = -2, - columns = { - { heading = 'Key', key = 'name' }, - { heading = 'Value', key = 'value' }, + tabs = UI.Tabs { + y = 3, + [1] = UI.Tab { + tabTitle = 'Formatted', + grid = UI.ScrollingGrid { + columns = { + { heading = 'Key', key = 'name' }, + { heading = 'Value', key = 'value' }, + }, + sortColumn = 'name', + autospace = true, + }, + }, + [2] = UI.Tab { + tabTitle = 'Output', + output = UI.Embedded { + visible = true, + maxScroll = 1000, + backgroundColor = colors.black, + }, }, - sortColumn = 'name', - autospace = true, - }, - titleBar = UI.TitleBar { - title = 'Output', - y = -1, - event = 'show_output', - closeInd = '^' - }, - output = UI.Embedded { - y = -6, - visible = true, - backgroundColor = colors.gray, }, } +page.grid = page.tabs[1].grid +page.output = page.tabs[2].output + function page:setPrompt(value, focus) self.prompt:setValue(value) self.prompt.scroll = 0 @@ -84,9 +89,8 @@ function page:setPrompt(value, focus) end function page:enable() - self:setFocus(self.prompt) UI.Page.enable(self) - self.output:disable() + self:setFocus(self.prompt) end local function autocomplete(env, oLine, x) @@ -145,18 +149,11 @@ function page:eventHandler(event) self:draw() + elseif event.type == 'tab_select' then + self:setFocus(self.prompt) + elseif event.type == 'show_output' then - self.output:enable() - - self.titleBar.oy = -7 - self.titleBar.event = 'hide_output' - self.titleBar.closeInd = 'v' - self.titleBar:resize() - - self.grid.ey = -8 - self.grid:resize() - - self:draw() + self.tabs:selectTab(self.tabs[2]) elseif event.type == 'autocomplete' then local sz = #self.prompt.value @@ -186,8 +183,6 @@ function page:eventHandler(event) local s = tostring(self.prompt.value) if #s > 0 then - history:add(s) - history:back() self:executeStatement(s) else local t = { } @@ -331,9 +326,18 @@ end function page:executeStatement(statement) command = statement + history:add(statement) + history:back() + local s, m local oterm = term.redirect(self.output.win) self.output.win.scrollBottom() + local bg, fg = term.getBackgroundColor(), term.getTextColor() + term.setBackgroundColor(colors.black) + term.setTextColor(colors.yellow) + print('> ' .. tostring(statement)) + term.setBackgroundColor(bg) + term.setTextColor(fg) pcall(function() s, m = self:rawExecute(command) end) diff --git a/sys/apps/system/requires.lua b/sys/apps/system/requires.lua index 46eaed8..dfa7a02 100644 --- a/sys/apps/system/requires.lua +++ b/sys/apps/system/requires.lua @@ -13,7 +13,7 @@ local tab = UI.Tab { accelerators = { enter = 'update_path', }, - help = 'add a new path', + help = 'add a new path (reboot required)', }, grid = UI.Grid { y = 4, ey = -3,