Module: TabScroll
- Defined in:
- lib/tabscroll.rb,
lib/tabscroll/version.rb
Overview
The main program.
Note that we expect a global hash ‘$settings`. It contains settings from the commandline argument parser (Settings class).
Constant Summary collapse
- VERSION =
'1.1.0'
Class Method Summary collapse
-
.run(filename) ⇒ Object
Starts the Curses engine and parses ‘filename`, finally displaying things onscreen.
-
.show_help_window ⇒ Object
Displays a help window that waits for a keypress.
Class Method Details
.run(filename) ⇒ Object
Starts the Curses engine and parses ‘filename`, finally displaying things onscreen.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/tabscroll.rb', line 18 def self.run filename if not File.exists? filename puts "Error: File '#{filename}' doesn't exist." exit 69 end @engine = Engine.new if not @engine puts "Error: Failed to start Curses!" exit 1337 end @engine.timeout 10 win = Screen.new(0, 1, @engine.width, @engine.height - 2) track = Track.new win track.load filename track.auto_scroll true = Screen.new(0, 0, @engine.width, 1) = Screen.new(0, (@engine.height - 1), @engine.width, 1) = false finished = false while not finished # WHY DOES GETCH CLEARS UP THE WHOLE SCREEN? # IT DOESNT MAKE ANY SENSE c = @engine.getchar case c when 'e' track.end when 'a' track.begin when 'h' show_help_window when 'o' = ( ? false : true) Curses::clear when '<' track.scroll -10 when '>' track.scroll 10 when Curses::KEY_LEFT track.speed -= 1 when Curses::KEY_RIGHT track.speed += 1 when Curses::KEY_DOWN, Curses::KEY_UP, ' ' track.speed = 0 when 'q' @engine.exit exit end track.update track.show if not .mvaddstr(0, 0, "#{File.basename filename} (#{track.percent_completed}%) ", Engine::Colors[:cyan]) .mvaddstr_right(0, " Speed: #{track.speed}", Engine::Colors[:cyan]) .mvaddstr_left(0, "tabscroll v#{VERSION} - press `h` for help", Engine::Colors[:green]) end end @engine.exit return nil end |
.show_help_window ⇒ Object
Displays a help window that waits for a keypress.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/tabscroll.rb', line 87 def self.show_help_window title = 'Help' text = <<END_OF_TEXT q quit h help/go back left/right auto-scroll left/right up/down/space bar stop auto-scrolling </> step scroll left/right o toggle status/title bars _|_ _. |_ _ _ ._ _ | | |_ (_| |_) _> (_ | (_) | | #{VERSION} homepage alexdantas.net/projects/tabscroll author Alexandre Dantas <[email protected]> END_OF_TEXT pop = Popup.new(title, text) will_quit = pop.show if will_quit @engine.exit exit end end |