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.



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

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

Instance Attribute Details

#search_queryObject (readonly)

Returns the value of attribute search_query.



27
28
29
# File 'lib/twterm/tab/searchable.rb', line 27

def search_query
  @search_query
end

Instance Method Details

#find_nextObject



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

def find_next
  searching_forward!

  search_query_window.render_last_query
  search
end

#find_previousObject



47
48
49
50
51
52
# File 'lib/twterm/tab/searchable.rb', line 47

def find_previous
  searching_backward!

  search_query_window.render_last_query
  search
end

#respond_to_key(key) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/twterm/tab/searchable.rb', line 54

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



85
86
87
88
89
90
91
92
93
# File 'lib/twterm/tab/searchable.rb', line 85

def search_down
  searching_down!
  searching_forward!
  ask

  return if search_query.empty?

  find_next
end

#search_upObject



75
76
77
78
79
80
81
82
83
# File 'lib/twterm/tab/searchable.rb', line 75

def search_up
  searching_up!
  searching_forward!
  ask

  return if search_query.empty?

  find_next
end