Add Cursive::active_screen

This commit is contained in:
Alexandre Bury 2018-01-11 18:20:23 +01:00
parent 4879d8cc71
commit 2d62d2c91f

View File

@ -55,9 +55,9 @@ impl Cursive {
let (tx, rx) = mpsc::channel(); let (tx, rx) = mpsc::channel();
let mut res = Cursive { Cursive {
theme: theme, theme: theme,
screens: Vec::new(), screens: vec![views::StackView::new()],
last_sizes: Vec::new(), last_sizes: Vec::new(),
global_callbacks: HashMap::new(), global_callbacks: HashMap::new(),
menubar: views::Menubar::new(), menubar: views::Menubar::new(),
@ -66,11 +66,7 @@ impl Cursive {
cb_source: rx, cb_source: rx,
cb_sink: tx, cb_sink: tx,
backend: backend, backend: backend,
}; }
res.screens.push(views::StackView::new());
res
} }
/// Returns a sink for asynchronous callbacks. /// Returns a sink for asynchronous callbacks.
@ -218,6 +214,11 @@ impl Cursive {
&mut self.screens[id] &mut self.screens[id]
} }
/// Returns the id of the currently active screen.
pub fn active_screen(&self) -> ScreenId {
self.active_screen
}
/// Adds a new screen, and returns its ID. /// Adds a new screen, and returns its ID.
pub fn add_screen(&mut self) -> ScreenId { pub fn add_screen(&mut self) -> ScreenId {
let res = self.screens.len(); let res = self.screens.len();