118 lines
3.4 KiB
Lua
118 lines
3.4 KiB
Lua
# .tlv file generated by https://github.com/akkartik/teliva
|
|
# You may edit it if you are careful; however, you may see cryptic errors if you
|
|
# violate Teliva's assumptions.
|
|
#
|
|
# .tlv files are representations of Teliva programs. Teliva programs consist of
|
|
# sequences of definitions. Each definition is a table of key/value pairs. Keys
|
|
# and values are both strings.
|
|
#
|
|
# Lines in .tlv files always follow exactly one of the following forms:
|
|
# - comment lines at the top of the file starting with '#' at column 0
|
|
# - beginnings of definitions starting with '- ' at column 0, followed by a
|
|
# key/value pair
|
|
# - key/value pairs consisting of ' ' at column 0, containing either a
|
|
# spaceless value on the same line, or a multi-line value
|
|
# - multiline values indented by more than 2 spaces, starting with a '>'
|
|
#
|
|
# If these constraints are violated, Teliva may unceremoniously crash. Please
|
|
# report bugs at http://akkartik.name/contact
|
|
- __teliva_timestamp: original
|
|
str_helpers:
|
|
>-- some string helpers from http://lua-users.org/wiki/StringIndexing
|
|
>
|
|
>-- index characters using []
|
|
>getmetatable('').__index = function(str,i)
|
|
> if type(i) == 'number' then
|
|
> return str:sub(i,i)
|
|
> else
|
|
> return string[i]
|
|
> end
|
|
>end
|
|
>
|
|
>-- ranges using (), selected bytes using {}
|
|
>getmetatable('').__call = function(str,i,j)
|
|
> if type(i)~='table' then
|
|
> return str:sub(i,j)
|
|
> else
|
|
> local t={}
|
|
> for k,v in ipairs(i) do
|
|
> t[k]=str:sub(v,v)
|
|
> end
|
|
> return t:concat()
|
|
> end
|
|
>end
|
|
>
|
|
>-- iterate over an ordered sequence
|
|
>function q(x)
|
|
> if type(x) == 'string' then
|
|
> return x:gmatch('.')
|
|
> else
|
|
> return ipairs(x)
|
|
> end
|
|
>end
|
|
>
|
|
>-- insert within string
|
|
>function string.insert(str1, str2, pos)
|
|
> return str1:sub(1,pos)..str2..str1:sub(pos+1)
|
|
>end
|
|
>
|
|
>function string.remove(s, pos)
|
|
> return s:sub(1,pos-1)..s:sub(pos+1)
|
|
>end
|
|
>
|
|
>-- TODO: backport utf-8 support from Lua 5.3
|
|
- __teliva_timestamp: original
|
|
menu:
|
|
>-- To show app-specific hotkeys in the menu bar, add hotkey/command
|
|
>-- arrays of strings to the menu array.
|
|
>menu = {}
|
|
- __teliva_timestamp: original
|
|
Window:
|
|
>Window = curses.stdscr()
|
|
- __teliva_timestamp: original
|
|
render:
|
|
>function render(window)
|
|
> window:clear()
|
|
> for f in lfs.dir('.') do
|
|
> if f ~= '.' and f ~= '..' then
|
|
> local attr = lfs.attributes(f)
|
|
> print(f, attr.permissions, attr.size, attr.access, attr.modification)
|
|
> end
|
|
> end
|
|
> window:refresh()
|
|
>end
|
|
- __teliva_timestamp: original
|
|
update:
|
|
>function update(window)
|
|
> local key = window:getch()
|
|
> -- process key here
|
|
>end
|
|
- __teliva_timestamp: original
|
|
init_colors:
|
|
>function init_colors()
|
|
> for i=0,7 do
|
|
> curses.init_pair(i, i, -1)
|
|
> end
|
|
> curses.init_pair(8, 7, 0)
|
|
> curses.init_pair(9, 7, 1)
|
|
> curses.init_pair(10, 7, 2)
|
|
> curses.init_pair(11, 7, 3)
|
|
> curses.init_pair(12, 7, 4)
|
|
> curses.init_pair(13, 7, 5)
|
|
> curses.init_pair(14, 7, 6)
|
|
> curses.init_pair(15, -1, 15)
|
|
>end
|
|
- __teliva_timestamp: original
|
|
main:
|
|
>function main()
|
|
> init_colors()
|
|
>
|
|
> while true do
|
|
> render(Window)
|
|
> update(Window)
|
|
> end
|
|
>end
|
|
- __teliva_timestamp: original
|
|
doc:blurb:
|
|
>beginnings of a file browser..
|