@@ -166,6 +166,8 @@ export class PolyglotWordset extends Wordset {
166166 }
167167}
168168
169+ let tunnelVisionAnimationFrame : number | null = null ;
170+
169171const list : Partial < Record < FunboxName , FunboxFunctions > > = {
170172 "58008" : {
171173 getWord ( ) : string {
@@ -679,6 +681,49 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
679681 return word . toUpperCase ( ) ;
680682 } ,
681683 } ,
684+ tunnel_vision : {
685+ applyGlobalCSS ( ) : void {
686+ const words = qs ( "#words" ) ;
687+ if ( ! words ) return ;
688+
689+ const updateCaretPos = ( ) : void => {
690+ const caretElem = qs ( "#caret" ) ;
691+ if ( caretElem !== null ) {
692+ const caretStyle = caretElem . getStyle ( ) ;
693+ const left = caretStyle . left || "0px" ;
694+ const top = caretStyle . top || "0px" ;
695+ const marginLeft = caretStyle . marginLeft || "0px" ;
696+ const marginTop = caretStyle . marginTop || "0px" ;
697+
698+ words . native . style . setProperty (
699+ "--caret-left" ,
700+ `calc(${ left } + ${ marginLeft } )` ,
701+ ) ;
702+ words . native . style . setProperty (
703+ "--caret-top" ,
704+ `calc(${ top } + ${ marginTop } )` ,
705+ ) ;
706+ }
707+ tunnelVisionAnimationFrame = requestAnimationFrame ( updateCaretPos ) ;
708+ } ;
709+
710+ if ( tunnelVisionAnimationFrame !== null ) {
711+ cancelAnimationFrame ( tunnelVisionAnimationFrame ) ;
712+ }
713+ updateCaretPos ( ) ;
714+ } ,
715+ clearGlobal ( ) : void {
716+ if ( tunnelVisionAnimationFrame !== null ) {
717+ cancelAnimationFrame ( tunnelVisionAnimationFrame ) ;
718+ tunnelVisionAnimationFrame = null ;
719+ }
720+ const words = qs ( "#words" ) ;
721+ if ( words ) {
722+ words . native . style . removeProperty ( "--caret-left" ) ;
723+ words . native . style . removeProperty ( "--caret-top" ) ;
724+ }
725+ } ,
726+ } ,
682727 polyglot : {
683728 async withWords ( _words ) {
684729 const promises = Config . customPolyglot . map ( async ( language ) =>
0 commit comments