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

Make layer-next handle only the next button [vim like layers] #793

Open
recallthis opened this issue Jan 12, 2024 · 2 comments
Open

Make layer-next handle only the next button [vim like layers] #793

recallthis opened this issue Jan 12, 2024 · 2 comments

Comments

@recallthis
Copy link

recallthis commented Jan 12, 2024

I want to switch into another layer for one keypress only, similar to how layers work in vim.

Layer-next seems to be suited for this, as defined in the tutorial:

'layer-next', once pressed, primes KMonad to handle the next press from some
  arbitrary layer.

However, it really handles multiple next presses if they are pressed together.

This issue applies to around-next also, and closely resembles #166 and #167.

Steps to reproduce the issue

To borrow the examples from #167, suppose I have

(defalias
  nsh (layer-next sft)) ;; layer with all alpha keys capitalised 

Expected behaviour

I expect to see the layer used for only one keypress.

T@nsh Ta Tb       ==> Ab
T@nsh Pa Pb Ra Rb ==> Ab

Actual/current behaviour

But if many keys are pressed together they are all made in the layer

T@nsh Ta Tb       ==> Ab
T@nsh Pa Pb Ra Rb ==> AB

Attempt to create a button

David Janssen created an "around-next-single" button (discussed in this comment) to solve the around-next issue. I attempted to use that logic but the behaviour was no different to layer-next.

layerNextSingle :: LayerTag -> Button
layerNextSingle t = onPress $ await isPress $ \_ -> do
  layerOp (PushLayer t)
  await (pure True) $ \_ -> do
    layerOp (PopLayer t)
    pure NoCatch
  pure NoCatch

Other ways of doing this

This can be done by creating layers full of aliases whose only function is to perform one key or button and return but it uses a lot of config space if you use a lot of these type of layers.

Maybe I'm using this incorrectly or missing a better way?

@slotThe
Copy link
Member

slotThe commented Jan 13, 2024

What version of KMonad are you running? Perhaps #167 (which indeed should fix the issue) too new for it?

@recallthis
Copy link
Author

I was using a commit from Jun 2021 (Add logo to README #277)

I tried the first layer-next commit that Added leader-key like button

And the v0.4.1 prerelease from Sep 2020

And #167 Make aroundNext only affect the next button

I got the same results with (layer-next mylayer) and (around-next (layer-toggle mylayer)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants