1 CharacterAdder
VetheonGames edited this page 2023-06-08 11:33:49 -06:00

CharacterAdder Class

The CharacterAdder class is responsible for adding characters to the input string in the DynamicCursesInput gem. It provides a method to add a character at the current cursor position.

Methods

.add(chk, input, cursor_pos)

This is a class method that adds a character at the current cursor position. It takes three parameters:

  • chk: the character to be added.
  • input: the current input string.
  • cursor_pos: the current cursor position.

The method inserts the character at the cursor position and increases the cursor position by 1. This simulates the effect of typing a character at the cursor's position in a text editor.

The method returns an array containing two elements: the updated input string and the updated cursor position.