gdh1995 / vimium-c

A keyboard shortcut browser extension for keyboard-based navigation and tab operations with an advanced omnibar
https://chrome.google.com/webstore/detail/vimium-c/hfjbmagddngcpeloejdejnfgbamkjaeg
Other
3.42k stars 253 forks source link

swap or hide hints termporary #89

Closed Monirzadeh closed 4 years ago

Monirzadeh commented 4 years ago

hi some time hint key hide the link that you like or two hint overlap for better control please add two key bind in hint mode that hide key hints while you press (maybe space) and a key (maybe alt) that swap hints) Surfingkeys has similar feature but vimium-c is a little faster. i have a side question speed is important for me so more option make vimium-c slower?

gdh1995 commented 4 years ago

This is a good feature and I'll add it in some weeks - currently I'm merging the "filter hint" feature from the original Vimium, so other features have to be delayed.

As for performance, Vimium C has called "as less as possible" browser APIs during all commands, cost little loop code and created few temporary memory objects. Compared with Vimium, I've added lots of short path to skip expensive actions (like duplicated or unnecessary UI changes).

Therefore, I think such options won't slow down Vimium C. They will only increase the file sizes a little.

gdh1995 commented 4 years ago

BTW, currently Vimium use Tab to toggle visibility of some hints. When you have typed a prefix character, Tab will hide visible hints, and show those hidden ones, and a second Tab will revert back the visibility.

gdh1995 commented 4 years ago

Hello, I've add a function and you may press Shift+F1 to toggle opacity of hint markers:

Monirzadeh commented 4 years ago
  • .HM1 { opacity: 0.3; }

hi i test that on firefox and brave and work like a charm but i think 2 change can be helpful

  1. i can't find an option for remap Shift+F1 to simpler keybinding for example that happen with alt in hint mode
  2. i think if this mode active while press keybind can be better- or be optional. this situation is temporary. for example while i press alt in hint mode hide all hints. so i save one key press in this example.
gdh1995 commented 4 years ago
  1. Alt / Ctrl / Meta / Shift have been used to switch among modes in LinkHints, and currently not remappable.
  2. F2 has been used to toggle quite a few switches, including s-f2 / a-f2 / c-f2
  3. F1 is used to simulate Backspace, and this is why I use Shift+F1 to add this feature.

As a result, I think it's hard to find a new key which is easy to understand, to toggle this switch. If you get one, please tell me; and let's released a new version just with the current Shift+F1 solution.

I still recommend you to: type a prefix character, and then use Tab to show one part of hint markers and then a second Tab to show the other part.

Monirzadeh commented 4 years ago
  1. Alt / Ctrl / Meta / Shift have been used to switch among modes in LinkHints, and currently not remappable.
  2. F2 has been used to toggle quite a few switches, including s-f2 / a-f2 / c-f2
  3. F1 is used to simulate Backspace, and this is why I use Shift+F1 to add this feature.

As a result, I think it's hard to find a new key which is easy to understand, to toggle this switch. If you get one, please tell me; and let's released a new version just with the current Shift+F1 solution.

I still recommend you to: type a prefix character, and then use Tab to show one part of hint markers and then a second Tab to show the other part.

i think space key can be good option for this. i test default settings and it is available i unmap all key and replace that with specific commend ,that i use regularly so it can be available in specific situation

gdh1995 commented 4 years ago

Space has been used to rotate hints...

Tab has been used to re-init LinkHints, toggle visibility of parts of hints (in alphabet mode), or "select" among hints (in "filtered hint" mode).

Or if you like, ` may be a choice.

Monirzadeh commented 4 years ago

Space has been used to rotate hints...

Tab has been used to re-init LinkHints, toggle visibility of parts of hints (in alphabet mode), or "select" among hints (in "filtered hint" mode).

Or if you like, ` may be a choice.

can be use shift + space (more reachable) or can set any differences between left and right shift so left shift for open in new tab and right shift for hide hints (only in hint mode) or an option i can remove shift action in hint and map to my preference or , in hint mode key map is separate for each mode?

gdh1995 commented 4 years ago

Yes, mapKey works differently in different modes, and currently Alt/Ctrl/Meta/Shift can not be mapKey-ed; Left/Right shift is hard to distingush - at least hard on old Chromes (Vimium C supports Chrome 32+ in its source code).

Shift+Space has been used to rotate hints in a reverse order.

You may use Auto Hot Key to re-map some keys when a current focused window is Chrome/Firefox. It can re-map almost all keys.

Monirzadeh commented 4 years ago

off the topic

Or if you like, ` may be a choice.

thanks for your time and favor :heart: is there any way to support project with bitcoin,etc..? i try to make keybinding close together as much as possible

Monirzadeh commented 4 years ago

Yes, mapKey works differently in different modes, and currently Alt/Ctrl/Meta/Shift can not be mapKey-ed; Left/Right shift is hard to distingush - at least hard on old Chromes (Vimium C supports Chrome 32+ in its source code).

Shift+Space has been used to rotate hints in a reverse order.

You may use Auto Hot Key to re-map some keys when a current focused window is Chrome/Firefox. It can re-map almost all keys.

i use linux so Auto Hot Key is not available for linux. beside i use sxchkd and it can make some conflict so i can setting for unmap shift + space or shift in hint mode and use shift or shift + space for hide hints in hint mode. i think right and left shift is the best option it can be better add an option in settings, if anybody active that in right version of chrome can use right and left shift mapping.

gdh1995 commented 4 years ago

Is it enough to (add an option item and) give Right Shift a special key like <rshift>?

Added: or give Right *** keys like <rshift>, <ralt> and <rctrl>?

BTW, a complete "mapKey" support in LinkHints won't land in a next release of Vimium C - in my plan the next version only includes the "Filtered Hints" mode.

Monirzadeh commented 4 years ago

s it enoug

i think it is prefect. side note: i use shift+jkl for control youtube player in normal mode. ( i an not set anything for that) so if for example somebody set overlap in a mode setting get error while save setting

gdh1995 commented 4 years ago

Vimium C can not learn what shortcuts you've set on websites, but you may add them to the "Excluded URLs and keys". Like this: Pattern is :https://www.youtube.com/ and Keys is J K L.

image

Monirzadeh commented 4 years ago

BTW, a complete "mapKey" support in LinkHints won't land in a next release of Vimium C - in my plan the next version only includes the "Filtered Hints" mode.

i am a little confuse can you link a wiki or something about "Filter Hints" i don't get difference between "Hint mode" and "Filter Hint mode"

gdh1995 commented 4 years ago

It's a mode that Vimium C has "lacked" for years, compared with the origin Vimium. The wiki of "Filtered Hints" is https://github.com/philc/vimium/wiki/Using-Link-Hints

gdh1995 commented 4 years ago

Hello, Vimium c v1.79.1 has been released on Chrome Web Store and Firefox Add-ons, and you may have a try then.

Shift+F1 has landed, while ` is not used to trigger it on this version.

Monirzadeh commented 4 years ago

Hello, Vimium c v1.79.1 has been released on Chrome Web Store and Firefox Add-ons, and you may have a try then.

Shift+F1 has landed, while ` is not used to trigger it on this version.

thanks i will wait for an option to remap that to right shift in following update :)

gdh1995 commented 4 years ago

Hello, there has been a base version of per-mode mapKey: v1.80.1 (released on Firefox Add-ons), vimium_c-1.80.1-chrome-8f1c7f7.zip

Usage:

Monirzadeh commented 4 years ago

hi i test this version on Firefox and it's work fine. but if the user can set hide while press shift key (in mapkey) it can save one unnecessary press key.(i usually hide hint completely)

i know below part is a little complicated but only write that as an idea.( may be it can be useful for someone ) current mode(toggle with each press) can be useful in this example: user active Allow mapping right-hand (or left-hand) modifier keys one press shift it map to toggle hide/show hints if user hold shift (and press hints) it can use right shift to open in new tab too.

by the way i think it can be better to set while press shift. (save one unnecessary key press) i explain that here

think if this mode active while press keybind can be better- or be optional. this situation is temporary. for example while i press alt in hint mode hide all hints. so i save one key press in this example.

sorry,I explain that a little complicated. if you don't get my point say that. i will try to explain that in a better way.

gdh1995 commented 4 years ago

Um, currently Vimium C (almost) has no actions on a key gets "up", while in most time it responds on key "down" events, so it will be a little odd if there's only one small feature for keyup. Anyway, I'll try to add it and see how much it will increase the code size. Currently Vimium C's content scripts is 95KB, I want it to keep smaller than 100KB in this year...

I has another question: now you need a feature to toggle hints' classname, and I can make it auto-reverted on a key up, but do I need to make this auto-reverting for other features, and how to represent and configure this need in Vimium C Options?

Monirzadeh commented 4 years ago

n a key up, but

i am not sure i get your point completely you have similar feature right now if you press f hint open link in current tab and if you hold shift in this mode it change to open in new tab while you press that

for now if i set mapkey <s-modifier> <s-f1> that mean set shift as shift + f1 it better something like this mapkey <s-modifier> :right: :while: <s-f1> (or any syntax that you like ) with this config you can add some tag to keys

  1. i can set :right: or :left: for modifier keys shift alt ctr if i don't set this tags it mean both side
  2. i can use :while: that it is mean do something while i press that and revert it ,if i release that key. don't set :while: tag, means like current behavior (press do something press again revert that) so i can use this config

now i can set this config mapkey <s-modifier> :right: :while: <s-f1>

but it is better to set new command like toggleHintsOpacity you can set opacity in two way

  1. like now :in css setting .HM1 { opacity: 0.3; }
  2. in mapkey toggleHintsOpacity0.3

so i can configure that in any way that i like

set shift + f1 and right shift as toggleHintsOpacity while you press them

mapkey <s-f1> :while: toggleHintsOpacity
mapkey <s-modifier> :right: :while: <s-f1>

set only right shift for toggleHintsOpacity while you press that

mapkey <s-modifier> :right: :while: toggleHintsOpacity

current behavior for this modifier, it can be set with this config

mapkey <s-f1> toggleHintsOpacity
mapkey <s-modifier>:right: <s-f1>

set shift + f1 as one press key(and set opacity from CSS for next hint mode) and right shift in while mode

mapkey <s-f1> toggleHintsOpaicity
mapkey <s-modifier> :right: :while: toggleHintsOpacity0.0

if anybody set :right: or :left: tag in config Vimium C check Allow mapping right-hand (or left-hand) modifier keys option is active or not

it is a little long so i make a summery for that this feature can be useful for now

  1. add tags :right: :left: :while: in config
  2. add toggleHintsOpacity as new command

in long run

  1. preeminent opacity if anybody need that
  2. user can set percent opacity for toggleHintsOpicity directly in mapkey
Monirzadeh commented 4 years ago

Um, currently Vimium C (almost) has no actions on a key gets "up", while in most time it responds on key "down" events, so it will be a little odd if there's only one small feature for keyup. Anyway, I'll try to add it and see how much it will increase the code size. Currently Vimium C's content scripts is 95KB, I want it to keep smaller than 100KB in this year...

I has another question: now you need a feature to toggle hints' classname, and I can make it auto-reverted on a key up, but do I need to make this auto-reverting for other features, and how to represent and configure this need in Vimium C Options?

why you set this goal? for performance reseon? is it possible to make Vimium C modular? something like arch that user can select feature that he need and make a personal version of Vimium C? it is need to create an automatic build process to make a local version of that Vimium C. if it is possible should i make a new issue for that as requested feature? and explain that in more detail?

UPDATE: Suckless program is a better example

gdh1995 commented 4 years ago

right or left

:right: or :left: is not so useful:

  1. the checkbox has decided which side to use
  2. I want to keep at least one side modifier keys "never hooked" by Vimium C, so that everyone can find a way to trigger Ctrl/Alt/Shift (in case one provides his/her computer to another for a small task)

mapKey usage

Firstly, Vimium C converts a KeydownEvent instance from browser to a "key" string, and it will include key name (named key char) and status of Alt/Ctrl/Meta/Shift.

mapKey is used to translate a "key" to another, and though you may write lots of rules, for one keydown event there'll be only one rule to be used. The priority now is:

  1. try to map "<" + key + ":" + modeId + ">" if modeId (defined in https://github.com/gdh1995/vimium-c/issues/110#issuecomment-580088981) is not Empty
  2. if step 1 finds nothing, try to map "<" + key ">" if key has at least 2 characters, or map key
  3. if step 2 finds nothing, try to map key char to another key char if both a source char and its mapped target are single characters.
      1. if step 3 succeeds, re-build key using the new target key char and modifier key status
  4. return mapped key or re-built key or key

Therefore, I think we should avoid adding further more complex usage into mapkey

:while: and toggleHintsOpacity

:while: is hard to implement in the map key phase. the hints opacity is a too small point to deserve a new special command to trigger it.

I think there's another way to "make hints disappear and then re-appear" - if only change the condition on a key being released to for a small time, then CSS animation should be enough.

For example, .HM1 can be configured to declare such an animation: opacity from 1 to 0, and wait a while before setting opacity=1:

.HM1 {
  animation: animated_opacity 2s 1;
}
@keyframes animated_opacity
{
    0%      {opacity: 1}
    5%      {opacity: 0}
    95%     {opacity: 0}
    100%    {opacity: 1}
}

And here're some docments of animation:

Monirzadeh commented 4 years ago

I prefer controllable instead of animation but it's Ok. performance is most important things. This feature don't use so frequently By the way Surfingkeys Has similar feature maybe it can be helpful

gdh1995 commented 4 years ago

Um, in my last comment, I want to represent that "this work is too heavy for me to execute". Although performance won't be harmed (maybe a new function of 200~300 bytes), the related code lines are too many, and I'll have to review all of them once by once, to find potential typos and logic bugs.

You see Vimium C has few test cases, so I prefer adding new features than doing wide logic rewriting, since this intent of "hide and then show hints" is very small.

Monirzadeh commented 4 years ago

Um, in my last comment, I want to represent that "this work is too heavy for me to execute". Although performance won't be harmed (maybe a new function of 200~300 bytes), the related code lines are too many, and I'll have to review all of them once by once, to find potential typos and logic bugs.

You see Vimium C has few test cases, so I prefer adding new features than doing wide logic rewriting, since this intent of "hide and then show hints" is very small.

Ok If you add feature for go to visual mode with select word in a webpage (so helpful for translate word so faster) while feature is so important for that. While feature can be add if you start work on enter visual mode with select a word

Should I create an issue for this?

why you set this goal? for performance reseon? is it possible to make Vimium C modular? something like arch that user can select feature that he need and make a personal version of Vimium C? it is need to create an automatic build process to make a local version of that Vimium C. if it is possible should i make a new issue for that as requested feature? and explain that in more detail?

UPDATE: Suckless program is a better example

gdh1995 commented 4 years ago

there's a bulid script based on Gulp: gulp local will build a local version in place for Chrome 73+ and Firefox 63+, and you may update types/build/index.d.ts (or set environment variable BUILD_MinCVer and BUILD_BTypes) to configure detailed support - a higher min-version means Vimium C can be faster.

gdh1995 commented 4 years ago

Hello, I'm releasing Vimium C v1.81.5, and it changes the CSS classname of HM1 into HM-f1: