@@ -515,21 +515,25 @@ function LauncherUI:onDismiss()
515515 view = nil
516516end
517517
518- -- expected to be run under script.start()
519- local function safe_run (reappear , command , prev_parent_focus )
520- -- allow our dismissed viewscreen to be removed from the stack. this allows
521- -- hotkey guards and tools that detect the top viewscreen to work reliably.
522- script .sleep (2 , ' frames' )
523- local output = dfhack .run_command_silent (command )
518+ function LauncherUI :run_command (reappear , command )
519+ command = command :trim ()
520+ if # command == 0 then return end
521+ dfhack .addCommandToHistory (HISTORY_ID , HISTORY_FILE , command )
522+ record_command (command )
523+ self :dismiss ()
524+ -- remove our (dismissed) viewscreen from the stack while we run the
525+ -- command. this allows hotkey guards and tools that interact with the top
526+ -- viewscreen without checking whether it is active to work reliably.
527+ local output = dfhack .screen .hideGuard (self , dfhack .run_command_silent ,
528+ command )
524529 if # output > 0 then
525530 print (' Output from command run from gui/launcher:' )
526531 print (' > ' .. command )
527532 print ()
528533 print (output )
529534 end
530535 -- if we displayed a new dfhack screen, don't come back up even if reappear
531- -- is true. otherwise, the user can't interact with the new screen. if we're
532- -- not reappearing with the output, print the output to the console.
536+ -- is true so the user can interact with the new screen.
533537 local parent_focus = dfhack .gui .getCurFocus (true )
534538 if not reappear or (parent_focus :startswith (' dfhack/' ) and
535539 parent_focus ~= prev_parent_focus ) then
@@ -540,15 +544,6 @@ local function safe_run(reappear, command, prev_parent_focus)
540544 launch ({initial_help = initial_help })
541545end
542546
543- function LauncherUI :run_command (reappear , text )
544- text = text :trim ()
545- if # text == 0 then return end
546- dfhack .addCommandToHistory (HISTORY_ID , HISTORY_FILE , text )
547- record_command (text )
548- self :dismiss ()
549- script .start (safe_run , reappear , text , self .parent_focus )
550- end
551-
552547function LauncherUI :getWantedFrameSize ()
553548 local width , height = dfhack .screen .getWindowSize ()
554549 return math.max (76 , width - 10 ), math.max (24 , height - 10 )
0 commit comments