Skip to content

Commit 91ea040

Browse files
Merge pull request #123 from TheRustyPickle/themes
New themes
2 parents 7bbe39a + 441fc32 commit 91ea040

21 files changed

Lines changed: 236 additions & 120 deletions

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<p align="center">
2-
<img src="https://github.com/TheRustyPickle/Rex/assets/35862475/04575a15-53f7-497f-b2e7-88a7a66d1136" width=400>
3-
</p>
4-
51
<div align="center"><h1>Rex</h1></div>
62
<div align="center">
73
<a href="https://wakatime.com/@RustyPickle"><img src="https://wakatime.com/badge/github/TheRustyPickle/Rex.svg" alt="wakatime"></a>
@@ -57,6 +53,7 @@ cargo run --release
5753
**4. Install using a package manager:**
5854

5955
* On NetBSD a package is available from the [official repositories](https://pkgsrc.se/finance/rex). To install it simply run:
56+
6057
```sh
6158
pkgin install rex
6259
```

logo.png

-1.21 MB
Binary file not shown.

tui/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct Config {
2121
pub location: PathBuf,
2222
pub backup_db_path: Option<Vec<PathBuf>>,
2323
pub new_location: Option<PathBuf>,
24+
pub theme_index: Option<usize>,
2425
}
2526

2627
impl Config {
@@ -35,6 +36,7 @@ impl Config {
3536
backup_db_path: None,
3637
new_location: None,
3738
location: target_dir,
39+
theme_index: Some(0),
3840
});
3941
}
4042

@@ -44,6 +46,11 @@ impl Config {
4446
let mut config: Config = serde_json::from_str(&file_content)?;
4547

4648
config.location = target_dir;
49+
50+
if config.theme_index.is_none() {
51+
config.theme_index = Some(0);
52+
}
53+
4754
Ok(config)
4855
}
4956

@@ -157,6 +164,7 @@ pub fn migrate_config(config_path: &PathBuf) -> Result<()> {
157164
backup_db_path: None,
158165
new_location: None,
159166
location: PathBuf::new(),
167+
theme_index: Some(0),
160168
};
161169

162170
let mut backup_path = config_path.to_owned();

tui/src/key_checker/activity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn activity_keys(handler: &mut InputKeyHandler) -> Result<Option<HandlingOut
1717
KeyCode::Char('z') => handler.go_summary()?,
1818
KeyCode::Char('w') => handler.go_search(),
1919
KeyCode::Char('v') => handler.show_activity_tx_details()?,
20+
KeyCode::Char('t') => handler.next_theme()?,
2021
KeyCode::Right => handler.handle_right_arrow()?,
2122
KeyCode::Left => handler.handle_left_arrow()?,
2223
KeyCode::Up => handler.handle_up_arrow(),

tui/src/key_checker/add_tx.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn add_tx_keys(handler: &mut InputKeyHandler) -> Result<Option<HandlingOutpu
2222
KeyCode::Char('w') => handler.go_search(),
2323
KeyCode::Char('c') => handler.clear_input()?,
2424
KeyCode::Char('y') => handler.go_activity(),
25+
KeyCode::Char('t') => handler.next_theme()?,
2526
KeyCode::Enter => handler.select_date_field(),
2627
KeyCode::Char(c) => {
2728
if c.is_numeric() {

tui/src/key_checker/chart.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn chart_keys(handler: &mut InputKeyHandler) -> Result<Option<HandlingOutput
1919
KeyCode::Char('R') => handler.do_chart_lgeneds(),
2020
KeyCode::Char('w') => handler.go_search(),
2121
KeyCode::Char('y') => handler.go_activity(),
22+
KeyCode::Char('t') => handler.next_theme()?,
2223
KeyCode::Right => handler.handle_right_arrow()?,
2324
KeyCode::Left => handler.handle_left_arrow()?,
2425
KeyCode::Up => handler.handle_up_arrow(),

tui/src/key_checker/home.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn home_keys(handler: &mut InputKeyHandler) -> Result<Option<HandlingOutput>
2222
KeyCode::Char(',') => handler.switch_tx_position_up()?,
2323
KeyCode::Char('.') => handler.switch_tx_position_down()?,
2424
KeyCode::Char('v') => handler.show_home_tx_details(),
25+
KeyCode::Char('t') => handler.next_theme()?,
2526
KeyCode::Right => handler.handle_right_arrow()?,
2627
KeyCode::Left => handler.handle_left_arrow()?,
2728
KeyCode::Up => handler.handle_up_arrow(),

tui/src/key_checker/key_handler.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,14 @@ impl<'a> InputKeyHandler<'a> {
11191119
pub fn popup_down(&mut self) {
11201120
self.popup_status.next();
11211121
}
1122+
1123+
pub fn next_theme(&mut self) -> Result<()> {
1124+
let new_index = self.theme.next();
1125+
self.config.theme_index = Some(new_index);
1126+
self.config.save_config()?;
1127+
1128+
Ok(())
1129+
}
11221130
}
11231131

11241132
impl InputKeyHandler<'_> {

tui/src/key_checker/search.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn search_keys(handler: &mut InputKeyHandler) -> Result<Option<HandlingOutpu
2525
KeyCode::Char('e') => handler.search_edit_tx()?,
2626
KeyCode::Char('d') => handler.do_deletion_popup(),
2727
KeyCode::Char('y') => handler.go_activity(),
28+
KeyCode::Char('t') => handler.next_theme()?,
2829
KeyCode::Up => handler.handle_up_arrow(),
2930
KeyCode::Down => handler.handle_down_arrow(),
3031
KeyCode::Enter => handler.select_date_field(),

tui/src/key_checker/summary.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn summary_keys(handler: &mut InputKeyHandler) -> Result<Option<HandlingOutp
1919
KeyCode::Char('z') => handler.do_summary_hidden_mode(),
2020
KeyCode::Char('x') => handler.change_summary_sort(),
2121
KeyCode::Char('y') => handler.go_activity(),
22+
KeyCode::Char('t') => handler.next_theme()?,
2223
KeyCode::Right => handler.handle_right_arrow()?,
2324
KeyCode::Left => handler.handle_left_arrow()?,
2425
KeyCode::Up => handler.handle_up_arrow(),

0 commit comments

Comments
 (0)