Skip to content

Commit

Permalink
fix: switch to crossterm for cross platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Jun 26, 2024
1 parent b711e8a commit 0ba2de9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 47 deletions.
86 changes: 49 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ ureq = { version = "2.9.1", features = ["json"] }
tempfile = "3.8.1"
toml_edit = "0.21.0"
rust-embed = { version = "8.2.0", features = ["debug-embed"] }
bollard = { workspace=true }
bollard = { workspace = true }
futures-util = "0.3.30"
home = "0.5.9"
termion = "4.0.0"
crossterm = "0.27.0"
# For hyper-tls
[target.'cfg(unix)'.dependencies]
openssl = { version = "=0.10.55", features = ["vendored"] }
Expand Down
16 changes: 8 additions & 8 deletions cmd/soroban-cli/src/signer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crossterm::event::{read, Event, KeyCode};
use ed25519_dalek::ed25519::signature::Signer;
use sha2::{Digest, Sha256};
use termion::{event::Key, get_tty, input::TermRead};

use crate::xdr::{
self, AccountId, DecoratedSignature, Hash, HashIdPreimage, HashIdPreimageSorobanAuthorization,
Expand Down Expand Up @@ -246,13 +246,13 @@ impl Stellar for LocalKey {
}

pub fn read_key() -> char {
let tty = get_tty().unwrap();
if let Some(key) = tty.keys().next() {
match key.unwrap() {
Key::Char(c) => c,
_ => '_',
loop {
if let Event::Key(key) = read().unwrap() {
match key.code {
KeyCode::Char(c) => return c,
KeyCode::Esc => return '\x1b', // escape key
_ => (),
}
}
} else {
' '
}
}

0 comments on commit 0ba2de9

Please sign in to comment.