Top Level Namespace
Defined Under Namespace
Instance Method Summary collapse
- #display_list(search_term, matches, id = 0) ⇒ Object
- #get_input ⇒ Object
- #get_matching_notes(search_term) ⇒ Object
Instance Method Details
#display_list(search_term, matches, id = 0) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/qv/qv.rb', line 48 def display_list(search_term, matches, id = 0) system("clear") puts "#{search_term}: #{matches.count}" notes = matches.take(IO.console.winsize.first-2) puts notes.map {|note| if notes.index(note) == id "* #{note.title}" else note.title end } end |
#get_input ⇒ Object
16 17 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 |
# File 'lib/qv/qv.rb', line 16 def get_input search_term = "" io = IO.console position = 0 returned = false until returned char = io.getch case char when "\u007F" # backspace search_term.slice!(-1) when "\u0003" # C-c exit when "\e" # esc exit when "\u0015" # C-u search_term.replace "" when "\r" # hard return returned = true when "\n" # C-j position = position + 1 when "\v" # C-k position = position - 1 else search_term << char end matches = Note.sort_notes_by_date(get_matching_notes(search_term)) display_list(search_term, matches, position) end matches[position] end |