teliva/template.tlv

70 lines
2.2 KiB
Lua
Raw Normal View History

# .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
window:
>window = curses.stdscr()
- __teliva_timestamp: original
render:
>function render(window)
> window:clear()
> -- draw stuff to screen here
> window:attron(curses.A_BOLD)
> window:mvaddstr(1, 5, "example app")
> window:attrset(curses.A_NORMAL)
> for i=0,15 do
> window:attrset(curses.color_pair(i))
> window:mvaddstr(3+i, 5, "========================")
> end
> curses.refresh()
>end
- __teliva_timestamp: original
menu:
>menu = {}
- __teliva_timestamp: original
update:
>function update(window)
> local key = curses.getch()
> -- process key here
>end
2021-12-16 10:52:52 +00:00
- __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
- main:
>function main()
> init_colors()
>
> while true do
> render(window)
> update(window)
> end
>end
__teliva_timestamp: original