diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-06 10:43:35 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-06 10:43:35 -0700 |
commit | 307c1df502bf159995da3a4a0fe63a2a877168c0 (patch) | |
tree | 4419db65b52d386bba843cdf2828e347234f8fbd /hanoi.lua | |
parent | 3e94073a889c65336ceb4d2e59c6ec5d93a04e49 (diff) | |
download | teliva-307c1df502bf159995da3a4a0fe63a2a877168c0.tar.gz |
tweak the example app
Diffstat (limited to 'hanoi.lua')
-rw-r--r-- | hanoi.lua | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/hanoi.lua b/hanoi.lua index d8730bd..7a5a938 100644 --- a/hanoi.lua +++ b/hanoi.lua @@ -31,9 +31,9 @@ end local function render_disk(window, line, col, size) col = col-size+1 for i=1,size do - window:attron(curses.color_pair(1)) + window:attron(curses.color_pair(size)) window:mvaddstr(line, col, " ") - window:attroff(curses.color_pair(1)) + window:attroff(curses.color_pair(size)) col = col+2 end end @@ -42,17 +42,17 @@ local 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) - window:attron(curses.color_pair(2)) + window:attron(curses.color_pair(7)) window:mvaddstr(line+1, col-6, " ") - window:attroff(curses.color_pair(2)) + window:attroff(curses.color_pair(7)) for i, n in ipairs(tower) do render_disk(window, line, col, n) line = line - 1 end for i=1,5-len(tower)+1 do - window:attron(curses.color_pair(2)) + window:attron(curses.color_pair(7)) window:mvaddstr(line, col, " ") - window:attroff(curses.color_pair(2)) + window:attroff(curses.color_pair(7)) line = line - 1 end end @@ -90,8 +90,9 @@ end local function main() local window = curses.initscr() curses.start_color() - curses.init_pair(1, 0, 2) - curses.init_pair(2, 0, 8) + for i=1,7 do + curses.init_pair(i, 0, i) + end while true do render(window) |