I have a paragraph macro (just dot enter enter), but in some contexts, the second enter doesn’t belong as one enter puts you in the right place for a new paragraph. Obviously I could just make another macro and bind it to a different spot in my keymap or a different layer, but I have a pretty comfortable relationship with where that macro is, and if I could use it for both and find some way to toggle between macros, that’d be kinda cool. And again, I could just make another almost identical layer differing only by that macro and toggle between them when needed, but I’d rather not.
Is there a way for this? Maybe a macro with an if statement based on a on/off variable that can be switched by another key? An entry in a keymap which can pick between different macros based on a similar variable?
This can be done by adding another macro key that sets a static boolean variable in the macroAction() function on key press. Then based on the value of that boolean, your “new paragraph” macro would conditionally output the second enter tap.
I would be tempted to use Qukeys to put that “paragraph style toggle” macro on the same key as your “new paragraph” macro key, so a tap outputs a new paragraph, and a long press toggles the paragraph style.
If that wasn’t clear enough, I’d be happy to write up some example code for you, when I get the time.
I think I get the general idea, but I don’t really know how I’d do it, so some example code would be very appreciated! My paragraph key is already a qukey (with RightAlt), but having it somewhere else, or on the same key on a different layer, should be fine!
Ok, so far it does the first part fine, but the switching macro doesn’t seem to toggle the conditional part yet, that just never appears. Here’s what I have so far: