Skip to content

Commit

Permalink
Minor comment improvements to the input parser
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed May 9, 2022
1 parent 495413a commit 5b4aa0e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func readInputs(input io.Reader) ([]Msg, error) {
return nil, err
}

// See if it's a mouse event. For now we're parsing X10-type mouse events
// Check if it's a mouse event. For now we're parsing X10-type mouse events
// only.
mouseEvent, err := parseX10MouseEvents(buf[:numBytes])
if err == nil {
Expand All @@ -492,23 +492,23 @@ func readInputs(input io.Reader) ([]Msg, error) {
return m, nil
}

// Is it a special sequence, like an arrow key?
// Is it a sequence, like an arrow key?
if k, ok := sequences[string(buf[:numBytes])]; ok {
return []Msg{
KeyMsg(k),
}, nil
}

// Some of these need special handling
// Some of these need special handling.
hex := fmt.Sprintf("%x", buf[:numBytes])
if k, ok := hexes[hex]; ok {
return []Msg{
KeyMsg(k),
}, nil
}

// Is the alt key pressed? The buffer will be prefixed with an escape
// sequence if so.
// Is the alt key pressed? If so, the buffer will be prefixed with an
// escape.
if numBytes > 1 && buf[0] == 0x1b {
// Now remove the initial escape sequence and re-process to get the
// character being pressed in combination with alt.
Expand Down

0 comments on commit 5b4aa0e

Please sign in to comment.