jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
3.08k stars 129 forks source link

Feature request: base layer in bool expr #1247

Closed GrewHair closed 2 months ago

GrewHair commented 2 months ago

Is your feature request related to a problem? Please describe.

My use case is rather complex, so I hope you'll excuse me for not going into gory details right away.

I'd rather just say that while Kanata now provides various handy devices/hacks that allow to store and reuse "state" for complex scenarios, like key-history, noop keys, virtual keys, etc, I feel like sometimes it would just make more sense to piggyback on Kanata's own wonderful layer model, keeping config cleaner and saner. Also just for completeness' sake.

So we already have a predicate that checks the current layer in switch statements, thanks to #1060. How hard would it be to also make one for the current base layer (the one Kanata goes back to when you release layer-while-held)?

Describe the solution you'd like.

a check for current base layer, like this:

(defalias
  sw (switch
    ((base-layer base-layer-1)) a break
    ((base-layer base-layer-2)) b fallthrough
    () c break
  )
)

Describe alternatives you've considered.

Defining dummy virtual keys and using them as flags that other bool expressions can query.

Additional context

No response

jtroo commented 2 months ago

Seems reasonable enough :)

jtroo commented 2 months ago

Does this work for the use case? https://github.com/jtroo/kanata/pull/1250

GrewHair commented 2 months ago

Wow that was quick, thanks!

Haven't tested it yet, as I'm using the wintercept version, and apparently it doesn't build now. Filed #1253 for that.

GrewHair commented 2 months ago

Commented out a bunch of lines in parser/src/cfg/mod.rs for now, haha :) And yeah, it does work! Will come back after more testing.

GrewHair commented 2 months ago

Ok it works perfectly for me, thanks @jtroo! Should I close the issue?