Class: Totpc::Window
Overview
curses window to show codes
Instance Method Summary collapse
- #close ⇒ Object
- #getch ⇒ Object
- #init_curses ⇒ Object
- #show_curses(secrets, totp) ⇒ Object
- #show_header_footer ⇒ Object
- #show_message(x, y, message) ⇒ Object
- #show_remaining ⇒ Object
Instance Method Details
#close ⇒ Object
43 44 45 |
# File 'lib/totpc/window.rb', line 43 def close close_screen end |
#getch ⇒ Object
39 40 41 |
# File 'lib/totpc/window.rb', line 39 def getch Curses.getch end |
#init_curses ⇒ Object
7 8 9 10 11 |
# File 'lib/totpc/window.rb', line 7 def init_curses init_screen Curses.timeout = 1000 crmode end |
#show_curses(secrets, totp) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/totpc/window.rb', line 13 def show_curses(secrets, totp) ypos = 2 secrets.each do |secret| (ypos, 0, secret[:id] + ' : ' + totp[secret[:id]].now) ypos += 1 end refresh end |
#show_header_footer ⇒ Object
24 25 26 27 |
# File 'lib/totpc/window.rb', line 24 def (lines - 1, cols - 20, 'Hit any key to quit') show_remaining end |
#show_message(x, y, message) ⇒ Object
29 30 31 32 |
# File 'lib/totpc/window.rb', line 29 def (x, y, ) setpos(x, y) addstr() end |
#show_remaining ⇒ Object
34 35 36 37 |
# File 'lib/totpc/window.rb', line 34 def show_remaining count = 30 - Time.now.to_i % 30 (0, 0, 'remaining ' + format('%02d', count)) end |