Sublime Forum

Entry History for Input Panel?

#1

I’m currently using show_input_panel to take user input (for a particular kind of search).

I’d like to show the user their recent entries, navigable with up and down arrows as in the Find (Cmd-f) panel.

Does such a feature exist in the package API? If not, what would be the best way to implement it? I obviously have programmatic access to the values when the user confirms their input, but how do I store them and retrieve them?

Thanks!

Tom

0 Likes

#2

To capture all of the input panel entries, you would have to tie into each individual plugin. I don’t know that there is a way to do this.

0 Likes

#3

Thanks for the reply!

I’m actually interested only in giving a navigable history for “this” input panel … that is, the one for this plugin.

So if you input “a” and “b” before for this same plugin’s input panel then you should be able to navigate with the up arrow to “b” and then “a” for easy re-entry of the same input.

Is that possible?

(I also want to add a couple of buttons alongside the input panel but I’ve come to the conclusion that this is impossible.)

0 Likes

#4

Take a look at this plugin, I think it’s what you want:
github.com/randy3k/AlignTab/blo … ab.py#L247

If you want to make history persistent, I suppose you can use:

window.settings()

or

project_data() / set_project_data(data)

or
store it in a file on the disk

0 Likes

#5

In that case, it’s possible. Take a look at what bizoo posted. In addition, take a look at the key binding file (github.com/randy3k/AlignTab/blo … ime-keymap). It looks like it applies a scope to the input panel, which can then be used to force the correct behavior (via context on key binding). You could probably do something similar by setting some setting on the view. I do this in AdvancedNewFile. You can apply a setting like link, then use a key binding like this

0 Likes

#6

Thanks for the responses guys. I finally got around to this today.

I got the history working fine and defaulting to last entry by copying how AlignTab does it.

The problem I have now is that I don’t know how to supply a context to the keymap that means “only when you are in this panel”.

I looked at the plugin docs but they didn’t help.

How can I “name” the panel that my plugin brings up to collect user input so that I can use it in the context part of the keyboard shortcut?

Thanks!

0 Likes

#7

Scratch that, I got it working with:

 {
   "keys": "down"],
   "command": "big_grep_history",
   "context":  { "key": "setting.big_grep_panel" } ]
 },

After setting setting.big_grep_panel with:

   panel = window.show_input_panel(prompt, suggestion, callback, None, None)
   panel.settings().set('big_grep_panel', True)

Still not working but getting closer … !

1 Like

#8

Got there!

Thanks for the hints folks.

0 Likes