From e803aa488c3a95193d3e3ae358b640c299f8f121 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 23 Nov 2026 20:36:22 +0100 Subject: License --- src/line.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/line.rs') diff --git a/src/line.rs b/src/line.rs index 9877c48..e178f5b 100644 --- a/src/line.rs +++ b/src/line.rs @@ -1,3 +1,10 @@ +/* + * This file is part of agent686 + * Copyright (C) 2026 Salmonik + * SPDX-License-Identifier: GPL-3.0-or-later + * https://git.2137697.xyz/agent686 + */ + use std::io::{self, IsTerminal, Write}; use std::os::unix::fs::PermissionsExt; use std::path::PathBuf; @@ -5,8 +12,8 @@ use std::path::PathBuf; use crossterm::cursor::{MoveToColumn, MoveUp}; use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; use crossterm::event::{DisableBracketedPaste, EnableBracketedPaste}; -use crossterm::terminal::{self, Clear, ClearType}; use crossterm::execute; +use crossterm::terminal::{self, Clear, ClearType}; const HISTORY_LIMIT: usize = 200; @@ -311,12 +318,7 @@ struct DrawState { cursor_row: usize, } -fn draw( - prompt: &str, - buffer: &[char], - cursor: usize, - state: &mut DrawState, -) -> io::Result<()> { +fn draw(prompt: &str, buffer: &[char], cursor: usize, state: &mut DrawState) -> io::Result<()> { let mut out = io::stdout(); draw_to(&mut out, prompt, buffer, cursor, state)?; out.flush() @@ -396,7 +398,10 @@ fn load_history() -> Vec { lines.drain(..lines.len() - HISTORY_LIMIT); // Keep the file from growing without bound, not just the in-memory list. if lines.len() * 2 < text.lines().count() { - let body: Vec = lines.iter().map(|line| line.replace('\n', "\u{0}")).collect(); + let body: Vec = lines + .iter() + .map(|line| line.replace('\n', "\u{0}")) + .collect(); let _ = std::fs::write(&path, format!("{}\n", body.join("\n"))); } } -- cgit v1.2.3