From 0a828fecc558394e82e2e0948c098f733de78736 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Wed, 13 Nov 2019 14:38:24 -0700 Subject: [PATCH] oops --- sys/apps/shell.lua | 5 ++++- sys/modules/opus/entry.lua | 2 +- sys/modules/opus/ui/components/TextEntry.lua | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/apps/shell.lua b/sys/apps/shell.lua index d64f046..6124a3d 100644 --- a/sys/apps/shell.lua +++ b/sys/apps/shell.lua @@ -586,6 +586,7 @@ local function shellRead(history) end local _,cy = term.getCursorPos() term.setCursorPos(3, cy) + entry.value = entry.value or '' local filler = #entry.value < lastLen and string.rep(' ', lastLen - #entry.value) or '' @@ -635,6 +636,7 @@ local function shellRead(history) redraw() elseif ie.code == 'tab' then + entry.value = entry.value or '' if entry.pos == #entry.value then local cline = autocomplete(entry.value) if cline then @@ -650,6 +652,7 @@ local function shellRead(history) else entry:process(ie) + entry.value = entry.value or '' if entry.textChanged then redraw() elseif entry.posChanged then @@ -666,7 +669,7 @@ local function shellRead(history) print() term.setCursorBlink( false ) - return entry.value + return entry.value or '' end local history = History.load('usr/.shell_history', 25) diff --git a/sys/modules/opus/entry.lua b/sys/modules/opus/entry.lua index 46e4eeb..7deb36f 100644 --- a/sys/modules/opus/entry.lua +++ b/sys/modules/opus/entry.lua @@ -393,7 +393,7 @@ function Entry:process(ie) if not self.value or #_val(self.value) == 0 then self.value = nil end -_syslog(tostring(line) .. ' ' .. tostring(self.value) .. ' ' .. tostring(self.textChanged)) + self.textChanged = self.textChanged or self.value ~= line self.posChanged = pos ~= self.pos self:updateScroll() diff --git a/sys/modules/opus/ui/components/TextEntry.lua b/sys/modules/opus/ui/components/TextEntry.lua index 1a3f604..75665a6 100644 --- a/sys/modules/opus/ui/components/TextEntry.lua +++ b/sys/modules/opus/ui/components/TextEntry.lua @@ -41,15 +41,15 @@ function UI.TextEntry:layout() end function UI.TextEntry:setValue(value) - self.value = value --or '' + self.value = value self.entry:unmark() - self.entry.value = value --tostring(value or '') + self.entry.value = value self.entry:updateScroll() end function UI.TextEntry:setPosition(pos) self.entry.pos = pos - self.entry.value = self.value --tostring(self.value or '') -- WHY HERE ? + self.entry.value = self.value -- WHY HERE ? self.entry:updateScroll() end @@ -117,7 +117,6 @@ function UI.TextEntry:eventHandler(event) self.entry.value = text if event.ie and self.entry:process(event.ie) then if self.entry.textChanged then ---_syslog(tostring(self.entry.value) .. ' ' .. tostring(self.value)) self.value = self.entry.value self:draw() self:emit({ type = 'text_change', text = self.value, element = self })