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

Better display and completion of hints #406

Open
AndreaOrru opened this issue Jun 20, 2020 · 4 comments
Open

Better display and completion of hints #406

AndreaOrru opened this issue Jun 20, 2020 · 4 comments

Comments

@AndreaOrru
Copy link

AndreaOrru commented Jun 20, 2020

Assuming Hinter is designed to work similarly to the completion mechanism offered by fish and prompt-toolkit, there are a couple of things that need to be adjusted:

  • Accept the completion using Ctrl-E instead of (or in addition to) Right. See Use Ctrl-E for hint completion #407.
  • Show the hint in a different color (i.e. a darker grey).
  • Change the color back to default once the hint has been completed.

I've tried to return a colored string from the hint function, and it works (with some tweaks), but there's no way to change the color back to white after completion. Suggestions welcome.

@AndreaOrru AndreaOrru changed the title Complete based on hints Better completion based on hints Jun 20, 2020
@AndreaOrru AndreaOrru changed the title Better completion based on hints Better display of hints Jun 20, 2020
@AndreaOrru AndreaOrru changed the title Better display of hints Better display and completion of hints Jun 20, 2020
@gwenn
Copy link
Collaborator

gwenn commented Jun 21, 2020

See CompleteHint command:
https://docs.rs/rustyline/6.2.0/rustyline/enum.Cmd.html#variant.CompleteHint
Mapped to Right key by default:

KeyPress::Right if wrt.has_hint() && wrt.is_cursor_at_end() => Cmd::CompleteHint,

You can associate Ctrl-E to CompleteHint with:

    let mut rl = Editor::with_config(config);
    rl.bind_sequence(KeyPress::Ctrl('E'), Cmd:: CompleteHint);

@AndreaOrru
Copy link
Author

AndreaOrru commented Jun 22, 2020

Hi @gwenn, thanks for your answer. That's not what I want though. Ctrl-E may also be used to go to the end of the line when no hint is available - the binding you're suggesting overrides that behaviour. My PR #407 addresses that.

Still looking for solutions for issue n. 2 & 3. 🤔

@gwenn
Copy link
Collaborator

gwenn commented Jun 22, 2020

See highlight_hint
and highlight for 2 & 3.
And see #306 (and associated PR) to bind one action conditionally.

@AndreaOrru
Copy link
Author

Thank you! I solved my issues 2 & 3 with highlight_hint.

I appreciate the PR you linked would solve my issue n. 1. However, I still think Ctrl-E should complete the hint by default, like in fish and prompt-toolkit.

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

No branches or pull requests

2 participants