Class: Twterm::Tab::Searchable::Scroller

Inherits:
Twterm::Tab::Scrollable::Scroller show all
Extended by:
Forwardable
Includes:
Publisher
Defined in:
lib/twterm/tab/searchable.rb

Instance Attribute Summary collapse

Attributes inherited from Twterm::Tab::Scrollable::Scroller

#delegate, #index, #offset

Instance Method Summary collapse

Methods included from Publisher

#publish

Methods included from Utils

check_type

Methods inherited from Twterm::Tab::Scrollable::Scroller

#after_move, #current_index?, #current_item, #drawable_items, #item_appended!, #item_prepended!, #move_down, #move_to, #move_to_bottom, #move_to_top, #move_up, #no_cursor_mode?, #nth_item_drawable?, #set_no_cursor_mode!

Constructor Details

#initializeScroller

Returns a new instance of Scroller.



29
30
31
32
# File 'lib/twterm/tab/searchable.rb', line 29

def initialize(*)
  super
  @search_query = ''
end

Instance Attribute Details

#search_queryObject (readonly)

Returns the value of attribute search_query.



21
22
23
# File 'lib/twterm/tab/searchable.rb', line 21

def search_query
  @search_query
end

Instance Method Details

#find_nextObject



34
35
36
37
38
39
# File 'lib/twterm/tab/searchable.rb', line 34

def find_next
  searching_forward!

  search_query_window.render_last_query
  search
end

#find_previousObject



41
42
43
44
45
46
# File 'lib/twterm/tab/searchable.rb', line 41

def find_previous
  searching_backward!

  search_query_window.render_last_query
  search
end

#respond_to_key(key) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/twterm/tab/searchable.rb', line 48

def respond_to_key(key)
  k = KeyMapper.instance

  return if super

  case key
  when k[:tab, :find_next]
    find_next
  when k[:tab, :find_previous]
    find_previous
  when k[:tab, :search_down]
    search_down
  when k[:tab, :search_up]
    search_up
  else
    return false
  end

  true
end

#search_downObject



79
80
81
82
83
84
85
86
87
# File 'lib/twterm/tab/searchable.rb', line 79

def search_down
  searching_down!
  searching_forward!
  ask

  return if search_query.empty?

  find_next
end

#search_upObject



69
70
71
72
73
74
75
76
77
# File 'lib/twterm/tab/searchable.rb', line 69

def search_up
  searching_up!
  searching_forward!
  ask

  return if search_query.empty?

  find_next
end