My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.

feat/tui: signals + bare config #5

closed opened by suri.codes targeting main from tui
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:nxdjlcnomw44wvso6myag2e6/sh.tangled.repo.pull/3mgl5nipbhd22
+229 -4
Diff #0
+50
.config/config.kdl
··· 1 + scroll_offset 4 2 + 3 + keybindings { 4 + Explorer { 5 + "<q>" Quit // Quit the application 6 + "<Ctrl-d>" Quit // Another way to quit 7 + "<Ctrl-c>" Quit // Yet another way to quit 8 + "<Ctrl-z>" Suspend // Suspend the application 9 + "<2>" switch-to="TodoList" 10 + "<3>" switch-to="Inspector" 11 + f ToggleShowFinished 12 + x Delete 13 + t NewTask 14 + g NewSubGroup 15 + "<Shift-g>" NewGroup 16 + j MoveDown 17 + k MoveUp 18 + l MoveInto 19 + h MoveOutOf 20 + } 21 + 22 + TodoList { 23 + "<q>" Quit // Quit the application 24 + "<Ctrl-d>" Quit // Another way to quit 25 + "<Ctrl-c>" Quit // Yet another way to quit 26 + "<Ctrl-z>" Suspend // Suspend the application 27 + "<1>" switch-to="Explorer" 28 + "<3>" switch-to="Inspector" 29 + j MoveDown 30 + k MoveUp 31 + } 32 + 33 + Inspector { 34 + "<q>" Quit // Quit the application 35 + "<Ctrl-d>" Quit // Another way to quit 36 + "<Ctrl-c>" Quit // Yet another way to quit 37 + "<Ctrl-z>" Suspend // Suspend the application 38 + "<1>" switch-to="Explorer" 39 + "<2>" switch-to="TodoList" 40 + r RandomColor 41 + n EditName 42 + c EditColor 43 + p EditPriority 44 + u EditDue 45 + d EditDescription 46 + f ToggleFinishTask 47 + t NewTask 48 + g NewSubGroup 49 + } 50 + }
+85 -3
Cargo.lock
··· 415 415 "crypto-common", 416 416 ] 417 417 418 + [[package]] 419 + name = "directories" 420 + version = "6.0.0" 421 + source = "registry+https://github.com/rust-lang/crates.io-index" 422 + checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" 423 + dependencies = [ 424 + "dirs-sys", 425 + ] 426 + 427 + [[package]] 428 + name = "dirs-sys" 429 + version = "0.5.0" 430 + source = "registry+https://github.com/rust-lang/crates.io-index" 431 + checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" 432 + dependencies = [ 433 + "libc", 434 + "option-ext", 435 + "redox_users", 436 + "windows-sys 0.61.2", 437 + ] 438 + 418 439 [[package]] 419 440 name = "document-features" 420 441 version = "0.2.12" ··· 488 509 "better-panic", 489 510 "color-eyre", 490 511 "crossterm", 512 + "directories", 491 513 "futures", 492 514 "human-panic", 515 + "lazy_static", 493 516 "ratatui", 494 517 "serde", 495 518 "signal-hook 0.4.3", 519 + "strum 0.28.0", 496 520 "tokio", 497 521 "tokio-util", 498 522 "tracing", ··· 637 661 "version_check", 638 662 ] 639 663 664 + [[package]] 665 + name = "getrandom" 666 + version = "0.2.17" 667 + source = "registry+https://github.com/rust-lang/crates.io-index" 668 + checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" 669 + dependencies = [ 670 + "cfg-if", 671 + "libc", 672 + "wasi", 673 + ] 674 + 640 675 [[package]] 641 676 name = "getrandom" 642 677 version = "0.3.4" ··· 834 869 source = "registry+https://github.com/rust-lang/crates.io-index" 835 870 checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" 836 871 872 + [[package]] 873 + name = "libredox" 874 + version = "0.1.14" 875 + source = "registry+https://github.com/rust-lang/crates.io-index" 876 + checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" 877 + dependencies = [ 878 + "libc", 879 + ] 880 + 837 881 [[package]] 838 882 name = "line-clipping" 839 883 version = "0.3.5" ··· 1044 1088 source = "registry+https://github.com/rust-lang/crates.io-index" 1045 1089 checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" 1046 1090 1091 + [[package]] 1092 + name = "option-ext" 1093 + version = "0.2.0" 1094 + source = "registry+https://github.com/rust-lang/crates.io-index" 1095 + checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" 1096 + 1047 1097 [[package]] 1048 1098 name = "ordered-float" 1049 1099 version = "4.6.0" ··· 1277 1327 "itertools", 1278 1328 "kasuari", 1279 1329 "lru", 1280 - "strum", 1330 + "strum 0.27.2", 1281 1331 "thiserror 2.0.18", 1282 1332 "unicode-segmentation", 1283 1333 "unicode-truncate", ··· 1329 1379 "itertools", 1330 1380 "line-clipping", 1331 1381 "ratatui-core", 1332 - "strum", 1382 + "strum 0.27.2", 1333 1383 "time", 1334 1384 "unicode-segmentation", 1335 1385 "unicode-width", ··· 1344 1394 "bitflags 2.11.0", 1345 1395 ] 1346 1396 1397 + [[package]] 1398 + name = "redox_users" 1399 + version = "0.5.2" 1400 + source = "registry+https://github.com/rust-lang/crates.io-index" 1401 + checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" 1402 + dependencies = [ 1403 + "getrandom 0.2.17", 1404 + "libredox", 1405 + "thiserror 2.0.18", 1406 + ] 1407 + 1347 1408 [[package]] 1348 1409 name = "regex" 1349 1410 version = "1.12.3" ··· 1584 1645 source = "registry+https://github.com/rust-lang/crates.io-index" 1585 1646 checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" 1586 1647 dependencies = [ 1587 - "strum_macros", 1648 + "strum_macros 0.27.2", 1649 + ] 1650 + 1651 + [[package]] 1652 + name = "strum" 1653 + version = "0.28.0" 1654 + source = "registry+https://github.com/rust-lang/crates.io-index" 1655 + checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" 1656 + dependencies = [ 1657 + "strum_macros 0.28.0", 1588 1658 ] 1589 1659 1590 1660 [[package]] ··· 1599 1669 "syn 2.0.117", 1600 1670 ] 1601 1671 1672 + [[package]] 1673 + name = "strum_macros" 1674 + version = "0.28.0" 1675 + source = "registry+https://github.com/rust-lang/crates.io-index" 1676 + checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" 1677 + dependencies = [ 1678 + "heck", 1679 + "proc-macro2", 1680 + "quote", 1681 + "syn 2.0.117", 1682 + ] 1683 + 1602 1684 [[package]] 1603 1685 name = "syn" 1604 1686 version = "1.0.109"
+4 -1
Cargo.toml
··· 51 51 crossterm = { version = "0.29.0", features = ["event-stream"] } 52 52 futures = "0.3.32" 53 53 ratatui = "0.30.0" 54 - serde = "1.0.228" 54 + serde = { version = "1.0.228", features = ["derive"] } 55 55 tokio = { version = "1.50.0", features = ["full"] } 56 56 tokio-util = "0.7.18" 57 57 signal-hook = "0.4.3" 58 + strum = { version = "0.28.0", features = ["derive"] } 59 + lazy_static = "1.5.0" 60 + directories = "6.0.0"
+71
src/config.rs
··· 1 + use directories::ProjectDirs; 2 + use lazy_static::lazy_static; 3 + use serde::Deserialize; 4 + use std::{env, path::PathBuf}; 5 + 6 + lazy_static! { 7 + /// Filaments 8 + pub static ref PROJECT_NAME: String = env!("CARGO_CRATE_NAME").to_uppercase().to_string(); 9 + /// Data folder override if user has manually set FILAMENTS_DATA to a directory. 10 + pub static ref DATA_FOLDER: Option<PathBuf> = 11 + env::var(format!("{}_DATA", PROJECT_NAME.clone())) 12 + .ok() 13 + .map(PathBuf::from); 14 + /// Config folder override if user has manually set FILAMENTS_CONFIG to a directory. 15 + pub static ref CONFIG_FOLDER: Option<PathBuf> = 16 + env::var(format!("{}_CONFIG", PROJECT_NAME.clone())) 17 + .ok() 18 + .map(PathBuf::from); 19 + } 20 + 21 + /// The App Config and Data locations. 22 + #[derive(Clone, Debug, Deserialize, Default)] 23 + 24 + pub struct AppDirs { 25 + #[serde(default)] 26 + pub data_dir: PathBuf, 27 + #[serde(default)] 28 + pub config_dir: PathBuf, 29 + } 30 + 31 + /// Configuration for the App 32 + pub struct Config { 33 + pub app_dirs: AppDirs, // pub data_dir: PathBuf, 34 + // pub keybindings: KeyBindings, 35 + 36 + // pub styles: Styles, 37 + } 38 + 39 + impl Config { 40 + pub fn new() -> Self { 41 + todo!() 42 + } 43 + } 44 + 45 + /// Returns the path to the OS-agnostic data directory. 46 + pub fn get_data_dir() -> PathBuf { 47 + let directory = if let Some(s) = DATA_FOLDER.clone() { 48 + s 49 + } else if let Some(proj_dirs) = project_directory() { 50 + proj_dirs.data_local_dir().to_path_buf() 51 + } else { 52 + PathBuf::from(".").join(".data") 53 + }; 54 + directory 55 + } 56 + 57 + /// Returns the path to the OS-agnostic config directory. 58 + pub fn get_config_dir() -> PathBuf { 59 + let directory = if let Some(s) = CONFIG_FOLDER.clone() { 60 + s 61 + } else if let Some(proj_dirs) = project_directory() { 62 + proj_dirs.config_local_dir().to_path_buf() 63 + } else { 64 + PathBuf::from(".").join(".config") 65 + }; 66 + directory 67 + } 68 + 69 + fn project_directory() -> Option<ProjectDirs> { 70 + ProjectDirs::from("com", "suri-codes", env!("CARGO_PKG_NAME")) 71 + }
+2
src/main.rs
··· 2 2 //! My (suri.codes) personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities. 3 3 //! 4 4 5 + mod config; 5 6 mod errors; 7 + mod signal; 6 8 mod tui; 7 9 8 10 fn main() -> color_eyre::Result<()> {
+17
src/signal.rs
··· 1 + use strum::Display; 2 + 3 + use serde::{Deserialize, Serialize}; 4 + 5 + /// The varying signals that can be emitted. 6 + #[derive(Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)] 7 + pub enum Signal { 8 + Tick, 9 + Render, 10 + Resize(u16, u16), 11 + Suspend, 12 + Resume, 13 + Quit, 14 + ClearScreen, 15 + Error(String), 16 + Help, 17 + }

History

1 round 0 comments
sign up or login to add to the discussion
suri.codes submitted #0
1 commit
expand
feat/tui: signals + bare config
expand 0 comments
closed without merging