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