From 2da9d27e545845a233000d5fdf8730fee88734bf Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Fri, 21 Mar 2025 13:42:18 +0100 Subject: [PATCH 1/2] fix printing lmao --- modules/desktop-environment/default.nix | 1 + modules/desktop-environment/printing.nix | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/desktop-environment/default.nix b/modules/desktop-environment/default.nix index 51d9ee6..ef44236 100644 --- a/modules/desktop-environment/default.nix +++ b/modules/desktop-environment/default.nix @@ -8,6 +8,7 @@ ./dm.nix ./tlp.nix ./locale.nix + ./printing.nix ]; services.flatpak.enable = true; security.polkit.enable = true; diff --git a/modules/desktop-environment/printing.nix b/modules/desktop-environment/printing.nix index 006ea0b..3233279 100644 --- a/modules/desktop-environment/printing.nix +++ b/modules/desktop-environment/printing.nix @@ -11,10 +11,9 @@ ptouch-driver epsonscan2 epson-escpr - epson-inkjet-printer-escpr2 + epson-escpr2 epson_201207w epson-alc1100 - epson ]; }; } From 07a58afaff73f025bd4a027b78e9a8215716e8c8 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Fri, 21 Mar 2025 14:15:12 +0100 Subject: [PATCH 2/2] improve flip-bool --- modules/shell/helix.nix | 2 +- programs/flip-bool/src/main.rs | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/shell/helix.nix b/modules/shell/helix.nix index d24aa16..adfda34 100644 --- a/modules/shell/helix.nix +++ b/modules/shell/helix.nix @@ -102,7 +102,7 @@ d = "@vgd"; f = "@vgy"; h = ":toggle-option lsp.display-inlay-hints"; - t = "@|flip-bool"; + t = ":pipe flip-bool"; }; }; insert = { diff --git a/programs/flip-bool/src/main.rs b/programs/flip-bool/src/main.rs index 299685f..0b99ab8 100644 --- a/programs/flip-bool/src/main.rs +++ b/programs/flip-bool/src/main.rs @@ -4,7 +4,6 @@ #![feature(pattern)] use std::{ - hint::black_box, io::{Read, Write}, str::pattern::Pattern, }; @@ -86,29 +85,27 @@ fn find_bools(input: &str) -> [[Vec; 2]; BOOL_COUNT] { input .match_indices(it) .filter_map(|it| { - let char_guard = |c: char| !(c.is_alphanumeric() || c.is_contained_in("-_")); - let mut allow = true; + fn char_guard(c: char) -> bool { + !(c.is_alphanumeric() || c.is_contained_in("-_")) + } - if it.0 > 0 { - allow &= char_guard( + let last_idx = it.0 + it.1.len(); + + (it.0 > 0 + && last_idx < input.len() + && char_guard( input[it.1.floor_char_boundary(it.0 - 1)..it.0] .chars() .last() .unwrap(), - ); - } - - let last_idx = it.0 + it.1.len(); - if last_idx < input.len() { - allow &= char_guard( + ) + && char_guard( input[(last_idx)..(input.ceil_char_boundary(last_idx + 1))] .chars() .last() .unwrap(), - ); - } - - allow.then_some(it.0) + )) + .then_some(it.0) }) .collect() })