mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Fix clippy lints
This commit is contained in:
parent
5728136350
commit
e34dccdabf
8 changed files with 355 additions and 294 deletions
560
Cargo.lock
generated
560
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1718,10 +1718,10 @@ mod tests {
|
|||
.expect("deserialize config");
|
||||
|
||||
// Sanity check that mouse bindings are being parsed
|
||||
assert!(config.mouse_bindings.len() >= 1);
|
||||
assert!(!config.mouse_bindings.is_empty());
|
||||
|
||||
// Sanity check that key bindings are being parsed
|
||||
assert!(config.key_bindings.len() >= 1);
|
||||
assert!(!config.key_bindings.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,8 +162,8 @@ impl Display {
|
|||
let height = cell_height as u32 * dimensions.lines_u32();
|
||||
|
||||
let new_viewport_size = Size {
|
||||
width: Pixels(width + 2 * config.padding().x as u32),
|
||||
height: Pixels(height + 2 * config.padding().y as u32),
|
||||
width: Pixels(width + 2 * u32::from(config.padding().x)),
|
||||
height: Pixels(height + 2 * u32::from(config.padding().y)),
|
||||
};
|
||||
|
||||
window.set_inner_size(&new_viewport_size);
|
||||
|
@ -178,8 +178,8 @@ impl Display {
|
|||
height: viewport_size.height.0 as f32,
|
||||
cell_width: cell_width as f32,
|
||||
cell_height: cell_height as f32,
|
||||
padding_x: config.padding().x as f32,
|
||||
padding_y: config.padding().y as f32,
|
||||
padding_x: f32::from(config.padding().x),
|
||||
padding_y: f32::from(config.padding().y),
|
||||
};
|
||||
|
||||
// Channel for resize events
|
||||
|
@ -238,8 +238,8 @@ impl Display {
|
|||
// font metrics should be computed before creating the window in the first
|
||||
// place so that a resize is not needed.
|
||||
let metrics = glyph_cache.font_metrics();
|
||||
let cell_width = metrics.average_advance as f32 + font.offset().x as f32;
|
||||
let cell_height = metrics.line_height as f32 + font.offset().y as f32;
|
||||
let cell_width = metrics.average_advance as f32 + f32::from(font.offset().x);
|
||||
let cell_height = metrics.line_height as f32 + f32::from(font.offset().y);
|
||||
|
||||
// Prevent invalid cell sizes
|
||||
if cell_width < 1. || cell_height < 1. {
|
||||
|
|
21
src/event.rs
21
src/event.rs
|
@ -57,17 +57,16 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
|
|||
|
||||
fn copy_selection(&self, buffer: ::copypasta::Buffer) {
|
||||
if let Some(ref selection) = *self.selection {
|
||||
selection.to_span(self.terminal)
|
||||
.map(|span| {
|
||||
let buf = self.terminal.string_from_selection(&span);
|
||||
if !buf.is_empty() {
|
||||
Clipboard::new()
|
||||
.and_then(|mut clipboard| clipboard.store(buf, buffer))
|
||||
.unwrap_or_else(|err| {
|
||||
warn!("Error storing selection to clipboard. {}", Red(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
if let Some(ref span) = selection.to_span(self.terminal) {
|
||||
let buf = self.terminal.string_from_selection(&span);
|
||||
if !buf.is_empty() {
|
||||
Clipboard::new()
|
||||
.and_then(|mut clipboard| clipboard.store(buf, buffer))
|
||||
.unwrap_or_else(|err| {
|
||||
warn!("Error storing selection to clipboard. {}", Red(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -94,9 +94,9 @@ fn run(mut config: Config, options: &cli::Options) -> Result<(), Box<Error>> {
|
|||
logging::initialize(options)?;
|
||||
|
||||
info!("Welcome to Alacritty.");
|
||||
config.path().map(|config_path| {
|
||||
if let Some(config_path) = config.path() {
|
||||
info!("Configuration loaded from {}", config_path.display());
|
||||
});
|
||||
};
|
||||
|
||||
// Create a display.
|
||||
//
|
||||
|
@ -179,15 +179,16 @@ fn run(mut config: Config, options: &cli::Options) -> Result<(), Box<Error>> {
|
|||
let mut terminal = processor.process_events(&terminal, display.window());
|
||||
|
||||
// Handle config reloads
|
||||
config_monitor.as_ref()
|
||||
if let Some(new_config) = config_monitor
|
||||
.as_ref()
|
||||
.and_then(|monitor| monitor.pending_config())
|
||||
.map(|new_config| {
|
||||
config = new_config;
|
||||
display.update_config(&config);
|
||||
processor.update_config(&config);
|
||||
terminal.update_config(&config);
|
||||
terminal.dirty = true;
|
||||
});
|
||||
{
|
||||
config = new_config;
|
||||
display.update_config(&config);
|
||||
processor.update_config(&config);
|
||||
terminal.update_config(&config);
|
||||
terminal.dirty = true;
|
||||
}
|
||||
|
||||
// Maybe draw the terminal
|
||||
if terminal.needs_draw() {
|
||||
|
|
|
@ -285,8 +285,8 @@ impl GlyphCache {
|
|||
let mut rasterized = rasterizer.get_glyph(glyph_key)
|
||||
.unwrap_or_else(|_| Default::default());
|
||||
|
||||
rasterized.left += glyph_offset.x as i32;
|
||||
rasterized.top += glyph_offset.y as i32;
|
||||
rasterized.left += i32::from(glyph_offset.x);
|
||||
rasterized.top += i32::from(glyph_offset.y);
|
||||
rasterized.top -= metrics.descent as i32;
|
||||
|
||||
loader.load_glyph(&rasterized)
|
||||
|
@ -719,8 +719,8 @@ impl QuadRenderer {
|
|||
}
|
||||
|
||||
pub fn resize(&mut self, width: i32, height: i32) {
|
||||
let padding_x = self.program.padding_x as i32;
|
||||
let padding_y = self.program.padding_y as i32;
|
||||
let padding_x = i32::from(self.program.padding_x);
|
||||
let padding_y = i32::from(self.program.padding_y);
|
||||
|
||||
// viewport
|
||||
unsafe {
|
||||
|
@ -1030,8 +1030,8 @@ impl ShaderProgram {
|
|||
|
||||
fn update_projection(&self, width: f32, height: f32) {
|
||||
// Bounds check
|
||||
if (width as u32) < (2 * self.padding_x as u32) ||
|
||||
(height as u32) < (2 * self.padding_y as u32)
|
||||
if (width as u32) < (2 * u32::from(self.padding_x)) ||
|
||||
(height as u32) < (2 * u32::from(self.padding_y))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1041,8 +1041,14 @@ impl ShaderProgram {
|
|||
// NB Not sure why padding change only requires changing the vertical
|
||||
// translation in the projection, but this makes everything work
|
||||
// correctly.
|
||||
let ortho = cgmath::ortho(0., width - 2. * self.padding_x as f32, 2. * self.padding_y as f32,
|
||||
height, -1., 1.);
|
||||
let ortho = cgmath::ortho(
|
||||
0.,
|
||||
width - 2. * f32::from(self.padding_x),
|
||||
2. * f32::from(self.padding_y),
|
||||
height,
|
||||
-1.,
|
||||
1.,
|
||||
);
|
||||
let projection: [[f32; 4]; 4] = ortho.into();
|
||||
|
||||
info!("width: {}, height: {}", width, height);
|
||||
|
|
|
@ -917,8 +917,9 @@ impl Term {
|
|||
|
||||
let range = Some(cols.start..line_end);
|
||||
if cols.end >= grid.num_cols() - 1 {
|
||||
range.as_ref()
|
||||
.map(|range| self.maybe_newline(grid, line, range.end));
|
||||
if let Some(ref range) = range {
|
||||
self.maybe_newline(grid, line, range.end);
|
||||
}
|
||||
}
|
||||
|
||||
range
|
||||
|
|
|
@ -57,13 +57,13 @@ pub mod fmt {
|
|||
|
||||
impl<T: fmt::Display> fmt::Display for $s<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "\x1b[{}m{}\x1b[0m", $color, self.0)
|
||||
write!(f, concat!("\x1b[", $color, "m{}\x1b[0m"), self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for $s<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "\x1b[{}m{:?}\x1b[0m", $color, self.0)
|
||||
write!(f, concat!("\x1b[", $color, "m{:?}\x1b[0m"), self.0)
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
|
Loading…
Reference in a new issue