From 3f35b87757e245a8a1c358528164378da543d8ed Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Tue, 20 Feb 2018 10:35:38 -0800 Subject: [PATCH] Use print! rather than println! for ncurses configuration --- src/backend/curses/n.rs | 7 +++++-- src/backend/curses/pan.rs | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/curses/n.rs b/src/backend/curses/n.rs index 8e11ed8..53a9f6e 100644 --- a/src/backend/curses/n.rs +++ b/src/backend/curses/n.rs @@ -6,6 +6,7 @@ use backend; use event::{Event, Key, MouseButton, MouseEvent}; use std::cell::{Cell, RefCell}; use std::collections::HashMap; +use std::io::{stdout, Write}; use theme::{Color, ColorPair, Effect}; use utf8; use vec::Vec2; @@ -183,7 +184,8 @@ impl backend::Backend for Concrete { // This asks the terminal to provide us with mouse drag events // (Mouse move when a button is pressed). // Replacing 1002 with 1003 would give us ANY mouse move. - println!("\x1B[?1002h"); + print!("\x1B[?1002h"); + stdout().flush().expect("could not flush stdout"); Concrete { current_style: Cell::new(ColorPair::from_256colors(0, 0)), @@ -208,7 +210,8 @@ impl backend::Backend for Concrete { } fn finish(&mut self) { - println!("\x1B[?1002l"); + print!("\x1B[?1002l"); + stdout().flush().expect("could not flush stdout"); ncurses::endwin(); } diff --git a/src/backend/curses/pan.rs b/src/backend/curses/pan.rs index 0b4eb87..48cb436 100644 --- a/src/backend/curses/pan.rs +++ b/src/backend/curses/pan.rs @@ -6,6 +6,7 @@ use backend; use event::{Event, Key, MouseButton, MouseEvent}; use std::cell::{Cell, RefCell}; use std::collections::HashMap; +use std::io::{stdout, Write}; use theme::{Color, ColorPair, Effect}; use utf8; use vec::Vec2; @@ -148,6 +149,7 @@ impl backend::Backend for Concrete { // (Mouse move when a button is pressed). // Replacing 1002 with 1003 would give us ANY mouse move. print!("\x1B[?1002h"); + stdout().flush().expect("could not flush stdout"); Concrete { current_style: Cell::new(ColorPair::from_256colors(0, 0)), @@ -168,6 +170,8 @@ impl backend::Backend for Concrete { } fn finish(&mut self) { + print!("\x1B[?1002l"); + stdout().flush().expect("could not flush stdout"); pancurses::endwin(); }