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")
-- add source files
add_files("lcurses.c", {languages = "c99", cflags = "-Wno-expansion-to-defined"})
-- add source files
add_files("lcurses.c", {languages = "c99", cflags = "-Wno-expansion-to-defined"})

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @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")
-- init buttons
self:button_add("select", "< Select >", function (v, e)
self:choicebox():on_event(event.command {"cm_enter"})
self:button_add("select", "< Select >", function (v, e)
self:choicebox():on_event(event.command {"cm_enter"})
self:quit()
end)
self:button_add("cancel", "< Cancel >", function (v, e)
self:button_add("cancel", "< Cancel >", function (v, e)
self:quit()
end)
self:buttons():select(self:button("select"))
@@ -82,7 +82,7 @@ function choicedialog:on_event(e)
return self:choicebox():on_event(e)
end
end
return boxdialog.on_event(self, e)
return boxdialog.on_event(self, e)
end
-- return module

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,7 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
@@ -42,7 +42,7 @@ function mconfdialog:init(name, bounds, title)
boxdialog.init(self, name, bounds, title)
-- 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
]])
@@ -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("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("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:buttons():select(self:button("select"))
@@ -144,7 +144,7 @@ function mconfdialog:inputdialog()
dialog_input:background_set(self:frame():background())
dialog_input:frame():background_set("cyan")
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")
if config.kind == "string" then
config.value = dialog_input:textedit():text()
@@ -154,9 +154,9 @@ function mconfdialog:inputdialog()
config.value = value
end
end
dialog_input:quit()
dialog_input:quit()
end)
dialog_input:button_add("cancel", "< Cancel >", function (v)
dialog_input:button_add("cancel", "< Cancel >", function (v)
dialog_input:quit()
end)
dialog_input:button_select("ok")
@@ -185,7 +185,7 @@ function mconfdialog:searchdialog()
dialog_search:frame():background_set("cyan")
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: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 results = "Search('" .. dialog_search:textedit():text() .. "') results:"
for _, config in ipairs(configs) do
@@ -205,9 +205,9 @@ function mconfdialog:searchdialog()
results = results .. "\n"
end
self:show_result(results)
dialog_search:quit()
dialog_search:quit()
end)
dialog_search:button_add("cancel", "< Cancel >", function (v)
dialog_search:button_add("cancel", "< Cancel >", function (v)
dialog_search:quit()
end)
dialog_search:button_select("ok")
@@ -237,7 +237,7 @@ function mconfdialog:show_help()
-- get the current config item
local item = self:menuconf():current()
-- get the current config
local config = item:extra("config")
@@ -307,7 +307,7 @@ function mconfdialog:on_event(e)
return true
end
end
return boxdialog.on_event(self, e)
return boxdialog.on_event(self, e)
end
-- on resize

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,3 +1,3 @@
-- init load directories
-- init load directories
package.path = package.path .. ';./src/?.lua'
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.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
@@ -40,7 +40,7 @@ local demo = application()
-- init demo
function demo:init()
-- init name
-- init name
application.init(self, "demo")
-- init background
@@ -82,7 +82,7 @@ function demo:dialog_mconf()
if not dialog_mconf then
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_save, function (v)
dialog_mconf:action_set(action.ac_on_save, function (v)
-- TODO save configs
dialog_mconf:quit()
end)

View File

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

View File

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