diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-05 17:48:09 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-05 17:48:09 -0700 |
commit | 18f06a5169951b4f7d5dc57720c6204672ae8f09 (patch) | |
tree | 9a1f97cce9a65a0f88f940aae6046f855a9b847f /hanoi.lua | |
parent | 1757de9df601748fab29f243be776caaa552146f (diff) | |
download | teliva-18f06a5169951b4f7d5dc57720c6204672ae8f09.tar.gz |
rename 'screen' to 'window'
We're going to set aside a portion of the screen soon that apps can't touch.
Diffstat (limited to 'hanoi.lua')
-rw-r--r-- | hanoi.lua | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/hanoi.lua b/hanoi.lua index c9c0158..9a8c9aa 100644 --- a/hanoi.lua +++ b/hanoi.lua @@ -28,29 +28,29 @@ local function cols(window) end -local function render_tower(screen, line, col, tower_index, tower) - screen:attron(curses.A_BOLD) - screen:mvaddch(line+2, col, string.char(96+tower_index)) - screen:attroff(curses.A_BOLD) - screen:mvaddstr(line+1, col-3, "-------") +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:mvaddstr(line+1, col-3, "-------") for i, n in ipairs(tower) do - screen:mvaddstr(line, col, n) + window:mvaddstr(line, col, n) line = line - 1 end for i=1,5-len(tower) do - screen:mvaddstr(line, col, "|") + window:mvaddstr(line, col, "|") line = line - 1 end end -local function render(screen) - screen:clear() - local lines, cols = screen:getmaxyx() +local function render(window) + window:clear() + local lines, cols = window:getmaxyx() local line = math.floor(lines/2) local col = math.floor(cols/4) for i,t in ipairs(tower) do - render_tower(screen, line, i*col, i, t) + render_tower(window, line, i*col, i, t) end end @@ -61,11 +61,11 @@ local function make_move(from, to) end -local function update(screen) - screen:mvaddstr(lines(screen)-2, 5, "tower to remove top disk from? ") +local function update(window) + window:mvaddstr(lines(window)-2, 5, "tower to remove top disk from? ") local from = string.byte(curses.getch()) - 96 curses.refresh() - screen:mvaddstr(lines(screen)-1, 5, "tower to stack it on? ") + window:mvaddstr(lines(window)-1, 5, "tower to stack it on? ") local to = string.byte(curses.getch()) - 96 curses.refresh() make_move(from, to) @@ -73,11 +73,11 @@ end local function main() - local screen = curses.initscr() + local window = curses.initscr() while true do - render(screen) - update(screen) + render(window) + update(window) end curses.endwin() |