Skip to content

Conversation

@artur-shaik
Copy link
Contributor

@artur-shaik artur-shaik commented Apr 9, 2015

Allow user switch in caret mode for browsing with caret, and visual mode
for select and yank text with keyboard. #597

Default keybindings is c or v for caret mode, and again v for visual mode. All
basic movements provided by WebAction enum implemened with vim-like
bindings. Yanking with y and Y for selection and clipboard respectively.

There is bug/feature in WebKit that after caret enabled, caret doesn't
show until mouse click (or sometimes Tab helps). So I add some workaround
for that with mouse event. I think should be better aproach.

Signed-off-by: Artur Shaik ashaihullin@gmail.com


This change is Reviewable

Allow user switch in caret mode for browsing with caret, and visual mode
for select and yank text with keyboard.

Default keybindings is c or v for caret mode, and again v for visual mode. All
basic movements provided by WebAction enum implemened with vim-like
bindings. Yanking with y and Y for selection and clipboard respectively.

There is bug/feature in WebKit that after caret enabled, caret doesn't
show until mouse click (or sometimes Tab helps). So I add some workaround
for that with mouse event. I think should be better aproach.

Signed-off-by: Artur Shaik <ashaihullin@gmail.com>
@The-Compiler
Copy link
Member

Whoa, this is pretty damn cool! Thanks a lot!

Some improvements (and ideas, if you feel like implementing them):

  • The status bar should probably be colored in that mode - if I remember correctly, Pentadactyl/Vimperator uses purple for that, so maybe two shades of purple by default? The coloring logic is already there, so it shouldn't be too hard to add this.
  • I don't really like binding the c character by default, as it might be used in the future (see Missing dwb keybindings #13) - I'd prefer to bind v only.
  • With a separate mode, it might be possible to bind custom keys in those modes (Spatial Navigation - change key bindings #579) which then emulate a key press event on the cursor keys.
  • As you said yourself, the fake mouse click solution is rather bad... Maybe try if QWebFrame::setFocus() does anything, or QWebElement::setFocus() on some element (e.g. the QWebFrame::documentElement()) or if QWebPage::focusNextPrevChild() works or toggling QWebPage:: setContentEditable() or some WebAction.

@artur-shaik
Copy link
Contributor Author

  • Yes, coloring must be. Hm, for me Pendatactyl doesn't coloring any mode. I will play with purple colors.
  • c key is absolutely unnecessary, I will remove it from default.
  • I didn't understand a little, so what we should to do here?
  • I tried that, but not some of this. Will make an attempt once again.

@The-Compiler
Copy link
Member

Some people (like @mgraham - and possibly me too when I use those modes) would like to use hjkl or other keys instead of the cursor keys for spatial navigaton/caret browsing.

It seems QtWebKit doesn't give us a way to customize those bindings - but we could add a new hidden command :visual-move {up,down,left,right} or so, then bind custom keys (like hjkl) to them, and then emulate keypresses on the cursor keys (similiar to your emulated mouse events) in those commands.

Make mouseclick event point slightly down.
Add commented tries of more reliable methods of caret focusing.
@artur-shaik
Copy link
Contributor Author

  • Added purple color for caret and lighter purple (#a12dff) for visual.
  • c key removed from defaults.
  • As I can see, here we shoud add one more mode for spatial nav?
  • Unfortunatly, any of your suggestion doesn't solve the problem. I leaved my attempts commented there in the code, so may be you can find some ways to do it right.

@The-Compiler
Copy link
Member

Thanks! I didn't notice you already did bind hjkl in that mode. I'll test it and see what I think about it 😄

For the caret issue I'll try to play a bit in the hope of finding something... Clicking at an essentially random location in the page definitely is something I don't want to do, as it could have unintended effects (like, dunno, buying something).

@artur-shaik
Copy link
Contributor Author

😄

The good thing is that, this mouse event doesn't trigger links to open. But of course needs to test it on all platforms.

@The-Compiler
Copy link
Member

I don't think this will make it into v0.2 as I'll have to test it and try to find an alternative solution to make the caret appear. Is this okay for you? 😄

v0.3 will probably be a release without many new spectacular features from my side (as I'll be working on #499 and other config migrations, so that'd be a good time to add it.

@artur-shaik
Copy link
Contributor Author

Yeah, that's ok. Thanks.

On 04-13 (22:41), Florian Bruhin wrote:

I don't think this will make it into v0.2 as I'll have to test it and try to
find an alternative solution to make the caret appear. Is this okay for you?
😄

v0.3 will probably be a release without many new spectacular features from my
side (as I'll be working on #499 and other config migrations, so that'd be a
good time to add it.


Reply to this email directly or view it on GitHub.*

Best regards,
Artur Shaikhullin

@The-Compiler The-Compiler added enhancement component: keyinput Issues related to processing keypresses. labels Apr 14, 2015
@The-Compiler The-Compiler added this to the v0.3 milestone Apr 14, 2015
@The-Compiler The-Compiler mentioned this pull request Apr 22, 2015
@The-Compiler
Copy link
Member

Sorry for the long delay!

I've now looked at this a bit, resolved the conflicts and pushed to the visual branch.

I still have some questions/ideas - if you do new commits, can you please do them on top of the visual branch and submit a new pull request agains that branch?

First of all about the workaround: I'm still trying to find something suitable, but on the pages I tested (http://www.heise.de/ and http://www.cmpl.cc/) your workaround didn't help at all - and since it could maybe also do weird things, I'm afraid I'd really prefer no workaround to that 😢

I also wonder if it's really a good idea to have separate modes for caret/visual, as they are very similiar. I know right now it's like it's implemented in dwb, but I think something else would be better - I wonder what you think about this.

I've never used the visual feature in dwb before, so in qutebrowser that's what I tried intuively and what didn't work (very similiar to the copy mode in screen/tmux):

  • Enter caret mode
  • Go to the start of the selection
  • Press space to start the selection
  • Navigate to the end of the selection
  • Press y to yank the selected text (to clipboard, it'll probably already be in primary selection), or space to abort.

How does that sound to you?

@artur-shaik
Copy link
Contributor Author

Hi.

That's strange, I've just tested, for me your links work nice. My usual usage of caret was: scroll page in normal mode to plain text (because browser is positioning caret at top of the window), click caret navigate to text for selection, than select it, yank. But even if I press caret key at default top position (with no scroll in normal mode) it gives me caret in menu of this sites, you gave me.

I really see this workaround as some dog-nail, and I hope we will find nice approach to do it right, but without it, wee always must use mouse to position our caret at first time. This hurts me 😄 . May be QtWebkit team can do something?

About modes. Separates modes I see more vim like, and why I did separate, because I got used it in dwb and cVim (Chrome). And this is nice indication about what you are doing right now. And adding additional mode more like configuration instead programming, thanks you for that 😃 . I think we need more opinions about it. My pros: vim-like, indication.

@The-Compiler
Copy link
Member

I've now found a different workaround (calling clearFocus and setFocus on the QWebView).

Now the caret always gets shown correctly, but as you said, it starts at the top of the page. Is this acceptable for you?

About the different modes: As we discussed in IRC, I think it'd be better to have one shared mode and just have an indication in the statusbar. Do you want to do this or should I?

@artur-shaik
Copy link
Contributor Author

Yeah, I think I can do it.

For now, I can accept focus at top of the page, will see how new workaround works.

@The-Compiler
Copy link
Member

Closing this because #653 is open now.

@demure demure mentioned this pull request Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: keyinput Issues related to processing keypresses.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants