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

PoC: KeyC and keyItemC shorter secondary constructors #2

Closed
wants to merge 3 commits into from

Conversation

zworek
Copy link
Owner

@zworek zworek commented Mar 26, 2024

Maybe it should use helper functions instead of secondary constructors?

Is dummy keys filtering breaking compile-time checking?

Copy link

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this is a solution without a problem, because people are still going to have to copy-paste to create keyboards, this doesn't change that in the slightest. It just makes it a tiny more compact, while placing additional burden on me, not you, to support this alternate definition.

Overall it just makes more work for me, when we inevitably change fields in KeyC in the future.

Why not just go with my original suggestion: define your own format in your own repo, and create a script to convert them to thumbkey keyboard files. Then you're not making more work for me. I'll even link to it in the thumbkey readme (as long as you do the work to maintain it).

color = ColorVariant.MUTED,
),
),
DUMMY_KEY, DUMMY_KEY, DUMMY_KEY,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you've lost all the swipetype direction limiters by adding dummy keys.

Copy link
Owner Author

@zworek zworek Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've introduced filtering dummy-keys out in second commit of this branch

ef4f7ea

But I don't know whether this approach isn't too liberal for your compile-time checking requirements

@@ -48,15 +48,46 @@ data class KeyItemC(
val swipeType: SwipeNWay = SwipeNWay.EIGHT_WAY,
val slideType: SlideType = SlideType.NONE,
val longPress: KeyAction? = null,
)
) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a much worse constructor than the default. None of these are optional, and forces you to use dummy keys. I'd prefer you got rid of this one.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was the idea. It forces exactly 9 args, which split into 3 lines represent key actions in human-friendly way

KeyItemC(
    KeyC('f'), KeyC('&'), KeyC('°'),
    KeyC('ś'), KeyC('s'), KeyC('>'),
    KeyC(';'), DUMMY_KEY, DUMMY_KEY
)


data class KeyC(
val display: KeyDisplay?,
val capsModeDisplay: KeyDisplay? = null,
val action: KeyAction,
val color: ColorVariant = ColorVariant.SECONDARY,
val size: FontSizeVariant = FontSizeVariant.SMALL,
)
) {
constructor(character: Char) : this(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I could see being useful. Still scares me, because people might start defining keyboards like this, and this constructor logic could get complicated. Overall, still much worse than just the default data class constructor.

@zworek
Copy link
Owner Author

zworek commented Mar 26, 2024

@dessalines ok, I think I understand your PoV. Thank you for your time 🙇

@dessalines
Copy link

Its no probs, if I wasn't extremely overburdened with other duties I'd consider it. ping me if you end up creating that script, and I'll add it to the thumbkey readme.

@zworek zworek closed this Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants