From 2786865591757911049ba9ba7d68b650ed67d86e Mon Sep 17 00:00:00 2001 From: stjet <49297268+stjet@users.noreply.github.com> Date: Sat, 26 Sep 2026 05:50:37 +0000 Subject: [PATCH] remove id3 dep; malvim qol some clippy cleanup --- Cargo.toml | 5 ++--- bmps/shippori-mincho/死0.bmp | Bin 0 -> 630 bytes bmps/shippori-mincho/話0.bmp | Bin 0 -> 630 bytes bmps/shippori-mincho/離0.bmp | Bin 0 -> 630 bytes docs/window-likes/audio-player.md | 4 ++++ docs/window-likes/malvim.md | 10 +++++++--- ming-wm-lib/src/serialize.rs | 12 ++---------- src/bin/audio_player.rs | 27 +++++++++++++++++++++++---- src/bin/draw.rs | 12 ++---------- src/bin/file_explorer.rs | 2 +- src/bin/malvim.rs | 18 +++++++++++++++++- wm/src/window_manager.rs | 2 +- 12 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 bmps/shippori-mincho/死0.bmp create mode 100644 bmps/shippori-mincho/話0.bmp create mode 100644 bmps/shippori-mincho/離0.bmp diff --git a/Cargo.toml b/Cargo.toml index 1f4c718..1754b1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ming-wm" -version = "1.3.0-rc.0" +version = "1.3.0-rc.1" repository = "https://github.com/stjet/ming-wm" license = "GPL-3.0-or-later" edition = "2021" @@ -34,14 +34,13 @@ ming-wm-lib = { path = "ming-wm-lib" } wm = { path = "wm", optional = true } linux = { path = "linux", optional = true } rodio = { version = "0.19.0", default-features = false, features = [ "flac", "mp3", "symphonia-vorbis", "wav" ], optional = true } -id3 = { version = "1.10.0", optional = true } mp4ameta = { version = "0.11.0", optional = true } metaflac = { version = "0.2.5", optional = true } [features] default = [ "wm", "terminal" ] terminal = [ "linux" ] -audio_player = [ "id3", "mp4ameta", "metaflac", "rodio" ] +audio_player = [ "mp4ameta", "metaflac", "rodio" ] [profile.release] lto = true diff --git a/bmps/shippori-mincho/死0.bmp b/bmps/shippori-mincho/死0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9ab0e57332aad9817f38cc7928371053ff202068 GIT binary patch literal 630 zcmajdu}eZx6vy%VM4TKF1BaG~hA^CpTty_1Xb2R-%?3f7lZYlAMEV0N#993hj8!W-ZBT@-5` zp7CMcnLFxXRPYk(&#|_)n(Eh>hCRehJVo*&@~<%0%xJ{&DQo9e`>Q`oJ#X~`;t^*5 z_1n76R=@y{nBx@M{~MnAqF9^Z-rjE$ccK0jhN#B+b*Fvn*WTJUI6rd|6TIQjdUV$t z=sYd_ppM{vm{S-d6Ml#I6%Y2le%T_H*f~FW4R`2afr`<0v`3h0zQ85)_c__)lX_zd D#pkS; literal 0 HcmV?d00001 diff --git a/bmps/shippori-mincho/話0.bmp b/bmps/shippori-mincho/話0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ea3f3d0fb54764f03e2ebf14c9d8982705ed9c69 GIT binary patch literal 630 zcmZwF!Ak-`6vy$=gpv%3AVkW%Bt@Qr#9QLUI&=^b1fe`chk}Zr2!gOf;3){ac+L2ddS5`o4Lz d@q!6Xp#AF)(QmVg1llOMwQP_2rd@ns?jIbScEqS~33@Ma|pc-s)Na&5CFiUKyga!>F+Oj1Y zngSC_h-h&s`XBluZr`7rUWSCvJ?9>u=lHxBj;uF2_0K5JUbL77r<=@iT>HNM^83h< zPI#WDiVwReLTxS)_@j$_4>LBtnY;~;7(xZ(s3D00wk_(t6B{U_2PNzCplJC%^;sNZ z5qW65=H6o%uNH&EQ_SNS(+J@OeYk_x|BMC9VF{C1gMMoS2N=MA>v5^yB8>~IKz;k6 zbu8lpSwu006RbjK7=z~PEPncv>xx` and `` argument The copy shortcut will copy the currently playing song's file name, if there is a currently playing song. +## Artist Name + +For mp3, artist name shows up only if there is an id3v1 tag present. For flac and mp4, the built-in metadata system should be supported. + ## Playlists Example playlist file: diff --git a/docs/window-likes/malvim.md b/docs/window-likes/malvim.md index a80cc65..d20077a 100644 --- a/docs/window-likes/malvim.md +++ b/docs/window-likes/malvim.md @@ -24,14 +24,14 @@ Tab completion is supported for the `` argument. Down arrow will clear the - `A` - `r` - `dd` -- `dd` +- `dd` - `dw` (`dw` is not identical to vim's behaviour), `dW` - `d$` - `G` - `gg` -- `gg` +- `gg` - `f`, `F` -- `f`, `F` +- `f`, `F` - `;` (same as `f` but with the char the cursor is on, so not the same as vim) - `;` - `,` (same as `F` but with the char the cursor is on, so not the same as vim) @@ -45,3 +45,7 @@ Tab completion is supported for the `` argument. Down arrow will clear the ### Malvim Specific In Command-line Mode, `autoindent` can be done to toggle auto-indenting (when making new line in Insert Mode [ie, by hitting Enter/Return], space indentation of the new line will be the same as the space indentation of the current line). **Toggling on `autoindent` is highly recommended when editing code.** + +- `>` indent two spaces +- `>` indent variable amount of spaces +- `Alt+C` copy variable amount of lines to clipboard (if no number, defaults to only the current line) diff --git a/ming-wm-lib/src/serialize.rs b/ming-wm-lib/src/serialize.rs index d413698..eaae936 100644 --- a/ming-wm-lib/src/serialize.rs +++ b/ming-wm-lib/src/serialize.rs @@ -289,11 +289,7 @@ impl Serializable for DrawInstructions { "N" => None, _ => { if arg.len() > 1 { - if let Ok(n) = arg[1..].parse() { - Some(n) - } else { - None - } + arg[1..].parse().ok() } else { None } @@ -308,11 +304,7 @@ impl Serializable for DrawInstructions { "N" => None, _ => { if arg.len() > 1 { - if let Ok(n) = arg[1..].parse() { - Some(n) - } else { - None - } + arg[1..].parse().ok() } else { None } diff --git a/src/bin/audio_player.rs b/src/bin/audio_player.rs index 223dd9c..bf645f4 100644 --- a/src/bin/audio_player.rs +++ b/src/bin/audio_player.rs @@ -3,14 +3,14 @@ use std::vec; use std::io::BufReader; use std::path::PathBuf; use std::collections::HashMap; -use std::io::Read; +use std::io::{ Read, Seek }; use std::time::Duration; use std::fs::{ read_to_string, File }; use std::thread; use std::sync::{ Arc, Mutex }; use rodio::{ Decoder, OutputStream, Sink, Source }; -use id3::TagLike; +//use id3::TagLike; use mp4ameta; use metaflac; @@ -37,8 +37,27 @@ fn get_artist(path: &PathBuf) -> Option { }; x } else if ext == "mp3" { - let tag = id3::Tag::read_from_path(path).unwrap(); - tag.artist().map(|s| s.to_string()) + //let tag = id3::Tag::read_from_path(path).unwrap(); + //tag.artist().map(|s| s.to_string()) + //read id3v1 tag at end of file + let mut tag = File::open(path).unwrap(); + tag.seek(std::io::SeekFrom::End(-128)).unwrap(); + let mut tag_constant = vec![0; 3]; + tag.read_exact(&mut tag_constant).unwrap(); + //look for "TAG" + if tag_constant == vec![84, 65, 71] { + //first 30 chars are title, next 30 are artist, then next 30 are album + tag.seek_relative(30).unwrap(); + let mut artist = vec![0; 30]; + tag.read_exact(&mut artist).unwrap(); + //I hope stackoverflow doesn't die + if let Some(first) = artist.iter().position(|b| *b == 0) { + artist.truncate(first); + } + Some(String::from_utf8(artist).unwrap_or_default()) + } else { + None + } } else { None } diff --git a/src/bin/draw.rs b/src/bin/draw.rs index 2ebdfee..d3e2264 100644 --- a/src/bin/draw.rs +++ b/src/bin/draw.rs @@ -117,16 +117,8 @@ impl WindowLike for Draw { DrawAction::Line(p, _, u, r) => DrawAction::Line(*p, Some(self.current_location), *u, *r), DrawAction::Rect(p, _, r) => { let d = [ - if self.current_location[0] > p[0] { - self.current_location[0] - p[0] - } else { - p[0] - self.current_location[0] - }, - if self.current_location[1] > p[1] { - self.current_location[1] - p[1] - } else { - p[1] - self.current_location[1] - } + self.current_location[0].abs_diff(p[0]), + self.current_location[1].abs_diff(p[1]), ]; //find top left corner let tl = [ diff --git a/src/bin/file_explorer.rs b/src/bin/file_explorer.rs index fc9793f..4e6aa77 100644 --- a/src/bin/file_explorer.rs +++ b/src/bin/file_explorer.rs @@ -191,7 +191,7 @@ impl FileExplorer { //should include .. if not / fn get_current_dir_contents(&self) -> Vec { let mut contents = Vec::new(); - if self.current_path != PathBuf::from("/") { + if *self.current_path != *"/" { contents.push(DirectoryChild { override_name: Some("..".to_string()), is_file: false, diff --git a/src/bin/malvim.rs b/src/bin/malvim.rs index 700f997..8a66de2 100644 --- a/src/bin/malvim.rs +++ b/src/bin/malvim.rs @@ -278,6 +278,11 @@ impl WindowLike for Malvim { } else { changed = false; } + } else if key_press.key == '>' { + let num = self.maybe_num.unwrap_or(2); + let line = ¤t_file.content[current_file.line_pos]; + current_file.content[current_file.line_pos] = " ".repeat(num) + line; + current_file.cursor_pos += num; } else if key_press.key == 'h' || key_press.is_left_arrow() { current_file.cursor_pos = current_file.cursor_pos.checked_sub(self.maybe_num.unwrap_or(1)).unwrap_or(0); changed = false; @@ -485,7 +490,18 @@ impl WindowLike for Malvim { ShortcutType::ClipboardCopy => { if self.files.len() > 0 { let current_file = &mut self.files[self.current_file_index]; - WindowMessageResponse::Request(WindowManagerRequest::ClipboardCopy(current_file.content[current_file.line_pos].clone())) + let line_count = self.maybe_num.unwrap_or(1); + let mut copy_lines = String::new(); + for i in 0..line_count { + if current_file.content.len() == self.current_file_index + i { + break; + } + if !copy_lines.is_empty() { + copy_lines += "\n"; + } + copy_lines += ¤t_file.content[current_file.line_pos + i]; + } + WindowMessageResponse::Request(WindowManagerRequest::ClipboardCopy(copy_lines)) } else { WindowMessageResponse::DoNothing } diff --git a/wm/src/window_manager.rs b/wm/src/window_manager.rs index ff0acaa..533a7e3 100644 --- a/wm/src/window_manager.rs +++ b/wm/src/window_manager.rs @@ -721,7 +721,7 @@ impl WindowManager { self.writer.borrow_mut().write_saved_buffer_to_raw(); } //get windows to redraw - let redraw_ids = maybe_redraw_ids.unwrap_or(Vec::new()); + let redraw_ids = maybe_redraw_ids.unwrap_or_default(); let mut all_in_workspace = self.get_windows_in_workspace(true); if let Some(osk) = &self.osk { all_in_workspace.push(osk);