Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [unreleased]

### Features

- (keys) Support Vim motions [#163](https://github.com/sectore/timr-tui/issues/163)

### Misc.

- (deps) Update deps [#162](https://github.com/sectore/timr-tui/pull/162)
Expand Down
67 changes: 39 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ Options:
-m, --mode <MODE> Mode to start with. [possible values: countdown, timer, pomodoro, event, localtime]
-s, --style <STYLE> Style to display time with. [possible values: full, light, medium, dark, thick, cross, braille]
--menu Open menu.
-v, --vim <VIM> Enable/disable Vim motions. [possible values: on, off]
-r, --reset Reset stored values to defaults.
-n, --notification <NOTIFICATION> Toggle desktop notifications. Experimental. [possible values: on, off]
--blink <BLINK> Toggle blink mode to animate a clock when it reaches its finished mode. [possible values: on, off]
-n, --notification <NOTIFICATION> Enable/disable desktop notifications. Experimental. [possible values: on, off]
--blink <BLINK> Enable/disable blink mode to animate a clock when it reaches its finished mode. [possible values: on, off]
--log [<LOG>] Directory for log file. If not set, standard application log directory is used (check README for details).
-h, --help Print help
-V, --version Print version
Expand All @@ -116,23 +117,27 @@ Extra option (if `--features sound` is enabled by local build only):

# Keybindings

Note: To enable Vim motions key binding, run with `--vim=on` once. It will be stored as part of settings, so only running once is needed. To disable, run `--vim=off`.

## Menu

| Key | Description |
| --------------------------- | ----------- |
| <kbd>↑</kbd> / <kbd>↓</kbd> | Toggle menu |
| Key | Description |
| ---------------------------- | ----------- |
| <kbd>↑</kbd> or <kbd>↓</kbd> | Toggle menu |

## Screens

| Key | Description |
| ------------ | --------------- |
| <kbd>1</kbd> | Pomodoro |
| <kbd>2</kbd> | Countdown |
| <kbd>3</kbd> | Timer |
| <kbd>4</kbd> | Event |
| <kbd>0</kbd> | Local Time |
| <kbd>→</kbd> | next screen |
| <kbd>←</kbd> | previous screen |
| Key | Description |
| ------------ | ------------------------------- |
| <kbd>1</kbd> | Pomodoro |
| <kbd>2</kbd> | Countdown |
| <kbd>3</kbd> | Timer |
| <kbd>4</kbd> | Event |
| <kbd>0</kbd> | Local Time |
| <kbd>→</kbd> | next screen |
| <kbd>←</kbd> | previous screen |
| <kbd>l</kbd> | next screen _(Vim motions)_ |
| <kbd>h</kbd> | previous screen _(Vim motions)_ |

## Controls

Expand All @@ -145,15 +150,20 @@ Extra option (if `--features sound` is enabled by local build only):

**In `edit` mode only:**

| Key | Description |
| ---------------------------- | ------------------- |
| <kbd>s</kbd> | save changes |
| <kbd>esc</kbd> | skip changes |
| <kbd>←</kbd> or <kbd>→</kbd> | change selection |
| <kbd>↑</kbd> | edit to go up |
| <kbd>ctrl+↑</kbd> | edit to go up 10x |
| <kbd>↓</kbd> | edit to go down |
| <kbd>ctrl+↓</kbd> | edit to go down 10x |
| Key | Description |
| ---------------------------- | ----------------------------------- |
| <kbd>s</kbd> | save changes |
| <kbd>esc</kbd> | skip changes |
| <kbd>←</kbd> or <kbd>→</kbd> | change selection |
| <kbd>h</kbd> or <kbd>l</kbd> | change selection _(Vim motions)_ |
| <kbd>↑</kbd> | edit to go up |
| <kbd>k</kbd> | edit to go up _(Vim motions)_ |
| <kbd>ctrl+↑</kbd> | edit to go up 10x |
| <kbd>ctrl+k</kbd> | edit to go up 10x _(Vim motions)_ |
| <kbd>↓</kbd> | edit to go down |
| <kbd>j</kbd> | edit to go down _(Vim motions)_ |
| <kbd>ctrl+↓</kbd> | edit to go down 10x |
| <kbd>ctrl+j</kbd> | edit to go down 10x _(Vim motions)_ |

**In `Event` `edit` mode only:**

Expand All @@ -165,11 +175,12 @@ Extra option (if `--features sound` is enabled by local build only):

**In `Pomodoro` screen only:**

| Key | Description |
| -------------------------------------- | ------------------ |
| <kbd>ctrl+←</kbd> or <kbd>ctrl+→</kbd> | switch work/pause |
| <kbd>ctrl+r</kbd> | reset round |
| <kbd>ctrl+s</kbd> | save initial value |
| Key | Description |
| -------------------------------------- | --------------------------------- |
| <kbd>ctrl+←</kbd> or <kbd>ctrl+→</kbd> | switch work/pause |
| <kbd>ctrl+h</kbd> or <kbd>ctrl+l</kbd> | switch work/pause _(Vim motions)_ |
| <kbd>ctrl+r</kbd> | reset round |
| <kbd>ctrl+s</kbd> | save initial value |

**In `Countdown` screen only:**

Expand Down
29 changes: 22 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct App {
local_time: LocalTimeState,
style: Style,
with_decis: bool,
vim_motions: bool,
footer: FooterState,
cursor_position: Option<Position>,
}
Expand All @@ -68,6 +69,7 @@ pub struct AppArgs {
pub notification: Toggle,
pub blink: Toggle,
pub show_menu: bool,
pub vim_motions: bool,
pub app_time_format: AppTimeFormat,
pub content: Content,
pub pomodoro_mode: PomodoroMode,
Expand Down Expand Up @@ -102,6 +104,7 @@ impl From<FromAppArgs> for App {
App::new(AppArgs {
with_decis: args.decis || stg.with_decis,
show_menu: args.menu || stg.show_menu,
vim_motions: args.vim.unwrap_or(stg.vim).into(),
notification: args.notification.unwrap_or(stg.notification),
blink: args.blink.unwrap_or(stg.blink),
app_time_format: stg.app_time_format,
Expand Down Expand Up @@ -155,6 +158,7 @@ impl App {
let AppArgs {
style,
show_menu,
vim_motions,
app_time_format,
initial_value_work,
initial_value_pause,
Expand Down Expand Up @@ -192,13 +196,15 @@ impl App {
app_time_format,
style,
with_decis,
vim_motions,
countdown: CountdownState::new(CountdownStateArgs {
initial_value: initial_value_countdown,
current_value: current_value_countdown,
elapsed_value: elapsed_value_countdown,
app_time,
with_decis,
app_tx: app_tx.clone(),
vim_motions,
}),
timer: TimerState::new(
ClockState::<clock::Timer>::new(ClockStateArgs {
Expand All @@ -209,6 +215,7 @@ impl App {
app_tx: Some(app_tx.clone()),
})
.with_name("Timer".to_owned()),
vim_motions,
),
pomodoro: PomodoroState::new(PomodoroStateArgs {
mode: pomodoro_mode,
Expand All @@ -219,6 +226,7 @@ impl App {
with_decis,
round: pomodoro_round,
app_tx: app_tx.clone(),
vim_motions,
}),
local_time: LocalTimeState::new(LocalTimeStateArgs {
app_time,
Expand All @@ -237,6 +245,7 @@ impl App {
} else {
None
},
vim_motions,
),
cursor_position: None,
}
Expand All @@ -252,17 +261,22 @@ impl App {
debug!("Received key {:?}", key.code);
match key.code {
KeyCode::Char('q') => app.mode = Mode::Quit,
KeyCode::Char('1') | KeyCode::Char('c') /* TODO: deprecated, remove it in next major version */ => app.content = Content::Countdown,
KeyCode::Char('2') | KeyCode::Char('t') /* TODO: deprecated, remove it in next major version */ => app.content = Content::Timer,
KeyCode::Char('3') | KeyCode::Char('p') /* TODO: deprecated, remove it in next major version */ => app.content = Content::Pomodoro,
KeyCode::Char('1') => app.content = Content::Countdown,
KeyCode::Char('2') => app.content = Content::Timer,
KeyCode::Char('3') => app.content = Content::Pomodoro,
KeyCode::Char('4') => app.content = Content::Event,
// toogle app time format
KeyCode::Char('0') | KeyCode::Char('l') /* TODO: deprecated, remove it in next major version */ => app.content = Content::LocalTime,
KeyCode::Char('0') => app.content = Content::LocalTime,
// switch `screens`
KeyCode::Right => {
KeyCode::Right if !app.vim_motions => {
app.content = app.content.next();
}
KeyCode::Char('l') if app.vim_motions => {
app.content = app.content.next();
}
KeyCode::Left => {
KeyCode::Left if !app.vim_motions => {
app.content = app.content.prev();
}
KeyCode::Char('h') if app.vim_motions => {
app.content = app.content.prev();
}
// toogle app time format
Expand Down Expand Up @@ -486,6 +500,7 @@ impl App {
AppStorage {
content: self.content,
show_menu: self.footer.get_show_menu(),
vim: self.vim_motions.into(),
notification: self.notification,
blink: self.blink,
app_time_format: self.app_time_format,
Expand Down
7 changes: 5 additions & 2 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,24 @@ pub struct Args {
#[arg(long, value_enum, help = "Open menu.")]
pub menu: bool,

#[arg(long, short = 'v', value_enum, help = "Enable/disable Vim motions.")]
pub vim: Option<Toggle>,

#[arg(long, short = 'r', help = "Reset stored values to defaults.")]
pub reset: bool,

#[arg(
long,
short,
value_enum,
help = "Toggle desktop notifications. Experimental."
help = "Enable/disable desktop notifications. Experimental."
)]
pub notification: Option<Toggle>,

#[arg(
long,
value_enum,
help = "Toggle blink mode to animate a clock when it reaches its finished mode."
help = "Enable/disable blink mode to animate a clock when it reaches its finished mode."
)]
pub blink: Option<Toggle>,

Expand Down
9 changes: 9 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ impl From<bool> for Toggle {
}
}

impl From<Toggle> for bool {
fn from(value: Toggle) -> Self {
match value {
Toggle::On => true,
Toggle::Off => false,
}
}
}

#[cfg(test)]
mod tests {

Expand Down
3 changes: 3 additions & 0 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ where
pub struct AppStorage {
pub content: Content,
pub show_menu: bool,
#[serde(default)]
pub vim: Toggle,
pub notification: Toggle,
pub blink: Toggle,
#[serde(deserialize_with = "deserialize_app_time_format")]
Expand Down Expand Up @@ -59,6 +61,7 @@ impl Default for AppStorage {
AppStorage {
content: Content::default(),
show_menu: true,
vim: Toggle::Off,
notification: Toggle::Off,
blink: Toggle::Off,
app_time_format: AppTimeFormat::default(),
Expand Down
Loading
Loading