|
|
|
@ -8,6 +8,7 @@ local utils = require('utils')
|
|
|
|
|
|
|
|
|
|
local dscreen = dfhack.screen
|
|
|
|
|
local getval = utils.getval
|
|
|
|
|
local to_pen = dfhack.pen.parse
|
|
|
|
|
|
|
|
|
|
local function show_view(view,vis)
|
|
|
|
|
if view then
|
|
|
|
@ -25,16 +26,13 @@ end
|
|
|
|
|
|
|
|
|
|
STANDARDSCROLL = {
|
|
|
|
|
STANDARDSCROLL_UP = -1,
|
|
|
|
|
KEYBOARD_CURSOR_UP = -1,
|
|
|
|
|
STANDARDSCROLL_DOWN = 1,
|
|
|
|
|
KEYBOARD_CURSOR_DOWN = 1,
|
|
|
|
|
STANDARDSCROLL_PAGEUP = '-page',
|
|
|
|
|
KEYBOARD_CURSOR_UP_FAST = '-page',
|
|
|
|
|
STANDARDSCROLL_PAGEDOWN = '+page',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SECONDSCROLL = {
|
|
|
|
|
SECONDSCROLL_UP = -1,
|
|
|
|
|
SECONDSCROLL_DOWN = 1,
|
|
|
|
|
SECONDSCROLL_PAGEUP = '-page',
|
|
|
|
|
SECONDSCROLL_PAGEDOWN = '+page',
|
|
|
|
|
KEYBOARD_CURSOR_DOWN_FAST = '+page',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
------------
|
|
|
|
@ -365,8 +363,10 @@ function Panel:setKeyboardDragEnabled(enabled)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if enabled then
|
|
|
|
|
local kbd_get_pos = function() return {x=0, y=0} end
|
|
|
|
|
Panel_begin_drag(self, kbd_get_pos())
|
|
|
|
|
local kbd_get_pos = function()
|
|
|
|
|
return {x=self.frame_rect.x1, y=self.frame_rect.y1}
|
|
|
|
|
end
|
|
|
|
|
Panel_begin_drag(self)
|
|
|
|
|
self.kbd_get_pos = kbd_get_pos
|
|
|
|
|
else
|
|
|
|
|
Panel_end_drag(self)
|
|
|
|
@ -441,6 +441,9 @@ end
|
|
|
|
|
-- if self.autoarrange_subviews is true, lay out visible subviews vertically,
|
|
|
|
|
-- adding gaps between widgets according to self.autoarrange_gap.
|
|
|
|
|
function Panel:postUpdateLayout()
|
|
|
|
|
-- don't leave artifacts behind on the parent screen when we move
|
|
|
|
|
gui.Screen.request_full_screen_refresh = true
|
|
|
|
|
|
|
|
|
|
if not self.autoarrange_subviews then return end
|
|
|
|
|
|
|
|
|
|
local gap = self.autoarrange_gap
|
|
|
|
@ -465,7 +468,7 @@ function Panel:onRenderFrame(dc, rect)
|
|
|
|
|
gui.paint_frame(dc, rect, self.frame_style, self.frame_title)
|
|
|
|
|
if self.kbd_get_pos then
|
|
|
|
|
local pos = self.kbd_get_pos()
|
|
|
|
|
local pen = dfhack.pen.parse{fg=COLOR_GREEN, bg=COLOR_BLACK}
|
|
|
|
|
local pen = to_pen{fg=COLOR_GREEN, bg=COLOR_BLACK}
|
|
|
|
|
dc:seek(pos.x, pos.y):pen(pen):char(string.char(0xDB))
|
|
|
|
|
end
|
|
|
|
|
if self.drag_offset and not self.kbd_get_pos
|
|
|
|
@ -654,6 +657,12 @@ function EditField:onRenderBody(dc)
|
|
|
|
|
dc:string((' '):rep(dc.clip_x2 - dc.x))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EditField:insert(text)
|
|
|
|
|
local old = self.text
|
|
|
|
|
self:setText(old:sub(1,self.cursor-1)..text..old:sub(self.cursor),
|
|
|
|
|
self.cursor + #text)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EditField:onInput(keys)
|
|
|
|
|
if not self.focus then
|
|
|
|
|
-- only react to our hotkey
|
|
|
|
@ -676,22 +685,20 @@ function EditField:onInput(keys)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if keys.SELECT then
|
|
|
|
|
if keys.SELECT or keys.CUSTOM_SHIFT_ENTER then
|
|
|
|
|
if self.key then
|
|
|
|
|
self:setFocus(false)
|
|
|
|
|
end
|
|
|
|
|
if keys.CUSTOM_SHIFT_ENTER then
|
|
|
|
|
if self.on_submit2 then
|
|
|
|
|
self.on_submit2(self.text)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if self.on_submit then
|
|
|
|
|
self.on_submit(self.text)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return not not self.key
|
|
|
|
|
elseif keys.SEC_SELECT then
|
|
|
|
|
if self.key then
|
|
|
|
|
self:setFocus(false)
|
|
|
|
|
end
|
|
|
|
|
if self.on_submit2 then
|
|
|
|
|
self.on_submit2(self.text)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return not not self.key
|
|
|
|
|
elseif keys._MOUSE_L then
|
|
|
|
@ -712,8 +719,7 @@ function EditField:onInput(keys)
|
|
|
|
|
else
|
|
|
|
|
local cv = string.char(keys._STRING)
|
|
|
|
|
if not self.on_char or self.on_char(cv, old) then
|
|
|
|
|
self:setText(old:sub(1,self.cursor-1)..cv..old:sub(self.cursor),
|
|
|
|
|
self.cursor + 1)
|
|
|
|
|
self:insert(cv)
|
|
|
|
|
elseif self.on_char then
|
|
|
|
|
return self.modal
|
|
|
|
|
end
|
|
|
|
@ -722,25 +728,25 @@ function EditField:onInput(keys)
|
|
|
|
|
self.on_change(self.text, old)
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CURSOR_LEFT then
|
|
|
|
|
elseif keys.KEYBOARD_CURSOR_LEFT then
|
|
|
|
|
self:setCursor(self.cursor - 1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_MOVE_W_DOWN then -- Ctrl-Left (end of prev word)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_B then -- back one word
|
|
|
|
|
local _, prev_word_end = self.text:sub(1, self.cursor-1):
|
|
|
|
|
find('.*[%w_%-][^%w_%-]')
|
|
|
|
|
self:setCursor(prev_word_end or 1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_CARE_MOVE_W then -- Alt-Left (home)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_A then -- home
|
|
|
|
|
self:setCursor(1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CURSOR_RIGHT then
|
|
|
|
|
elseif keys.KEYBOARD_CURSOR_RIGHT then
|
|
|
|
|
self:setCursor(self.cursor + 1)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_MOVE_E_DOWN then -- Ctrl-Right (beginning of next word)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_F then -- forward one word
|
|
|
|
|
local _,next_word_start = self.text:find('[^%w_%-][%w_%-]', self.cursor)
|
|
|
|
|
self:setCursor(next_word_start)
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.A_CARE_MOVE_E then -- Alt-Right (end)
|
|
|
|
|
elseif keys.CUSTOM_CTRL_E then -- end
|
|
|
|
|
self:setCursor()
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
@ -759,14 +765,12 @@ SCROLL_DELAY_MS = 20
|
|
|
|
|
Scrollbar = defclass(Scrollbar, Widget)
|
|
|
|
|
|
|
|
|
|
Scrollbar.ATTRS{
|
|
|
|
|
fg = COLOR_LIGHTGREEN,
|
|
|
|
|
bg = COLOR_CYAN,
|
|
|
|
|
on_scroll = DEFAULT_NIL,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Scrollbar:preinit(init_table)
|
|
|
|
|
init_table.frame = init_table.frame or {}
|
|
|
|
|
init_table.frame.w = init_table.frame.w or 1
|
|
|
|
|
init_table.frame.w = init_table.frame.w or 2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Scrollbar:init()
|
|
|
|
@ -824,36 +828,95 @@ local function scrollbar_is_visible(scrollbar)
|
|
|
|
|
return scrollbar.elems_per_page < scrollbar.num_elems
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local UP_ARROW_CHAR = string.char(24)
|
|
|
|
|
local DOWN_ARROW_CHAR = string.char(25)
|
|
|
|
|
local NO_ARROW_CHAR = string.char(32)
|
|
|
|
|
local BAR_CHAR = string.char(7)
|
|
|
|
|
local BAR_BG_CHAR = string.char(179)
|
|
|
|
|
local SCROLLBAR_UP_LEFT_PEN = to_pen{tile=922, ch=47, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_UP_RIGHT_PEN = to_pen{tile=923, ch=92, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_DOWN_LEFT_PEN = to_pen{tile=946, ch=92, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_DOWN_RIGHT_PEN = to_pen{tile=947, ch=47, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_UP_LEFT_PEN = to_pen{tile=930, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_UP_RIGHT_PEN = to_pen{tile=931, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_LEFT_PEN = to_pen{tile=954, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_RIGHT_PEN = to_pen{tile=955, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_UP_LEFT_PEN = to_pen{tile=932, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_UP_RIGHT_PEN = to_pen{tile=933, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_DOWN_LEFT_PEN = to_pen{tile=960, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_DOWN_RIGHT_PEN = to_pen{tile=961, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_LEFT_PEN = to_pen{tile=940, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_RIGHT_PEN = to_pen{tile=941, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_DOWN_LEFT_PEN = to_pen{tile=966, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_DOWN_RIGHT_PEN = to_pen{tile=967, ch=219, fg=COLOR_CYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_UP_LEFT_HOVER_PEN = to_pen{tile=924, ch=47, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_UP_RIGHT_HOVER_PEN = to_pen{tile=925, ch=92, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_DOWN_LEFT_HOVER_PEN = to_pen{tile=936, ch=92, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_DOWN_RIGHT_HOVER_PEN = to_pen{tile=937, ch=47, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_UP_LEFT_HOVER_PEN = to_pen{tile=930, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_UP_RIGHT_HOVER_PEN = to_pen{tile=931, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_LEFT_HOVER_PEN = to_pen{tile=954, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_RIGHT_HOVER_PEN = to_pen{tile=955, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_UP_LEFT_HOVER_PEN = to_pen{tile=956, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_UP_RIGHT_HOVER_PEN = to_pen{tile=957, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_DOWN_LEFT_HOVER_PEN = to_pen{tile=968, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_DOWN_RIGHT_HOVER_PEN = to_pen{tile=969, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_LEFT_HOVER_PEN = to_pen{tile=942, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_CENTER_RIGHT_HOVER_PEN = to_pen{tile=943, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_DOWN_LEFT_HOVER_PEN = to_pen{tile=966, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_DOWN_RIGHT_HOVER_PEN = to_pen{tile=967, ch=219, fg=COLOR_LIGHTCYAN, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_BG_LEFT_PEN = to_pen{tile=934, ch=176, fg=COLOR_DARKGREY, bg=COLOR_BLACK}
|
|
|
|
|
local SCROLLBAR_BAR_BG_RIGHT_PEN = to_pen{tile=935, ch=176, fg=COLOR_DARKGREY, bg=COLOR_BLACK}
|
|
|
|
|
|
|
|
|
|
function Scrollbar:onRenderBody(dc)
|
|
|
|
|
-- don't draw if all elements are visible
|
|
|
|
|
if not scrollbar_is_visible(self) then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- render up arrow if we're not at the top
|
|
|
|
|
dc:seek(0, 0):char(
|
|
|
|
|
self.top_elem == 1 and NO_ARROW_CHAR or UP_ARROW_CHAR, self.fg, self.bg)
|
|
|
|
|
-- determine which elements should be highlighted
|
|
|
|
|
local _,hover_y = self:getMousePos()
|
|
|
|
|
local hover_up, hover_down, hover_bar = false, false, false
|
|
|
|
|
if hover_y == 0 then
|
|
|
|
|
hover_up = true
|
|
|
|
|
elseif hover_y == dc.height-1 then
|
|
|
|
|
hover_down = true
|
|
|
|
|
elseif hover_y then
|
|
|
|
|
hover_bar = true
|
|
|
|
|
end
|
|
|
|
|
-- render up arrow
|
|
|
|
|
dc:seek(0, 0)
|
|
|
|
|
dc:char(nil, hover_up and SCROLLBAR_UP_LEFT_HOVER_PEN or SCROLLBAR_UP_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_up and SCROLLBAR_UP_RIGHT_HOVER_PEN or SCROLLBAR_UP_RIGHT_PEN)
|
|
|
|
|
-- render scrollbar body
|
|
|
|
|
local starty = self.bar_offset + 1
|
|
|
|
|
local endy = self.bar_offset + self.bar_height
|
|
|
|
|
local midy = (starty + endy)/2
|
|
|
|
|
for y=1,dc.height-2 do
|
|
|
|
|
dc:seek(0, y)
|
|
|
|
|
if y >= starty and y <= endy then
|
|
|
|
|
dc:char(BAR_CHAR, self.fg)
|
|
|
|
|
if y == starty and y <= midy - 1 then
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_UP_LEFT_HOVER_PEN or SCROLLBAR_BAR_UP_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_UP_RIGHT_HOVER_PEN or SCROLLBAR_BAR_UP_RIGHT_PEN)
|
|
|
|
|
elseif y == midy - 0.5 then
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_CENTER_UP_LEFT_HOVER_PEN or SCROLLBAR_BAR_CENTER_UP_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_CENTER_UP_RIGHT_HOVER_PEN or SCROLLBAR_BAR_CENTER_UP_RIGHT_PEN)
|
|
|
|
|
elseif y == midy + 0.5 then
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_CENTER_DOWN_LEFT_HOVER_PEN or SCROLLBAR_BAR_CENTER_DOWN_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_CENTER_DOWN_RIGHT_HOVER_PEN or SCROLLBAR_BAR_CENTER_DOWN_RIGHT_PEN)
|
|
|
|
|
elseif y == midy then
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_CENTER_LEFT_HOVER_PEN or SCROLLBAR_BAR_CENTER_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_CENTER_RIGHT_HOVER_PEN or SCROLLBAR_BAR_CENTER_RIGHT_PEN)
|
|
|
|
|
elseif y == endy and y >= midy + 1 then
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_DOWN_LEFT_HOVER_PEN or SCROLLBAR_BAR_DOWN_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_DOWN_RIGHT_HOVER_PEN or SCROLLBAR_BAR_DOWN_RIGHT_PEN)
|
|
|
|
|
else
|
|
|
|
|
dc:char(BAR_BG_CHAR, self.bg)
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_LEFT_HOVER_PEN or SCROLLBAR_BAR_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_bar and SCROLLBAR_BAR_RIGHT_HOVER_PEN or SCROLLBAR_BAR_RIGHT_PEN)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
dc:char(nil, SCROLLBAR_BAR_BG_LEFT_PEN)
|
|
|
|
|
dc:char(nil, SCROLLBAR_BAR_BG_RIGHT_PEN)
|
|
|
|
|
end
|
|
|
|
|
-- render down arrow if we're not at the bottom
|
|
|
|
|
local last_visible_el = self.top_elem + self.elems_per_page - 1
|
|
|
|
|
dc:seek(0, dc.height-1):char(
|
|
|
|
|
last_visible_el >= self.num_elems and NO_ARROW_CHAR or DOWN_ARROW_CHAR,
|
|
|
|
|
self.fg, self.bg)
|
|
|
|
|
end
|
|
|
|
|
-- render down arrow
|
|
|
|
|
dc:seek(0, dc.height-1)
|
|
|
|
|
dc:char(nil, hover_down and SCROLLBAR_DOWN_LEFT_HOVER_PEN or SCROLLBAR_DOWN_LEFT_PEN)
|
|
|
|
|
dc:char(nil, hover_down and SCROLLBAR_DOWN_RIGHT_HOVER_PEN or SCROLLBAR_DOWN_RIGHT_PEN)
|
|
|
|
|
if not self.on_scroll then return end
|
|
|
|
|
-- manage state for dragging and continuous scrolling
|
|
|
|
|
if self.is_dragging then
|
|
|
|
@ -877,10 +940,26 @@ function Scrollbar:onRenderBody(dc)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Scrollbar:onInput(keys)
|
|
|
|
|
if not keys._MOUSE_L_DOWN or not self.on_scroll
|
|
|
|
|
or not scrollbar_is_visible(self) then
|
|
|
|
|
if not self.on_scroll or not scrollbar_is_visible(self) then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if self.parent_view:getMousePos() then
|
|
|
|
|
if keys.CONTEXT_SCROLL_UP then
|
|
|
|
|
self.on_scroll('up_small')
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CONTEXT_SCROLL_DOWN then
|
|
|
|
|
self.on_scroll('down_small')
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CONTEXT_SCROLL_PAGEUP then
|
|
|
|
|
self.on_scroll('up_large')
|
|
|
|
|
return true
|
|
|
|
|
elseif keys.CONTEXT_SCROLL_PAGEDOWN then
|
|
|
|
|
self.on_scroll('down_large')
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if not keys._MOUSE_L_DOWN then return false end
|
|
|
|
|
local _,y = self:getMousePos()
|
|
|
|
|
if not y then return false end
|
|
|
|
|
local scroll_spec = nil
|
|
|
|
@ -988,13 +1067,13 @@ function render_text(obj,dc,x0,y0,pen,dpen,disabled)
|
|
|
|
|
if token.tile then
|
|
|
|
|
x = x + 1
|
|
|
|
|
if dc then
|
|
|
|
|
dc:char(nil, token.tile)
|
|
|
|
|
dc:tile(nil, token.tile)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if token.text or token.key then
|
|
|
|
|
local text = ''..(getval(token.text) or '')
|
|
|
|
|
local keypen = dfhack.pen.parse(token.key_pen or COLOR_LIGHTGREEN)
|
|
|
|
|
local keypen = to_pen(token.key_pen or COLOR_LIGHTGREEN)
|
|
|
|
|
|
|
|
|
|
if dc then
|
|
|
|
|
local tpen = getval(token.pen)
|
|
|
|
@ -1247,7 +1326,7 @@ end
|
|
|
|
|
-- we can't set the text in init() since we may not yet have a frame that we
|
|
|
|
|
-- can get wrapping bounds from.
|
|
|
|
|
function WrappedLabel:postComputeFrame()
|
|
|
|
|
local wrapped_text = self:getWrappedText(self.frame_body.width-1)
|
|
|
|
|
local wrapped_text = self:getWrappedText(self.frame_body.width-3)
|
|
|
|
|
if not wrapped_text then return end
|
|
|
|
|
local text = {}
|
|
|
|
|
for _,line in ipairs(wrapped_text:split(NEWLINE)) do
|
|
|
|
@ -1622,12 +1701,14 @@ end
|
|
|
|
|
function List:submit()
|
|
|
|
|
if self.on_submit and #self.choices > 0 then
|
|
|
|
|
self.on_submit(self:getSelected())
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function List:submit2()
|
|
|
|
|
if self.on_submit2 and #self.choices > 0 then
|
|
|
|
|
self.on_submit2(self:getSelected())
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -1635,12 +1716,10 @@ function List:onInput(keys)
|
|
|
|
|
if self:inputToSubviews(keys) then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if self.on_submit and keys.SELECT then
|
|
|
|
|
self:submit()
|
|
|
|
|
return true
|
|
|
|
|
elseif self.on_submit2 and keys.SEC_SELECT then
|
|
|
|
|
self:submit2()
|
|
|
|
|
return true
|
|
|
|
|
if keys.SELECT then
|
|
|
|
|
return self:submit()
|
|
|
|
|
elseif keys.CUSTOM_SHIFT_ENTER then
|
|
|
|
|
return self:submit2()
|
|
|
|
|
elseif keys._MOUSE_L_DOWN then
|
|
|
|
|
local idx = self:getIdxUnderMouse()
|
|
|
|
|
if idx then
|
|
|
|
|