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

Help message in the completion bar, for auto-discoverable bindings #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gasche
Copy link

@gasche gasche commented Sep 28, 2015

Having #utop_help;; is great, but the best help is a feature that user
can discover during their normal interaction with the tool. (utop is
already strong on this point thanks to the fact that, for example,
typing # allows to discover toplevel directives.)

This patch makes the key-bindings useful to navigate the completion
bar auto-discoverable by printing them (right-justified) inside the
bar whenever there is enough space to do so.

Before:

utop # Ar
┌───┬────────────┬─────┬───────────┬───────────────────────────────────────────────────┐
│Arg│Arith_status│Array│ArrayLabels│                                                   │
└───┴────────────┴─────┴───────────┴───────────────────────────────────────────────────┘

After:

utop # Ar
┌───┬────────────┬─────┬───────────┬───────────────────────────────────────────────────┐
│Arg│Arith_status│Array│ArrayLabels│                         (M-left, M-right, M-enter)│
└───┴────────────┴─────┴───────────┴───────────────────────────────────────────────────┘

This patch is only a very first attempt to get this feature
(in limited time). Hard-coding the precise key-bindings at the
lambda-term level is certainly the wrong design choice. I suppose the
help message should be configurable, and I would welcome advice on
what a better interface would be.

Also, we could discuss other "auto-discovery features" that would benefit utop and other lambda-term-using projects. For example right now when nothing is typed in the bar, utop proposes to complete module identifiers, and it is kind of noisy and not so useful in my opinion. I would rather use the space to provide some hints of useful key-bindings that users will not naturally try (I mean the basic history navigation is intuitive and familiar, but for example notifying users that search-in-history is available could be useful). We could have a fixed hint message, or rotate. What do you think?

Having #utop_help;; is great, but the best help is a feature that user
can discover during their normal interaction with the tool. (utop is
already strong on this point thanks to the fact that, for example,
typing `#` allows to discover toplevel directives.)

This patch makes the key-bindings useful to navigate the completion
bar auto-discoverable by printing them (right-justified) inside the
bar whenever there is enough space to do so.

Before:

```
utop # Ar
┌───┬────────────┬─────┬───────────┬─────────────────────────────────────────────────┐
│Arg│Arith_status│Array│ArrayLabels│                                                 │
└───┴────────────┴─────┴───────────┴─────────────────────────────────────────────────┘
```

After:

```
utop # Ar
┌───┬────────────┬─────┬───────────┬─────────────────────────────────────────────────┐
│Arg│Arith_status│Array│ArrayLabels│                       (M-left, M-right, M-enter)│
└───┴────────────┴─────┴───────────┴─────────────────────────────────────────────────┘
```

This patch is only a very first attempt to get this feature
(in limited time). Hard-coding the precise key-bindings at the
lambda-term level is certainly the wrong design choice. I suppose the
help message should be configurable, and I would welcome advice on
what a better interface would be.
@ghost
Copy link

ghost commented Sep 28, 2015

I think it's a good idea to have this kind of contextual help.

Hard-coding the precise key-bindings at the
lambda-term level is certainly the wrong design choice. I suppose the
help message should be configurable, and I would welcome advice on
what a better interface would be.

We can get the exact bindings by looking at the LTerm_read_line.bindings variable, and print them with LTerm_key.to_string_compact. To make the hint message configurable, the [engine] class could have a hint method in the same style as the message method:

  method hint : LTerm_text.t option signal

Also, we could discuss other "auto-discovery features" that would benefit utop and other lambda-term-using projects. For example right now when nothing is typed in the bar, utop proposes to complete module identifiers, and it is kind of noisy and not so useful in my opinion. I would rather use the space to provide some hints of useful key-bindings that users will not naturally try (I mean the basic history navigation is intuitive and familiar, but for example notifying users that search-in-history is available could be useful). We could have a fixed hint message, or rotate. What do you think?

I think fixed for a given prompt: i.e. if you start typing and delete everything you get the same thing. But can change with new prompts. It could be connected to what happened: UTop waited on a Lwt.t thread, change with UTop.set_auto_run_lwt. We could also display longer hints on utop startup.

@pmetzger
Copy link
Member

Is this still of interest? It's been in the queue for three years. If so, lets finish it up.

qheath pushed a commit to qheath/lambda-term that referenced this pull request Mar 21, 2019
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.

2 participants