Class: DynamicCursesInput::CharacterDeleter

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamic_curses_input/input_handler.rb

Overview

Class for deleting characters

Class Method Summary collapse

Class Method Details

.delete(input, cursor_pos) ⇒ Object

Delete character at cursor position



137
138
139
140
141
142
143
# File 'lib/dynamic_curses_input/input_handler.rb', line 137

def self.delete(input, cursor_pos)
  if cursor_pos.positive?
    input = input[0...cursor_pos - 1] + input[cursor_pos..]
    cursor_pos -= 1
  end
  [input, cursor_pos]
end