File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 ViewType ,
88} from '@augmentos/sdk' ;
99import { TranscriptProcessor } from './utils/src/text-wrapping/TranscriptProcessor' ;
10+ import { convertLineWidth } from './utils/src/text-wrapping/convertLineWidth' ;
1011
1112// Configuration constants
1213const PORT = process . env . PORT ? parseInt ( process . env . PORT ) : 80 ;
@@ -380,10 +381,12 @@ class TeleprompterApp extends TpaServer {
380381 ) : Promise < void > {
381382 try {
382383 // Extract settings from the session
383- const lineWidth = session . settings . get < number > ( 'line_width' , 38 ) ;
384+ const lineWidthString = session . settings . get < string > ( 'line_width' , "Medium" ) ;
384385 const scrollSpeed = session . settings . get < number > ( 'scroll_speed' , 120 ) ;
385386 const numberOfLines = session . settings . get < number > ( 'number_of_lines' , 4 ) ;
386387 const customText = session . settings . get < string > ( 'custom_text' , '' ) ;
388+
389+ const lineWidth = convertLineWidth ( lineWidthString , false ) ;
387390
388391 console . log ( `Applied settings for user ${ userId } : lineWidth=${ lineWidth } , scrollSpeed=${ scrollSpeed } , numberOfLines=${ numberOfLines } ` ) ;
389392
Original file line number Diff line number Diff line change @@ -164,6 +164,9 @@ export class TranscriptProcessor {
164164
165165 // Wrap text into lines based on max line length
166166 public wrapText ( text : string , maxLineLength : number ) : string [ ] {
167+ if ( typeof maxLineLength !== "number" || isNaN ( maxLineLength ) ) {
168+ throw new Error ( `wrapText: maxLineLength must be a number, got ${ typeof maxLineLength } : ${ maxLineLength } ` ) ;
169+ }
167170 const result : string [ ] = [ ] ;
168171 // Split the text by newlines first
169172 const lines = text . split ( / \r ? \n / ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Converts a line width setting to a numeric character count
3+ * @param width The width setting as a string or number
4+ * @param isHanzi Whether the text uses Hanzi characters (Chinese, Japanese)
5+ * @returns The number of characters per line
6+ */
7+ export function convertLineWidth ( width : string | number , isHanzi : boolean ) : number {
8+ if ( typeof width === 'number' ) return width ;
9+
10+ if ( ! isHanzi ) {
11+ switch ( width . toLowerCase ( ) ) {
12+ case 'very narrow' : return 21 ;
13+ case 'narrow' : return 30 ;
14+ case 'medium' : return 38 ;
15+ case 'wide' : return 44 ;
16+ case 'very wide' : return 52 ;
17+ default : return 45 ;
18+ }
19+ } else {
20+ switch ( width . toLowerCase ( ) ) {
21+ case 'very narrow' : return 7 ;
22+ case 'narrow' : return 10 ;
23+ case 'medium' : return 14 ;
24+ case 'wide' : return 18 ;
25+ case 'very wide' : return 21 ;
26+ default : return 14 ;
27+ }
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments