Class: Textbringer::MinorMode

Inherits:
Object
  • Object
show all
Extended by:
Commands
Includes:
Commands
Defined in:
lib/textbringer/minor_mode.rb

Direct Known Subclasses

OverwriteMode

Constant Summary

Constants included from Commands

Commands::CLIPBOARD_AVAILABLE, Commands::CTAGS, Commands::HELP_RING, Commands::ISEARCH_STATUS, Commands::KEYBOARD_MACROS, Commands::REGISTERS, Commands::RE_SEARCH_STATUS

Constants included from Utils

Utils::COMPLETION, Utils::EXPRESSION_COMPLETOR, Utils::EXPRESSION_COMPLETOR_OPTIONS, Utils::HOOKS

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Commands

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

Methods included from Utils

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

Constructor Details

#initialize(buffer) ⇒ MinorMode

Returns a new instance of MinorMode.



27
28
29
# File 'lib/textbringer/minor_mode.rb', line 27

def initialize(buffer)
  @buffer = buffer
end

Class Attribute Details

.command_nameObject

Returns the value of attribute command_name.



8
9
10
# File 'lib/textbringer/minor_mode.rb', line 8

def command_name
  @command_name
end

.mode_nameObject

Returns the value of attribute mode_name.



7
8
9
# File 'lib/textbringer/minor_mode.rb', line 7

def mode_name
  @mode_name
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



25
26
27
# File 'lib/textbringer/minor_mode.rb', line 25

def buffer
  @buffer
end

Class Method Details

.inherited(child) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/textbringer/minor_mode.rb', line 11

def self.inherited(child)
  base_name = child.name.slice(/[^:]*\z/)
  child.mode_name = base_name.sub(/Mode\z/, "")
  command_name = base_name.sub(/\A[A-Z]/) { |s| s.downcase }.
    gsub(/(?<=[a-z])([A-Z])/) {
      "_" + $1.downcase
    }
  command = command_name.intern
  child.command_name = command
  define_command(command) do
    Buffer.current.toggle_minor_mode(child)
  end
end

Instance Method Details

#nameObject



31
32
33
# File 'lib/textbringer/minor_mode.rb', line 31

def name
  self.class.mode_name
end