mirror of
https://github.com/kepler155c/opus
synced 2025-01-25 22:56:53 +00:00
better colors
This commit is contained in:
parent
2af6f098c8
commit
9cb7180f10
@ -1366,6 +1366,37 @@ function UI.StringBuffer:clear()
|
|||||||
self.buffer = { }
|
self.buffer = { }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- alternate - better ?
|
||||||
|
local SB = { }
|
||||||
|
function SB:new(width)
|
||||||
|
return setmetatable({
|
||||||
|
width = width,
|
||||||
|
buf = string.rep(' ', width)
|
||||||
|
}, { __index = SB })
|
||||||
|
end
|
||||||
|
function SB:insert(x, str, width)
|
||||||
|
if x < 1 then
|
||||||
|
x = self.width + x + 1
|
||||||
|
end
|
||||||
|
width = width or #str
|
||||||
|
if x + width - 1 > self.width then
|
||||||
|
width = self.width - x
|
||||||
|
end
|
||||||
|
if width > 0 then
|
||||||
|
self.buf = self.buf:sub(1, x - 1) .. str:sub(1, width) .. self.buf:sub(x + width)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function SB:fill(x, ch, width)
|
||||||
|
width = width or self.width - x + 1
|
||||||
|
self:insert(x, string.rep(ch, width))
|
||||||
|
end
|
||||||
|
function SB:center(str)
|
||||||
|
self:insert(math.max(1, math.ceil((self.width - #str + 1) / 2)), str)
|
||||||
|
end
|
||||||
|
function SB:get()
|
||||||
|
return self.buf
|
||||||
|
end
|
||||||
|
|
||||||
--[[-- Page (focus manager) --]]--
|
--[[-- Page (focus manager) --]]--
|
||||||
UI.Page = class(UI.Window)
|
UI.Page = class(UI.Window)
|
||||||
UI.Page.defaults = {
|
UI.Page.defaults = {
|
||||||
@ -1377,7 +1408,7 @@ UI.Page.defaults = {
|
|||||||
shiftTab = 'focus_prev',
|
shiftTab = 'focus_prev',
|
||||||
up = 'focus_prev',
|
up = 'focus_prev',
|
||||||
},
|
},
|
||||||
backgroundColor = colors.black,
|
backgroundColor = colors.cyan,
|
||||||
textColor = colors.white,
|
textColor = colors.white,
|
||||||
}
|
}
|
||||||
function UI.Page:init(args)
|
function UI.Page:init(args)
|
||||||
@ -2123,8 +2154,11 @@ UI.TitleBar = class(UI.Window)
|
|||||||
UI.TitleBar.defaults = {
|
UI.TitleBar.defaults = {
|
||||||
UIElement = 'TitleBar',
|
UIElement = 'TitleBar',
|
||||||
height = 1,
|
height = 1,
|
||||||
backgroundColor = colors.brown,
|
textColor = colors.lightGray,
|
||||||
title = ''
|
backgroundColor = colors.gray,
|
||||||
|
title = '',
|
||||||
|
frameChar = '-',
|
||||||
|
closeInd = '*',
|
||||||
}
|
}
|
||||||
function UI.TitleBar:init(args)
|
function UI.TitleBar:init(args)
|
||||||
local defaults = UI:getDefaults(UI.TitleBar, args)
|
local defaults = UI:getDefaults(UI.TitleBar, args)
|
||||||
@ -2132,13 +2166,13 @@ function UI.TitleBar:init(args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function UI.TitleBar:draw()
|
function UI.TitleBar:draw()
|
||||||
self:clear()
|
local sb = SB:new(self.width)
|
||||||
local centered = math.ceil((self.width - #self.title) / 2)
|
sb:fill(2, self.frameChar, sb.width - 3)
|
||||||
self:write(1 + centered, 1, self.title, self.backgroundColor)
|
sb:center(string.format(' %s ', self.title))
|
||||||
if self.previousPage or self.event then
|
if self.previousPage or self.event then
|
||||||
self:write(self.width, 1, '*', self.backgroundColor, colors.black)
|
sb:insert(-1, self.closeInd)
|
||||||
end
|
end
|
||||||
--self:write(self.width-1, 1, '?', self.backgroundColor)
|
self:write(1, 1, sb:get())
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.TitleBar:eventHandler(event)
|
function UI.TitleBar:eventHandler(event)
|
||||||
@ -2186,6 +2220,7 @@ function UI.MenuBar:init(args)
|
|||||||
x = x,
|
x = x,
|
||||||
width = #button.text + self.spacing,
|
width = #button.text + self.spacing,
|
||||||
backgroundColor = self.backgroundColor,
|
backgroundColor = self.backgroundColor,
|
||||||
|
backgroundFocusColor = colors.gray,
|
||||||
textColor = self.textColor,
|
textColor = self.textColor,
|
||||||
centered = false,
|
centered = false,
|
||||||
}
|
}
|
||||||
@ -2712,7 +2747,8 @@ end
|
|||||||
UI.StatusBar = class(UI.GridLayout)
|
UI.StatusBar = class(UI.GridLayout)
|
||||||
UI.StatusBar.defaults = {
|
UI.StatusBar.defaults = {
|
||||||
UIElement = 'StatusBar',
|
UIElement = 'StatusBar',
|
||||||
backgroundColor = colors.gray,
|
backgroundColor = colors.lightGray,
|
||||||
|
textColor = colors.gray,
|
||||||
columns = {
|
columns = {
|
||||||
{ '', 'status', 10 },
|
{ '', 'status', 10 },
|
||||||
},
|
},
|
||||||
@ -2848,7 +2884,7 @@ UI.Button.defaults = {
|
|||||||
UIElement = 'Button',
|
UIElement = 'Button',
|
||||||
text = 'button',
|
text = 'button',
|
||||||
backgroundColor = colors.gray,
|
backgroundColor = colors.gray,
|
||||||
backgroundFocusColor = colors.green,
|
backgroundFocusColor = colors.lightGray,
|
||||||
textFocusColor = colors.black,
|
textFocusColor = colors.black,
|
||||||
centered = true,
|
centered = true,
|
||||||
height = 1,
|
height = 1,
|
||||||
@ -2912,8 +2948,9 @@ UI.TextEntry.defaults = {
|
|||||||
value = '',
|
value = '',
|
||||||
shadowText = '',
|
shadowText = '',
|
||||||
focused = false,
|
focused = false,
|
||||||
backgroundColor = colors.lightGray,
|
textColor = colors.white,
|
||||||
backgroundFocusColor = colors.lightGray,
|
backgroundColor = colors.black, -- colors.lightGray,
|
||||||
|
backgroundFocusColor = colors.black, --lightGray,
|
||||||
height = 1,
|
height = 1,
|
||||||
limit = 6,
|
limit = 6,
|
||||||
pos = 0,
|
pos = 0,
|
||||||
@ -3093,8 +3130,8 @@ UI.Chooser.defaults = {
|
|||||||
UIElement = 'Chooser',
|
UIElement = 'Chooser',
|
||||||
choices = { },
|
choices = { },
|
||||||
nochoice = 'Select',
|
nochoice = 'Select',
|
||||||
backgroundColor = colors.lightGray,
|
--backgroundColor = colors.lightGray,
|
||||||
backgroundFocusColor = colors.green,
|
backgroundFocusColor = colors.lightGray,
|
||||||
height = 1,
|
height = 1,
|
||||||
}
|
}
|
||||||
function UI.Chooser:init(args)
|
function UI.Chooser:init(args)
|
||||||
@ -3320,6 +3357,7 @@ UI.Dialog.defaults = {
|
|||||||
y = 4,
|
y = 4,
|
||||||
z = 2,
|
z = 2,
|
||||||
height = 7,
|
height = 7,
|
||||||
|
textColor = colors.black,
|
||||||
backgroundColor = colors.white,
|
backgroundColor = colors.white,
|
||||||
}
|
}
|
||||||
function UI.Dialog:init(args)
|
function UI.Dialog:init(args)
|
||||||
|
@ -24,7 +24,6 @@ return function(args)
|
|||||||
-- rey = args.rey or -3,
|
-- rey = args.rey or -3,
|
||||||
height = args.height,
|
height = args.height,
|
||||||
width = args.width,
|
width = args.width,
|
||||||
backgroundColor = colors.brown,
|
|
||||||
title = 'Select file',
|
title = 'Select file',
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
x = 2,
|
x = 2,
|
||||||
|
@ -27,7 +27,6 @@ local page = UI.Page({
|
|||||||
prompt = UI.TextEntry({
|
prompt = UI.TextEntry({
|
||||||
y = 2,
|
y = 2,
|
||||||
shadowText = 'enter command',
|
shadowText = 'enter command',
|
||||||
backgroundFocusColor = colors.black,
|
|
||||||
limit = 256,
|
limit = 256,
|
||||||
accelerators = {
|
accelerators = {
|
||||||
enter = 'command_enter',
|
enter = 'command_enter',
|
||||||
|
@ -254,6 +254,7 @@ function page.container:setCategory(categoryName)
|
|||||||
y = 4,
|
y = 4,
|
||||||
text = title,
|
text = title,
|
||||||
backgroundColor = self.backgroundColor,
|
backgroundColor = self.backgroundColor,
|
||||||
|
--backgroundFocusColor = colors.gray,
|
||||||
width = #title + 2,
|
width = #title + 2,
|
||||||
event = 'button',
|
event = 'button',
|
||||||
app = program,
|
app = program,
|
||||||
@ -414,7 +415,7 @@ function page:eventHandler(event)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local formWidth = math.max(UI.term.width - 14, 26)
|
local formWidth = math.max(UI.term.width - 8, 26)
|
||||||
|
|
||||||
local editor = UI.Dialog {
|
local editor = UI.Dialog {
|
||||||
height = 11,
|
height = 11,
|
||||||
|
@ -15,10 +15,7 @@ local env = {
|
|||||||
}
|
}
|
||||||
Config.load('shell', env)
|
Config.load('shell', env)
|
||||||
|
|
||||||
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
|
||||||
|
|
||||||
local systemPage = UI.Page {
|
local systemPage = UI.Page {
|
||||||
backgroundColor = colors.cyan,
|
|
||||||
tabs = UI.Tabs {
|
tabs = UI.Tabs {
|
||||||
pathTab = UI.Window {
|
pathTab = UI.Window {
|
||||||
tabTitle = 'Path',
|
tabTitle = 'Path',
|
||||||
@ -80,7 +77,6 @@ local systemPage = UI.Page {
|
|||||||
x = 9, y = 2, rex = -4,
|
x = 9, y = 2, rex = -4,
|
||||||
limit = 32,
|
limit = 32,
|
||||||
value = os.getComputerLabel(),
|
value = os.getComputerLabel(),
|
||||||
backgroundFocusColor = colors.black,
|
|
||||||
accelerators = {
|
accelerators = {
|
||||||
enter = 'update_label',
|
enter = 'update_label',
|
||||||
},
|
},
|
||||||
@ -97,7 +93,6 @@ local systemPage = UI.Page {
|
|||||||
{ name = 'Day', value = tostring(os.day()) },
|
{ name = 'Day', value = tostring(os.day()) },
|
||||||
},
|
},
|
||||||
selectable = false,
|
selectable = false,
|
||||||
--backgroundColor = colors.blue,
|
|
||||||
columns = {
|
columns = {
|
||||||
{ key = 'name', width = 12 },
|
{ key = 'name', width = 12 },
|
||||||
{ key = 'value', width = UI.term.width - 15 },
|
{ key = 'value', width = UI.term.width - 15 },
|
||||||
|
@ -114,7 +114,7 @@ local function draw()
|
|||||||
parentTerm.setTextColor(_colors.focusTextColor)
|
parentTerm.setTextColor(_colors.focusTextColor)
|
||||||
parentTerm.setBackgroundColor(_colors.backgroundColor)
|
parentTerm.setBackgroundColor(_colors.backgroundColor)
|
||||||
parentTerm.setCursorPos( w, 1 )
|
parentTerm.setCursorPos( w, 1 )
|
||||||
parentTerm.write('*')
|
parentTerm.write('\215')
|
||||||
end
|
end
|
||||||
|
|
||||||
if currentTab then
|
if currentTab then
|
||||||
|
@ -12,4 +12,8 @@
|
|||||||
focusIndicator = '\183',
|
focusIndicator = '\183',
|
||||||
inverseSortIndicator = '\24',
|
inverseSortIndicator = '\24',
|
||||||
},
|
},
|
||||||
|
TitleBar = {
|
||||||
|
frameChar = '\140',
|
||||||
|
closeInd = '\215',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,9 @@ local function netUp()
|
|||||||
requireInjector(getfenv(1))
|
requireInjector(getfenv(1))
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
|
|
||||||
local files = fs.list('/sys/network')
|
for _,file in pairs(fs.list('sys/network')) do
|
||||||
|
local fn, msg = Util.run(getfenv(1), 'sys/network/' .. file)
|
||||||
for _,file in pairs(files) do
|
if not fn then
|
||||||
local fn, msg = loadfile('/sys/network/' .. file, getfenv(1))
|
|
||||||
if fn then
|
|
||||||
fn()
|
|
||||||
else
|
|
||||||
printError(msg)
|
printError(msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user