Class: SearchTerm

Inherits:
Object show all
Defined in:
lib/xiki/search_term.rb

Constant Summary collapse

@@last_dash_search =
""

Class Method Summary collapse

Class Method Details

.keysObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xiki/search_term.rb', line 9

def self.keys
  $el.define_key :isearch_mode_map, $el.kbd("C--") do  # During isearch, remember current search term
    $el.isearch_done
    $el.isearch_clean_overlays
    match = $el.buffer_substring $el.match_beginning(0), $el.match_end(0)
    @@last_dash_search = match
  end
  Keys.set("C--") do
    started = $el.point
    chars = @@last_dash_search.size
    # Go to it
    $el.search_forward @@last_dash_search
    # Go forward again if you were already at it
    $el.search_forward @@last_dash_search if started == $el.point - chars
    # Back up to beginning
    $el.backward_char chars
  end
end

.timed_searchObject

Does an isearch on the characters typed, until the user pauses more than .4 seconds



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/xiki/search_term.rb', line 28

def self.timed_search

#    isearch_forward
  c = $el.read_char "search: "
#    keys = self.to_letter(keys)
  $el.call_interactively $el.key_binding(c)
  while(c = $el.read_char("Input: ", nil, 0.40))
    $el.call_interactively $el.key_binding(c)
  end

end