Merge pull request #844 from llyyr/sort-numbers-numerically
output: use natural sort for workspace ordering
This commit is contained in:
commit
5fd94e39fb
7 changed files with 16 additions and 7 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -823,6 +823,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"numeric-sort",
|
||||||
"opera",
|
"opera",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
|
|
@ -1080,6 +1081,12 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "numeric-sort"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2dcb6053ab98da45585315f79932c5c9821fab8efa4301c0d7b637c91630eb7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.37.3"
|
version = "0.37.3"
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ blake3 = "1.8.2"
|
||||||
run-on-drop = "1.0.0"
|
run-on-drop = "1.0.0"
|
||||||
egui = { version = "0.34.1", default-features = false }
|
egui = { version = "0.34.1", default-features = false }
|
||||||
egui_tiles = { version = "0.15.0", default-features = false }
|
egui_tiles = { version = "0.15.0", default-features = false }
|
||||||
|
numeric-sort = "0.1.5"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
repc = "0.1.1"
|
repc = "0.1.1"
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ appear in the bar:
|
||||||
: Workspaces can be reordered by dragging (default)
|
: Workspaces can be reordered by dragging (default)
|
||||||
|
|
||||||
`sorted`
|
`sorted`
|
||||||
: Workspaces are displayed in alphabetical order
|
: Workspaces are displayed using natural ordering.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
workspace-display-order = "sorted"
|
workspace-display-order = "sorted"
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,8 @@ modes:
|
||||||
|
|
||||||
- **manual** (default) -- workspaces appear in the order they were created and
|
- **manual** (default) -- workspaces appear in the order they were created and
|
||||||
can be reordered by dragging their titles in the bar.
|
can be reordered by dragging their titles in the bar.
|
||||||
- **sorted** -- workspaces are sorted alphabetically. Dragging to reorder is
|
- **sorted** -- workspaces are sorted using natural ordering. Dragging to
|
||||||
disabled.
|
reorder is disabled.
|
||||||
|
|
||||||
Set the order in your configuration:
|
Set the order in your configuration:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ use {
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
jay_config::video::{TearingMode as ConfigTearingMode, VrrMode as ConfigVrrMode},
|
jay_config::video::{TearingMode as ConfigTearingMode, VrrMode as ConfigVrrMode},
|
||||||
|
numeric_sort::cmp,
|
||||||
smallvec::SmallVec,
|
smallvec::SmallVec,
|
||||||
std::{
|
std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
|
|
@ -730,7 +731,7 @@ impl OutputNode {
|
||||||
pub fn find_workspace_insertion_point(&self, name: &str) -> Option<NodeRef<Rc<WorkspaceNode>>> {
|
pub fn find_workspace_insertion_point(&self, name: &str) -> Option<NodeRef<Rc<WorkspaceNode>>> {
|
||||||
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
|
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
|
||||||
for existing_ws in self.workspaces.iter() {
|
for existing_ws in self.workspaces.iter() {
|
||||||
if name < existing_ws.name.as_str() {
|
if cmp(name, &existing_ws.name) == std::cmp::Ordering::Less {
|
||||||
return Some(existing_ws);
|
return Some(existing_ws);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1133,7 +1134,7 @@ impl OutputNode {
|
||||||
pub fn handle_workspace_display_order_update(self: &Rc<Self>) {
|
pub fn handle_workspace_display_order_update(self: &Rc<Self>) {
|
||||||
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
|
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
|
||||||
let mut workspaces: Vec<_> = self.workspaces.iter().collect();
|
let mut workspaces: Vec<_> = self.workspaces.iter().collect();
|
||||||
workspaces.sort_by(|a, b| a.name.cmp(&b.name));
|
workspaces.sort_by(|a, b| cmp(&a.name, &b.name));
|
||||||
for ws_ref in workspaces {
|
for ws_ref in workspaces {
|
||||||
ws_ref.detach();
|
ws_ref.detach();
|
||||||
self.workspaces.add_last_existing(&ws_ref);
|
self.workspaces.add_last_existing(&ws_ref);
|
||||||
|
|
|
||||||
|
|
@ -5609,7 +5609,7 @@ The string should have one of the following values:
|
||||||
|
|
||||||
- `sorted`:
|
- `sorted`:
|
||||||
|
|
||||||
Workspaces are sorted alphabetically and cannot be manually dragged.
|
Workspaces are sorted using natural ordering and cannot be manually dragged.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4533,7 +4533,7 @@ WorkspaceDisplayOrder:
|
||||||
- value: manual
|
- value: manual
|
||||||
description: Workspaces are not sorted and can be manually dragged.
|
description: Workspaces are not sorted and can be manually dragged.
|
||||||
- value: sorted
|
- value: sorted
|
||||||
description: Workspaces are sorted alphabetically and cannot be manually dragged.
|
description: Workspaces are sorted using natural ordering and cannot be manually dragged.
|
||||||
|
|
||||||
|
|
||||||
BlendSpace:
|
BlendSpace:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue