From 65cf759747c159fd5aa26189e3614a7a3957c761 Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Sun, 20 Jul 2014 11:00:00 +0930 Subject: [PATCH] Bug Fixes. 1.2.3 release. --- Programs/App Store.program/startup | 4 +- Programs/Ink.program/startup | 88 +++++++++++++++++++++++- System/.hash | 2 +- System/API/Bedrock.lua | 2 +- System/API/Environment.lua | 2 +- System/API/Settings.lua | 5 ++ System/Objects/Button.lua | 4 +- System/Objects/FileView.lua | 17 ++++- System/Objects/Overlay.lua | 4 ++ System/Objects/ProgramView.lua | 51 ++++---------- System/Programs/Files.program/startup | 4 +- System/Programs/Settings.program/startup | 4 +- System/main.lua | 11 ++- startup | 4 +- 14 files changed, 143 insertions(+), 59 deletions(-) diff --git a/Programs/App Store.program/startup b/Programs/App Store.program/startup index fb61ea3..b065196 100755 --- a/Programs/App Store.program/startup +++ b/Programs/App Store.program/startup @@ -201,7 +201,7 @@ end) end Drawing.DrawBlankArea(e.X+1,e.Y+1,e.Width,e.Height,colours.grey) Drawing.DrawBlankArea(e.X,e.Y,e.Width,e.Height,colours.white) -Drawing.DrawCharacters(e.X+8,e.Y+1,e.Title,colours.black,colours.white) +Drawing.DrawCharacters(e.X+8,e.Y+1,tostring(e.Title),colours.black,colours.white) if e.Type~=2 then Drawing.DrawCharacters(e.X+8,e.Y+2,"by "..e.Author,colours.grey,colours.white) Drawing.DrawCharacters(e.Width-8,e.Y+t-1," Install ",colours.white,colours.green) @@ -284,7 +284,7 @@ elseif e.Type==2 then t=1 end for o,a in ipairs(e.Description)do -Drawing.DrawCharacters(e.X+8,e.Y+t+o,a,colours.lightGrey,colours.white) +Drawing.DrawCharacters(e.X+8,e.Y+t+o,tostring(a),colours.lightGrey,colours.white) end end, Initialise=function(o,i,r,n,c,l,u,d,s,h,a,t) diff --git a/Programs/Ink.program/startup b/Programs/Ink.program/startup index 5cc0114..b4638e4 100755 --- a/Programs/Ink.program/startup +++ b/Programs/Ink.program/startup @@ -58,7 +58,93 @@ end local s=function(e) return e:gsub('['..string.char(14)..'-'..string.char(29)..']','') end -OneOS.LoadAPI('System/API/Printer.lua') +Printer = { +Name = nil, +PeripheralType = 'printer', +paperLevel = function(self) +return Peripheral.CallNamed(self.Name, 'getPaperLevel') +end, +newPage = function(self) +return Peripheral.CallNamed(self.Name, 'newPage') +end, +endPage = function(self) +return Peripheral.CallNamed(self.Name, 'endPage') +end, +pageWrite = function(self, text) +return Peripheral.CallNamed(self.Name, 'write', text) +end, +setPageTitle = function(self, title) +return Peripheral.CallNamed(self.Name, 'setPageTitle', title) +end, +inkLevel = function(self) +return Peripheral.CallNamed(self.Name, 'getInkLevel') +end, +getCursorPos = function(self) +return Peripheral.CallNamed(self.Name, 'getCursorPos') +end, +setCursorPos = function(self, x, y) +return Peripheral.CallNamed(self.Name, 'setCursorPos', x, y) +end, +pageSize = function(self) +return Peripheral.CallNamed(self.Name, 'getPageSize') +end, +Present = function() +if Peripheral.GetPeripheral(Printer.PeripheralType) == nil then +return false +else +return true +end +end, +PrintLines = function(self, lines, title, copies) +local pages = {} +local pageLines = {} +for i, line in ipairs(lines) do +table.insert(pageLines, TextLine:Initialise(s(line))) +if i % 25 == 0 then +table.insert(pages, pageLines) +pageLines = {} +end +end +if #pageLines ~= 0 then +table.insert(pages, pageLines) +end +return self:PrintPages(pages, title, copies) +end, +PrintPages = function(self, pages, title, copies) +copies = copies or 1 +for c = 1, copies do +for p, page in ipairs(pages) do +if self:paperLevel() < #pages * copies then +return 'Add more paper to the printer' +end +if self:inkLevel() < #pages * copies then +return 'Add more ink to the printer' +end +self:newPage() +for i, line in ipairs(page) do +self:setCursorPos(1, i) +self:pageWrite(s(line.Text)) +end +if title then +self:setPageTitle(title) +end +self:endPage() +end +end +end, +Initialise = function(self, name) +if Printer.Present() then --fix +local new = {} -- the new instance +setmetatable( new, {__index = self} ) +if name and Peripheral.PresentNamed(name) then +new.Name = name +else +new.Name = Peripheral.GetPeripheral(Printer.PeripheralType).Side +end +return new +end +end +} Clipboard=OneOS.Clipboard OneOS.LoadAPI('System/API/Drawing.lua') Current={ diff --git a/System/.hash b/System/.hash index 9c13b90..6a3a1a6 100755 --- a/System/.hash +++ b/System/.hash @@ -1 +1 @@ -1.16075615E9 \ No newline at end of file +1.033768345E9 \ No newline at end of file diff --git a/System/API/Bedrock.lua b/System/API/Bedrock.lua index fb402a8..8fb4b66 100755 --- a/System/API/Bedrock.lua +++ b/System/API/Bedrock.lua @@ -424,6 +424,7 @@ end function ForceDraw(self) if not self.DrawTimer or self.DrawTimerExpiry <= os.clock() then + self.DrawTimer = true self.DrawTimer = self:StartTimer(function() self.DrawTimer = nil self:Draw() @@ -600,7 +601,6 @@ function StartRepeatingTimer(self, func, interval) return end local timer = os.startTimer(int) - self.Timers[timer] = {func, true, interval} return timer end diff --git a/System/API/Environment.lua b/System/API/Environment.lua index 4a3c856..3a28672 100755 --- a/System/API/Environment.lua +++ b/System/API/Environment.lua @@ -270,7 +270,7 @@ end FS = function(env, program, path) local function doIndex() - _G.indexTimer = os.startTimer(Indexer.FSIndexRate) + Current.Bedrock:StartTimer(Indexer.DoIndex, 4) end local relPath = Helpers.RemoveFileName(path) local list = {} diff --git a/System/API/Settings.lua b/System/API/Settings.lua index 048e57e..8451a3d 100755 --- a/System/API/Settings.lua +++ b/System/API/Settings.lua @@ -25,6 +25,11 @@ Defaults = { Label = 'Startup Program', Default = nil, }, + DoubleClick = { + Type = 'Bool', + Label = 'Double Click', + Default = false, + }, Monitor = { Type = 'Side', Label = 'Monitor Side', diff --git a/System/Objects/Button.lua b/System/Objects/Button.lua index 4da36e6..907123d 100755 --- a/System/Objects/Button.lua +++ b/System/Objects/Button.lua @@ -40,8 +40,8 @@ OnDraw = function(self, x, y) end Drawing.DrawCharacters(x + _x, y, self.Text, txt, bg) - if self.Momentary and self.Toggle ~= false then - self.Bedrock:StartTimer(function()self.Toggle = false end,0.15) + if self.Momentary and self.Toggle then + local t = self.Bedrock:StartTimer(function()self.Toggle = false end,0.15) end end diff --git a/System/Objects/FileView.lua b/System/Objects/FileView.lua index 47a4859..e72692a 100755 --- a/System/Objects/FileView.lua +++ b/System/Objects/FileView.lua @@ -4,6 +4,7 @@ BackgroundColour = colours.transparent Path = '' Width = 10 Height = 4 +ClickTime = nil OnLoad = function(self) self.Width = 10 @@ -38,7 +39,21 @@ OnLoad = function(self) Name = 'ShortcutLabel' }) end - local click = function(obj, event, side, x, y) self:OnClick(event, side, x, y, obj) end + local click = function(obj, event, side, x, y) + --local settings = OneOS.Settings or Settings + local setting = false + if OneOS then + setting = OneOS.Settings:GetValues()['DoubleClick'] + else + setting = Settings:GetValues()['DoubleClick'] + end + --s:GetValues()['DoubleClick'] + if side == 1 and setting and (not self.ClickTime or os.clock() - self.ClickTime <= 0.5) then + self.ClickTime = os.clock() + else + self:OnClick(event, side, x, y, obj) + end + end label.OnClick = click image.OnClick = click diff --git a/System/Objects/Overlay.lua b/System/Objects/Overlay.lua index 1190e10..babc929 100755 --- a/System/Objects/Overlay.lua +++ b/System/Objects/Overlay.lua @@ -48,14 +48,18 @@ UpdateButtons = function(self) if Current.Program then if Current.Program.Environment.OneOS.ToolBarColor ~= colours.white then self.BackgroundColour = Current.Program.Environment.OneOS.ToolBarColor + Current.Program.Environment.OneOS.ToolBarColour = Current.Program.Environment.OneOS.ToolBarColor else self.BackgroundColour = Current.Program.Environment.OneOS.ToolBarColour + Current.Program.Environment.OneOS.ToolBarColor = Current.Program.Environment.OneOS.ToolBarColour end if Current.Program.Environment.OneOS.ToolBarTextColor ~= colours.black then self.TextColour = Current.Program.Environment.OneOS.ToolBarTextColor + Current.Program.Environment.OneOS.ToolBarTextColour = Current.Program.Environment.OneOS.ToolBarTextColor else self.TextColour = Current.Program.Environment.OneOS.ToolBarTextColour + Current.Program.Environment.OneOS.ToolBarTextColor = Current.Program.Environment.OneOS.ToolBarTextColour end else self.BackgroundColour = colours.white diff --git a/System/Objects/ProgramView.lua b/System/Objects/ProgramView.lua index fc1c970..64d8a57 100755 --- a/System/Objects/ProgramView.lua +++ b/System/Objects/ProgramView.lua @@ -118,7 +118,6 @@ OnDraw = function(self, x, y) if Current.Overlay and self.CachedProgram and self.CachedProgram.Environment and (Current.Program.Environment.OneOS.ToolBarColor ~= Current.Overlay.BackgroundColour or Current.Program.Environment.OneOS.ToolBarColour ~= Current.Overlay.BackgroundColour or Current.Program.Environment.OneOS.ToolBarTextColor ~= Current.Overlay.TextColour or Current.Program.Environment.OneOS.ToolBarTextColour ~= Current.Overlay.TextColour) then UpdateOverlay() end - self:DrawProgram(Current.Program, x, y) self.CachedProgram = Current.Program self.CachedIndex = currentIndex @@ -139,15 +138,22 @@ OnDraw = function(self, x, y) end DrawAnimation = function(self) - self.Animation.Function(self.Animation.Count) - self.Animation.Count = self.Animation.Count - 1 - if self.Animation.Count <= 0 then + if Settings:GetValues()['UseAnimations'] then + self.Animation.Function(self.Animation.Count) + self.Animation.Count = self.Animation.Count - 1 + if self.Animation.Count <= 0 then + self.Animation = nil + self.CachedProgram = Current.Program + self.CachedIndex = currentIndex + end + self:ForceDraw() + else self.Animation = nil self.CachedProgram = Current.Program self.CachedIndex = currentIndex + self:ForceDraw() + self.Bedrock:Draw() end - self:ForceDraw() - --self.Bedrock:Draw() end DrawProgram = function(self, program, x, y) @@ -173,35 +179,4 @@ OnKeyChar = function(self, event, keychar) end OnDrag = OnClick -OnScroll = OnClick - - ---[[ -for i, program in ipairs(Current.Programs) do - if program == self then - table.remove(Current.Programs, i) - - if Current.Programs[i] then - --Current.Program = Current.Programs[i] - Animation.SwipeProgram(self, Current.Programs[i], 1) - elseif Current.Programs[i-1] then - --Current.Program = Current.Programs[i-1] - Animation.SwipeProgram(self, Current.Programs[i-1], -1) - end - break - end - end - - if Desktop then - Desktop:RefreshFiles() - UpdateOverlay() - if Current.Program then - Drawing.Clear(colours.black) - Drawing.DrawBuffer() - os.queueEvent('oneos_draw') - else - if Desktop then - --Desktop:Draw() - end - end -]]-- \ No newline at end of file +OnScroll = OnClick \ No newline at end of file diff --git a/System/Programs/Files.program/startup b/System/Programs/Files.program/startup index b58ee10..38bf829 100755 --- a/System/Programs/Files.program/startup +++ b/System/Programs/Files.program/startup @@ -170,11 +170,11 @@ function NoFileClick(self, event, side, x, y) end program:GetObject('NewFolderMenuItem').OnClick = function(_item) - OneOS.Helpers.NewFolder(OneOS.Helpers.ParentFolder(item.Path)..'/', RefreshFiles, program) + OneOS.Helpers.NewFolder(Current.Path, RefreshFiles, program) end program:GetObject('NewFileMenuItem').OnClick = function(_item) - OneOS.Helpers.NewFile(OneOS.Helpers.ParentFolder(item.Path)..'/', RefreshFiles, program) + OneOS.Helpers.NewFile(Current.Path, RefreshFiles, program) end end diff --git a/System/Programs/Settings.program/startup b/System/Programs/Settings.program/startup index 783df44..01e1848 100755 --- a/System/Programs/Settings.program/startup +++ b/System/Programs/Settings.program/startup @@ -91,8 +91,8 @@ program:Run(function() Y = startY, Width = 23, Text = value, - OnClick = function(self) - OneOS.Settings:SetValue(k, self.TextInput.Value) + OnChange = function(self) + OneOS.Settings:SetValue(k, settings[k].Control.Text) end }) elseif v.Type == 'Program' then diff --git a/System/main.lua b/System/main.lua index cb542cd..0dbc07d 100755 --- a/System/main.lua +++ b/System/main.lua @@ -63,11 +63,11 @@ bedrock.EventHandler = function(self) end local event = { os.pullEventRaw() } - -- local s = 'Event: ' - -- for i, v in ipairs(event) do - -- s = s..tostring(v)..', ' - -- end - -- Log.i(s) + local s = 'Event: ' + for i, v in ipairs(event) do + s = s..tostring(v)..', ' + end + Log.i(s) if self.EventHandlers[event[1]] then for i, e in ipairs(self.EventHandlers[event[1]]) do @@ -116,7 +116,6 @@ function AnimateShutdown(restart, animate) Drawing.Clear(colours.white) Drawing.DrawBuffer() sleep(0) - Log.i('out') local x = 0 local y = 0 local w = 0 diff --git a/startup b/startup index e9f1297..d724c02 100755 --- a/startup +++ b/startup @@ -399,7 +399,7 @@ local function addFolder(path, input) local _path = path .. '/' .. file if fs.isDir(_path) then input = addFolder(_path, input) - elseif file:sub(1,1) ~= '.' then + elseif file:sub(1,1) ~= '.' and not file:find('.log') then input = addFile(_path, input) end end @@ -674,7 +674,7 @@ elseif Start() then local detailString = textutils.serialize(detail) ..'\n\n' - local h = fs.open('/System/OneOS.log') + local h = fs.open('/System/OneOS.log', 'r') if h then detailString = detailString .. 'Log:\n'..h.readAll() h.close()