bragefuglseth / keypunch

Practice your typing skills
GNU General Public License v3.0
85 stars 13 forks source link

Rework input system #24

Closed bragefuglseth closed 3 weeks ago

bragefuglseth commented 1 month ago

The current input system only listens to when text has been committed from the input method, and then pushes that directly to a string. For #22 and #8 to be implemented, we need to mark letters as partially typed more often:

idoric commented 1 month ago

I thought about this proposal in connection with #22. There is a case that I had not talked about in #22 because it was not covered by Monkeytype, but which has its place with this new proposal: French quotation mark.

French quotation marks are used as follows: « + NNBSP + the quote + NNBSP + ». Example: « Ceci est une citation ». By default, when typing in a word processor configured for French, the character " is automatically replaced by « + (N)NBSP¹ or (N)NBSP + » depending on the context. Analyzing the context would be a much more ambitious proposition than expected. Fortunately I think there is another solution.

Keypunch wouldn’t need to act like a word processor, because it has an enormous facility compared to that type of software: it knows in advance the text that is going to be typed. It seems simpler to me to split the text into tokens and for each accept one or more sequences of characters. For example « C’est un œuf ! » would be cut into |« |C|’|e|s|t| |u|n| |œ|u|f| !| »|, then |« | would be validated with « + NNBSP, « + NBSP or ", |C| would (only) be validated with C, |’| would be validated with ’ or ', |œ| with œ or o + e, | !| with NNBSP + !, NBSP + ! or !, etc.

(In the hypothesis of such a system it would be easy to add an option for those who would like to type the text exactly as it is written but who would not trust themselves not to yeld to temptation during training.)

I hope to move the thinking forward, and not confuse things more than necessary.

¹ By default LibreOffice uses NBSP for historical reasons but it’s configurable

bragefuglseth commented 1 month ago

Thanks for the input! We use the guillemets in Norwegian typography too, so I'm familiar with them. I agree that it would be cool if those could just be entered as typewriter quotation marks.

In the system I'm fleshing out now, the app has a list of special letters with "aliases", which are additional accepted ways to type those letters. When an alias has been fully typed, it's converted to the corresponding letter. This system solves basically all the problems we have, especially if it can be made to play along with "preediting", commonly used by some input methods, too.

idoric commented 1 month ago

I think I misunderstood your initial explanation, sorry. I would like to clarify one point, does the special list contain only single characters or also sequences of characters? if it’s the second answer, then it’s possible to indicate that the « + NNBSP sequence can be typed alternately with « + NBSP or ", and my previous comment would be obsolete.

especially if it can be made to play along with "preediting", commonly used by some input methods, too

I was worried that systems I don't even know could cause problems, so much the better if that's not the case.

bragefuglseth commented 1 month ago

With the system I'm working on, we can at least have regular spaces as aliases for non-breaking ones, and typewriter quotation marks as aliases for guillemets. An alias can only apply to a single letter, not sequences of them. The aliases themselves can (obviously) consist of more than 1 letter, though.

bragefuglseth commented 3 weeks ago

Happy to report that the rework has landed. This required quite a lot of new plumbing and string manipulation, so please let me know if there are any issues to iron out.

@idoric:

French demo

@developomp:

Korean demo