1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00
This commit is contained in:
Wez Furlong 2019-11-24 07:20:41 -08:00
parent 385b3bedbd
commit 517084ff2f
12 changed files with 60 additions and 68 deletions

View File

@ -79,7 +79,7 @@ impl NamedFontListImpl {
if candidate < f.font_list_size {
return Some((f, candidate));
}
candidate = candidate - f.font_list_size;
candidate -= f.font_list_size;
}
None
}

View File

@ -101,6 +101,7 @@ impl Font for FreeTypeFontImpl {
}
}
#[allow(clippy::cognitive_complexity)]
fn rasterize_glyph(&self, glyph_pos: u32) -> Result<RasterizedGlyph, Error> {
let render_mode = //ftwrap::FT_Render_Mode::FT_RENDER_MODE_NORMAL;
// ftwrap::FT_Render_Mode::FT_RENDER_MODE_LCD;

View File

@ -1,3 +1,7 @@
// Clippy hates the implement_vertex macro and won't let me scope
// this warning to its use
#![allow(clippy::unneeded_field_pattern)]
use ::window::bitmaps::TextureRect;
use ::window::*;

View File

@ -70,7 +70,7 @@ impl TabBarState {
available_cells / number_of_tabs
};
let colors = colors.cloned().unwrap_or_else(|| TabBarColors::default());
let colors = colors.cloned().unwrap_or_else(TabBarColors::default);
let mut line = Line::with_width(title_width);

View File

@ -138,13 +138,10 @@ impl WindowCallbacks for TermWindow {
self.last_mouse_coords = (x, y);
if self.show_tab_bar && y == 0 {
match event.kind {
WMEK::Press(MousePress::Left) => self.drag_start_coords = Some(event.coords),
_ => {}
}
if let WMEK::Press(MousePress::Left) = event.kind {
self.drag_start_coords = Some(event.coords);
match event.kind {
WMEK::Press(MousePress::Left) => match self.tab_bar.hit_test(x) {
match self.tab_bar.hit_test(x) {
TabBarItem::Tab(tab_idx) => {
self.activate_tab(tab_idx).ok();
}
@ -152,8 +149,7 @@ impl WindowCallbacks for TermWindow {
self.spawn_tab(&SpawnTabDomain::CurrentTabDomain).ok();
}
TabBarItem::None => {}
},
_ => {}
}
}
} else {
let y = y.saturating_sub(first_line_offset);
@ -262,10 +258,9 @@ impl WindowCallbacks for TermWindow {
if !self.config.send_composed_key_when_alt_is_pressed
&& modifiers.contains(::termwiz::input::Modifiers::ALT)
&& tab.key_down(key, modifiers).is_ok()
{
if tab.key_down(key, modifiers).is_ok() {
return true;
}
return true;
}
}
}

View File

@ -41,7 +41,7 @@ impl RateLimiter {
// we use a 32k buffer which means that in the worst case
// (where the buffer is 100% full), we'll take ~15 iterations
// to reach a decision of a single byte or a sleep delay.
amount = amount / 2;
amount /= 2;
}
}
}

View File

@ -26,7 +26,7 @@ fn password_prompt(
username: &str,
remote_address: &str,
) -> Option<String> {
let title = format!("🔐 wezterm: SSH authentication");
let title = "🔐 wezterm: SSH authentication".to_string();
let text = format!(
"🔐 SSH Authentication for {} @ {}\r\n{}\r\n",
username, remote_address, instructions
@ -92,7 +92,7 @@ fn input_prompt(
username: &str,
remote_address: &str,
) -> Option<String> {
let title = format!("🔐 wezterm: SSH authentication");
let title = "🔐 wezterm: SSH authentication".to_string();
let text = format!(
"SSH Authentication for {} @ {}\r\n{}\r\n{}\r\n",
username, remote_address, instructions, prompt
@ -224,7 +224,7 @@ pub fn ssh_connect(remote_address: &str, username: &str) -> Fallible<ssh2::Sessi
);
let allow = termwiztermtab::run(80, 10, move |mut term| {
let title = format!("🔐 wezterm: SSH authentication");
let title = "🔐 wezterm: SSH authentication".to_string();
term.render(&[Change::Title(title), Change::Text(message.to_string())])?;
let mut editor = LineEditor::new(term);

View File

@ -227,6 +227,40 @@ fn is_double_click_word(s: &str) -> bool {
}
}
fn encode_modifiers(mods: KeyModifiers) -> u8 {
let mut number = 0;
if mods.contains(KeyModifiers::SHIFT) {
number |= 1;
}
if mods.contains(KeyModifiers::ALT) {
number |= 2;
}
if mods.contains(KeyModifiers::CTRL) {
number |= 4;
}
number
}
fn csi_u_encode(buf: &mut String, c: char, mods: KeyModifiers) -> Result<(), Error> {
// FIXME: provide an option to enable this, because it is super annoying
// in vim when accidentally pressing shift-space and it emits a sequence
// that undoes some number of commands
if false {
write!(buf, "\x1b[{};{}u", c as u32, 1 + encode_modifiers(mods))?;
}
Ok(())
}
/// characters that when masked for CTRL could be an ascii control character
/// or could be a key that a user legitimately wants to process in their
/// terminal application
fn is_ambiguous_ascii_ctrl(c: char) -> bool {
match c {
'i' | 'I' | 'm' | 'M' | '[' | '{' | '@' => true,
_ => false,
}
}
impl TerminalState {
pub fn new(
physical_rows: usize,
@ -822,6 +856,7 @@ impl TerminalState {
/// that is embedding the Terminal. This method translates the
/// keycode into a sequence of bytes to send to the slave end
/// of the pty via the `Write`-able object provided by the caller.
#[allow(clippy::cognitive_complexity)]
pub fn key_down(
&mut self,
key: KeyCode,
@ -843,44 +878,10 @@ impl TerminalState {
_ => mods,
};
fn encode_modifiers(mods: KeyModifiers) -> u8 {
let mut number = 0;
if mods.contains(KeyModifiers::SHIFT) {
number |= 1;
}
if mods.contains(KeyModifiers::ALT) {
number |= 2;
}
if mods.contains(KeyModifiers::CTRL) {
number |= 4;
}
number
}
let mut buf = String::new();
// TODO: also respect self.application_keypad
fn csi_u_encode(buf: &mut String, c: char, mods: KeyModifiers) -> Result<(), Error> {
// FIXME: provide an option to enable this, because it is super annoying
// in vim when accidentally pressing shift-space and it emits a sequence
// that undoes some number of commands
if false {
write!(buf, "\x1b[{};{}u", c as u32, 1 + encode_modifiers(mods))?;
}
Ok(())
}
/// characters that when masked for CTRL could be an ascii control character
/// or could be a key that a user legitimately wants to process in their
/// terminal application
fn is_ambiguous_ascii_ctrl(c: char) -> bool {
match c {
'i' | 'I' | 'm' | 'M' | '[' | '{' | '@' => true,
_ => false,
}
}
let to_send = match key {
Char(c) if is_ambiguous_ascii_ctrl(c) && mods.contains(KeyModifiers::CTRL) => {
csi_u_encode(&mut buf, c, mods)?;

View File

@ -67,7 +67,7 @@ impl Texture2d for SrgbTexture2d {
// glium to use SRGB for the texture.
fn conv(v: u8) -> u8 {
let f = (v as f32) / 255.;
let c = if f <= 0.0031308 {
let c = if f <= 0.003_130_8 {
f * 12.92
} else {
f.powf(1.0 / 2.4) * 1.055 - 0.055
@ -121,6 +121,9 @@ mod avx {
size == align_lo(size, align)
}
/// # Safety
/// It is up to the caller to ensure that the destination pointer,
/// stride, width and height all result in valid memory operations.
#[allow(clippy::cast_ptr_alignment)]
pub unsafe fn fill_pixel(
mut dest: *mut u8,

View File

@ -408,13 +408,7 @@ impl Connection {
.allowed_depths()
.filter(|depth| depth.depth() == 24)
.flat_map(|depth| depth.visuals())
.filter_map(|vis| {
if vis.class() == xcb::xproto::VISUAL_CLASS_TRUE_COLOR as _ {
Some(vis.clone())
} else {
None
}
})
.filter(|vis| vis.class() == xcb::xproto::VISUAL_CLASS_TRUE_COLOR as _)
.nth(0)
.ok_or_else(|| failure::err_msg("did not find 24-bit visual"))?;
eprintln!(

View File

@ -353,7 +353,7 @@ impl WindowInner {
Ok(())
}
#[allow(dead_code)]
#[allow(dead_code, clippy::identity_op)]
fn disable_decorations(&mut self) -> Fallible<()> {
// Set the motif hints to disable decorations.
// See https://stackoverflow.com/a/1909708

View File

@ -65,14 +65,8 @@ impl SpawnQueue {
}
fn has_any_queued(&self) -> bool {
let len = self.spawned_funcs.lock().unwrap().len();
let low_len = self.spawned_funcs_low_pri.lock().unwrap().len();
if len + low_len > 0 {
// eprintln!("{} + {} queued spawns", len, low_len);
true
} else {
false
}
!self.spawned_funcs.lock().unwrap().is_empty()
|| !self.spawned_funcs_low_pri.lock().unwrap().is_empty()
}
}