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

Transitioning from insert mode to editor normal mode without losing cursor focus? [Question] #26

Closed
Positron010 opened this issue Jul 10, 2021 · 18 comments
Labels
bug Something isn't working enhancement New feature or request question Further information is requested

Comments

@Positron010
Copy link

Question

Currently, switching from insert mode to editor normal mode causes the text field to lose focus, requiring clicking on the field to activate the text cursor again which is inconvenient. Is it possible to make the switch without the editor losing focus?

Thanks

@pit-ray
Copy link
Owner

pit-ray commented Jul 10, 2021

Hi

There is nothing in win-vind to make the transition from Insert Mode to Editor Normal Mode lose focus of text field. What application's text field are you targeting? Perhaps the same keystroke as to_edi_normal will lose focus without win-vind? In that case, I recommend you change the bindings of to_edi_normal.

Thanks again

@Positron010
Copy link
Author

Positron010 commented Jul 12, 2021

Hi,

This happens even when using the default shortcut (esc+right). I'm not sure if it happens everywhere, but it does happen in multiple instances, even in this comment field.

It sometimes happens and sometimes don't. For example it happens in this GitHub comment field, but doesn't happen in notepad.

Thanks.

@pit-ray
Copy link
Owner

pit-ray commented Jul 14, 2021

Sorry for my late reply.

I tried but could not reproduce the phenomenon. Can you give me the details of .vindrc and the name of your browser?

Thanks.

@Positron010
Copy link
Author

No problem.

I use the Microsoft Edge (Chromium based) browser.

Here is my .vindrc:

set vscroll_speed = 100
set hscroll_speed = 100
set cmd_fontname = monaco
set shell = cmd
set easyclick_fontsize = 24
set easyclick_fontname = CalendasPlus
set autotrack_popup
set cmd_roughpos = LowerLeft


gnnoremap H move_cursor_left
gnnoremap L move_cursor_right
gnnoremap K move_cursor_up
gnnoremap J move_cursor_down
gnnoremap <C-g> jump_cursor_to_top
gnnoremap <C-G> jump_cursor_to_bottom
gnnoremap <C-m> jump_cursor_to_hcenter
gnnoremap <C-M> jump_cursor_to_vcenter
gnnoremap k scroll_up
gnnoremap j scroll_down
gnnoremap s scroll_up_halfpage
gnnoremap d scroll_down_halfpage
gnnoremap gg scroll_up_onepage
gnnoremap G scroll_down_onepage
gnnoremap f easy_click_left
gnnoremap N goto_next_page
gnnoremap C goto_prev_page
gnnoremap h switch_to_left_tab
gnnoremap l switch_to_right_tab
gnmap <Capslock> <ctrl>



gvnoremap K scroll_up
gvnoremap J scroll_down
gvmap <Capslock> <Esc>  
gvnoremap gh switch_to_left_tab
gvnoremap gl switch_to_right_tab
gvnoremap <Esc> to_gui_normal


evnoremap <Esc> to_edi_normal
evmap <Capslock> <Esc> 


command tp switch_to_left_tab
command tn switch_to_right_tab
command tt open_new_tab


inoremap <c-[> to_edi_normal

Apparently the issue occurs when the text field can lose focus, like by pressing esc. It doesn't happen in desktop apps like notepad.

Thanks

@pit-ray
Copy link
Owner

pit-ray commented Jul 14, 2021

Thanks for the quick reply! I'll try it.

@pit-ray
Copy link
Owner

pit-ray commented Jul 14, 2021

Thanks to your report, I found some bugs in the parser of .vindrc. As soon as fixed, I will give you its build binary. However, I still don't know the cause of the loss of focus, as I could not reproduce. Hopefully, this fix will solve it indirectly.

Thanks

@pit-ray
Copy link
Owner

pit-ray commented Jul 15, 2021

Hi.

I fixed some bugs in the .vindrc parser. You can download the build directly from here, and its code is here.

If does not solve the problem, I will add an option to autofocus the appropriate text filed near the mouse cursor with to_edi_normal.

Thanks.

@Positron010
Copy link
Author

Hi,
Thanks for your effort.
Unfortunately, the issue still persists with this build. I used the default .vindrc, just changed the shortcut for transitioning to edi_normal to avoid pressing esc, but that didn't solve the issue.

Thanks

@pit-ray
Copy link
Owner

pit-ray commented Jul 16, 2021

Thanks for trying.
Now, I'm implementing the new option to solve this problem. Please wait for a while.

@Positron010
Copy link
Author

Hi,
Thanks for your efforts and take your time. Appreciate it.

@Positron010
Copy link
Author

Hi, just a quick update.

I just found out that this issue resolves when changing the hotkey to something that is written in the input field. For example, I don't face the issue when I make the to_edi_normal from insert mode to be jj. It just transitions to it. You can then undo these two letters to get a somehow working solution.
Hope this helps.

Thanks

@Positron010
Copy link
Author

Well, this is embarrassing 😅. It was apparently the shortcut causing the issue. I also just changed my shortcut to something not typed like ctrl-/ and now it works without losing focus. Sorry for that, and thanks again for your efforts. I believe the default shortcut might need changing because esc causes many input fields to lose focus.

Thanks again, and I am sorry for consuming your time. Feel free to close the issue if you like.

@pit-ray
Copy link
Owner

pit-ray commented Jul 18, 2021

Even little things can be helpful for development.

A feature to prevent losing focus is implementable. I'm sure some users would be helped by this option.
I keep the issue open until implementation is completed.

@Positron010
Copy link
Author

Yes, I agree with that. It would be better to have such an option.
All the best.

@pit-ray
Copy link
Owner

pit-ray commented Jul 19, 2021

Thank you for waiting. I added a new option autofocus_textarea. It will automatically focus the nearest text field to the mouse cursor when to_edi_normal is called. You can try it from the pre-release.

To enable

set autofocus_textarea

@Positron010
Copy link
Author

Hi,
I just tested it, and it works really great! The only area of improvement I can see is increasing the speed of the process, but that is negligible. Thanks for your efforts!

@pit-ray pit-ray added bug Something isn't working enhancement New feature or request question Further information is requested labels Jul 21, 2021
@pit-ray
Copy link
Owner

pit-ray commented Jul 25, 2021

Today, I released v4.1 and it includes the new option uiacachebuild. If enable this option, autofocus_textarea and EasyClick become very faster. However, depending on the value of uiacachebuild_lifetime, the accuracy may decrease.

@Positron010
Copy link
Author

Hi,
Thanks as always. Keep up the good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants