Skip to content
Kward Search API index

Class: Kward::PromptInterface::VibeEditorState

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/prompt_interface/editor/vibe_state.rb

Overview

Modal Vibe editor state for one editor buffer.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(editor_mode: "modern") ⇒ VibeEditorState

Returns a new instance of VibeEditorState.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 11

def initialize(editor_mode: "modern")
  @mode = editor_mode == "vibe" ? "normal" : nil
  @pending = ""
  @command = ""
  @last_change = nil
  @last_find = nil
  @last_visual_selection = nil
  @visual_block_insert = nil
  @marks = {}
  @registers = {}
  @macros = {}
  @recording_macro = nil
  @last_macro = nil
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



7
8
9
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 7

def command
  @command
end

#last_changeObject

Returns the value of attribute last_change.



7
8
9
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 7

def last_change
  @last_change
end

#last_findObject

Returns the value of attribute last_find.



7
8
9
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 7

def last_find
  @last_find
end

#last_macroObject

Returns the value of attribute last_macro.



9
10
11
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 9

def last_macro
  @last_macro
end

#last_visual_selectionObject

Returns the value of attribute last_visual_selection.



8
9
10
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 8

def last_visual_selection
  @last_visual_selection
end

#macrosObject

Returns the value of attribute macros.



9
10
11
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 9

def macros
  @macros
end

#marksObject

Returns the value of attribute marks.



9
10
11
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 9

def marks
  @marks
end

#modeObject

Returns the value of attribute mode.



7
8
9
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 7

def mode
  @mode
end

#pendingObject

Returns the value of attribute pending.



7
8
9
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 7

def pending
  @pending
end

#recording_macroObject

Returns the value of attribute recording_macro.



9
10
11
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 9

def recording_macro
  @recording_macro
end

#registersObject

Returns the value of attribute registers.



9
10
11
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 9

def registers
  @registers
end

#visual_block_insertObject

Returns the value of attribute visual_block_insert.



8
9
10
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 8

def visual_block_insert
  @visual_block_insert
end

Class Method Details

.copy(other) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kward/prompt_interface/editor/vibe_state.rb', line 26

def self.copy(other)
  state = new(editor_mode: other.mode ? "vibe" : "modern")
  state.mode = other.mode&.dup
  state.pending = other.pending.dup
  state.command = other.command.dup
  state.last_change = other.last_change&.dup
  state.last_find = other.last_find&.dup
  state.last_visual_selection = other.last_visual_selection&.dup
  state.visual_block_insert = other.visual_block_insert&.dup
  state.marks = other.marks.transform_values(&:dup)
  state.registers = other.registers.transform_values(&:dup)
  state.macros = other.macros.transform_values(&:dup)
  state.recording_macro = other.recording_macro
  state.last_macro = other.last_macro
  state
end