use super::IStateCommand;
use Context;
use std::rc::Rc;
pub struct EmptyCommand;
impl IStateCommand for EmptyCommand {
fn execute(&mut self) -> bool {
return false;
}
fn undo(&mut self) -> bool {
return false;
}
}
pub struct ToAlternateScreenBufferCommand {
context: Rc<Context>,
}
impl ToAlternateScreenBufferCommand {
pub fn new(context: Rc<Context>) -> u16 {
let mut state = context.state_manager.lock().unwrap();
{
let key = state.get_changes_count();
let command = ToAlternateScreenBufferCommand {
context: context.clone(),
};
state.register_change(Box::from(command), key);
key
}
}
}
impl IStateCommand for ToAlternateScreenBufferCommand {
fn execute(&mut self) -> bool {
let mut screen = self.context.screen_manager.lock().unwrap();
{
screen.write_str(csi!("?1049h"));
screen.toggle_is_alternate_screen(true);
return true;
}
}
fn undo(&mut self) -> bool {
let mut screen = self.context.screen_manager.lock().unwrap();
{
screen.write_str(csi!("?1049l"));
screen.toggle_is_alternate_screen(false);
return true;
}
}
}