@@ -628,10 +628,17 @@ function contextActions(state: AppState): ShortcutAction[] {
628628 ]
629629}
630630
631- function createShortcutBarText ( state : AppState , theme : Theme ) : StyledText {
631+ function createShortcutBarText ( state : AppState , theme : Theme , width = 0 ) : StyledText {
632632 const chunks : TextChunk [ ] = [ ]
633+ const actions = contextActions ( state )
634+ const brand = './npmx'
635+ const shortcutsLength = actions . reduce (
636+ ( length , action , index ) =>
637+ length + ( index > 0 ? 3 : 0 ) + action . key . length + 1 + action . label . length ,
638+ 0 ,
639+ )
633640
634- contextActions ( state ) . forEach ( ( action , index ) => {
641+ actions . forEach ( ( action , index ) => {
635642 if ( index > 0 ) {
636643 chunks . push ( fg ( theme . fg . muted ) ( ' ' ) )
637644 }
@@ -640,8 +647,9 @@ function createShortcutBarText(state: AppState, theme: Theme): StyledText {
640647 chunks . push ( fg ( theme . fg . secondary ) ( ` ${ action . label } ` ) )
641648 } )
642649
643- chunks . push ( fg ( theme . fg . muted ) ( ' ' ) )
644- chunks . push ( fg ( theme . fg . primary ) ( bold ( './npmx' ) ) )
650+ const spacerWidth = width - shortcutsLength - brand . length
651+ chunks . push ( fg ( theme . fg . muted ) ( spacerWidth > 0 ? ' ' . repeat ( spacerWidth ) : ' ' ) )
652+ chunks . push ( fg ( theme . fg . primary ) ( bold ( brand ) ) )
645653
646654 return new StyledText ( chunks )
647655}
@@ -913,9 +921,9 @@ export async function runTui(options: RunTuiOptions = {}): Promise<void> {
913921 const statusBar = instantiate (
914922 renderer ,
915923 Text ( {
916- content : createShortcutBarText ( state , theme ) ,
924+ content : createShortcutBarText ( state , theme , renderer . terminalWidth ) ,
917925 fg : theme . fg . muted ,
918- bg : theme . bg . elevated ,
926+ bg : theme . bg . base ,
919927 height : 1 ,
920928 truncate : true ,
921929 } ) ,
@@ -935,15 +943,19 @@ export async function runTui(options: RunTuiOptions = {}): Promise<void> {
935943 ) ,
936944 ) as BoxRenderable
937945
946+ function getStatusBarWidth ( ) : number {
947+ return Math . max ( 1 , Number ( statusBar . width ) || renderer . terminalWidth )
948+ }
949+
938950 function setStatus ( message : string , kind : StatusKind = 'info' ) : void {
939951 state . statusMessage = message
940952 state . statusKind = kind
941- statusBar . content = createShortcutBarText ( state , theme )
953+ statusBar . content = createShortcutBarText ( state , theme , getStatusBarWidth ( ) )
942954 statusBar . fg = theme . status [ kind ]
943955 }
944956
945957 function updateStatusBar ( ) : void {
946- statusBar . content = createShortcutBarText ( state , theme )
958+ statusBar . content = createShortcutBarText ( state , theme , getStatusBarWidth ( ) )
947959 statusBar . fg = theme . status [ state . statusKind ]
948960 }
949961
@@ -1483,7 +1495,7 @@ export async function runTui(options: RunTuiOptions = {}): Promise<void> {
14831495 inspector . bg = theme . bg . base
14841496 resultsFooter . bg = theme . bg . base
14851497 resultsFooter . content = createResultsFooterText ( state , theme )
1486- statusBar . bg = theme . bg . elevated
1498+ statusBar . bg = theme . bg . base
14871499 statusBar . fg = theme . status [ state . statusKind ]
14881500 updateInspector ( )
14891501 }
0 commit comments