Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[workspace.package]
edition = "2021"
edition = "2024"
authors = ["saying121 <saying121@outlook.com>"]
homepage = "https://github.com/saying121/lcode"
rust-version = "1.80.1"
rust-version = "1.85"
repository = "https://github.com/saying121/lcode"

[workspace]
members = ["crates/*"]
resolver = "2"
resolver = "3"
exclude = [".github", "sample/"]

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion crates/key_parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = { workspace = true }
authors = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
rust-version = "1.77"
rust-version = { workspace = true }
keywords = ["vim", "keymap"]
categories = ["config"]
readme = "./README.md"
Expand Down
2 changes: 1 addition & 1 deletion crates/key_parse/src/key_parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::string_slice)]
#![allow(clippy::string_slice, reason = "todo: make it more grace")]

use crossterm::event::KeyCode;
use miette::bail;
Expand Down
6 changes: 3 additions & 3 deletions crates/lcode-config/src/config/read_config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::fs::{self, write, OpenOptions};
use std::fs::{self, OpenOptions, write};

use miette::{Context, IntoDiagnostic, Result};

use super::{global::*, user_nested::Suffix, LcodeConfig};
use super::{LcodeConfig, global::*, user_nested::Suffix};
use crate::{
config::{user_nested::Urls, Config},
config::{Config, user_nested::Urls},
keymap::TuiKeyMap,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/lcode-config/src/config/user_serializes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ where
};
Ok(res)
}
#[expect(clippy::trivially_copy_pass_by_ref)]
#[expect(clippy::trivially_copy_pass_by_ref, reason = "follow signature")]
pub fn serialize<S>(v: &Suffix, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode-config/src/theme/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::module_inception)]
#![allow(clippy::module_inception, reason = "that's ok")]
use self::theme::{Edit, Info, Select, Tab, TopicTags};

pub(crate) mod theme;
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode-config/tests/serde_config_work.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use lcode_config::{
config::{user_nested::Suffix, LcodeConfig},
config::{LcodeConfig, user_nested::Suffix},
global::G_USER_CONFIG,
};
use miette::Result;
Expand Down
4 changes: 2 additions & 2 deletions crates/lcode/src/app/dispatch/handle_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crossterm::event::{Event as CrossEvent, KeyCode, KeyEvent, KeyModifiers};
use lcode_config::{global::G_USER_CONFIG, keymap::*};
use miette::Result;

use crate::app::{inner::App, Tab2Panel, TuiIndex, TuiMode};
use crate::app::{Tab2Panel, TuiIndex, TuiMode, inner::App};

impl<'app_lf> App<'app_lf> {
impl App<'_> {
pub async fn handle_key(&mut self, keyevent: KeyEvent) {
let temp = if matches!(self.tab_index, TuiIndex::Select)
&& matches!(self.select.inputline.mode, TuiMode::Insert)
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/edit/cmds/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ButState {
}

impl ButState {
#[expect(dead_code)]
#[expect(dead_code, reason = "util fn")]
pub fn open(&mut self) {
self.show = true;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/edit/cmds/codeblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct CodeBlock<'block> {
pub mode: TuiMode,
}

impl<'block> CodeBlock<'block> {
impl CodeBlock<'_> {
pub fn quit_edit_tui(&mut self) -> bool {
self.mode = TuiMode::OutEdit;
true
Expand Down
8 changes: 4 additions & 4 deletions crates/lcode/src/app/edit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct EditCode<'tab1> {
pub test: test::TestState,
}

impl<'tab1> EditCode<'tab1> {
impl EditCode<'_> {
pub fn normal_map(&mut self, event: CrossEvent) -> bool {
self.code_block.normal_map(event)
}
Expand All @@ -42,7 +42,7 @@ impl<'tab1> EditCode<'tab1> {
}

// Show only one pop view every time.
impl<'tab1> EditCode<'tab1> {
impl EditCode<'_> {
pub fn toggle_menu(&mut self) -> bool {
self.button.toggle();
self.test.close();
Expand All @@ -63,7 +63,7 @@ impl<'tab1> EditCode<'tab1> {
}
}

impl<'tab1> EditCode<'tab1> {
impl EditCode<'_> {
pub fn close_pop(&mut self) -> bool {
if self.test.show {
self.test.close();
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<'tab1> EditCode<'tab1> {
true
}

#[allow(non_snake_case)]
#[expect(non_snake_case, reason = "semantic")]
pub fn vertical_scroll_G(&mut self) -> bool {
if self.submit.show {
self.submit.last();
Expand Down
4 changes: 2 additions & 2 deletions crates/lcode/src/app/impl_app/edit_qs.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use leetcode_api::{
glob_leetcode,
leetcode::{question::qs_detail::Question, resps::run_res::*, IdSlug},
leetcode::{IdSlug, question::qs_detail::Question, resps::run_res::*},
};
use tracing::error;

use crate::{app::inner::App, mytui::myevent::UserEvent};

impl<'app_lf> App<'app_lf> {
impl App<'_> {
pub fn get_qs_detail(&self, idslug: IdSlug, force: bool) {
let eve_tx = self.events.tx.clone();
tokio::spawn(async move {
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/impl_app/get_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
mytui::myevent::UserEvent,
};

impl<'app_lf> App<'app_lf> {
impl App<'_> {
pub fn sync_index(&mut self) -> bool {
if self.select.sync_bar.show {
return false;
Expand Down
16 changes: 9 additions & 7 deletions crates/lcode/src/app/impl_app/get_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use leetcode_api::{
use miette::IntoDiagnostic;
use notify_rust::Notification;
use ratatui::prelude::*;
use ratatui_image::{picker::Picker, protocol::StatefulProtocol, thread::ThreadProtocol, Resize};
use ratatui_image::{Resize, picker::Picker, protocol::StatefulProtocol, thread::ThreadProtocol};
use tokio::join;

use crate::{app::inner::App, mytui::myevent::UserEvent};

impl<'app> App<'app> {
impl App<'_> {
/// get use info
/// If haven't checked in, check in it.
pub fn user_info_and_checkin(&self) {
Expand Down Expand Up @@ -138,11 +138,13 @@ impl<'app> App<'app> {

// Resize and encode in background thread.
let tx_main_render = self.events.tx.clone();
thread::spawn(move || loop {
if let Ok((mut protocol, resize, area)) = rec_worker.recv() {
protocol.resize_encode(&resize, None, area);
if let Err(e) = tx_main_render.send(UserEvent::RedrawImg(protocol)) {
tracing::error!("{e}");
thread::spawn(move || {
loop {
if let Ok((mut protocol, resize, area)) = rec_worker.recv() {
protocol.resize_encode(&resize, None, area);
if let Err(e) = tx_main_render.send(UserEvent::RedrawImg(protocol)) {
tracing::error!("{e}");
}
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/impl_app/impl_tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
mytui::{myevent::EventsHandler, term::Term},
};

impl<'app_lf> App<'app_lf> {
impl App<'_> {
/// send info for render tui
pub fn render(&self) {
self.events.render();
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct Info<'tab3> {
}

// keymaps
impl<'tab3> Info<'tab3> {
impl Info<'_> {
pub fn new() -> Self {
let mut pat = Vec::with_capacity(G_USER_CONFIG.keymap.map_set.len() + 1);
pat.push(ListItem::new(
Expand Down
10 changes: 5 additions & 5 deletions crates/lcode/src/app/inner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use leetcode_api::{
dao::{query::Query, save_info::FileInfo},
leetcode::{question::qs_detail::Question, IdSlug},
leetcode::{IdSlug, question::qs_detail::Question},
};
use miette::{IntoDiagnostic, Result};
use ratatui_image::thread::ThreadProtocol;
Expand All @@ -10,7 +10,7 @@ use tokio::{
};
use tui_textarea::TextArea;

use super::{dispatch::next_key, edit::EditCode, info, select, topic, TuiIndex};
use super::{TuiIndex, dispatch::next_key, edit::EditCode, info, select, topic};
use crate::{
editor::{CodeTestFile, Editor},
glob_leetcode,
Expand Down Expand Up @@ -40,7 +40,7 @@ pub struct App<'app> {
pub events: EventsHandler,
}

impl<'app_lf> App<'app_lf> {
impl App<'_> {
pub fn add_test_case(&mut self) -> bool {
let id = self
.edit
Expand Down Expand Up @@ -69,7 +69,7 @@ impl<'app_lf> App<'app_lf> {
true
}
}
impl<'app_lf> App<'app_lf> {
impl App<'_> {
/// edit cursor qs with outer editor, for select tab
pub async fn select_edit_cur_qs(&mut self) -> Result<()> {
let id = self.select.current_qs();
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<'app_lf> App<'app_lf> {
}

// tab1 edit
impl<'app_lf> App<'app_lf> {
impl App<'_> {
/// from ui to file
pub async fn save_code(&mut self) -> Result<()> {
self.save_code = true;
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub enum TuiMode {
/// input panel
Insert,
/// input panel
#[expect(dead_code)]
#[expect(dead_code, reason = "todo use it")]
Visual,

/// not enter input
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/select/cmds/inputline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct InputLine<'line> {
pub text_line: TextArea<'line>,
}

impl<'line> InputLine<'line> {
impl InputLine<'_> {
pub fn handle_input(&mut self, input: Input) -> bool {
self.text_line.input(input)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct SelectQS<'tab0> {
pub inputline: inputline::InputLine<'tab0>,
}

impl<'tab0> SelectQS<'tab0> {
impl SelectQS<'_> {
pub fn keymap_insert(&mut self, event: CrossEvent) -> bool {
match event.into() {
Input { key: tui_textarea::Key::Esc, .. } => self.out_edit(),
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/app/topic/cmds/intputline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct InputLine<'line> {
pub text_line: TextArea<'line>,
}

impl<'line> InputLine<'line> {
impl InputLine<'_> {
/// return if the input modified text contents or not
pub fn handle_input(&mut self, input: Input) -> bool {
self.text_line.input(input)
Expand Down
10 changes: 5 additions & 5 deletions crates/lcode/src/app/topic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct TopicTagsQS<'tab2> {
pub ac_status: Box<[PassStat]>,
}

impl<'tab2> TopicTagsQS<'tab2> {
impl TopicTagsQS<'_> {
pub fn keymap_insert(&mut self, event: CrossEvent) -> bool {
match event.into() {
Input { key: tui_textarea::Key::Esc, .. } => self.be_out_edit(),
Expand Down Expand Up @@ -160,7 +160,7 @@ impl<'tab2> TopicTagsQS<'tab2> {
}

// for `difficulties`
impl<'tab2> TopicTagsQS<'tab2> {
impl TopicTagsQS<'_> {
pub async fn toggle_diff(&mut self) -> bool {
// the operate must trigger refresh
self.difficulty.toggle_diff();
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<'tab2> TopicTagsQS<'tab2> {
}

// all topic tags, add remove topic
impl<'tab2> TopicTagsQS<'tab2> {
impl TopicTagsQS<'_> {
/// remove a topic and refresh question
pub async fn rm_user_topic(&mut self) -> bool {
let trigger = self.topic.rm_user_topic();
Expand Down Expand Up @@ -301,7 +301,7 @@ impl<'tab2> TopicTagsQS<'tab2> {
}

// filtered questions
impl<'tab2> TopicTagsQS<'tab2> {
impl TopicTagsQS<'_> {
pub fn next_qs(&mut self) {
self.question_state.next();
}
Expand All @@ -322,7 +322,7 @@ impl<'tab2> TopicTagsQS<'tab2> {
}

// user topic tags
impl<'tab2> TopicTagsQS<'tab2> {
impl TopicTagsQS<'_> {
pub fn prev_user_topic(&mut self) {
self.topic.prev_user();
}
Expand Down
8 changes: 4 additions & 4 deletions crates/lcode/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::io;

use clap::{Args, Command, CommandFactory, Parser, Subcommand};
use clap_complete::{generate, Generator, Shell};
use clap_complete::{Generator, Shell, generate};
use colored::Colorize;
use lcode_config::{
config::{user_nested::Suffix, LcodeConfig},
config::{LcodeConfig, user_nested::Suffix},
global::G_DATABASE_PATH,
};
use leetcode_api::{leetcode::IdSlug, render::Render};
Expand All @@ -27,8 +27,8 @@ struct Cli {
command: Option<Commands>,
}

fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
generate(gen, cmd, cmd.get_name().to_owned(), &mut io::stdout());
fn print_completions<G: Generator>(genen: G, cmd: &mut Command) {
generate(genen, cmd, cmd.get_name().to_owned(), &mut io::stdout());
}

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use leetcode_api::{
};
use miette::{IntoDiagnostic, Result};
use tokio::{
fs::{self, create_dir_all, OpenOptions},
fs::{self, OpenOptions, create_dir_all},
io::AsyncWriteExt,
};
use tracing::{debug, instrument};
Expand Down
2 changes: 1 addition & 1 deletion crates/lcode/src/mytui/helper.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ratatui::{
prelude::*,
widgets::{block::Title, Block, Borders},
widgets::{Block, Borders, block::Title},
};

/// helper function to create a bottom rect using up certain percentage of the available rect `r`
Expand Down
4 changes: 2 additions & 2 deletions crates/lcode/src/mytui/my_widget/botton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Default for ButtonStates {
}
}

impl<'a> Button<'a> {
impl Button<'_> {
const fn colors(&self) -> (Color, Color, Color, Color) {
let theme = self.theme;
match self.state {
Expand All @@ -39,7 +39,7 @@ impl<'a> Button<'a> {
}
}

impl<'a> Widget for Button<'a> {
impl Widget for Button<'_> {
fn render(self, area: Rect, buf: &mut Buffer) {
let (background, text, shadow, highlight) = self.colors();
buf.set_style(area, Style::new().bg(background).fg(text));
Expand Down
Loading
Loading