From 7e382593a88dc0eb9a5dc08236cb698ea128c023 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 12 Oct 2016 14:14:32 -0700 Subject: [PATCH] Remember current color style in pancurses backend --- src/backend/curses/pan.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backend/curses/pan.rs b/src/backend/curses/pan.rs index 68c0c30..41be59b 100644 --- a/src/backend/curses/pan.rs +++ b/src/backend/curses/pan.rs @@ -1,14 +1,17 @@ extern crate pancurses; + use backend; use event::{Event, Key}; use self::super::find_closest; +use std::cell::Cell; use theme::{Color, ColorStyle, Effect}; use utf8; pub struct Concrete { window: pancurses::Window, + current_style: Cell, } impl backend::Backend for Concrete { @@ -22,7 +25,10 @@ impl backend::Backend for Concrete { pancurses::curs_set(0); window.bkgd(pancurses::COLOR_PAIR(ColorStyle::Background.id() as u64)); - Concrete { window: window } + Concrete { + window: window, + current_style: Cell::new(ColorStyle::Background), + } } fn screen_size(&self) -> (usize, usize) { @@ -50,12 +56,17 @@ impl backend::Backend for Concrete { // let mut current_style: pancurses::attr_t = 0; // let mut current_color: i16 = 0; // pancurses::attr_get(&mut current_style, &mut current_color); + let current_style = self.current_style.get(); let style = pancurses::COLOR_PAIR(color.id() as u64); self.window.attron(style); + + self.current_style.set(color); f(); - self.window.attroff(style); - // pancurses::attron(current_style); + self.current_style.set(current_style); + + // self.window.attroff(style); + self.window.attron(pancurses::COLOR_PAIR(current_style.id() as u64)); } fn with_effect(&self, effect: Effect, f: F) {