Fix clippy warnings
This commit is contained in:
parent
2b991129e3
commit
6c501c6640
9 changed files with 80 additions and 59 deletions
|
|
@ -74,7 +74,7 @@ impl fmt::Display for FontSize {
|
|||
}
|
||||
}
|
||||
|
||||
static WRAP_MODE: &'static [Wrap] = &[Wrap::None, Wrap::Glyph, Wrap::Word];
|
||||
static WRAP_MODE: &[Wrap] = &[Wrap::None, Wrap::Glyph, Wrap::Word];
|
||||
|
||||
fn main() -> cosmic::iced::Result {
|
||||
env_logger::init();
|
||||
|
|
@ -274,7 +274,7 @@ impl Application for Window {
|
|||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
static THEMES: &'static [&'static str] = &["Dark", "Light"];
|
||||
static THEMES: &[&str] = &["Dark", "Light"];
|
||||
let theme_picker = pick_list(
|
||||
THEMES,
|
||||
Some(match self.theme {
|
||||
|
|
@ -375,11 +375,11 @@ fn update_alignment<'a, T: Edit<'a>>(editor: &mut T, align: Align) {
|
|||
std::cmp::Ordering::Less => (select.line, current_line),
|
||||
std::cmp::Ordering::Equal => (current_line, current_line),
|
||||
};
|
||||
editor.buffer_mut().lines.get_mut(start..=end).map(|lines| {
|
||||
if let Some(lines) = editor.buffer_mut().lines.get_mut(start..=end) {
|
||||
for line in lines.iter_mut() {
|
||||
line.set_align(Some(align));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if let Some(line) = editor.buffer_mut().lines.get_mut(current_line) {
|
||||
line.set_align(Some(align));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ pub fn draw_pixel(
|
|||
|
||||
let mut current = buffer[offset + 2] as u32
|
||||
| (buffer[offset + 1] as u32) << 8
|
||||
| (buffer[offset + 0] as u32) << 16
|
||||
| (buffer[offset] as u32) << 16
|
||||
| (buffer[offset + 3] as u32) << 24;
|
||||
|
||||
if alpha >= 255 || current == 0 {
|
||||
|
|
@ -244,7 +244,7 @@ pub fn draw_pixel(
|
|||
|
||||
buffer[offset + 2] = current as u8;
|
||||
buffer[offset + 1] = (current >> 8) as u8;
|
||||
buffer[offset + 0] = (current >> 16) as u8;
|
||||
buffer[offset] = (current >> 16) as u8;
|
||||
buffer[offset + 3] = (current >> 24) as u8;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ impl<'a, Editor> TextBox<'a, Editor> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn text_box<'a, Editor>(editor: &'a Mutex<Editor>) -> TextBox<'a, Editor> {
|
||||
pub fn text_box<Editor>(editor: &Mutex<Editor>) -> TextBox<Editor> {
|
||||
TextBox::new(editor)
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ where
|
|||
&mut state.cache.lock().unwrap(),
|
||||
text_color,
|
||||
|x, y, w, h, color| {
|
||||
if w <= 0 || h <= 0 {
|
||||
if w == 0 || h == 0 {
|
||||
// Do not draw invalid sized rectangles
|
||||
return;
|
||||
}
|
||||
|
|
@ -235,10 +235,7 @@ where
|
|||
|
||||
let mut status = Status::Ignored;
|
||||
match event {
|
||||
Event::Keyboard(KeyEvent::KeyPressed {
|
||||
key_code,
|
||||
modifiers,
|
||||
}) => match key_code {
|
||||
Event::Keyboard(KeyEvent::KeyPressed { key_code, .. }) => match key_code {
|
||||
KeyCode::Left => {
|
||||
editor.action(Action::Left);
|
||||
status = Status::Captured;
|
||||
|
|
@ -318,15 +315,14 @@ where
|
|||
status = Status::Captured;
|
||||
}
|
||||
}
|
||||
Event::Mouse(MouseEvent::WheelScrolled { delta }) => match delta {
|
||||
ScrollDelta::Lines { x, y } => {
|
||||
editor.action(Action::Scroll {
|
||||
lines: (-y * 6.0) as i32,
|
||||
});
|
||||
status = Status::Captured;
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
Event::Mouse(MouseEvent::WheelScrolled {
|
||||
delta: ScrollDelta::Lines { y, .. },
|
||||
}) => {
|
||||
editor.action(Action::Scroll {
|
||||
lines: (-y * 6.0) as i32,
|
||||
});
|
||||
status = Status::Captured;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
env_logger::init();
|
||||
|
||||
let path = if let Some(arg) = env::args().nth(1) {
|
||||
arg.clone()
|
||||
arg
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
|
@ -35,7 +35,7 @@ fn main() {
|
|||
-1,
|
||||
1024 * display_scale as u32,
|
||||
768 * display_scale as u32,
|
||||
&format!("COSMIC Text - {}", path),
|
||||
&format!("COSMIC Text - {path}"),
|
||||
&[WindowFlag::Resizable],
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -110,7 +110,7 @@ fn main() {
|
|||
let mut end_line = 0;
|
||||
for run in editor.buffer().layout_runs() {
|
||||
end_line = run.line_i;
|
||||
if start_line_opt == None {
|
||||
if start_line_opt.is_none() {
|
||||
start_line_opt = Some(end_line);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,9 +131,8 @@ fn main() {
|
|||
redraw(&mut window, &mut editor, &mut swash_cache);
|
||||
|
||||
for event in window.events() {
|
||||
match event.to_option() {
|
||||
EventOption::Quit(_) => process::exit(1),
|
||||
_ => (),
|
||||
if let EventOption::Quit(_) = event.to_option() {
|
||||
process::exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
use cosmic_text::{Attrs, Buffer, Color, FontSystem, Metrics, SwashCache};
|
||||
use std::cmp;
|
||||
use std::cmp::{self, Ordering};
|
||||
use termion::{color, cursor};
|
||||
|
||||
fn main() {
|
||||
|
|
@ -66,21 +66,29 @@ fn main() {
|
|||
let scale = |c: u8| cmp::max(0, cmp::min(255, ((c as i32) * (a as i32)) / 255)) as u8;
|
||||
|
||||
// Navigate to x coordinate
|
||||
if x > last_x {
|
||||
print!("{}", cursor::Right((x - last_x) as u16));
|
||||
last_x = x;
|
||||
} else if x < last_x {
|
||||
print!("{}", cursor::Left((last_x - x) as u16));
|
||||
last_x = x;
|
||||
match x.cmp(&last_x) {
|
||||
Ordering::Greater => {
|
||||
print!("{}", cursor::Right((x - last_x) as u16));
|
||||
last_x = x;
|
||||
}
|
||||
Ordering::Less => {
|
||||
print!("{}", cursor::Left((last_x - x) as u16));
|
||||
last_x = x;
|
||||
}
|
||||
Ordering::Equal => {}
|
||||
}
|
||||
|
||||
// Navigate to y coordinate
|
||||
if y > last_y {
|
||||
print!("{}", cursor::Down((y - last_y) as u16));
|
||||
last_y = y;
|
||||
} else if y < last_y {
|
||||
print!("{}", cursor::Up((last_y - y) as u16));
|
||||
last_y = y;
|
||||
match y.cmp(&last_y) {
|
||||
Ordering::Greater => {
|
||||
print!("{}", cursor::Down((y - last_y) as u16));
|
||||
last_y = y;
|
||||
}
|
||||
Ordering::Less => {
|
||||
print!("{}", cursor::Up((last_y - y) as u16));
|
||||
last_y = y;
|
||||
}
|
||||
Ordering::Equal => {}
|
||||
}
|
||||
|
||||
// Print a space with the expected color as the background
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue