can now use named colors
This commit is contained in:
@@ -3,7 +3,6 @@ local Event = require('opus.event')
|
||||
local UI = require('opus.ui')
|
||||
local Util = require('opus.util')
|
||||
|
||||
local colors = _G.colors
|
||||
local peripheral = _G.peripheral
|
||||
|
||||
--[[ -- PeripheralsPage -- ]] --
|
||||
@@ -16,6 +15,20 @@ local peripheralsPage = UI.Page {
|
||||
},
|
||||
sortColumn = 'type',
|
||||
autospace = true,
|
||||
enable = function(self)
|
||||
local sides = peripheral.getNames()
|
||||
|
||||
Util.clear(self.values)
|
||||
for _,side in pairs(sides) do
|
||||
table.insert(self.values, {
|
||||
type = peripheral.getType(side),
|
||||
side = side
|
||||
})
|
||||
end
|
||||
self:update()
|
||||
self:adjustWidth()
|
||||
UI.Grid.enable(self)
|
||||
end,
|
||||
},
|
||||
statusBar = UI.StatusBar {
|
||||
values = 'Select peripheral',
|
||||
@@ -23,47 +36,30 @@ local peripheralsPage = UI.Page {
|
||||
accelerators = {
|
||||
[ 'control-q' ] = 'quit',
|
||||
},
|
||||
updatePeripherals = function(self)
|
||||
if UI:getCurrentPage() == self then
|
||||
self.grid:draw()
|
||||
self:sync()
|
||||
end
|
||||
end,
|
||||
eventHandler = function(self, event)
|
||||
if event.type == 'quit' then
|
||||
UI:quit()
|
||||
|
||||
elseif event.type == 'grid_select' then
|
||||
UI:setPage('methods', event.selected)
|
||||
|
||||
end
|
||||
return UI.Page.eventHandler(self, event)
|
||||
end,
|
||||
}
|
||||
|
||||
function peripheralsPage.grid:enable()
|
||||
local sides = peripheral.getNames()
|
||||
|
||||
Util.clear(self.values)
|
||||
for _,side in pairs(sides) do
|
||||
table.insert(self.values, {
|
||||
type = peripheral.getType(side),
|
||||
side = side
|
||||
})
|
||||
end
|
||||
self:update()
|
||||
self:adjustWidth()
|
||||
UI.Grid.enable(self)
|
||||
end
|
||||
|
||||
function peripheralsPage:updatePeripherals()
|
||||
if UI:getCurrentPage() == self then
|
||||
self.grid:draw()
|
||||
self:sync()
|
||||
end
|
||||
end
|
||||
|
||||
function peripheralsPage:eventHandler(event)
|
||||
if event.type == 'quit' then
|
||||
UI:quit()
|
||||
|
||||
elseif event.type == 'grid_select' then
|
||||
UI:setPage('methods', event.selected)
|
||||
|
||||
end
|
||||
return UI.Page.eventHandler(self, event)
|
||||
end
|
||||
|
||||
--[[ -- MethodsPage -- ]] --
|
||||
local methodsPage = UI.Page {
|
||||
backgroundColor = colors.black,
|
||||
doc = UI.TextArea {
|
||||
backgroundColor = colors.black,
|
||||
x = 2, y = 2, ex = -1, ey = -7,
|
||||
backgroundColor = 'black',
|
||||
ey = -7,
|
||||
marginLeft = 1, marginTop = 1,
|
||||
},
|
||||
grid = UI.ScrollingGrid {
|
||||
y = -6, ey = -2,
|
||||
|
||||
@@ -137,6 +137,7 @@ function page:scan()
|
||||
self.copyButton.inactive = not valid
|
||||
|
||||
self:draw()
|
||||
self.progress:clear()
|
||||
self.progress:centeredWrite(1, 'Analyzing Disks..')
|
||||
self.progress:sync()
|
||||
|
||||
@@ -166,6 +167,7 @@ function page:copy()
|
||||
throttle()
|
||||
end
|
||||
|
||||
self.progress:clear()
|
||||
self.progress:centeredWrite(1, 'Computing..')
|
||||
self.progress:sync()
|
||||
|
||||
@@ -210,6 +212,8 @@ function page:copy()
|
||||
self.progress:clear()
|
||||
rawCopy(sdrive.getMountPath(), tdrive.getMountPath())
|
||||
cleanup()
|
||||
|
||||
self.progress:clear()
|
||||
self.progress:centeredWrite(1, 'Copy Complete', colors.lime, colors.black)
|
||||
self.progress:sync()
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ page = UI.Page {
|
||||
columns = {
|
||||
{ heading = '', key = 'index', width = 2 },
|
||||
{ heading = '', key = 'count', width = 2 },
|
||||
{ heading = 'Inventory', key = 'key', width = UI.term.width - 7 },
|
||||
{ heading = 'Inventory', key = 'key' },
|
||||
},
|
||||
disableHeader = true,
|
||||
sortColumn = 'index',
|
||||
|
||||
@@ -4,7 +4,6 @@ local fuzzy = require('opus.fuzzy')
|
||||
local UI = require('opus.ui')
|
||||
local Util = require('opus.util')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
local fs = _G.fs
|
||||
local multishell = _ENV.multishell
|
||||
@@ -39,19 +38,25 @@ local undo = { chain = { }, redo = { } }
|
||||
|
||||
h = h - 1
|
||||
|
||||
local bgColor = 'gray'
|
||||
local color = {
|
||||
textColor = '0',
|
||||
keywordColor = '4',
|
||||
commentColor = 'd',
|
||||
stringColor = 'e',
|
||||
text = '0',
|
||||
keyword = '2',
|
||||
comment = 'd',
|
||||
string = '1',
|
||||
mark = '8',
|
||||
bg = '7',
|
||||
}
|
||||
|
||||
if not term.isColor() then
|
||||
bgColor = 'black'
|
||||
color = {
|
||||
textColor = '0',
|
||||
keywordColor = '8',
|
||||
commentColor = '8',
|
||||
stringColor = '8',
|
||||
text = '0',
|
||||
keyword = '8',
|
||||
comment = '8',
|
||||
string = '8',
|
||||
mark = '7',
|
||||
bg = 'f',
|
||||
}
|
||||
end
|
||||
|
||||
@@ -161,7 +166,7 @@ local page = UI.Page {
|
||||
} },
|
||||
},
|
||||
status = UI.Text {
|
||||
textColor = colors.gray,
|
||||
textColor = 'gray',
|
||||
x = -9, width = 9,
|
||||
align = 'right',
|
||||
},
|
||||
@@ -172,8 +177,6 @@ local page = UI.Page {
|
||||
lineNo = UI.TextEntry {
|
||||
x = 7, width = 7,
|
||||
limit = 5,
|
||||
backgroundFocusColor = colors.gray,
|
||||
backgroundColor = colors.gray,
|
||||
transform = 'number',
|
||||
accelerators = {
|
||||
[ 'enter' ] = 'accept',
|
||||
@@ -200,9 +203,6 @@ local page = UI.Page {
|
||||
search = UI.TextEntry {
|
||||
x = 7, ex = -3,
|
||||
limit = 512,
|
||||
markBackgroundColor = colors.lightGray,
|
||||
backgroundFocusColor = colors.gray,
|
||||
backgroundColor = colors.gray,
|
||||
accelerators = {
|
||||
[ 'enter' ] = 'accept',
|
||||
},
|
||||
@@ -233,9 +233,6 @@ local page = UI.Page {
|
||||
filename = UI.TextEntry {
|
||||
x = 7, ex = -3,
|
||||
limit = 512,
|
||||
markBackgroundColor = colors.lightGray,
|
||||
backgroundFocusColor = colors.gray,
|
||||
backgroundColor = colors.gray,
|
||||
accelerators = {
|
||||
[ 'enter' ] = 'accept',
|
||||
},
|
||||
@@ -263,7 +260,7 @@ local page = UI.Page {
|
||||
cancel = UI.Button {
|
||||
x = 16,
|
||||
text = 'Cancel',
|
||||
backgroundColor = UI.colors.primary,
|
||||
backgroundColor = 'primary',
|
||||
event = 'question_cancel',
|
||||
},
|
||||
show = function(self, action)
|
||||
@@ -355,7 +352,7 @@ local page = UI.Page {
|
||||
disableHeader = true,
|
||||
columns = {
|
||||
{ key = 'name' },
|
||||
{ key = 'dir', textColor = colors.lightGray },
|
||||
{ key = 'dir', textColor = 'lightGray' },
|
||||
},
|
||||
accelerators = {
|
||||
grid_select = 'accept',
|
||||
@@ -453,9 +450,9 @@ local page = UI.Page {
|
||||
cancel = UI.Button {
|
||||
y = -1, x = -9,
|
||||
text = 'Cancel',
|
||||
backgroundColor = colors.black,
|
||||
backgroundFocusColor = colors.black,
|
||||
textColor = colors.lightGray,
|
||||
backgroundColor = 'black',
|
||||
backgroundFocusColor = 'black',
|
||||
textColor = 'lightGray',
|
||||
event = 'slide_hide',
|
||||
},
|
||||
show = function(self, values)
|
||||
@@ -540,9 +537,9 @@ local page = UI.Page {
|
||||
cancel = UI.Button {
|
||||
y = -1, x = -9,
|
||||
text = 'Cancel',
|
||||
backgroundColor = colors.black,
|
||||
backgroundFocusColor = colors.black,
|
||||
textColor = colors.lightGray,
|
||||
backgroundColor = 'black',
|
||||
backgroundFocusColor = 'black',
|
||||
textColor = 'lightGray',
|
||||
event = 'slide_hide',
|
||||
},
|
||||
eventHandler = function(self, event)
|
||||
@@ -562,7 +559,7 @@ local page = UI.Page {
|
||||
},
|
||||
editor = UI.Window {
|
||||
y = 2,
|
||||
backgroundColor = colors.black,
|
||||
backgroundColor = bgColor,
|
||||
transitionHint = 'slideRight',
|
||||
cursorBlink = true,
|
||||
focus = function(self)
|
||||
@@ -687,15 +684,15 @@ local function writeHighlighted(sLine, ny, dy)
|
||||
while #sLine > 0 do
|
||||
sLine =
|
||||
-- tryWrite(sLine, "^[%\26]", '7' ) or
|
||||
tryWrite(sLine, "^%-%-%[%[.-%]%]", color.commentColor ) or
|
||||
tryWrite(sLine, "^%-%-.*", color.commentColor ) or
|
||||
tryWrite(sLine, "^\".-[^\\]\"", color.stringColor ) or
|
||||
tryWrite(sLine, "^\'.-[^\\]\'", color.stringColor ) or
|
||||
tryWrite(sLine, "^%[%[.-%]%]", color.stringColor ) or
|
||||
tryWrite(sLine, "^%-%-%[%[.-%]%]", color.comment ) or
|
||||
tryWrite(sLine, "^%-%-.*", color.comment ) or
|
||||
tryWrite(sLine, "^\".-[^\\]\"", color.string ) or
|
||||
tryWrite(sLine, "^\'.-[^\\]\'", color.string ) or
|
||||
tryWrite(sLine, "^%[%[.-%]%]", color.string ) or
|
||||
tryWrite(sLine, "^[%w_]+", function(match)
|
||||
return keywords[match] and color.keywordColor or color.textColor
|
||||
return keywords[match] and color.keyword or color.text
|
||||
end) or
|
||||
tryWrite(sLine, "^[^%w_]", color.textColor)
|
||||
tryWrite(sLine, "^[^%w_]", color.text)
|
||||
end
|
||||
|
||||
buffer.fg = _concat(buffer.fg) .. '7'
|
||||
@@ -704,11 +701,11 @@ local function writeHighlighted(sLine, ny, dy)
|
||||
if mark.active and ny >= mark.y and ny <= mark.ey then
|
||||
local sx = ny == mark.y and mark.x or 1
|
||||
local ex = ny == mark.ey and mark.ex or #buffer.text
|
||||
buffer.bg = _rep('f', sx - 1) ..
|
||||
_rep('7', ex - sx) ..
|
||||
_rep('f', #buffer.text - ex + 1)
|
||||
buffer.bg = _rep(color.bg, sx - 1) ..
|
||||
_rep(color.mark, ex - sx) ..
|
||||
_rep(color.bg, #buffer.text - ex + 1)
|
||||
else
|
||||
buffer.bg = _rep('f', #buffer.text)
|
||||
buffer.bg = _rep(color.bg, #buffer.text)
|
||||
end
|
||||
|
||||
page.editor:blit(1 - scrollX, dy, buffer.text, buffer.bg, buffer.fg)
|
||||
@@ -860,7 +857,6 @@ actions = {
|
||||
end
|
||||
actions.go_to(nx, ny)
|
||||
actions.mark_to(nx + #pattern, ny)
|
||||
actions.go_to(nx, ny)
|
||||
return
|
||||
end
|
||||
sx = 1
|
||||
|
||||
@@ -19,10 +19,14 @@ local Util = require('opus.util')
|
||||
local multishell = _ENV.multishell
|
||||
local os = _G.os
|
||||
|
||||
local recTerm, oldTerm, arg, showInput, skipLast, lastDelay, curInput = {}, Util.shallowCopy(multishell.term), {...}, false, false, 2, ""
|
||||
local colours = _G.colors
|
||||
|
||||
local args, options = Util.parse(...)
|
||||
|
||||
local oldTerm, showInput, skipLast, lastDelay, curInput = Util.shallowCopy(multishell.term), false, false, 2, ""
|
||||
local curBlink, oldBlink, tTerm, buffer, colourNum, xPos, yPos, oldXPos, oldYPos, tCol, bCol, xSize, ySize = false, false, {}, {}, {}, 1, 1, 1, 1, colours.white, colours.black, oldTerm.getSize()
|
||||
local greys, buttons = {["0"] = true, ["7"] = true, ["8"] = true, ["f"] = true}, {"l", "r", "m"}
|
||||
local charW, charH, chars, resp
|
||||
local charW, charH, chars
|
||||
|
||||
local calls = { }
|
||||
local curCalls = { delay = 0 }
|
||||
@@ -32,38 +36,44 @@ local callCount = 0
|
||||
local function showSyntax()
|
||||
print('Gif Recorder by Bomb Bloke\n')
|
||||
print('Syntax: recGif [-i] [-s] [-ld:<delay>] filename')
|
||||
print(' -i : show input')
|
||||
print(' -s : skip last')
|
||||
print(' -ld : last delay')
|
||||
print(' --showInput : show input')
|
||||
print(' --skipLast : skip last')
|
||||
print(' --lastDelay : last delay')
|
||||
print(' --noResize : dont resize')
|
||||
end
|
||||
|
||||
for i = #arg, 1, -1 do
|
||||
local curArg = arg[i]:lower()
|
||||
|
||||
if curArg == "-i" then
|
||||
showInput, ySize = true, ySize + 1
|
||||
table.remove(arg, i)
|
||||
elseif curArg == "-s" then
|
||||
skipLast = true
|
||||
table.remove(arg, i)
|
||||
elseif curArg:sub(1, 4) == "-ld:" then
|
||||
curArg = tonumber(curArg:sub(5))
|
||||
if curArg then lastDelay = curArg end
|
||||
table.remove(arg, i)
|
||||
elseif curArg == '-?' then
|
||||
showSyntax()
|
||||
return
|
||||
elseif i ~= #arg then
|
||||
showSyntax()
|
||||
printError('\nInvalid argument')
|
||||
return
|
||||
end
|
||||
if options.showInput then
|
||||
showInput, ySize = true, ySize + 1
|
||||
end
|
||||
|
||||
print('Gif Recorder by Bomb Bloke\n')
|
||||
print('Press control-p to stop recording')
|
||||
if options.skipLast then
|
||||
skipLast = true
|
||||
end
|
||||
|
||||
local filename = arg[#arg]
|
||||
if options.lastDelay then
|
||||
lastDelay = options.lastDelay
|
||||
end
|
||||
|
||||
if options.help then
|
||||
showSyntax()
|
||||
return
|
||||
end
|
||||
|
||||
if options.daemon then
|
||||
device.keyboard.addHotkey('control-P', function()
|
||||
multishell.openTab({
|
||||
path = 'sys/apps/shell.lua',
|
||||
args = { arg[0], '--noResize', '--rawOutput', 'recorder.gif' },
|
||||
})
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
print('Gif Recorder by Bomb Bloke')
|
||||
print(version)
|
||||
print('\nPress control-p to stop recording')
|
||||
|
||||
local filename = args[1]
|
||||
if not filename then
|
||||
print('Enter file name:')
|
||||
filename = read()
|
||||
@@ -131,7 +141,7 @@ end
|
||||
|
||||
-- Build a terminal that records stuff:
|
||||
|
||||
recTerm = multishell.term
|
||||
local recTerm = multishell.term
|
||||
|
||||
for key, func in pairs(oldTerm) do
|
||||
if type(func) == 'function' then
|
||||
@@ -149,21 +159,16 @@ for key, func in pairs(oldTerm) do
|
||||
end
|
||||
|
||||
local tabId = multishell.getCurrent()
|
||||
multishell.hideTab(tabId)
|
||||
|
||||
if not options.noResize then
|
||||
os.queueEvent('term_resize')
|
||||
end
|
||||
|
||||
_G.device.keyboard.addHotkey('control-p', function()
|
||||
os.queueEvent('recorder_stop')
|
||||
end)
|
||||
|
||||
local tabs = multishell.getTabs()
|
||||
for _,tab in pairs(tabs) do
|
||||
if tab.isOverview then
|
||||
multishell.hideTab(tabId)
|
||||
multishell.setFocus(tab.tabId)
|
||||
os.queueEvent('term_resize')
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local curTime = os.clock() - 1
|
||||
|
||||
while true do
|
||||
@@ -202,8 +207,12 @@ if skipLast and #calls > 1 then calls[#calls] = nil end
|
||||
|
||||
calls[#calls].delay = lastDelay
|
||||
|
||||
if options.rawOutput then
|
||||
Util.writeTable('tmp/raw.txt', calls)
|
||||
return
|
||||
end
|
||||
|
||||
print(string.format("Encoding %d frames...", #calls))
|
||||
--Util.writeTable('tmp/raw.txt', calls)
|
||||
|
||||
-- Perform a quick re-parse of the recorded data (adding frames for when the cursor blinks):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user