From 32517f428cf47a7df77d0681eb6929cf9db3296e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 23 Nov 2021 22:02:22 -0800 Subject: [PATCH] consistent style --- counter.tlv | 9 +++------ hanoi.tlv | 30 ++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/counter.tlv b/counter.tlv index 036f412..50e5194 100644 --- a/counter.tlv +++ b/counter.tlv @@ -11,8 +11,7 @@ function render(window) window:attroff(curses.color_pair(6)) window:attroff(curses.A_BOLD) curses.refresh() -end - ]==], +end]==], menu = [==[menu = {Enter="increment"}]==], update = [==[ function update(window) @@ -20,8 +19,7 @@ function update(window) if key == 10 then n = n+1 end -end - ]==], +end]==], main = [==[ function main() for i=1,7 do @@ -32,6 +30,5 @@ function main() render(window) update(window) end -end - ]==], +end]==], } diff --git a/hanoi.tlv b/hanoi.tlv index 28efbdc..502941d 100644 --- a/hanoi.tlv +++ b/hanoi.tlv @@ -1,5 +1,6 @@ teliva_program = { - render = [==[function render(window) + render = [==[ +function render(window) window:clear() local lines, cols = window:getmaxyx() local line = math.floor(lines/2) @@ -9,15 +10,18 @@ teliva_program = { end curses.refresh() end]==], - lines = [==[function lines(window) + lines = [==[ +function lines(window) local lines, cols = window:getmaxyx() return lines end]==], - pop = [==[function pop(array) + pop = [==[ +function pop(array) return table.remove(array) end]==], window = [==[window = curses.stdscr()]==], - render_tower = [==[function render_tower(window, line, col, tower_index, tower) + render_tower = [==[ +function render_tower(window, line, col, tower_index, tower) window:attron(curses.A_BOLD) window:mvaddch(line+2, col, string.char(96+tower_index)) window:attroff(curses.A_BOLD) @@ -36,7 +40,8 @@ end]==], end end]==], tower = [==[tower = {{6, 5, 4, 3, 2}, {}, {}}]==], - render_disk = [==[function render_disk(window, line, col, size) + render_disk = [==[ +function render_disk(window, line, col, size) col = col-size+1 for i=1,size do window:attron(curses.color_pair(size)) @@ -45,7 +50,8 @@ end]==], col = col+2 end end]==], - main = [==[function main() + main = [==[ +function main() for i=1,7 do curses.init_pair(i, 0, i) end @@ -56,25 +62,29 @@ end]==], end end ]==], - len = [==[function len(array) + len = [==[ +function len(array) local result = 0 for k in pairs(array) do result = result+1 end return result end]==], - update = [==[function update(window) + update = [==[ +function update(window) window:mvaddstr(lines(window)-2, 5, "tower to remove top disk from? ") local from = curses.getch() - 96 window:mvaddstr(lines(window)-1, 5, "tower to stack it on? ") local to = curses.getch() - 96 make_move(from, to) end]==], - make_move = [==[function make_move(from, to) + make_move = [==[ +function make_move(from, to) local disk = pop(tower[from]) table.insert(tower[to], disk) end]==], - cols = [==[function cols(window) + cols = [==[ +function cols(window) local lines, cols = window:getmaxyx() return cols end]==],