1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-11 03:27:05 +03:00

paint after each window input, remember mods for text input

Also need to tweak how we handle ALT-x and CTRL-x as the case of the input
is different with glium vs. xcb
This commit is contained in:
Wez Furlong 2018-02-22 08:41:51 -08:00
parent 697f07cb51
commit d03564aa10
2 changed files with 20 additions and 7 deletions

View File

@ -64,6 +64,7 @@ pub struct TerminalWindow {
terminal: Terminal,
process: Child,
last_mouse_coords: (f64, f64),
last_modifiers: KeyModifiers,
wakeup_receiver: Receiver<WakeupMsg>,
}
@ -120,6 +121,7 @@ impl TerminalWindow {
terminal,
process,
last_mouse_coords: (0.0, 0.0),
last_modifiers: Default::default(),
wakeup_receiver,
})
}
@ -165,6 +167,7 @@ impl TerminalWindow {
let cols = ((width as usize + 1) / self.cell_width) as u16;
self.host.pty.resize(rows, cols, width, height)?;
self.terminal.resize(rows as usize, cols as usize);
self.paint_if_needed()?;
Ok(true)
} else {
@ -207,6 +210,7 @@ impl TerminalWindow {
},
&mut self.host,
)?;
self.paint_if_needed()?;
Ok(())
}
@ -235,6 +239,7 @@ impl TerminalWindow {
},
&mut self.host,
)?;
self.paint_if_needed()?;
Ok(())
}
@ -269,15 +274,16 @@ impl TerminalWindow {
},
&mut self.host,
)?;
self.paint_if_needed()?;
Ok(())
}
fn key_event(&mut self, event: glium::glutin::KeyboardInput) -> Result<(), Error> {
let mods = Self::decode_modifiers(event.modifiers);
self.last_modifiers = mods;
if let Some(code) = event.virtual_keycode {
use glium::glutin::VirtualKeyCode as V;
let key = match code {
V::Key1
| V::Key2
@ -361,6 +367,14 @@ impl TerminalWindow {
ElementState::Released => self.terminal.key_up(key, mods, &mut self.host)?,
}
}
self.paint_if_needed()?;
Ok(())
}
pub fn paint_if_needed(&mut self) -> Result<(), Error> {
if self.terminal.has_dirty_lines() {
self.paint()?;
}
Ok(())
}
@ -384,7 +398,8 @@ impl TerminalWindow {
..
} => {
self.terminal
.key_down(KeyCode::Char(c), KeyModifiers::default(), &mut self.host)?;
.key_down(KeyCode::Char(c), self.last_modifiers, &mut self.host)?;
self.paint_if_needed()?;
}
Event::WindowEvent {
event: WindowEvent::KeyboardInput { input, .. },

View File

@ -538,21 +538,19 @@ impl TerminalState {
// TODO: also respect self.application_keypad
let to_send = match (key, ctrl, alt, shift, self.application_cursor_keys) {
(Char(c), CTRL, _, SHIFT, _) if c <= 0xff as char => {
(Char(c), CTRL, _, SHIFT, _) if c <= 0xff as char && c > 0x40 as char => {
// If shift is held we have C == 0x43 and want to translate
// that into 0x03
buf.push((c as u8 - 0x40) as char);
buf.as_str()
}
(Char(c), CTRL, ..) if c <= 0xff as char => {
(Char(c), CTRL, ..) if c <= 0xff as char && c > 0x60 as char => {
// If shift is not held we have C == 0x63 and want to translate
// that into 0x03
buf.push((c as u8 - 0x60) as char);
buf.as_str()
}
(Char(c), _, ALT, ..) if c <= 0xff as char => {
// TODO: add config option to select 8-bit vs. escape behavior?
//buf.push((c as u8 | 0x80) as char);
(Char(c), _, ALT, ..) => {
buf.push(0x1b as char);
buf.push(c);
buf.as_str()