Class: Textbringer::MinorMode
- Inherits:
-
Object
- Object
- Textbringer::MinorMode
- Extended by:
- Commands
- Includes:
- Commands
- Defined in:
- lib/textbringer/minor_mode.rb
Direct Known Subclasses
Constant Summary
Constants included from Commands
Commands::CLIPBOARD_AVAILABLE, Commands::CTAGS, Commands::EMAIL_REGEXP, Commands::HELP_RING, Commands::ISEARCH_STATUS, Commands::ISPELL_STATUS, Commands::ISPELL_WORD_REGEXP, Commands::KEYBOARD_MACROS, Commands::REGISTERS, Commands::RE_SEARCH_STATUS, Commands::URI_REGEXP
Constants included from Utils
Utils::COMPLETION, Utils::EXPRESSION_COMPLETOR, Utils::EXPRESSION_COMPLETOR_OPTIONS, Utils::HOOKS
Class Attribute Summary collapse
-
.command_name ⇒ Object
Returns the value of attribute command_name.
-
.mode_name ⇒ Object
Returns the value of attribute mode_name.
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(buffer) ⇒ MinorMode
constructor
A new instance of MinorMode.
- #name ⇒ Object
Methods included from Commands
[], command_help, command_table, current_prefix_arg, define_command, ensure_ispell_active, 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, ispell_done, ispell_forward, ispell_mode, keymap_bindings, list, match_beginning, match_end, match_string, message_misspelled, 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, delete_completions_window, 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.
30 31 32 |
# File 'lib/textbringer/minor_mode.rb', line 30 def initialize(buffer) @buffer = buffer end |
Class Attribute Details
.command_name ⇒ Object
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_name ⇒ Object
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
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
28 29 30 |
# File 'lib/textbringer/minor_mode.rb', line 28 def buffer @buffer end |
Class Method Details
.inherited(child) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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, doc: "Enable or disable #{command_name}. " \ "Toggle the mode if arg is nil. " \ "Enable the mode if arg is true. " \ "Disable the mode if arg is false") do |arg = nil| Buffer.current.set_minor_mode(child, arg) end end |
Instance Method Details
#name ⇒ Object
34 35 36 |
# File 'lib/textbringer/minor_mode.rb', line 34 def name self.class.mode_name end |