-
Notifications
You must be signed in to change notification settings - Fork 25
feat(hints): allow custom hint generator functions #80
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1665,6 +1665,12 @@ | |
| this.#hint_size = value; | ||
| GlideBrowser.set_css_property("--glide-hint-font-size", value); | ||
| } | ||
|
|
||
| // Ideally this would default to glide.api.hints.label_prefix_free, | ||
| // but we haven't made the api object yet! This may be an indication that | ||
| // the helper functions should go somewhere else (and maybe just | ||
| // get aliased into the api so users can see them). | ||
| hint_label_generator: (alphabet: string[], len: number) => string[]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah to add a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fyi that this type doesn't match the implementations as here the arguments are |
||
| } | ||
|
|
||
| function make_glide_api(): typeof glide { | ||
|
|
@@ -1857,7 +1863,20 @@ | |
| debug: Services.prefs.getBoolPref("devtools.testing", false), | ||
| }); | ||
| }, | ||
|
|
||
| label_prefix_free(len: number): string[] { | ||
|
Check failure on line 1867 in src/glide/browser/base/content/browser.mts
|
||
| return GlideCommands.hint_label_prefix_free(len); | ||
| }, | ||
|
|
||
| label_numeric(len: number): string[] { | ||
| var ret = []; | ||
| for (var i = 1; i <= len; i++) { | ||
| ret.push(i.toString()); | ||
| } | ||
| return ret; | ||
| }, | ||
| }, | ||
|
|
||
| addons: { | ||
| async install_from_url(xpi_url): Promise<glide.Addon> { | ||
| const installer = await AddonManager.getInstallForURL(xpi_url); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ text-decoration: none; | |
| [`glide.o.jumplist_max_entries`](#glide.o.jumplist_max_entries)\ | ||
| [`glide.o.hint_size`](#glide.o.hint_size)\ | ||
| [`glide.o.hint_chars`](#glide.o.hint_chars)\ | ||
| [`glide.o.hint_label_generator`](#glide.o.hint_label_generator)\ | ||
| [`glide.bo`](#glide.bo)\ | ||
| [`glide.options`](#glide.options)\ | ||
| [`glide.options.get()`](#glide.options.get)\ | ||
|
|
@@ -206,6 +207,17 @@ The characters to include in hint labels. | |
|
|
||
| `ts:@default "hjklasdfgyuiopqwertnmzxcvb"` | ||
|
|
||
| ### `glide.o.hint_label_generator: (len: number) => string[]` {% id="glide.o.hint_label_generator" %} | ||
|
|
||
| A function to produce labels for `len` hints. You can provide your own | ||
| function or use an included one: | ||
|
|
||
| - `glide.hints.label_prefix_free`: Generate prefix-free combinations | ||
| of the characters in [hint_chars](#glide.o.hint_chars). This is the default. | ||
|
|
||
| - `glide.hints.label_numeric`: Generate sequential numeric labels, | ||
| starting at `1` and counting up. Ignores [hint_chars](#glide.o.hint_chars). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah this file is auto-generated, so you should move this description to I also just added a header to this file so it should be more obvious that it's auto-generated :) |
||
|
|
||
| ## • `glide.bo: Partial<glide.Options>` {% id="glide.bo" %} | ||
|
|
||
| Set buffer specific options. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One option is to use a getter/setter like the above option, so that it's lazily initialised.
e.g.
But defining the default label generator in
hinting.mtsand then just referencing it here would also be a fine approach.