From dfb1b3bb5c5e9d9d9ee23f3f5bcc84fe6602392d Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Tue, 10 Jan 2017 21:21:19 -0800 Subject: Add support for setting title from OSC Resolves #23 Resolves #144 --- src/term/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/term/mod.rs') diff --git a/src/term/mod.rs b/src/term/mod.rs index cc1715a9..581f5039 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -210,6 +210,11 @@ pub struct Term { /// arrays. Without it we wold have to sanitize cursor.col every time we used it. input_needs_wrap: bool, + /// Got a request to set title; it's buffered here until next draw. + /// + /// Would be nice to avoid the allocation... + next_title: Option, + /// Alternate grid alt_grid: Grid, @@ -286,6 +291,11 @@ impl SizeInfo { } impl Term { + #[inline] + pub fn get_next_title(&mut self) -> Option { + self.next_title.take() + } + pub fn new(size: SizeInfo) -> Term { let template = Cell::default(); @@ -304,6 +314,7 @@ impl Term { let scroll_region = Line(0)..grid.num_lines(); Term { + next_title: None, dirty: false, input_needs_wrap: false, grid: grid, @@ -642,6 +653,12 @@ impl ansi::TermInfo for Term { } impl ansi::Handler for Term { + /// Set the window title + #[inline] + fn set_title(&mut self, title: &str) { + self.next_title = Some(title.to_owned()); + } + /// A character to be displayed #[inline] fn input(&mut self, c: char) { -- cgit v1.2.3-54-g00ecf