Apply cargo clippy --fix cleanups
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
19
src/app.rs
19
src/app.rs
@@ -231,7 +231,7 @@ impl Selection {
|
|||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
result.push(' ');
|
result.push(' ');
|
||||||
} else {
|
} else {
|
||||||
result.push_str(&s);
|
result.push_str(s);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.push(' ');
|
result.push(' ');
|
||||||
@@ -743,7 +743,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4. WM-keybinds – bara när ingen terminal är fokuserad
|
// 4. WM-keybinds – bara när ingen terminal är fokuserad
|
||||||
let terminal_focused = self.focused_id.map_or(false, |id| {
|
let terminal_focused = self.focused_id.is_some_and(|id| {
|
||||||
self.windows.iter().any(|w| w.id == id && matches!(w.content, WindowContent::Terminal { .. }))
|
self.windows.iter().any(|w| w.id == id && matches!(w.content, WindowContent::Terminal { .. }))
|
||||||
});
|
});
|
||||||
if !terminal_focused {
|
if !terminal_focused {
|
||||||
@@ -1125,12 +1125,12 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 5. Innehållsyta → fokus + vidarebefordra musklick till terminal
|
// 5. Innehållsyta → fokus + vidarebefordra musklick till terminal
|
||||||
let hit = self.windows.iter().rev().find(|w| w.in_content(col, row)).and_then(|w| {
|
let hit = self.windows.iter().rev().find(|w| w.in_content(col, row)).map(|w| {
|
||||||
let (mode, encoding) = match &w.content {
|
let (mode, encoding) = match &w.content {
|
||||||
WindowContent::Terminal { alive, .. } if *alive => (w.mouse_mode, w.mouse_encoding),
|
WindowContent::Terminal { alive, .. } if *alive => (w.mouse_mode, w.mouse_encoding),
|
||||||
_ => (vt100::MouseProtocolMode::None, vt100::MouseProtocolEncoding::Default),
|
_ => (vt100::MouseProtocolMode::None, vt100::MouseProtocolEncoding::Default),
|
||||||
};
|
};
|
||||||
Some((w.id, w.content_rect(), mode, encoding))
|
(w.id, w.content_rect(), mode, encoding)
|
||||||
});
|
});
|
||||||
if let Some((id, content_rect, mode, encoding)) = hit {
|
if let Some((id, content_rect, mode, encoding)) = hit {
|
||||||
crate::log::log(&format!(" click step5: window={} mode={:?} enc={:?} col={} row={} content_rect={:?}", id, mode, encoding, col, row, content_rect));
|
crate::log::log(&format!(" click step5: window={} mode={:?} enc={:?} col={} row={} content_rect={:?}", id, mode, encoding, col, row, content_rect));
|
||||||
@@ -1458,7 +1458,7 @@ impl App {
|
|||||||
Ok((pty, rx)) => {
|
Ok((pty, rx)) => {
|
||||||
let parser = vt100::Parser::new(rows, cols, 0);
|
let parser = vt100::Parser::new(rows, cols, 0);
|
||||||
self.next_id += 1;
|
self.next_id += 1;
|
||||||
let title = shell.split('/').last().unwrap_or(shell).to_string();
|
let title = shell.split('/').next_back().unwrap_or(shell).to_string();
|
||||||
self.windows.push(FloatingWindow {
|
self.windows.push(FloatingWindow {
|
||||||
id,
|
id,
|
||||||
x,
|
x,
|
||||||
@@ -1909,7 +1909,7 @@ fn key_to_bytes(key: KeyEvent, app_cursor: bool, _app_keypad: bool) -> Option<Ve
|
|||||||
fn base64_encode(data: &[u8]) -> String {
|
fn base64_encode(data: &[u8]) -> String {
|
||||||
const ALPHABET: &[u8; 64] =
|
const ALPHABET: &[u8; 64] =
|
||||||
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
let mut out = String::with_capacity((data.len() + 2) / 3 * 4);
|
let mut out = String::with_capacity(data.len().div_ceil(3) * 4);
|
||||||
for chunk in data.chunks(3) {
|
for chunk in data.chunks(3) {
|
||||||
let b0 = chunk[0] as u32;
|
let b0 = chunk[0] as u32;
|
||||||
let b1 = if chunk.len() > 1 { chunk[1] as u32 } else { 0 };
|
let b1 = if chunk.len() > 1 { chunk[1] as u32 } else { 0 };
|
||||||
@@ -2000,12 +2000,7 @@ fn find_apc_g_start(data: &[u8]) -> Option<usize> {
|
|||||||
if data.len() < 3 {
|
if data.len() < 3 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
for i in 0..data.len() - 2 {
|
(0..data.len() - 2).find(|&i| data[i] == 0x1b && data[i + 1] == b'_' && data[i + 2] == b'G')
|
||||||
if data[i] == 0x1b && data[i + 1] == b'_' && data[i + 2] == b'G' {
|
|
||||||
return Some(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hitta APC slut (ESC \) efter start. Returnerar end offset (inkl. ESC \).
|
/// Hitta APC slut (ESC \) efter start. Returnerar end offset (inkl. ESC \).
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pub fn run(socket_path: &str) -> io::Result<()> {
|
|||||||
match ipc::read_message::<_, ServerMessage>(&mut reader) {
|
match ipc::read_message::<_, ServerMessage>(&mut reader) {
|
||||||
Ok(ServerMessage::HelloOk { .. }) => {}
|
Ok(ServerMessage::HelloOk { .. }) => {}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(io::Error::new(io::ErrorKind::Other, "Ogiltigt svar från server"))
|
return Err(io::Error::other("Ogiltigt svar från server"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ pub fn show_bg(
|
|||||||
fn base64_encode(data: &[u8]) -> String {
|
fn base64_encode(data: &[u8]) -> String {
|
||||||
const ALPHABET: &[u8; 64] =
|
const ALPHABET: &[u8; 64] =
|
||||||
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
let mut out = String::with_capacity((data.len() + 2) / 3 * 4);
|
let mut out = String::with_capacity(data.len().div_ceil(3) * 4);
|
||||||
for chunk in data.chunks(3) {
|
for chunk in data.chunks(3) {
|
||||||
let b0 = chunk[0] as u32;
|
let b0 = chunk[0] as u32;
|
||||||
let b1 = if chunk.len() > 1 { chunk[1] as u32 } else { 0 };
|
let b1 = if chunk.len() > 1 { chunk[1] as u32 } else { 0 };
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub fn init() {
|
|||||||
match OpenOptions::new().create(true).append(true).open(&path) {
|
match OpenOptions::new().create(true).append(true).open(&path) {
|
||||||
Ok(f) => {
|
Ok(f) => {
|
||||||
*LOG.lock().unwrap() = Some(f);
|
*LOG.lock().unwrap() = Some(f);
|
||||||
log(&format!("=== TUI-WM startad ==="));
|
log(&"=== TUI-WM startad ===".to_string());
|
||||||
}
|
}
|
||||||
Err(e) => eprintln!("log::init: kunde inte öppna {:?}: {}", path, e),
|
Err(e) => eprintln!("log::init: kunde inte öppna {:?}: {}", path, e),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user