@@ -35,7 +35,7 @@ export function createAddress({
3535} ) {
3636 // ---------- the g chord: the page's destinations ----------
3737 // g names one-off travel. An uppercase mnemonic completes a panel destination (`g T`
38- // Threads, `g A` Asks, `g L` All leaves), while a numbered list takes a following decimal place
38+ // Threads, `g A` Asks, `g L` All leaves), while a numbered list takes a following digit
3939 // (`g h 3` is the third hyperlink and `g f 2` the second fold). Repeated movement
4040 // through threads and asks belongs to their single-key category walks, t/T and a/A, so
4141 // those categories do not also carry numbered addresses.
@@ -60,8 +60,9 @@ export function createAddress({
6060 // PR is `g h 2` is wrong a moment later; and it would put the key line's own truth on the
6161 // scroll, since a row that goes dead as the page moves is a row the line has to be
6262 // repainted to stop promising — a paint measured at 1.3ms on the corpus, on every scroll
63- // frame of every page, for one row. Decimal prefixes keep that stable document-order list
64- // reachable at any length.
63+ // frame of every page, for one row. The numbered route therefore keeps document order
64+ // stable and offers its first nine members; later members remain in the document's own
65+ // navigation rather than making a one-digit address ambiguous.
6566 //
6667 // Above the table rather than beside the other readings below it, because an entry
6768 // holds the function itself and the array literal reads it as the module evaluates.
@@ -161,26 +162,12 @@ export function createAddress({
161162 } ,
162163 } ,
163164 ] ;
164- // A list's addressable members, and the range its label names. The whole list is the
165- // contract: numeric prefixes extend past nine, so adding a tenth member never removes
166- // the keyboard route the list promised for its tail.
167- const addressed = ( entry ) => entry . list ( ) ;
165+ // A list's addressable members, and the range its label names. Nine is the whole numbered
166+ // vocabulary: every member has one digit, every digit completes immediately, and every
167+ // consumer below reads this same prefix rather than applying its own cap.
168+ const MAX_NUMBERED_ADDRESSES = 9 ;
169+ const addressed = ( entry ) => entry . list ( ) . slice ( 0 , MAX_NUMBERED_ADDRESSES ) ;
168170 const range = ( n ) => ( n > 1 ? `1–${ n } ` : "1" ) ;
169- const addressNumbers = ( entry ) => addressed ( entry ) . map ( ( _ , i ) => String ( i + 1 ) ) ;
170- const needsCommit = ( entry , n ) => Number ( n ) * 10 <= addressed ( entry ) . length ;
171- const nextAddressKeys = ( entry ) => {
172- const numbers = addressNumbers ( entry ) ;
173- const next = [
174- ...new Set (
175- numbers
176- . filter ( ( number ) => number . startsWith ( addressDigits ) )
177- . map ( ( number ) => number [ addressDigits . length ] )
178- . filter ( Boolean ) ,
179- ) ,
180- ] ;
181- if ( addressDigits && numbers . includes ( addressDigits ) ) next . push ( "Enter" ) ;
182- return next ;
183- } ;
184171 // How far the chord has come: `g`, and the list's letter once one has named a list. Every
185172 // surface that shows an address asks it — the chip that heads the key line, the ranges
186173 // beside it, the reference's full chords and the dimmed half of a chip on the page — so
@@ -193,8 +180,7 @@ export function createAddress({
193180 // what remains inside the mode. A chip is the one surface with nothing around it to carry
194181 // the leader, and it is drawn only while the window is up, so its two questions — how far
195182 // in, and how much the surroundings already say — have one answer.
196- const chordKeys = ( ) =>
197- [ labelOf ( GOTO ) , aimedList ?. key , addressDigits || null ] . filter ( Boolean ) ;
183+ const chordKeys = ( ) => [ labelOf ( GOTO ) , aimedList ?. key ] . filter ( Boolean ) ;
198184 // An address as the page wears it: the whole of it, the keys already pressed standing back
199185 // and the ones still to come lit. The whole of it, because a chip is the address — the same
200186 // one every address surface spells while the chord is armed.
@@ -228,17 +214,11 @@ export function createAddress({
228214 const number = String ( n ) ;
229215 let spent = labelOf ( GOTO ) ;
230216 let live = `${ entry . key } ${ number } ` ;
231- let join = " " ;
217+ const join = " " ;
232218 if ( aimedList ) {
233219 spent += ` ${ entry . key } ` ;
234220 live = number ;
235221 }
236- if ( addressDigits ) {
237- spent += ` ${ addressDigits } ` ;
238- live = number . slice ( addressDigits . length ) ;
239- join = "" ;
240- }
241- if ( needsCommit ( entry , n ) ) live += " ⏎" ;
242222 const chip = el ( "span" , "lf-address" ) ;
243223 chip . append ( el ( "span" , "lf-spent" , spent ) , join , el ( "span" , "lf-lit" , live ) ) ;
244224 return chip ;
@@ -256,7 +236,6 @@ export function createAddress({
256236 // other inside the functions that hold both.
257237 let chordArmed = false ;
258238 let aimedList = null ;
259- let addressDigits = "" ;
260239 // Arming, aiming and disarming are one call, because they are one window: naming a list
261240 // re-opens it rather than starting a second.
262241 //
@@ -273,7 +252,6 @@ export function createAddress({
273252 if ( on && ! chordArmed && claimsEsc ( focused ( ) ) ) return ;
274253 chordArmed = on ;
275254 aimedList = on ? list : null ;
276- addressDigits = "" ;
277255 // The chips are the eye's copy; the window itself is spoken, or the mode change is
278256 // silent to exactly the reader who can't see them. Off the rows either way, since the
279257 // rows are what the window answers now — the letters at the first stage, the named
@@ -282,11 +260,6 @@ export function createAddress({
282260 if ( on ) announce ( `Go to — ${ saying ( GO . rows ) } ` ) ;
283261 paintHere ( ) ;
284262 }
285- function setAddressDigits ( digits ) {
286- addressDigits = digits ;
287- announce ( `Go to — ${ saying ( GO . rows ) } ` ) ;
288- paintHere ( ) ;
289- }
290263
291264 // The chips: one per addressable member, drawn in the chrome's layer (addressLayer) and
292265 // placed from the member's own visible box, so a chip cannot claim room the page has
@@ -322,7 +295,6 @@ export function createAddress({
322295 // while panel mnemonics complete their trip without painting numeric chips.
323296 for ( const entry of aimedList ? [ aimedList ] : ADDRESSES ) {
324297 for ( const [ i , member ] of addressed ( entry ) . entries ( ) ) {
325- if ( addressDigits && ! String ( i + 1 ) . startsWith ( addressDigits ) ) continue ;
326298 const r = startsAt ( member , clips ) ;
327299 if ( ! r || r . bottom <= covered ) continue ; // nothing to see, nothing to address
328300 const chip = addressChip ( entry , i + 1 ) ;
@@ -390,7 +362,7 @@ export function createAddress({
390362
391363 // The chord: one scope, a row per panel and addressable list, a row for the page's two
392364 // edges, and the window's own way out. A panel's mnemonic completes its travel. A list
393- // row holds the whole motion — its letter names the list, and the decimal sequence it
365+ // row holds the whole motion — its letter names the list, and the one digit it
394366 // then binds is the address into it. That is `v`'s shape,
395367 // a chooser whose second key belongs to the scope the first one stood up, and the reason
396368 // it is one row rather than two is that a digits row of its own could not name which list
@@ -476,44 +448,20 @@ export function createAddress({
476448 runFromReference : false ,
477449 keys : ( ) => {
478450 if ( aimedList !== entry ) return [ entry . key ] ;
479- return nextAddressKeys ( entry ) ;
451+ return addressed ( entry ) . map ( ( _ , i ) => String ( i + 1 ) ) ;
480452 } ,
481- // The range the list actually holds, so the label cannot offer an address no member
482- // wears. Once a numeric prefix stands, the ordinary spelling of the remaining
483- // bindings is more useful than restating the full range.
453+ // The range the capped list actually holds, so the label cannot offer an address
454+ // no member wears.
484455 label : ( ) => {
485- if ( addressDigits ) {
486- const next = nextAddressKeys ( entry ) ;
487- const digits = next . filter ( ( key ) => key !== "Enter" ) ;
488- const compact =
489- digits . length > 1 ? `${ digits [ 0 ] } –${ digits . at ( - 1 ) } ` : digits [ 0 ] ;
490- return [ compact , next . includes ( "Enter" ) ? spell ( "Enter" ) : null ]
491- . filter ( Boolean )
492- . join ( " / " ) ;
493- }
494456 const members = range ( addressed ( entry ) . length ) ;
495457 return aimedList === entry ? members : `${ entry . key } ${ members } ` ;
496458 } ,
497- does : ( ) =>
498- addressDigits && addressNumbers ( entry ) . includes ( addressDigits )
499- ? `Continue the address, or go to ${ entry . word } ${ addressDigits } with Enter`
500- : entry . does ,
501- line : ( ) =>
502- addressDigits && addressNumbers ( entry ) . includes ( addressDigits )
503- ? `continue / choose ${ addressDigits } `
504- : addressDigits
505- ? "continue address"
506- : entry . word ,
507- when : ( ) => entry . list ( ) . length > 0 && ( ! aimedList || aimedList === entry ) ,
459+ does : entry . does ,
460+ line : entry . word ,
461+ when : ( ) => addressed ( entry ) . length > 0 && ( ! aimedList || aimedList === entry ) ,
508462 run : ( binding ) => {
509463 if ( aimedList !== entry ) return setChord ( true , entry ) ;
510- const number = binding === "Enter" ? addressDigits : addressDigits + binding ;
511- const numbers = addressNumbers ( entry ) ;
512- const longer = numbers . some (
513- ( candidate ) => candidate !== number && candidate . startsWith ( number ) ,
514- ) ;
515- if ( binding !== "Enter" && longer ) return setAddressDigits ( number ) ;
516- const member = addressed ( entry ) [ + number - 1 ] ;
464+ const member = addressed ( entry ) [ Number ( binding ) - 1 ] ;
517465 setChord ( false ) ; // before the travel, so the arrival's own scrolling paints nothing
518466 entry . go ( member ) ;
519467 } ,
@@ -552,21 +500,12 @@ export function createAddress({
552500 // cancelling put them back on the page, pressing `g` again to reach a window that
553501 // had been standing the whole time.
554502 keys : [ "Escape" ] ,
555- does : ( ) =>
556- addressDigits
557- ? "Remove the last address digit"
558- : aimedList
559- ? "Back to the lists"
560- : "Cancel the chord" ,
561- line : ( ) =>
562- addressDigits ? "back one digit" : aimedList ? "back to the lists" : "cancel" ,
503+ does : ( ) => ( aimedList ? "Back to the lists" : "Cancel the chord" ) ,
504+ line : ( ) => ( aimedList ? "back to the lists" : "cancel" ) ,
563505 // Re-arming rather than a field of its own: `setChord` is where arming, aiming and
564506 // disarming already live, and re-opening the window with no list named is exactly
565507 // what the second stage backs out to.
566- run : ( ) => {
567- if ( addressDigits ) return setAddressDigits ( addressDigits . slice ( 0 , - 1 ) ) ;
568- setChord ( Boolean ( aimedList ) ) ;
569- } ,
508+ run : ( ) => setChord ( Boolean ( aimedList ) ) ,
570509 } ,
571510 ] ,
572511 } ;
0 commit comments