Module: Textbringer::Commands
- Includes:
- Utils
- Included in:
- Mode, Mode
- Defined in:
- lib/textbringer/commands.rb
Constant Summary
collapse
- RE_SEARCH_STATUS =
{
last_regexp: nil
}
- UNIVERSAL_ARGUMENT_MAP =
Keymap.new
- ISEARCH_MODE_MAP =
Keymap.new
- ISEARCH_STATUS =
{
forward: true,
string: "",
last_string: "",
start: 0,
last_pos: 0
}
- @@command_list =
[]
Constants included
from Utils
Utils::HOOKS, Utils::Y_OR_N_MAP
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
#add_hook, #complete, #handle_exception, #message, #read_buffer, #read_char, #read_command_name, #read_file_name, #read_from_minibuffer, #read_single_char, #received_keyboard_quit?, #remove_hook, #run_hooks, #self_insert_and_exit_minibuffer, #set_transient_map, #sit_for, #sleep_for, #y_or_n?, #yes_or_no?
Class Method Details
.define_command(name, &block) ⇒ Object
16
17
18
19
|
# File 'lib/textbringer/commands.rb', line 16
def define_command(name, &block)
Commands.send(:define_method, name, &block)
@@command_list << name if !@@command_list.include?(name)
end
|
.list ⇒ Object
12
13
14
|
# File 'lib/textbringer/commands.rb', line 12
def self.list
@@command_list
end
|
.undefine_command(name) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/textbringer/commands.rb', line 22
def undefine_command(name)
if @@command_list.include?(name)
Commands.send(:undef_method, name)
@@command_list.delete(name)
end
end
|
Instance Method Details
#current_prefix_arg ⇒ Object
421
422
423
|
# File 'lib/textbringer/commands.rb', line 421
def current_prefix_arg
Controller.current.current_prefix_arg
end
|
#isearch_mode(forward) ⇒ Object
#isearch_pre_command_hook ⇒ Object
547
548
549
550
551
|
# File 'lib/textbringer/commands.rb', line 547
def isearch_pre_command_hook
if /\Aisearch_/ !~ Controller.current.this_command
isearch_done
end
end
|
#isearch_prompt ⇒ Object
539
540
541
542
543
544
545
|
# File 'lib/textbringer/commands.rb', line 539
def isearch_prompt
if ISEARCH_STATUS[:forward]
"I-search: "
else
"I-search backward: "
end
end
|
#isearch_repeat(forward) ⇒ Object
#isearch_repeat_backward ⇒ Object
610
611
612
|
# File 'lib/textbringer/commands.rb', line 610
def isearch_repeat_backward
isearch_repeat(false)
end
|
#isearch_repeat_forward ⇒ Object
606
607
608
|
# File 'lib/textbringer/commands.rb', line 606
def isearch_repeat_forward
isearch_repeat(true)
end
|
#match_beginning(n) ⇒ Object
128
129
130
|
# File 'lib/textbringer/commands.rb', line 128
def match_beginning(n)
Buffer.current.match_beginning(n)
end
|
#match_end(n) ⇒ Object
132
133
134
|
# File 'lib/textbringer/commands.rb', line 132
def match_end(n)
Buffer.current.match_end(n)
end
|
#match_string(n) ⇒ Object
136
137
138
|
# File 'lib/textbringer/commands.rb', line 136
def match_string(n)
Buffer.current.match_string(n)
end
|
#number_prefix_arg ⇒ Object
425
426
427
428
429
430
431
432
433
434
435
436
437
|
# File 'lib/textbringer/commands.rb', line 425
def number_prefix_arg
arg = current_prefix_arg
case arg
when Integer
arg
when Array
arg.first
when :-
-1
else
1
end
end
|
#replace_match(s) ⇒ Object
140
141
142
|
# File 'lib/textbringer/commands.rb', line 140
def replace_match(s)
Buffer.current.replace_match(s)
end
|
#universal_argument_mode ⇒ Object
412
413
414
|
# File 'lib/textbringer/commands.rb', line 412
def universal_argument_mode
set_transient_map(UNIVERSAL_ARGUMENT_MAP)
end
|