Skip to content

Commit

Permalink
examples: smux handle control characters
Browse files Browse the repository at this point in the history
  • Loading branch information
a-kenji committed Apr 21, 2024
1 parent d217da9 commit ccf73e4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/smux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,15 @@ async fn handle_pane_key_event(pane: &mut PtyPane, key: &KeyEvent) -> bool {
// Close the pane
return false;
}
'l' => {
send = vec![27, 91, 50, 74];
_ => {
let char = ch.to_ascii_uppercase();
let ascii_val = char as u8;
// Since char is guaranteed to be an ASCII character,
// we can safely subtract 64 to get
// the corresponding control character
let ascii_to_send = ascii_val - 64;
send = vec![ascii_to_send];
}

_ => {}
}
}
send
Expand Down

0 comments on commit ccf73e4

Please sign in to comment.