remove trailing white spaces

This commit is contained in:
ruki
2020-10-06 22:50:08 +08:00
parent edc266a881
commit c6c426d60b
45 changed files with 166 additions and 166 deletions

View File

@@ -1,5 +1,5 @@
target("ltui") target("ltui")
-- add source files -- add source files
add_files("lcurses.c", {languages = "c99", cflags = "-Wno-expansion-to-defined"}) add_files("lcurses.c", {languages = "c99", cflags = "-Wno-expansion-to-defined"})

View File

@@ -1,7 +1,7 @@
target("ltui") target("ltui")
-- add source files -- add source files
add_files("**.c") add_files("**.c")
-- add defines -- add defines
add_defines("PDC_WIDE") add_defines("PDC_WIDE")

View File

@@ -12,7 +12,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -37,8 +37,8 @@ function action:register(tag, ...)
end end
-- register action enums -- register action enums
action:register("ac_max", action:register("ac_max",
"ac_on_text_changed", "ac_on_text_changed",
"ac_on_selected", "ac_on_selected",
"ac_on_resized", "ac_on_resized",
"ac_on_enter", "ac_on_enter",

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -59,7 +59,7 @@ function application:exit()
log:flush() log:flush()
end end
-- get menubar -- get menubar
function application:menubar() function application:menubar()
if not self._MENUBAR then if not self._MENUBAR then
self._MENUBAR = menubar:new("menubar", rect{0, 0, self:width(), 1}) self._MENUBAR = menubar:new("menubar", rect{0, 0, self:width(), 1})
@@ -96,7 +96,7 @@ function application:on_resize()
program.on_resize(self) program.on_resize(self)
end end
-- run application -- run application
function application:run(...) function application:run(...)
-- init runner -- init runner

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -176,7 +176,7 @@ end
-- get items -- get items
-- --
-- .e.g -- .e.g
-- --
-- for item in dlist:items() do -- for item in dlist:items() do
-- print(item) -- print(item)

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
--o --o
-- @author ruki -- @author ruki
@@ -26,10 +26,10 @@ function log:file()
-- disable? -- disable?
if self._ENABLE ~= nil and not self._ENABLE then if self._ENABLE ~= nil and not self._ENABLE then
return return
end end
-- get the output file -- get the output file
if self._FILE == nil then if self._FILE == nil then
local outputfile = self:outputfile() local outputfile = self:outputfile()
if outputfile then if outputfile then

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -72,7 +72,7 @@ function os.host()
elseif package.config:sub(1, 1) == '\\' then elseif package.config:sub(1, 1) == '\\' then
os._HOST = "windows" os._HOST = "windows"
else else
local result = os.iorun("uname") local result = os.iorun("uname")
if result then if result then
if result:lower():find("linux", 1, true) then if result:lower():find("linux", 1, true) then
os._HOST = "linux" os._HOST = "linux"

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -104,7 +104,7 @@ end
-- convert path pattern to a lua pattern -- convert path pattern to a lua pattern
function path.pattern(pattern) function path.pattern(pattern)
-- translate wildcards, .e.g *, ** -- translate wildcards, .e.g *, **
pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1") pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1")
pattern = pattern:gsub("%*%*", "\001") pattern = pattern:gsub("%*%*", "\001")

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -22,7 +22,7 @@
local string = string or {} local string = string or {}
-- match the start string -- match the start string
function string:startswith(str) function string:startswith(str)
return self:find('^' .. str) ~= nil return self:find('^' .. str) ~= nil
end end
@@ -96,7 +96,7 @@ function string:append(substr, separator)
else else
s = string.format("%s%s%s", s, separator or "", substr) s = string.format("%s%s%s", s, separator or "", substr)
end end
-- ok -- ok
return s return s
end end
@@ -152,7 +152,7 @@ function string.tryformat(format, ...)
end end
end end
-- case-insensitive pattern-matching -- case-insensitive pattern-matching
-- --
-- print(("src/dadasd.C"):match(string.ipattern("sR[cd]/.*%.c", true))) -- print(("src/dadasd.C"):match(string.ipattern("sR[cd]/.*%.c", true)))
-- print(("src/dadasd.C"):match(string.ipattern("src/.*%.c", true))) -- print(("src/dadasd.C"):match(string.ipattern("src/.*%.c", true)))
@@ -167,7 +167,7 @@ function string.ipattern(pattern, brackets)
local tmp = {} local tmp = {}
local i = 1 local i = 1
while i <= #pattern do while i <= #pattern do
-- get current charactor -- get current charactor
local char = pattern:sub(i, i) local char = pattern:sub(i, i)
@@ -184,7 +184,7 @@ function string.ipattern(pattern, brackets)
i = i + 2 i = i + 2
end end
-- brackets? -- brackets?
elseif char == '[' then elseif char == '[' then
tmp[#tmp + 1] = char tmp[#tmp + 1] = char
i = i + 1 i = i + 1
while i <= #pattern do while i <= #pattern do
@@ -193,12 +193,12 @@ function string.ipattern(pattern, brackets)
tmp[#tmp + 1] = char tmp[#tmp + 1] = char
tmp[#tmp + 1] = pattern:sub(i + 1, i + 1) tmp[#tmp + 1] = pattern:sub(i + 1, i + 1)
i = i + 1 i = i + 1
elseif char:match("%a") then elseif char:match("%a") then
tmp[#tmp + 1] = not brackets and char or char:lower() .. char:upper() tmp[#tmp + 1] = not brackets and char or char:lower() .. char:upper()
else else
tmp[#tmp + 1] = char tmp[#tmp + 1] = char
end end
if char == ']' then break end if char == ']' then break end
i = i + 1 i = i + 1
end end
-- letter, [aA] -- letter, [aA]

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -24,7 +24,7 @@ local table = table or {}
-- clear the table -- clear the table
function table.clear(self) function table.clear(self)
for k in next, self do for k in next, self do
rawset(self, k, nil) rawset(self, k, nil)
end end
end end

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -54,10 +54,10 @@ function button:on_draw(transparent)
-- strip text string -- strip text string
local str = self:text() local str = self:text()
if str and #str > 0 then if str and #str > 0 then
str = string.sub(str, 1, self:width()) str = string.sub(str, 1, self:width())
end end
if not str or #str == 0 then if not str or #str == 0 then
return return
end end
-- get the text attribute value -- get the text attribute value
@@ -77,7 +77,7 @@ function button:on_event(e)
-- selected? -- selected?
if not self:state("selected") then if not self:state("selected") then
return return
end end
-- enter this button? -- enter this button?

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -84,7 +84,7 @@ end
-- put character to canvas -- put character to canvas
function canvas:putchar(ch, n, vertical) function canvas:putchar(ch, n, vertical)
-- acs character? -- acs character?
if type(ch) == "string" and #ch > 1 then if type(ch) == "string" and #ch > 1 then
ch = curses.acs(ch) ch = curses.acs(ch)
@@ -111,19 +111,19 @@ end
-- put a string to canvas -- put a string to canvas
function canvas:putstr(str) function canvas:putstr(str)
self._window:addstr(str) self._window:addstr(str)
return self return self
end end
-- put strings to canvas -- put strings to canvas
function canvas:putstrs(strs, startline) function canvas:putstrs(strs, startline)
-- draw strings -- draw strings
local sy, sx = self._window:getyx() local sy, sx = self._window:getyx()
local ey, _ = self._window:getmaxyx() local ey, _ = self._window:getmaxyx()
for idx = startline or 1, #strs do for idx = startline or 1, #strs do
local _, y = self:pos() local _, y = self:pos()
self._window:addstr(strs[idx]) self._window:addstr(strs[idx])
if y + 1 < ey and idx < #strs then if y + 1 < ey and idx < #strs then
self:move(sx, y + 1) self:move(sx, y + 1)
else else

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -44,7 +44,7 @@ end
-- on event -- on event
function choicebox:on_event(e) function choicebox:on_event(e)
-- select config -- select config
if e.type == event.ev_keyboard then if e.type == event.ev_keyboard then
if e.key_name == "Down" then if e.key_name == "Down" then
@@ -58,7 +58,7 @@ function choicebox:on_event(e)
elseif e.type == event.ev_command and e.command == "cm_enter" then elseif e.type == event.ev_command and e.command == "cm_enter" then
self:_do_select() self:_do_select()
return true return true
end end
end end
-- load values -- load values
@@ -101,7 +101,7 @@ function choicebox:_do_select()
-- get the current item -- get the current item
local item = self:current() local item = self:current()
-- get the current index -- get the current index
local index = item:extra("index") local index = item:extra("index")

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -41,11 +41,11 @@ function choicedialog:init(name, bounds, title)
self:text():text_set("Use the arrow keys to navigate this window or press the hotkey of the item you wish to select followed by the <SPACEBAR>. Press <?> for additional information about this") self:text():text_set("Use the arrow keys to navigate this window or press the hotkey of the item you wish to select followed by the <SPACEBAR>. Press <?> for additional information about this")
-- init buttons -- init buttons
self:button_add("select", "< Select >", function (v, e) self:button_add("select", "< Select >", function (v, e)
self:choicebox():on_event(event.command {"cm_enter"}) self:choicebox():on_event(event.command {"cm_enter"})
self:quit() self:quit()
end) end)
self:button_add("cancel", "< Cancel >", function (v, e) self:button_add("cancel", "< Cancel >", function (v, e)
self:quit() self:quit()
end) end)
self:buttons():select(self:button("select")) self:buttons():select(self:button("select"))
@@ -82,7 +82,7 @@ function choicedialog:on_event(e)
return self:choicebox():on_event(e) return self:choicebox():on_event(e)
end end
end end
return boxdialog.on_event(self, e) return boxdialog.on_event(self, e)
end end
-- return module -- return module

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -138,7 +138,7 @@ function curses.calc_attr(attrs)
local set = {} local set = {}
local fg = nil local fg = nil
local bg = nil local bg = nil
for _, a in ipairs(attrs) do for _, a in ipairs(attrs) do
if not set[a] and a then if not set[a] and a then
set[a] = true set[a] = true
if type(a) == "number" then if type(a) == "number" then
@@ -180,7 +180,7 @@ function curses.color_pair(fg, bg)
-- no colors? -- no colors?
if not curses.has_colors() then if not curses.has_colors() then
return 0 return 0
end end
-- update the colors count -- update the colors count

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -31,11 +31,11 @@ local curses = require("ltui/curses")
-- define module -- define module
local dialog = dialog or window() local dialog = dialog or window()
-- update the position of all buttons -- update the position of all buttons
function dialog:_update_buttons_layout() function dialog:_update_buttons_layout()
-- update the position of all buttons -- update the position of all buttons
local index = 1 local index = 1
local width = self:buttons():width() local width = self:buttons():width()
local count = self:buttons():count() local count = self:buttons():count()
@@ -87,7 +87,7 @@ function dialog:button_add(name, text, command)
-- insert button -- insert button
self:buttons():insert(btn) self:buttons():insert(btn)
-- update the position of all buttons -- update the position of all buttons
self:_update_buttons_layout() self:_update_buttons_layout()
-- invalidate -- invalidate

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -68,7 +68,7 @@ function label:text_set(text)
-- set text -- set text
text = text or "" text = text or ""
local changed = self._TEXT ~= text local changed = self._TEXT ~= text
self._TEXT = text self._TEXT = text
-- do action -- do action
if changed then if changed then
@@ -94,7 +94,7 @@ function label:textattr_val()
-- get text attribute -- get text attribute
local textattr = self:textattr() local textattr = self:textattr()
if not textattr then if not textattr then
return return
end end
-- no text background? use view's background -- no text background? use view's background
@@ -117,7 +117,7 @@ end
-- split text by width -- split text by width
function label:splitext(text, width) function label:splitext(text, width)
-- get width -- get width
width = width or self:width() width = width or self:width()

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -42,7 +42,7 @@ function mconfdialog:init(name, bounds, title)
boxdialog.init(self, name, bounds, title) boxdialog.init(self, name, bounds, title)
-- init text -- init text
self:text():text_set([[Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). self:text():text_set([[Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----).
Pressing <Y> includes, <N> excludes. Enter <Esc> or <Back> to go back, <?> for Help, </> for Search. Legend: [*] built-in [ ] excluded Pressing <Y> includes, <N> excludes. Enter <Esc> or <Back> to go back, <?> for Help, </> for Search. Legend: [*] built-in [ ] excluded
]]) ]])
@@ -50,7 +50,7 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> or <Back> to go back, <?> for H
self:button_add("select", "< Select >", function (v, e) self:menuconf():on_event(event.command {"cm_enter"}) end) self:button_add("select", "< Select >", function (v, e) self:menuconf():on_event(event.command {"cm_enter"}) end)
self:button_add("back", "< Back >", function (v, e) self:menuconf():on_event(event.command {"cm_back"}) end) self:button_add("back", "< Back >", function (v, e) self:menuconf():on_event(event.command {"cm_back"}) end)
self:button_add("exit", "< Exit >", function (v, e) self:quit() end) self:button_add("exit", "< Exit >", function (v, e) self:quit() end)
self:button_add("help", "< Help >", function (v, e) self:show_help() end) self:button_add("help", "< Help >", function (v, e) self:show_help() end)
self:button_add("save", "< Save >", function (v, e) self:action_on(action.ac_on_save) end) self:button_add("save", "< Save >", function (v, e) self:action_on(action.ac_on_save) end)
self:buttons():select(self:button("select")) self:buttons():select(self:button("select"))
@@ -144,7 +144,7 @@ function mconfdialog:inputdialog()
dialog_input:background_set(self:frame():background()) dialog_input:background_set(self:frame():background())
dialog_input:frame():background_set("cyan") dialog_input:frame():background_set("cyan")
dialog_input:textedit():option_set("multiline", false) dialog_input:textedit():option_set("multiline", false)
dialog_input:button_add("ok", "< Ok >", function (v) dialog_input:button_add("ok", "< Ok >", function (v)
local config = dialog_input:extra("config") local config = dialog_input:extra("config")
if config.kind == "string" then if config.kind == "string" then
config.value = dialog_input:textedit():text() config.value = dialog_input:textedit():text()
@@ -154,9 +154,9 @@ function mconfdialog:inputdialog()
config.value = value config.value = value
end end
end end
dialog_input:quit() dialog_input:quit()
end) end)
dialog_input:button_add("cancel", "< Cancel >", function (v) dialog_input:button_add("cancel", "< Cancel >", function (v)
dialog_input:quit() dialog_input:quit()
end) end)
dialog_input:button_select("ok") dialog_input:button_select("ok")
@@ -185,7 +185,7 @@ function mconfdialog:searchdialog()
dialog_search:frame():background_set("cyan") dialog_search:frame():background_set("cyan")
dialog_search:textedit():option_set("multiline", false) dialog_search:textedit():option_set("multiline", false)
dialog_search:text():text_set("Enter (sub)string or lua pattern string to search for configuration") dialog_search:text():text_set("Enter (sub)string or lua pattern string to search for configuration")
dialog_search:button_add("ok", "< Ok >", function (v) dialog_search:button_add("ok", "< Ok >", function (v)
local configs = self:search(self:configs(), dialog_search:textedit():text()) local configs = self:search(self:configs(), dialog_search:textedit():text())
local results = "Search('" .. dialog_search:textedit():text() .. "') results:" local results = "Search('" .. dialog_search:textedit():text() .. "') results:"
for _, config in ipairs(configs) do for _, config in ipairs(configs) do
@@ -205,9 +205,9 @@ function mconfdialog:searchdialog()
results = results .. "\n" results = results .. "\n"
end end
self:show_result(results) self:show_result(results)
dialog_search:quit() dialog_search:quit()
end) end)
dialog_search:button_add("cancel", "< Cancel >", function (v) dialog_search:button_add("cancel", "< Cancel >", function (v)
dialog_search:quit() dialog_search:quit()
end) end)
dialog_search:button_select("ok") dialog_search:button_select("ok")
@@ -237,7 +237,7 @@ function mconfdialog:show_help()
-- get the current config item -- get the current config item
local item = self:menuconf():current() local item = self:menuconf():current()
-- get the current config -- get the current config
local config = item:extra("config") local config = item:extra("config")
@@ -307,7 +307,7 @@ function mconfdialog:on_event(e)
return true return true
end end
end end
return boxdialog.on_event(self, e) return boxdialog.on_event(self, e)
end end
-- on resize -- on resize

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -44,7 +44,7 @@ end
-- on event -- on event
function menuconf:on_event(e) function menuconf:on_event(e)
-- select config -- select config
local back = false local back = false
if e.type == event.ev_keyboard then if e.type == event.ev_keyboard then
@@ -71,7 +71,7 @@ function menuconf:on_event(e)
elseif e.command == "cm_back" then elseif e.command == "cm_back" then
back = true back = true
end end
end end
-- back? -- back?
if back then if back then
@@ -135,19 +135,19 @@ function menuconf:_do_select()
-- get the current item -- get the current item
local item = self:current() local item = self:current()
-- get the current config -- get the current config
local config = item:extra("config") local config = item:extra("config")
-- clear new state -- clear new state
config.new = false config.new = false
-- do action: on selected -- do action: on selected
if self:action_on(action.ac_on_selected, config) then if self:action_on(action.ac_on_selected, config) then
return return
end end
-- select the boolean config -- select the boolean config
if config.kind == "boolean" then if config.kind == "boolean" then
config.value = not config.value config.value = not config.value
-- show sub-menu configs -- show sub-menu configs
@@ -163,14 +163,14 @@ function menuconf:_do_include(enabled)
-- get the current item -- get the current item
local item = self:current() local item = self:current()
-- get the current config -- get the current config
local config = item:extra("config") local config = item:extra("config")
-- clear new state -- clear new state
config.new = false config.new = false
-- select the boolean config -- select the boolean config
if config.kind == "boolean" then if config.kind == "boolean" then
config.value = enabled config.value = enabled
end end
@@ -200,7 +200,7 @@ end
-- menu config -- menu config
-- - {name = "...", kind = "menu", description = "menu config item", configs = {...}} -- - {name = "...", kind = "menu", description = "menu config item", configs = {...}}
-- --
local config = config or object{new = true, local config = config or object{new = true,
__index = function (tbl, key) __index = function (tbl, key)
if key == "value" then if key == "value" then
local val = rawget(tbl, "_value") local val = rawget(tbl, "_value")
@@ -222,7 +222,7 @@ local config = config or object{new = true,
v:text_set(tostring(tbl)) v:text_set(tostring(tbl))
end end
end end
end} end}
-- the prompt info -- the prompt info
function config:prompt() function config:prompt()
@@ -243,12 +243,12 @@ function config:__tostring()
-- get value -- get value
local value = self.value local value = self.value
-- update text -- update text
if self.kind == "boolean" or (not self.kind and type(value) == "boolean") then -- boolean config? if self.kind == "boolean" or (not self.kind and type(value) == "boolean") then -- boolean config?
text = (value and "[*] " or "[ ] ") .. text text = (value and "[*] " or "[ ] ") .. text
elseif self.kind == "number" or (not self.kind and type(value) == "number") then -- number config? elseif self.kind == "number" or (not self.kind and type(value) == "number") then -- number config?
text = " " .. text .. " (" .. tostring(value or 0) .. ")" text = " " .. text .. " (" .. tostring(value or 0) .. ")"
elseif self.kind == "string" or (not self.kind and type(value) == "string") then -- string config? elseif self.kind == "string" or (not self.kind and type(value) == "string") then -- string config?
text = " " .. text .. " (" .. tostring(value or "") .. ")" text = " " .. text .. " (" .. tostring(value or "") .. ")"
elseif self.kind == "choice" then -- choice config? elseif self.kind == "choice" then -- choice config?

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -76,7 +76,7 @@ local object = { _init = {} }
setmetatable (object, object) setmetatable (object, object)
-- object constructor -- object constructor
-- --
-- @param initial values for fields in -- @param initial values for fields in
-- --
-- @return new object -- @return new object

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -197,8 +197,8 @@ function panel:select(v)
-- get the current selected view -- get the current selected view
local current = self:current() local current = self:current()
if v == current then if v == current then
return return
end end
-- undo the previous selected view -- undo the previous selected view
@@ -233,7 +233,7 @@ function panel:select_next(start, reset)
-- is empty? -- is empty?
if self:empty() then if self:empty() then
return return
end end
-- reset? -- reset?
@@ -259,7 +259,7 @@ function panel:select_prev(start)
-- is empty? -- is empty?
if self:empty() then if self:empty() then
return return
end end
-- reset? -- reset?
@@ -282,10 +282,10 @@ end
-- on event -- on event
function panel:on_event(e) function panel:on_event(e)
-- select view? -- select view?
if e.type == event.ev_keyboard then if e.type == event.ev_keyboard then
-- @note we also use '-' to switch them on termux without right/left and -- @note we also use '-' to switch them on termux without right/left and
-- we cannot use tab, because we still need swith views on windows. e.g. inputdialog -- we cannot use tab, because we still need swith views on windows. e.g. inputdialog
-- @see https://github.com/tboox/ltui/issues/11 -- @see https://github.com/tboox/ltui/issues/11
if e.key_name == "Right" or e.key_name == "-" then if e.key_name == "Right" or e.key_name == "-" then
@@ -293,7 +293,7 @@ function panel:on_event(e)
elseif e.key_name == "Left" then elseif e.key_name == "Left" then
return self:select_prev() return self:select_prev()
end end
end end
end end
-- set state -- set state
@@ -305,7 +305,7 @@ function panel:state_set(name, enable)
return self return self
end end
-- draw panel -- draw panel
function panel:on_draw(transparent) function panel:on_draw(transparent)
-- redraw panel? -- redraw panel?
@@ -327,7 +327,7 @@ function panel:on_draw(transparent)
end end
end end
-- resize panel -- resize panel
function panel:on_resize() function panel:on_resize()
-- resize panel -- resize panel
@@ -347,7 +347,7 @@ function panel:on_refresh()
-- need not refresh? do not refresh it -- need not refresh? do not refresh it
if not self:state("refresh") or not self:state("visible") then if not self:state("refresh") or not self:state("visible") then
return return
end end
-- refresh all child views -- refresh all child views
@@ -373,17 +373,17 @@ end
-- tostring(panel, level) -- tostring(panel, level)
function panel:_tostring(level) function panel:_tostring(level)
local str = "" local str = ""
if self.views then if self.views then
str = str .. string.format("<%s %s>", self:name(), tostring(self:bounds())) str = str .. string.format("<%s %s>", self:name(), tostring(self:bounds()))
if not self:empty() then if not self:empty() then
str = str .. "\n" str = str .. "\n"
end end
for v in self:views() do for v in self:views() do
for l = 1, level do for l = 1, level do
str = str .. " " str = str .. " "
end end
str = str .. panel._tostring(v, level + 1) .. "\n" str = str .. panel._tostring(v, level + 1) .. "\n"
end end
else else
str = tostring(self) str = tostring(self)
end end

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -58,8 +58,8 @@ function program:init(name, argv)
curses.map_keyboard(true) curses.map_keyboard(true)
-- init colors -- init colors
if (curses.has_colors()) then if (curses.has_colors()) then
curses.start_color() curses.start_color()
end end
-- disable main window cursor -- disable main window cursor
@@ -108,7 +108,7 @@ function program:main_window()
-- init main window if not exists -- init main window if not exists
local main_window = self._MAIN_WINDOW local main_window = self._MAIN_WINDOW
if not main_window then if not main_window then
-- init main window -- init main window
main_window = curses.init() main_window = curses.init()
assert(main_window, "cannot init main window!") assert(main_window, "cannot init main window!")
@@ -175,7 +175,7 @@ function program:on_event(e)
return true return true
-- refresh? -- refresh?
elseif e.key_name == "Refresh" then elseif e.key_name == "Refresh" then
self:invalidate() self:invalidate()
return true return true
-- ctrl+c? quit program -- ctrl+c? quit program
elseif e.key_name == "CtrlC" then elseif e.key_name == "CtrlC" then
@@ -191,7 +191,7 @@ end
-- put an event to view -- put an event to view
function program:put_event(e) function program:put_event(e)
-- init event queue -- init event queue
self._EVENT_QUEUE = self._EVENT_QUEUE or {} self._EVENT_QUEUE = self._EVENT_QUEUE or {}
@@ -365,7 +365,7 @@ function program:_input_key()
-- get input character -- get input character
local ch = main_window:getch() local ch = main_window:getch()
if not ch then if not ch then
return return
end end
@@ -397,17 +397,17 @@ function program:_input_key()
end end
-- wait some time, 50ms -- wait some time, 50ms
curses.napms(50) curses.napms(50)
t = t + 50 t = t + 50
end end
-- nothing was typed... return Esc -- nothing was typed... return Esc
if not ch then if not ch then
return 27, "Esc", false return 27, "Esc", false
end end
end end
if ch > 96 and ch < 123 then if ch > 96 and ch < 123 then
ch = ch - 32 ch = ch - 32
end end
end end

View File

@@ -12,7 +12,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -88,7 +88,7 @@ function textarea:scroll(lines)
self._STARTLINE = 0 self._STARTLINE = 0
end end
if self._STARTLINE > self._LINECOUNT - self:height() then if self._STARTLINE > self._LINECOUNT - self:height() then
self._STARTLINE = self._LINECOUNT - self:height() self._STARTLINE = self._LINECOUNT - self:height()
end end
self:invalidate() self:invalidate()
end end
@@ -97,7 +97,7 @@ end
-- scroll to end -- scroll to end
function textarea:scroll_to_end() function textarea:scroll_to_end()
if self._LINECOUNT > self:height() then if self._LINECOUNT > self:height() then
self._STARTLINE = self._LINECOUNT - self:height() self._STARTLINE = self._LINECOUNT - self:height()
self:invalidate() self:invalidate()
end end
end end

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -58,7 +58,7 @@ end
-- on event -- on event
function textdialog:on_event(e) function textdialog:on_event(e)
-- pass event to dialog -- pass event to dialog
if dialog.on_event(self, e) then if dialog.on_event(self, e) then
return true return true

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -97,7 +97,7 @@ function textedit:on_event(e)
end end
-- do textarea event -- do textarea event
return textarea.on_event(self, e) return textarea.on_event(self, e)
end end
-- return module -- return module

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -60,7 +60,7 @@ function view:init(name, bounds)
state.block_cursor = false -- block cursor state.block_cursor = false -- block cursor
state.selected = false -- is selected? state.selected = false -- is selected?
state.focused = false -- is focused? state.focused = false -- is focused?
state.redraw = true -- need redraw state.redraw = true -- need redraw
state.on_refresh = true -- need refresh state.on_refresh = true -- need refresh
state.on_resize = true -- need resize state.on_resize = true -- need resize
self._STATE = state self._STATE = state
@@ -112,7 +112,7 @@ end
-- set window bounds -- set window bounds
function view:bounds_set(bounds) function view:bounds_set(bounds)
if bounds and self:bounds() ~= bounds then if bounds and self:bounds() ~= bounds then
self._BOUNDS = bounds() self._BOUNDS = bounds()
self:invalidate(true) self:invalidate(true)
end end
end end
@@ -142,7 +142,7 @@ function view:parent_set(parent)
self._PARENT = parent self._PARENT = parent
end end
-- get the application -- get the application
function view:application() function view:application()
if not self._APPLICATION then if not self._APPLICATION then
local app = self local app = self
@@ -236,13 +236,13 @@ function view:on_resize()
-- clear mark -- clear mark
self:state_set("resize", false) self:state_set("resize", false)
-- do action -- do action
self:action_on(action.ac_on_resized) self:action_on(action.ac_on_resized)
end end
-- show view? -- show view?
-- --
-- .e.g -- .e.g
-- v:show(false) -- v:show(false)
-- v:show(true, {focused = true}) -- v:show(true, {focused = true})
@@ -269,7 +269,7 @@ function view:invalidate(bounds)
end end
-- on event (abstract) -- on event (abstract)
-- --
-- @return true: done and break dispatching, false/nil: continous to dispatch to other views -- @return true: done and break dispatching, false/nil: continous to dispatch to other views
-- --
function view:on_event(e) function view:on_event(e)
@@ -326,7 +326,7 @@ function view:option_set(name, enable)
-- state is not changed? -- state is not changed?
enable = enable or false enable = enable or false
if self:option(name) == enable then if self:option(name) == enable then
return return
end end
-- set option -- set option
@@ -482,7 +482,7 @@ function view:_mark_refresh()
self:state_set("refresh", true) self:state_set("refresh", true)
end end
-- need refresh it's parent view -- need refresh it's parent view
if self:parent() then if self:parent() then
self:parent():_mark_refresh() self:parent():_mark_refresh()
end end

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -97,12 +97,12 @@ function window:title()
return self._TITLE return self._TITLE
end end
-- get shadow -- get shadow
function window:shadow() function window:shadow()
return self._SHADOW return self._SHADOW
end end
-- get border -- get border
function window:border() function window:border()
if not self._BORDER then if not self._BORDER then
self._BORDER = border:new("window.border", self:frame():bounds()) self._BORDER = border:new("window.border", self:frame():bounds())
@@ -118,7 +118,7 @@ function window:on_event(e)
if e.key_name == "Tab" then if e.key_name == "Tab" then
return self:panel():select_next() return self:panel():select_next()
end end
end end
end end
-- on resize -- on resize

View File

@@ -15,7 +15,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -37,7 +37,7 @@ local demo = application()
-- init demo -- init demo
function demo:init() function demo:init()
-- init name -- init name
application.init(self, "demo") application.init(self, "demo")
-- show desktop, menubar and statusbar -- show desktop, menubar and statusbar

View File

@@ -15,7 +15,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -40,7 +40,7 @@ local demo = application()
-- init demo -- init demo
function demo:init() function demo:init()
-- init name -- init name
application.init(self, "demo") application.init(self, "demo")
-- init background -- init background
@@ -99,9 +99,9 @@ function demo:dialog_input()
dialog_input:frame():background_set("cyan") dialog_input:frame():background_set("cyan")
dialog_input:text():text_set("please input text:"):textattr_set("red") dialog_input:text():text_set("please input text:"):textattr_set("red")
dialog_input:button_add("no", "< No >", function (v) dialog_input:show(false) end) dialog_input:button_add("no", "< No >", function (v) dialog_input:show(false) end)
dialog_input:button_add("yes", "< Yes >", function (v) dialog_input:button_add("yes", "< Yes >", function (v)
self:dialog_main():text():text_set(dialog_input:textedit():text()) self:dialog_main():text():text_set(dialog_input:textedit():text())
dialog_input:show(false) dialog_input:show(false)
end) end)
dialog_input:show(false) dialog_input:show(false)
self._DIALOG_INPUT = dialog_input self._DIALOG_INPUT = dialog_input
@@ -123,7 +123,7 @@ function demo:dialog_tips()
return dialog_tips return dialog_tips
end end
-- on resize -- on resize
function demo:on_resize() function demo:on_resize()
self:dialog_main():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1}) self:dialog_main():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
self:dialog_help():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1}) self:dialog_help():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})

View File

@@ -15,7 +15,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2020, TBOOX Open Source Group. -- Copyright (C) 2020, TBOOX Open Source Group.
-- --
-- @author Lael N. Santos -- @author Lael N. Santos
@@ -37,7 +37,7 @@ local demo = application()
-- init demo -- init demo
function demo:init() function demo:init()
-- init name -- init name
application.init(self, "demo") application.init(self, "demo")
-- init background -- init background
@@ -74,7 +74,7 @@ end
-- on event -- on event
function demo:on_event(e) function demo:on_event(e)
if e.type < event.ev_max then if e.type < event.ev_max then
self:teste():text_set('type: ' .. self:teste():text_set('type: ' ..
tostring(e.type) .. tostring(e.type) ..
'; name: ' .. '; name: ' ..

View File

@@ -15,7 +15,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -38,7 +38,7 @@ local demo = application()
-- init demo -- init demo
function demo:init() function demo:init()
-- init name -- init name
application.init(self, "demo") application.init(self, "demo")
-- init background -- init background

View File

@@ -1,3 +1,3 @@
-- init load directories -- init load directories
package.path = package.path .. ';./src/?.lua' package.path = package.path .. ';./src/?.lua'
package.cpath = package.cpath .. ';./build/ltui.dll;./build/libltui.so;./build/libltui.dylib' package.cpath = package.cpath .. ';./build/ltui.dll;./build/libltui.so;./build/libltui.dylib'

View File

@@ -15,7 +15,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -40,7 +40,7 @@ local demo = application()
-- init demo -- init demo
function demo:init() function demo:init()
-- init name -- init name
application.init(self, "demo") application.init(self, "demo")
-- init background -- init background
@@ -82,7 +82,7 @@ function demo:dialog_mconf()
if not dialog_mconf then if not dialog_mconf then
dialog_mconf = mconfdialog:new("mconfdialog.main", rect{1, 1, self:width() - 1, self:height() - 1}, "menu config") dialog_mconf = mconfdialog:new("mconfdialog.main", rect{1, 1, self:width() - 1, self:height() - 1}, "menu config")
dialog_mconf:action_set(action.ac_on_exit, function (v) self:quit() end) dialog_mconf:action_set(action.ac_on_exit, function (v) self:quit() end)
dialog_mconf:action_set(action.ac_on_save, function (v) dialog_mconf:action_set(action.ac_on_save, function (v)
-- TODO save configs -- TODO save configs
dialog_mconf:quit() dialog_mconf:quit()
end) end)

View File

@@ -15,7 +15,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and -- See the License for the specific language governing permissions and
-- limitations under the License. -- limitations under the License.
-- --
-- Copyright (C) 2015-2020, TBOOX Open Source Group. -- Copyright (C) 2015-2020, TBOOX Open Source Group.
-- --
-- @author ruki -- @author ruki
@@ -36,7 +36,7 @@ local demo = application()
-- init demo -- init demo
function demo:init() function demo:init()
-- init name -- init name
application.init(self, "demo") application.init(self, "demo")
-- init background -- init background

View File

@@ -29,8 +29,8 @@ set_strip("all")
add_cxflags("-fomit-frame-pointer") add_cxflags("-fomit-frame-pointer")
-- for the windows platform (msvc) -- for the windows platform (msvc)
if is_plat("windows") then if is_plat("windows") then
add_cxflags("-MT") add_cxflags("-MT")
add_defines("_CRT_SECURE_NO_WARNINGS") add_defines("_CRT_SECURE_NO_WARNINGS")
add_shflags("-nodefaultlib:msvcrt.lib") add_shflags("-nodefaultlib:msvcrt.lib")
add_links("kernel32", "user32", "gdi32", "advapi32") add_links("kernel32", "user32", "gdi32", "advapi32")
@@ -106,7 +106,7 @@ target("ltui")
-- add lua and do not link it on linux and macos -- add lua and do not link it on linux and macos
local lualinks = nil local lualinks = nil
if is_plat("macosx", "linux", "bsd") then if is_plat("macosx", "linux", "bsd") then
lualinks = {} lualinks = {}
end end
if has_config("luajit") then if has_config("luajit") then
add_defines("LUAJIT") add_defines("LUAJIT")
@@ -114,8 +114,8 @@ target("ltui")
else else
add_packages("lua", {links = lualinks}) add_packages("lua", {links = lualinks})
end end
-- add curses -- add curses
if is_plat("windows") then if is_plat("windows") then
add_defines("PDCURSES") add_defines("PDCURSES")
add_includedirs("src/core/pdcurses") add_includedirs("src/core/pdcurses")