Reindent to remove tabs.

develop
Alexander Gavrilov 2012-09-09 10:53:08 +04:00
parent 8e0f3e3bce
commit 94b729579e
1 changed files with 43 additions and 43 deletions

@ -180,10 +180,10 @@ function ListBox:init(info)
info = info or {} info = info or {}
self:init_fields{ self:init_fields{
selection = info.selection or 0, selection = info.selection or 0,
choices = info.choices or {}, choices = info.choices or {},
select_pen = info.select_pen, select_pen = info.select_pen,
on_input = info.on_input, on_input = info.on_input,
page_top = 0 page_top = 0
} }
MessageBox.init(self, info) MessageBox.init(self, info)
self.on_accept = nil self.on_accept = nil
@ -197,62 +197,62 @@ end
function ListBox:onRenderBody(dc) function ListBox:onRenderBody(dc)
MessageBox.onRenderBody(self, dc) MessageBox.onRenderBody(self, dc)
dc:newline(1) dc:newline(1)
if self.selection>dc.height-3 then if self.selection>dc.height-3 then
self.page_top=self.selection-(dc.height-3) self.page_top=self.selection-(dc.height-3)
elseif self.selection<self.page_top and self.selection >0 then elseif self.selection<self.page_top and self.selection >0 then
self.page_top=self.selection-1 self.page_top=self.selection-1
end end
for i,entry in ipairs(self.choices) do for i,entry in ipairs(self.choices) do
if type(entry)=="table" then if type(entry)=="table" then
entry=entry[1] entry=entry[1]
end end
if i>self.page_top then if i>self.page_top then
if i == self.selection then if i == self.selection then
dc:pen(self.select_pen or COLOR_LIGHTCYAN) dc:pen(self.select_pen or COLOR_LIGHTCYAN)
else else
dc:pen(self.text_pen or COLOR_GREY) dc:pen(self.text_pen or COLOR_GREY)
end end
dc:string(entry) dc:string(entry)
dc:newline(1) dc:newline(1)
end end
end end
end end
function ListBox:moveCursor(delta) function ListBox:moveCursor(delta)
local newsel=self.selection+delta local newsel=self.selection+delta
if #self.choices ~=0 then if #self.choices ~=0 then
if newsel<1 or newsel>#self.choices then if newsel<1 or newsel>#self.choices then
newsel=newsel % #self.choices newsel=newsel % #self.choices
end end
end end
self.selection=newsel self.selection=newsel
end end
function ListBox:onInput(keys) function ListBox:onInput(keys)
if keys.SELECT then if keys.SELECT then
self:dismiss() self:dismiss()
local choice=self.choices[self.selection] local choice=self.choices[self.selection]
if self.on_input then if self.on_input then
self.on_input(self.selection,choice) self.on_input(self.selection,choice)
end end
if choice and choice[2] then if choice and choice[2] then
choice[2](choice,self.selection) -- maybe reverse the arguments? choice[2](choice,self.selection) -- maybe reverse the arguments?
end end
elseif keys.LEAVESCREEN then elseif keys.LEAVESCREEN then
self:dismiss() self:dismiss()
if self.on_cancel then if self.on_cancel then
self.on_cancel() self.on_cancel()
end end
elseif keys.CURSOR_UP then elseif keys.CURSOR_UP then
self:moveCursor(-1) self:moveCursor(-1)
elseif keys.CURSOR_DOWN then elseif keys.CURSOR_DOWN then
self:moveCursor(1) self:moveCursor(1)
elseif keys.CURSOR_UP_FAST then elseif keys.CURSOR_UP_FAST then
self:moveCursor(-10) self:moveCursor(-10)
elseif keys.CURSOR_DOWN_FAST then elseif keys.CURSOR_DOWN_FAST then
self:moveCursor(10) self:moveCursor(10)
end end
end end