Skip to content

reader.trigger not working? #34

@ddoherty03

Description

@ddoherty03

Describe the problem

Trying to add simple C-a C-e keybindings to move the cursor to the beginning and end of the line no working as suggested in the README.

The README contains this hopeful example:

reader.on(:keypress) do |event|
  if event.value == "j"
    reader.trigger(:keydown)
  end
  if evevnt.value == "k"
    reader.trigger(:keyup)
  end
end

As a way to add vim key bindings.

Steps to reproduce the problem

But I tried something analagous:

    KEY_CTRL_A = "\u0001"
    KEY_CTRL_E = "\u0005"

      reader.on(:keypress) do |event|
        case event.value
        when KEY_CTRL_A
          reader.trigger(:keyhome)
        when KEY_CTRL_E
          reader.trigger(:keyend)
        end
      end
    end

Actual behaviour

But when reader.trigger(:keyhome) is executed, the cursor does not move as it does when the Home key is pressed.

Maybe I'm missing something, but this feels like a bug.

Expected behaviour

Cursor moves to beginning/end of line.

Describe your environment

  • OS version: Archlinux
  • Ruby version: 3.4.1
  • TTY::Reader version: 0.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions