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 0000000..9ab0e57 Binary files /dev/null and b/bmps/shippori-mincho/死0.bmp differ diff --git a/bmps/shippori-mincho/話0.bmp b/bmps/shippori-mincho/話0.bmp new file mode 100644 index 0000000..ea3f3d0 Binary files /dev/null and b/bmps/shippori-mincho/話0.bmp differ diff --git a/bmps/shippori-mincho/離0.bmp b/bmps/shippori-mincho/離0.bmp new file mode 100644 index 0000000..cdfed6c Binary files /dev/null and b/bmps/shippori-mincho/離0.bmp differ diff --git a/docs/window-likes/audio-player.md b/docs/window-likes/audio-player.md index ae2bd90..487c0e8 100644 --- a/docs/window-likes/audio-player.md +++ b/docs/window-likes/audio-player.md @@ -16,6 +16,10 @@ Tab completion is supported for the `` 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);