Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: from simple keybindings to commands like in vim #17

Merged
merged 38 commits into from
Feb 21, 2023

Conversation

jaehyun1ee-furiosa
Copy link
Owner

dot-viewer features were previously triggered by simple keybindings (i.e., s for subgraph, f for filter, ...).

Since it is quite burdensome for users to learn and memorize the keybindings, in this PR, dot-viewer triggers its features through commands.

Via :, users may enter command mode and enter commands: neighbors, filter, subgraph, help, export, xdot.

Several changes were made to the source code as well.

1. Changed definition of Mode.

Mode was previously defined as,

pub enum Mode {
    Main(MainMode),
    Popup(PopupMode),
}

pub enum MainMode {
    Navigate(NavMode),
    Input(InputMode),
}

pub enum PopupMode {
    Tree,
    Help,
}

pub enum NavMode {
    Current,
    Prevs,
    Nexts,
}

pub enum InputMode {
    Search(SearchMode),
    Filter,
}

pub enum SearchMode {
    Fuzzy,
    Regex,
}

It is now simplified as,

pub(crate) enum Mode {
    Normal,
    Command,
    Search(SearchMode),
    Popup(PopupMode),
}

pub(crate) enum PopupMode {
    Tree,
    Help,
}

pub(crate) enum SearchMode {
    Fuzzy,
    Regex,
}

This allowed simplified function arguments in the ui module as well. There is no such strange function signatures as,

// input block
pub(super) fn draw_input<B: Backend>(
    f: &mut Frame<B>,
    chunk: Rect,
    mmode: &MainMode,
    app: &mut App,
)

where mmode is actually a clone of app's field.

2. Semantics of search and filter.

Like in vim, users can search for nodes using keywords, and after hitting enter, users may navigate through the matched nodes with n/N keys.

So there is no separate screen showing search matches in this version.

Also, filter previously filtered nodes with a given prefix. However, such function is already supported by subgraph. Thus, filter now creates a filtered View based on search matches.

3. Semantics of neighbors

Previously, neighbors produced a dot file with 0-9 keybindings.

In this version, neighbors n command creates a new View instead. So it supports any integer n larger than 9.

4. Options in export and xdot

Now users may optionally provide filename that he or she wants to export to, or launch xdot from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant