cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.77k stars 176 forks source link

Feature Request: Switch sort mode LAST RUN and RANK by using menu's interface #238

Closed em2er closed 1 year ago

em2er commented 2 years ago

It's more convenient to use hot key to switch to different mode if current history output doesn't provide suitable results

cantino commented 2 years ago

Good suggestion, thanks @em2er

navazjm commented 2 years ago

I would like to work on this issue.

navazjm commented 2 years ago

I have made the necessary changes, but I have a few questions.

I have decided to use F(1) for the keybinding, can use a different one if need be. So the interface looks like:

    fn text(&self, interface: &Interface) -> &str {
        match *self {
            MenuMode::Normal => match interface.settings.key_scheme {
                KeyScheme::Emacs => {
                    "McFly | ESC - Exit | ⏎ - Run | TAB - Edit | **F1 - Switch** | F2 - Delete"
                }
                KeyScheme::Vim => {
                    if interface.in_vim_insert_mode {
                        "McFly (Ins) | ESC - Cmd  | ⏎ - Run | TAB - Edit | **F1 - Switch** | F2 - Delete"
                    } else {
                        "McFly (Cmd) | ESC - Exit | ⏎ - Run | TAB - Edit | **F1 - Switch** | F2 - Delete"
                    }
                }
            },
            MenuMode::ConfirmDelete => "Delete selected command from the history? (Y/N)",
        }
    }

Right now the command is called Switch (as a placeholder, only included the * to make it standout)

Also, after testing, I feel like there should be some type of feedback for the user to know which result sort they are currently using.

Finally, when the user does switch to the different result sort, they have to enter a new key into the input to see the different results. I do not know if it is possible to instant refresh, if it is, I would be more than happy to try an implement it, but it may be out of scope of my knowledge of rust.

em2er commented 2 years ago

What would be a more appropriate name? Change Sort? Result Sort? Other suggestions?

According to current sort mode it can be like: F1 - Sort by Rank F1 - Sort by Time

cantino commented 2 years ago

Or maybe F1 - Sort (Rank) or F1 - Sort (Time), so it visually changes when you press F1?