Add Shift+0-9 percentage seeking (#183)#186
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis pull request implements YouTube-style number key seeking. The changes add a pre-switch key handling branch that maps Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant KeyHandler as Key Handler<br/>(handleKey)
participant Player
participant SeekLogic as Seek Logic<br/>(seekAbsolute)
User->>KeyHandler: Press Shift+0-9
KeyHandler->>KeyHandler: Map shifted symbol to digit (0-9)
KeyHandler->>Player: Check duration
Player-->>KeyHandler: Return duration
alt Duration > 0
KeyHandler->>KeyHandler: Calculate target = duration × digit / 10
KeyHandler->>SeekLogic: Call seekAbsolute(target)
SeekLogic-->>KeyHandler: Return seek result
KeyHandler-->>User: Seek executed
else Duration ≤ 0
KeyHandler-->>KeyHandler: No action, fall through
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Oh no, I regret it already. There's been a lot of back-and-forth on this, but I really need to nail it. The reason is that my Nordic layout is different than yours, meaning the current mapping is off. I found a better solution which is something in between. Nj. Meaning 1j, 4j, 10j, means 10% jump. 40% jump. This works very well. Vim style. Give the latest commit a spin. |
|
I really liked your approach to this and loving it. It's working as expected. I had thought of doing n; meaning 1; 2; but out of simplicity I came up with my naive initial approach. But you enlightened me about Nordic layouts and consistency. I really learned a lot. Thanks. |
Closes #183
Implements YouTube-style percentage seeking via Shift+0-9.
(US, Nordic, etc.) since terminals translate modifier keys before
Bubbletea sees them
jump mode, URL input) intercept keys first
Development notes
Approach 1:
msg.Mod+msg.Code(didn't work)Tried checking
msg.Mod&tea.ModShift != 0andmsg.Code >= '0' && msg.Code <= '9'. This assumed the terminal would set the Shift modifier flag and report the unshifted digit in Code. On Windows,Modis always 0 - terminals translate Shift+5 into%before Bubbletea sees it.Approach 2:
msg.BaseCode+msg.ShiftedCode(didn't work)Bubbletea v2 provides
BaseCode(physical US-PC101 key) andShiftedCodefields for layout-independent detection. Tested by printing all key fields to the status bar. BothBaseCodeandShiftedCodeare always\x00on this terminal - not populated.Debug output revealed:
Bare 5: Code='5' Mod=0 Text="5" Base='\x00' Shifted='\x00'
Shift+5: Code='%' Mod=0 Text="%" Base='\x00' Shifted='\x00'
The terminal handles Shift entirely - it sends the shifted character with no modifier flags.
Approach 3: Shifted symbol matching (final solution)
Since the terminal sends the shifted symbol directly, match
msg.Textagainst a map of shifted-digit symbols (),!,@,#,$,%,^,&,*,() and map back to digits 0–9. Uses US keyboard layout as reference. Works on any keyboard where Shift+digit produces these symbols.Summary by CodeRabbit