mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
fix off-by-1 column widths; add edit cursor
This commit is contained in:
parent
59918491f6
commit
4bfdd28638
7 changed files with 57 additions and 59 deletions
44
Cargo.lock
generated
44
Cargo.lock
generated
|
|
@ -156,9 +156,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "borsh"
|
name = "borsh"
|
||||||
version = "1.5.5"
|
version = "1.5.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5430e3be710b68d984d1391c854eb431a9d548640711faa54eecb1df93db91cc"
|
checksum = "b2b74d67a0fc0af8e9823b79fd1c43a0900e5a8f0e0f4cc9210796bf3a820126"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"borsh-derive",
|
"borsh-derive",
|
||||||
"cfg_aliases",
|
"cfg_aliases",
|
||||||
|
|
@ -166,9 +166,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "borsh-derive"
|
name = "borsh-derive"
|
||||||
version = "1.5.5"
|
version = "1.5.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8b668d39970baad5356d7c83a86fee3a539e6f93bf6764c97368243e17a0487"
|
checksum = "2d37ed1b2c9b78421218a0b4f6d8349132d6ec2cfeba1cfb0118b0a8e268df9e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
|
|
@ -262,9 +262,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.16"
|
version = "1.2.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
|
checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
|
@ -479,9 +479,9 @@ checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "file_type"
|
name = "file_type"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2f41d9c0ff84ee5335227a501bfa01284d5fec029f504dc48bea8238a16ca04"
|
checksum = "e237c2e6ae6183998137b1157b9e0fddfa25ce480f99f40ec1a5c2d49747c6d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"phf",
|
"phf",
|
||||||
]
|
]
|
||||||
|
|
@ -1178,9 +1178,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_decimal"
|
name = "rust_decimal"
|
||||||
version = "1.37.0"
|
version = "1.37.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c24af6e7ac43c88a8a458d1139d0246fdce2f6cd2f1ac6cb51eb88b29c978af"
|
checksum = "faa7de2ba56ac291bd90c6b9bece784a52ae1411f9506544b3eae36dd2356d50"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"borsh",
|
"borsh",
|
||||||
|
|
@ -1445,8 +1445,8 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri"
|
name = "tengri"
|
||||||
version = "0.3.2"
|
version = "0.4.0"
|
||||||
source = "git+https://codeberg.org/unspeaker/tengri?rev=96ff10c#96ff10c4b0fda0d71308f488f5715c2f87f782d0"
|
source = "git+https://codeberg.org/unspeaker/tengri?rev=81e7f50#81e7f503634af7768d3d21276f383cb9fd63a1ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_input",
|
"tengri_input",
|
||||||
"tengri_output",
|
"tengri_output",
|
||||||
|
|
@ -1455,18 +1455,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_input"
|
name = "tengri_input"
|
||||||
version = "0.3.2"
|
version = "0.4.0"
|
||||||
source = "git+https://codeberg.org/unspeaker/tengri?rev=96ff10c#96ff10c4b0fda0d71308f488f5715c2f87f782d0"
|
source = "git+https://codeberg.org/unspeaker/tengri?rev=81e7f50#81e7f503634af7768d3d21276f383cb9fd63a1ce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_output"
|
name = "tengri_output"
|
||||||
version = "0.3.2"
|
version = "0.4.0"
|
||||||
source = "git+https://codeberg.org/unspeaker/tengri?rev=96ff10c#96ff10c4b0fda0d71308f488f5715c2f87f782d0"
|
source = "git+https://codeberg.org/unspeaker/tengri?rev=81e7f50#81e7f503634af7768d3d21276f383cb9fd63a1ce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_tui"
|
name = "tengri_tui"
|
||||||
version = "0.3.2"
|
version = "0.4.0"
|
||||||
source = "git+https://codeberg.org/unspeaker/tengri?rev=96ff10c#96ff10c4b0fda0d71308f488f5715c2f87f782d0"
|
source = "git+https://codeberg.org/unspeaker/tengri?rev=81e7f50#81e7f503634af7768d3d21276f383cb9fd63a1ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic_float",
|
"atomic_float",
|
||||||
"better-panic",
|
"better-panic",
|
||||||
|
|
@ -1819,18 +1819,18 @@ checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.23"
|
version = "0.8.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6"
|
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive",
|
"zerocopy-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy-derive"
|
name = "zerocopy-derive"
|
||||||
version = "0.8.23"
|
version = "0.8.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154"
|
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
||||||
26
Cargo.toml
26
Cargo.toml
|
|
@ -5,22 +5,22 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies.tengri]
|
[dependencies.tengri]
|
||||||
git = "https://codeberg.org/unspeaker/tengri"
|
git = "https://codeberg.org/unspeaker/tengri"
|
||||||
rev = "96ff10c"
|
rev = "81e7f50"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.4", features = [ "cargo" ] }
|
clap = { version = "^4.5.4", features = [ "cargo" ] }
|
||||||
enolib = { git = "https://codeberg.org/simonrepp/enolib-rs", tag = "0.5.0" }
|
enolib = { git = "https://codeberg.org/simonrepp/enolib-rs", tag = "0.5.0" }
|
||||||
byte-unit = "5.1.6"
|
byte-unit = "^5.1.6"
|
||||||
file_type = "0.8"
|
file_type = "^0.8"
|
||||||
hex = "0.4"
|
hex = "^0.4"
|
||||||
id3 = "1.16"
|
id3 = "^1.16"
|
||||||
lofty = "0.22.2"
|
lofty = "^0.22.2"
|
||||||
opener = "0.7"
|
opener = "^0.7"
|
||||||
opus_headers = "0.1.2"
|
opus_headers = "^0.1.2"
|
||||||
pad = "0.1"
|
pad = "^0.1"
|
||||||
rusty-chromaprint = "0.3.0"
|
rusty-chromaprint = "^0.3.0"
|
||||||
walkdir = "2"
|
walkdir = "^2"
|
||||||
xxhash-rust = { version = "0.8.5", features = ["xxh3"] }
|
xxhash-rust = { version = "^0.8.5", features = ["xxh3"] }
|
||||||
|
|
||||||
#base64 = "0.22"
|
#base64 = "0.22"
|
||||||
#moku = "0.2"
|
#moku = "0.2"
|
||||||
|
|
|
||||||
2
Justfile
2
Justfile
|
|
@ -1,4 +1,6 @@
|
||||||
run:
|
run:
|
||||||
|
cargo run -- -j16 ~/Studio/Camp
|
||||||
|
run2:
|
||||||
cargo run -- -j16 ~/Music
|
cargo run -- -j16 ~/Music
|
||||||
build-release:
|
build-release:
|
||||||
time cargo build -j4 --release
|
time cargo build -j4 --release
|
||||||
|
|
|
||||||
|
|
@ -92,14 +92,14 @@ impl Taggart {
|
||||||
}
|
}
|
||||||
pub fn edit_insert (&mut self, c: char) {
|
pub fn edit_insert (&mut self, c: char) {
|
||||||
if let Some((edit_index, value)) = &mut self.editing {
|
if let Some((edit_index, value)) = &mut self.editing {
|
||||||
self.editing = Some((*edit_index, format!("{value}{c}")));
|
self.editing = Some((*edit_index + 1, format!("{value}{c}")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn edit_backspace (&mut self) {
|
pub fn edit_backspace (&mut self) {
|
||||||
if let Some((edit_index, value)) = &mut self.editing {
|
if let Some((edit_index, value)) = &mut self.editing {
|
||||||
let mut chars = value.chars();
|
let mut chars = value.chars();
|
||||||
chars.next_back();
|
chars.next_back();
|
||||||
self.editing = Some((*edit_index, chars.as_str().into()));
|
self.editing = Some((edit_index.saturating_sub(1), chars.as_str().into()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn edit_delete (&mut self) {
|
pub fn edit_delete (&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,13 @@ impl Default for Columns<Entry, fn(&Entry)->Option<Arc<str>>, fn(&mut [Entry], u
|
||||||
fn default () -> Self {
|
fn default () -> Self {
|
||||||
Self(vec![
|
Self(vec![
|
||||||
|
|
||||||
Column::new(&"HASH", 16, |entry: &Entry|entry.hash()),
|
Column::new(&"HASH", 8, |entry: &Entry|entry.hash()),
|
||||||
|
|
||||||
Column::new(&"SIZE", 8, |entry: &Entry|entry.size()),
|
Column::new(&"SIZE", 8, |entry: &Entry|entry.size()),
|
||||||
|
|
||||||
Column::new(&"FILE", 80, |entry: &Entry|entry.name()),
|
Column::new(&"FILE", 80, |entry: &Entry|entry.name()),
|
||||||
|
|
||||||
Column::new(&"ARTIST", 30, |entry: &Entry|entry.artist())
|
Column::new(&"ARTIST", 30, |entry: &Entry|entry.artist())
|
||||||
.setter(|entries: &mut [Entry], index: usize, value: &str|{
|
.setter(|entries: &mut [Entry], index: usize, value: &str|{
|
||||||
if let Some(entries) = paths_under(entries, index) {
|
if let Some(entries) = paths_under(entries, index) {
|
||||||
for entry in entries.iter() {
|
for entry in entries.iter() {
|
||||||
|
|
|
||||||
11
src/view.rs
11
src/view.rs
|
|
@ -21,12 +21,12 @@ impl Content<TuiOut> for Taggart {
|
||||||
Fill::x(Align::w(Tui::bold(true, if self.editing.is_some() {
|
Fill::x(Align::w(Tui::bold(true, if self.editing.is_some() {
|
||||||
Bsp::e(
|
Bsp::e(
|
||||||
Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")),
|
Tui::bg(Self::BG_EDIT, Tui::fg(Self::FG_EDIT, " EDIT ")),
|
||||||
" Esc to cancel, Enter to save"
|
" Esc: cancel, Enter: set value"
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Bsp::e(
|
Bsp::e(
|
||||||
Tui::bg(Self::BG_BROWSE, Tui::fg(Self::FG_BROWSE, " BROWSE ")),
|
Tui::bg(Self::BG_BROWSE, Tui::fg(Self::FG_BROWSE, " BROWSE ")),
|
||||||
" Q to exit, Arrows to select, Enter to edit"
|
" Q: exit, Arrows: select, Enter: edit"
|
||||||
)
|
)
|
||||||
}))),
|
}))),
|
||||||
Fill::x(Align::e(size)),
|
Fill::x(Align::e(size)),
|
||||||
|
|
@ -58,11 +58,4 @@ impl Entry {
|
||||||
Self::ICON_UNKNOWN
|
Self::ICON_UNKNOWN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fn style (&self) -> Option<Style> {
|
|
||||||
//if self.is_dir() {
|
|
||||||
//None
|
|
||||||
//} else {
|
|
||||||
//Some(Style::default().bold())
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,19 +55,26 @@ impl<'a> TreeTable<'a> {
|
||||||
to.fill_bg(fill, Self::BG_CELL);
|
to.fill_bg(fill, Self::BG_CELL);
|
||||||
}
|
}
|
||||||
fn row_data (&self, to: &mut TuiOut, entry: &Entry, row: usize, x: &mut u16) {
|
fn row_data (&self, to: &mut TuiOut, entry: &Entry, row: usize, x: &mut u16) {
|
||||||
for (column_index, Column { width, getter, .. }) in self.0.columns.0.iter().enumerate() {
|
let y = to.area().y();
|
||||||
|
for (column_index, Column {
|
||||||
|
width,
|
||||||
|
getter,
|
||||||
|
..
|
||||||
|
}) in self.0.columns.0.iter().enumerate() {
|
||||||
to.area[0] = *x;
|
to.area[0] = *x;
|
||||||
if let Some((_edit_index, value)) = self.0.editing.as_ref()
|
if let Some((edit_index, value)) = self.0.editing.as_ref()
|
||||||
&& self.0.column == column_index
|
&& self.0.column == column_index
|
||||||
&& self.0.cursor == row
|
&& self.0.cursor == row
|
||||||
{
|
{
|
||||||
to.fill_bg([*x, to.area().y(), *width as u16, 1], Self::BG_EDIT);
|
to.fill_bg([*x, y, *width as u16, 1], Self::BG_EDIT);
|
||||||
to.fill_fg([*x, to.area().y(), *width as u16, 1], Self::FG_EDIT);
|
to.fill_fg([*x, y, *width as u16, 1], Self::FG_EDIT);
|
||||||
|
to.fill_reversed([*x + *edit_index as u16, y, 1, 1], true);
|
||||||
Content::render(&TrimStringRef(*width as u16, &value), to);
|
Content::render(&TrimStringRef(*width as u16, &value), to);
|
||||||
} else if let Some(value) = getter(entry) {
|
} else if let Some(value) = getter(entry) {
|
||||||
Content::render(&TrimStringRef(*width as u16, &value), to);
|
Content::render(&TrimStringRef(*width as u16, &value), to);
|
||||||
}
|
}
|
||||||
*x += *width as u16 + 1;
|
*x += *width as u16 + 1;
|
||||||
|
to.blit(&"│", *x - 1, y, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,11 +93,7 @@ impl<T, G, S> Columns<T, G, S> {
|
||||||
for (index, Column { width, .. }) in self.0.iter().enumerate() {
|
for (index, Column { width, .. }) in self.0.iter().enumerate() {
|
||||||
let w = *width as u16 + 1;
|
let w = *width as u16 + 1;
|
||||||
if index == column {
|
if index == column {
|
||||||
if x > 0 {
|
return (x, w)
|
||||||
return (x - 1, w + 1)
|
|
||||||
} else {
|
|
||||||
return (x, w)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue