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",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"numeric-sort",
|
||||
"opera",
|
||||
"parking_lot",
|
||||
"pin-project",
|
||||
|
|
@ -1080,6 +1081,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numeric-sort"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2dcb6053ab98da45585315f79932c5c9821fab8efa4301c0d7b637c91630eb7"
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.37.3"
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ blake3 = "1.8.2"
|
|||
run-on-drop = "1.0.0"
|
||||
egui = { version = "0.34.1", default-features = false }
|
||||
egui_tiles = { version = "0.15.0", default-features = false }
|
||||
numeric-sort = "0.1.5"
|
||||
|
||||
[build-dependencies]
|
||||
repc = "0.1.1"
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ appear in the bar:
|
|||
: Workspaces can be reordered by dragging (default)
|
||||
|
||||
`sorted`
|
||||
: Workspaces are displayed in alphabetical order
|
||||
: Workspaces are displayed using natural ordering.
|
||||
|
||||
```toml
|
||||
workspace-display-order = "sorted"
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ modes:
|
|||
|
||||
- **manual** (default) -- workspaces appear in the order they were created and
|
||||
can be reordered by dragging their titles in the bar.
|
||||
- **sorted** -- workspaces are sorted alphabetically. Dragging to reorder is
|
||||
disabled.
|
||||
- **sorted** -- workspaces are sorted using natural ordering. Dragging to
|
||||
reorder is disabled.
|
||||
|
||||
Set the order in your configuration:
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
jay_config::video::{TearingMode as ConfigTearingMode, VrrMode as ConfigVrrMode},
|
||||
numeric_sort::cmp,
|
||||
smallvec::SmallVec,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
|
|
@ -730,7 +731,7 @@ impl OutputNode {
|
|||
pub fn find_workspace_insertion_point(&self, name: &str) -> Option<NodeRef<Rc<WorkspaceNode>>> {
|
||||
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1133,7 +1134,7 @@ impl OutputNode {
|
|||
pub fn handle_workspace_display_order_update(self: &Rc<Self>) {
|
||||
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
|
||||
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 {
|
||||
ws_ref.detach();
|
||||
self.workspaces.add_last_existing(&ws_ref);
|
||||
|
|
|
|||
|
|
@ -5609,7 +5609,7 @@ The string should have one of the following values:
|
|||
|
||||
- `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
|
||||
description: Workspaces are not sorted and can be manually dragged.
|
||||
- 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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue