Giter Site home page Giter Site logo

Comments (13)

aadcg avatar aadcg commented on July 19, 2024 2

@MaxGyver83 could you open two issues on that? Just copy and paste. I think that the modality of VI mode is lacking.

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024 1

New issues: #3190 and #3191.

from nyxt.

jmercouris avatar jmercouris commented on July 19, 2024

What you need are modal bindings. For this reason either you can model your own mode off of vi, or you can make your mode aware of the state. I think it is easier to just modify the vi bindings to suit you :-)

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024

But how is it possible that it works for the n in the CUA keybindings? Is this modal, too?

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024

OK, I have searched the source code: the n keybindings is only valid in help-mode:

"n" 'nyxt/mode/document:next-heading

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024

I think it is easier to just modify the vi bindings to suit you :-)

It doesn't sound so easy to me. How would I do this practically? The best way I can come up with is to grep the source/mode directory of the repository for all lines between keyscheme:cua and keyscheme:emacs (hoping that it's always in this order) and add them to the configuration snippet above.

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024

This way I can get all CUA keybindings:

cd ~/repos/nyxt/source/mode
fd -e lisp -d 1 -x awk '/:cua/,/:emacs/' | rg '^ +"' | tr -d ')' | sort

I have tried it. But actually I don't want to have a normal mode when I enter text. I'd rather use no single-key bindings.

from nyxt.

jmercouris avatar jmercouris commented on July 19, 2024

I really don't understand what your end state is, sounds like you'll need to write a rather extensive configuration. Sorry about that :-(, we can try to help when we have some time.

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024

Thank you! I also want to understand better how the keybindings (and Common Lisp in general :-) ) work. Maybe it's somehow possible to detect when a text input has focus and have a mode that gets disabled then.

from nyxt.

jmercouris avatar jmercouris commented on July 19, 2024

That's exactly what vi mode does!

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024

I have changed this in the source code:

diff --git a/source/mode/vi.lisp b/source/mode/vi.lisp
index d2b0409b7..ec4281c7d 100644
--- a/source/mode/vi.lisp
+++ b/source/mode/vi.lisp
@@ -22,10 +22,10 @@ the web page.

 See also `vi-insert-mode'."
   ((glyph "vi:N")
-   (keyscheme keyscheme:vi-normal)
+   (keyscheme keyscheme:cua)
    (keyscheme-map
     (define-keyscheme-map "vi-normal-mode" ()
-      keyscheme:vi-normal
+      keyscheme:cua
       (list
        "i" 'vi-insert-mode
        "v" 'nyxt/mode/visual:visual-mode)))))

And this in my config.lisp:

(define-configuration buffer
  ((default-modes
    (pushnew 'nyxt/mode/vi:vi-normal-mode %slot-value%))))

(define-configuration base-mode
  "Bind some custom keys in CUA map."
  ((keyscheme-map
    (keymaps:define-keyscheme-map "custom" (list :import %slot-value%)
      nyxt/keyscheme:cua
      (list
       "f" 'nyxt/mode/hint:follow-hint
       "{" 'previous-heading
       "}" 'next-heading)))))

This is close to what I want. But I always have to change to vi-insert mode after C-space. When I enter text inputs in HTML documents, I'm directly in insert mode. But I couldn't find a way to unfocus without using the mouse. Escape just switches to vi-normal mode. Sometimes I can't scroll with the arrow keys after unfocusing with a mouse click. Sometimes I can't focus the text input with Alt-i anymore.

from nyxt.

aadcg avatar aadcg commented on July 19, 2024

My personal conclusion on this issue follows.

All default keyschemes could have been modal since the web factors into two modes, a mode for input and another for non-input. Instead, we decided that vi is the only default modal keyscheme that follows that strategy. CUA's case is debatable since modality could trip users. On the other hand, I believe it would be more efficient and our users could have embraced the idea.

@MaxGyver83 I still think that you're be better off using the vi keyscheme and binding commands to your personal preferences in the config file. You're going against the tide by trying to make CUA modal, see #2956.

from nyxt.

MaxGyver83 avatar MaxGyver83 commented on July 19, 2024

I still have two issues with using the vi keyscheme:

  1. When I type f (to follow links), I can't type the hint letters next. The prompt ("Interact with element") is in normal mode then and I have to switch to insert mode first, before I type the hint letters. What's the benefit of normal mode in such a case? Is this configurable?
  2. When I focus a text input on a web page with Alt+i, I'm directly in insert mode and can enter some text. But then I'm caught in this text input. How can I unfocus (without using the mouse)? Esc brings me to normal mode but never out of the text input.

from nyxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.