Class: Textbringer::CompletionListMode

Inherits:
Mode
  • Object
show all
Defined in:
lib/textbringer/modes/completion_list_mode.rb

Constant Summary collapse

COMPLETION_LIST_MODE_MAP =
Keymap.new

Constants inherited from Mode

Mode::DEFAULT_SYNTAX_TABLE

Constants included from Commands

Textbringer::Commands::CLIPBOARD_AVAILABLE, Textbringer::Commands::CTAGS, Textbringer::Commands::HELP_RING, Textbringer::Commands::ISEARCH_MODE_MAP, Textbringer::Commands::ISEARCH_STATUS, Textbringer::Commands::KEYBOARD_MACROS, Textbringer::Commands::REGISTERS, Textbringer::Commands::RE_SEARCH_STATUS, Textbringer::Commands::UNIVERSAL_ARGUMENT_MAP

Constants included from Utils

Utils::COMPLETION, Utils::HOOKS, Utils::Y_OR_N_MAP

Instance Attribute Summary

Attributes inherited from Mode

#buffer

Instance Method Summary collapse

Methods inherited from Mode

define_generic_command, define_local_command, define_syntax, inherited, list, #name, #syntax_table

Methods included from Commands

[], #command_help, command_table, #current_prefix_arg, define_command, #execute_keyboard_macro, #get_tags, #isearch_done, #isearch_mode, #isearch_pre_command_hook, #isearch_prompt, #isearch_repeat, #isearch_repeat_backward, #isearch_repeat_forward, #isearch_search, list, #match_beginning, #match_end, #match_string, #number_prefix_arg, #prefix_numeric_value, #read_keyboard_macro, #read_register, #replace_match, undefine_command, #universal_argument_mode

Methods included from Utils

add_hook, background, complete_for_minibuffer, foreground, foreground!, message, read_buffer, read_char, read_command_name, read_encoding, read_event, read_file_name, read_from_minibuffer, read_key_sequence, read_single_char, received_keyboard_quit?, remove_hook, ruby_install_name, run_hooks, self_insert_and_exit_minibuffer, set_transient_map, show_exception, sit_for, sleep_for, y_or_n?, yes_or_no?

Constructor Details

#initialize(buffer) ⇒ CompletionListMode

Returns a new instance of CompletionListMode.



10
11
12
13
# File 'lib/textbringer/modes/completion_list_mode.rb', line 10

def initialize(buffer)
  super(buffer)
  buffer.keymap = COMPLETION_LIST_MODE_MAP
end

Instance Method Details

#choose_completionObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/textbringer/modes/completion_list_mode.rb', line 15

def choose_completion
  unless Window.echo_area.active?
    raise EditorError, "Minibuffer is not active"
  end
  s = @buffer.save_excursion {
    @buffer.beginning_of_line
    @buffer.looking_at?(/.*/)
    @buffer.match_string(0)
  }
  if s.size > 0
    Window.current = Window.echo_area
    complete_minibuffer_with_string(s)
    if COMPLETION[:original_buffer]
      COMPLETION[:completions_window].buffer =
        COMPLETION[:original_buffer]
    end
  end
end