Sha256: ab4a4acfcbbd6d56cb87f91f18f6830775dff9854ec773970434245b321cece6

Contents?: true

Size: 905 Bytes

Versions: 10

Compression:

Stored size: 905 Bytes

Contents

module Textbringer
  class CompletionListMode < Mode
    define_generic_command :choose_completion

    define_keymap :COMPLETION_LIST_MODE_MAP
    COMPLETION_LIST_MODE_MAP.define_key("\C-m", :choose_completion_command)

    define_syntax :link, /^.+$/

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

    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
textbringer-1.4.1 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.3.0 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.2.0 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.1.2 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.1.1 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.1.0 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.0.9 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.0.4 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.0.3 lib/textbringer/modes/completion_list_mode.rb
textbringer-1.0.2 lib/textbringer/modes/completion_list_mode.rb