opus/sys/modules/opus/ui/components/TextArea.lua

49 lines
927 B
Lua
Raw Normal View History

local class = require('opus.class')
local UI = require('opus.ui')
2019-02-06 04:03:57 +00:00
UI.TextArea = class(UI.Viewport)
UI.TextArea.defaults = {
UIElement = 'TextArea',
marginRight = 2,
value = '',
showScrollBar = true,
2019-02-06 04:03:57 +00:00
}
function UI.TextArea:setText(text)
self:reset()
self.value = text
self:draw()
end
function UI.TextArea.focus()
2019-02-06 04:03:57 +00:00
-- allow keyboard scrolling
end
function UI.TextArea:draw()
self:clear()
self:print(self.value)
self:drawChildren()
2019-02-06 04:03:57 +00:00
end
2019-11-13 04:13:17 +00:00
function UI.TextArea.example()
local Ansi = require('opus.ansi')
return UI.Window {
backgroundColor = 2048,
t1 = UI.TextArea {
ey = 3,
value = 'sample text\nabc'
},
t2 = UI.TextArea {
y = 5,
backgroundColor = 'green',
value = string.format([[now %%is the %stime %sfor%s all good men to come to the aid of their country.
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
3
4
5
6
7
8]], Ansi.yellow, Ansi.onred, Ansi.reset),
}
2019-11-13 04:13:17 +00:00
}
end