Skip to content

Commit

Permalink
Feat/reorder tabs (#67)
Browse files Browse the repository at this point in the history
* add tab reordering

* update CHANGELOG
  • Loading branch information
tarkah authored Feb 12, 2021
1 parent ec7dcf1 commit 457199a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and `Removed`.
- Linux: `$HOME/.config/tickrs/config.yml`
- macOS: `$HOME/Library/Application Support/tickrs/config.yml`
- Windows: `%APPDATA%\tickrs\config.yml`
- Current tab can be reordered by using `Ctrl + Left / Right`

## [0.10.2] - 2021-02-10

Expand Down
25 changes: 22 additions & 3 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,28 @@ pub fn handle_keys_display_stock(
_ => {}
}
} else if key_event.modifiers == KeyModifiers::CONTROL {
if let KeyCode::Char('c') = key_event.code {
cleanup_terminal();
std::process::exit(0);
match key_event.code {
KeyCode::Left => {
let new_idx = if app.current_tab == 0 {
app.stocks.len() - 1
} else {
app.current_tab - 1
};
app.stocks.swap(app.current_tab, new_idx);
app.current_tab = new_idx;
let _ = request_redraw.try_send(());
}
KeyCode::Right => {
let new_idx = (app.current_tab + 1) % app.stocks.len();
app.stocks.swap(app.current_tab, new_idx);
app.current_tab = new_idx;
let _ = request_redraw.try_send(());
}
KeyCode::Char('c') => {
cleanup_terminal();
std::process::exit(0);
}
_ => {}
}
} else if key_event.modifiers == KeyModifiers::SHIFT {
if let KeyCode::Char('?') = key_event.code {
Expand Down
7 changes: 5 additions & 2 deletions src/widget/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Remove Stock:
Change Tab:
- <Tab>: next stock
- <Shift+Tab>: previous stock
Reorder Current Tab:
- <Ctrl+Left>: move 1 tab left
- <Ctrl+Right>: move 1 tab right
Change Time Frame:
- <Right>: next time frame
- <Left>: previous time frame
Expand All @@ -36,8 +39,8 @@ Graphing Display:
- x: toggle labels
"#;

pub const HELP_WIDTH: u16 = 36;
pub const HELP_HEIGHT: u16 = 30;
pub const HELP_WIDTH: u16 = 37;
pub const HELP_HEIGHT: u16 = 33;

#[derive(Copy, Clone)]
pub struct HelpWidget {}
Expand Down

0 comments on commit 457199a

Please sign in to comment.