Removed println (#127)

* Removed println
This commit is contained in:
Timon 2019-04-19 10:02:25 +02:00 committed by GitHub
parent 4423db687a
commit e967c0410a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 36 deletions

View File

@ -1,3 +1,6 @@
# Changes crossterm_input 0.3.3
- Removed println from `SyncReader`
# Changes crossterm_input 0.3.2 # Changes crossterm_input 0.3.2
- Fixed some special key combination detections for UNIX systems - Fixed some special key combination detections for UNIX systems
- Windows mouse input event position was 0-based and should be 1-based - Windows mouse input event position was 0-based and should be 1-based

View File

@ -1,6 +1,6 @@
[package] [package]
name = "crossterm_input" name = "crossterm_input"
version = "0.3.2" version = "0.3.3"
authors = ["T. Post"] authors = ["T. Post"]
description = "A cross-platform library for reading userinput." description = "A cross-platform library for reading userinput."
repository = "https://github.com/TimonPost/crossterm" repository = "https://github.com/TimonPost/crossterm"

View File

@ -1,8 +1,7 @@
extern crate crossterm_input; extern crate crossterm_input;
extern crate crossterm_screen; extern crate crossterm_screen;
use crossterm_input::{InputEvent, KeyEvent, MouseButton, MouseEvent, TerminalInput}; use crossterm_input::{input, InputEvent, KeyEvent, MouseButton, MouseEvent, RawScreen};
use crossterm_screen::Screen;
use std::{thread, time::Duration}; use std::{thread, time::Duration};
fn process_input_event(key_event: InputEvent) -> bool { fn process_input_event(key_event: InputEvent) -> bool {
@ -79,8 +78,7 @@ fn process_input_event(key_event: InputEvent) -> bool {
pub fn read_asynchronously() { pub fn read_asynchronously() {
// make sure to enable raw mode, this will make sure key events won't be handled by the terminal it's self and allows crossterm to read the input and pass it back to you. // make sure to enable raw mode, this will make sure key events won't be handled by the terminal it's self and allows crossterm to read the input and pass it back to you.
let _ = Screen::new(true); if let Ok(_raw) = RawScreen::into_raw_mode() {
let input = input(); let input = input();
// enable mouse events to be captured. // enable mouse events to be captured.
@ -99,12 +97,12 @@ pub fn read_asynchronously() {
// disable mouse events to be captured. // disable mouse events to be captured.
input.disable_mouse_mode().unwrap(); input.disable_mouse_mode().unwrap();
} // <=== raw modes will be disabled here
} // <=== background reader will be disposed when dropped. } // <=== background reader will be disposed when dropped.
pub fn read_synchronously() { pub fn read_synchronously() {
// make sure to enable raw mode, this will make sure key events won't be handled by the terminal it's self and allows crossterm to read the input and pass it back to you. // make sure to enable raw mode, this will make sure key events won't be handled by the terminal it's self and allows crossterm to read the input and pass it back to you.
let _ = Screen::new(true); if let Ok(_raw) = RawScreen::into_raw_mode() {
let input = input(); let input = input();
// enable mouse events to be captured. // enable mouse events to be captured.
@ -124,11 +122,12 @@ pub fn read_synchronously() {
// disable mouse events to be captured. // disable mouse events to be captured.
input.disable_mouse_mode().unwrap(); input.disable_mouse_mode().unwrap();
} // <=== raw modes will be disabled here
} }
fn main() { fn main() {
// un-comment below and run with // un-comment below and run with
// `cargo run --example key_events`: // `cargo run --example key_events`:
// read_synchronously(); read_synchronously();
// read_asynchronously(); // read_asynchronously();
} }

View File

@ -119,7 +119,6 @@ impl Iterator for SyncReader {
Ok(1) => match buf[0] { Ok(1) => match buf[0] {
b'\x1B' => return Some(InputEvent::Keyboard(KeyEvent::Esc)), b'\x1B' => return Some(InputEvent::Keyboard(KeyEvent::Esc)),
c => { c => {
println!("size 1: {:?}", buf);
if let Ok(e) = parse_event(c, &mut source.bytes().flatten()) { if let Ok(e) = parse_event(c, &mut source.bytes().flatten()) {
return Some(e); return Some(e);
} else { } else {
@ -128,7 +127,6 @@ impl Iterator for SyncReader {
} }
}, },
Ok(2) => { Ok(2) => {
println!("size 2: {:?}", buf);
let option_iter = &mut Some(buf[1]).into_iter(); let option_iter = &mut Some(buf[1]).into_iter();
let mut iter = option_iter.map(|c| Ok(c)).chain(source.bytes()); let mut iter = option_iter.map(|c| Ok(c)).chain(source.bytes());
if let Ok(e) = parse_event(buf[0], &mut iter.flatten()) { if let Ok(e) = parse_event(buf[0], &mut iter.flatten()) {

View File

@ -184,8 +184,6 @@ fn into_virtual_terminal_sequence() -> Result<(u32, Vec<u8>)> {
} }
fn handle_key_event(key_event: &KeyEventRecord, seq: &mut Vec<u8>) { fn handle_key_event(key_event: &KeyEventRecord, seq: &mut Vec<u8>) {
// println!("key code: {:?}, state: {:?}", key_event.virtual_key_code, key_event.control_key_state);
match key_event.virtual_key_code as i32 { match key_event.virtual_key_code as i32 {
VK_SHIFT | VK_CONTROL | VK_MENU => { VK_SHIFT | VK_CONTROL | VK_MENU => {
// ignore SHIFT, CTRL, ALT standalone presses // ignore SHIFT, CTRL, ALT standalone presses

View File

@ -1,3 +1,6 @@
# Changes crossterm_input 0.9.3
- Removed println from `SyncReader`
## Changes crossterm 0.9.2 ## Changes crossterm 0.9.2
- Terminal size linux was not 0-based - Terminal size linux was not 0-based
- Windows mouse input event position was 0-based ans should be 1-based - Windows mouse input event position was 0-based ans should be 1-based