~lucasemmoreira/hitter

e5936a7a5068589c113fd4e890a4591fd37cf743 — Lucas Moreira 2 years ago 6e101a0
add: top message and quit case
1 files changed, 5 insertions(+), 6 deletions(-)

M src/tui.janet
M src/tui.janet => src/tui.janet +5 -6
@@ 10,18 10,16 @@

(defn run-ui [[names urls]]
  (nc/initscr)

  (nc/cbreak)

  (nc/noecho)

  (nc/keypad (nc/stdscr) true)
  
  (def url-status (fiber/new (fn []
			       (while true
				 (yield (map (fn [status] (string status))
					     (hit/status-urls urls)))))))

  (nc/mvwprintw (nc/stdscr) 1 1 "Press 'q' to leave. And any other key to update the table")
  (nc/refresh)
  (var status (map (fn [url] "checking...") urls))
  (var menu-win (nc/newwin 10 40 4 4))
  (nc/box menu-win 0 0)


@@ 30,8 28,9 @@
  (while true
    (var status (resume url-status))
    (build-win menu-win names status)
    (let [c (nc/wgetch menu-win)]
    (let [c (nc/getch)]
      (nc/printw (string c))
      (case c 
	"q" (nc/endwin))))
	113 (break)))) # 113 is the letter q

  (nc/endwin))