Skip to content

better repeat logic for text and ... - #164

Open
bfritscher wants to merge 1 commit into
Code52:masterfrom
bfritscher:better-repeat-logic-for-letters
Open

bfritscher wants to merge 1 commit into
Code52:masterfrom
bfritscher:better-repeat-logic-for-letters

Conversation

@bfritscher

Copy link
Copy Markdown
Contributor

This should solve issue #92

@mawdesign

Copy link
Copy Markdown

Can this work with numerals as well as letters? E.g. “600” instead of “60 x2”

NyaMisty pushed a commit to NyaMisty/carnac that referenced this pull request Mar 11, 2023
doggy8088 added a commit to doggy8088/carnac that referenced this pull request Oct 9, 2026
…Code52#164) (#7)

* Only summarise repeated typed characters after four in a row

A repeated key was always collapsed to "x N" from the second press, so
ordinary words showed up as "hel x 2 o" and "1000" as "10 x 3". Letters,
digits and full stops are now shown as typed for runs of up to three and
summarised as "x N" from four. Other keys and anything pressed with a
modifier still collapse from two, as before.

Based on the idea in Code52#164.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Treat any single visible character as a typed character

Address review feedback: repeated brackets, operators and quotes
("((", "==", "//") also read naturally as typed, so classify by Unicode
category (letters, digits, punctuation, symbols) instead of a letter/digit
allow-list. The classification uses the raw key input, so named keys and
arrows ("Left" -> an arrow glyph) keep collapsing from two, and a single
text element is required so surrogate pairs and decomposed accents count.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Refine typed-character detection after review

- Classify with char.IsLetter/IsNumber/IsPunctuation/IsSymbol instead of a
  long UnicodeCategory switch, and only when a key is actually repeated.
- Treat a space as a typed character ("end.  Next" no longer shows "x 2")
  and look through the padding of the numpad operators (" + ").
- Digits are only summarised from ten in a row, so "1000000" no longer
  reads as "10 x 6"; other typed characters still summarise from four.
- Add tests that go through the real KeyProvider for digits, numpad keys and
  shifted symbols.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Keep runs consistent and make the provider tests focus-independent

- IsRepeatedBy also compares the modifier state, so a run cannot mix typed
  characters with the same text pressed with a modifier and the result no
  longer depends on which came first.
- Skip the text-element scan for the common single-char case.
- The provider tests merge their key presses under a fixed process instead
  of whichever window has the focus while the suite runs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Count AltGr characters as typed and simplify the classification

- Decide "typed" from the raw input only, not from the modifier flags: a
  shortcut has its modifiers in the input ("Ctrl", "L"), while a character
  typed with AltGr, which Windows reports as Ctrl+Alt, is a single character
  and must not collapse from two ("{{" stays "{{").
- Drop the text-element scan (a surrogate pair is enough) and compute the
  threshold once per group instead of on every text rebuild.
- The provider tests assert that key presses arrived at all, so a missing
  foreground window fails with a message instead of an empty aggregate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Spell out the non-ASCII test data as escapes

An editor or a formatter that normalises Unicode would turn a decomposed or
otherwise unusual literal into another one and change what the test checks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Say when an AltGr character reads as typed

With the US key names AltGr+7 is "Ctrl", "Alt", "7" and collapses from two like any
shortcut; it is one character, and reads as typed, once the keys are named after
the keyboard layout. Comment only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: merge check <merge-check@example.invalid>
@doggy8088

Copy link
Copy Markdown

Hi there! 👋

I (@doggy8088 / Will Huang) have stepped in to take over active maintenance of Carnac at doggy8088/carnac (project website: https://carnac.gh.miniasp.com/).

This issue regarding repeated key grouping (x 2, x 3, etc.) and repeated shortcuts has been resolved in my fork!
Thank you @bfritscher for contributing this PR! We merged your smart repeat threshold logic in doggy8088#7 and built further upon it in doggy8088#36 with user-configurable grouping modes and thresholds.

Context & What Changed

Availability

  • Source Code: Available now on the dev branch of doggy8088/carnac.
  • Upcoming Release: This will be included in the next official release, which will be published to GitHub Releases (both installer and portable .zip), WinGet (winget install doggy8088.Carnac), and Chocolatey.

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

Successfully merging this pull request may close these issues.

3 participants