@@ -34,6 +34,10 @@ function BasaltProgram.new(program, env, addEnvironment)
3434 return self
3535end
3636
37+ function BasaltProgram :setArgs (...)
38+ self .args = {... }
39+ end
40+
3741local function createShellEnv (dir )
3842 local env = { shell = shell , multishell = multishell }
3943 env .require , env .package = newPackage (env , dir )
@@ -53,6 +57,7 @@ function BasaltProgram:run(path, width, height)
5357 local env = setmetatable (createShellEnv (fs .getDir (path )), { __index = _ENV })
5458 env .term = self .window
5559 env .term .current = term .current
60+ env .term .redirect = term .redirect
5661 env .term .native = function ()
5762 return self .window
5863 end
102107--- @private
103108function BasaltProgram :resize (width , height )
104109 self .window .reposition (1 , 1 , width , height )
110+ self :resume (" term_resize" , width , height )
105111end
106112
107113--- @private
165171function Program :init (props , basalt )
166172 VisualElement .init (self , props , basalt )
167173 self .set (" type" , " Program" )
174+ self :observe (" width" , function (self , width )
175+ local program = self .get (" program" )
176+ if program then
177+ program :resize (width , self .get (" height" ))
178+ end
179+ end )
180+ self :observe (" height" , function (self , height )
181+ local program = self .get (" program" )
182+ if program then
183+ program :resize (self .get (" width" ), height )
184+ end
185+ end )
168186 return self
169187end
170188
@@ -174,12 +192,13 @@ end
174192--- @param env ? table The environment to run the program in
175193--- @param addEnvironment ? boolean Whether to add the environment to the program ' s environment (false = overwrite instead of adding)
176194--- @return Program self The Program instance
177- function Program :execute (path , env , addEnvironment )
195+ function Program :execute (path , env , addEnvironment , ... )
178196 self .set (" path" , path )
179197 self .set (" running" , true )
180198 local program = BasaltProgram .new (self , env , addEnvironment )
181199 self .set (" program" , program )
182- program :run (path , self .get (" width" ), self .get (" height" ))
200+ program :setArgs (... )
201+ program :run (path , self .get (" width" ), self .get (" height" ), ... )
183202 self :updateRender ()
184203 return self
185204end
0 commit comments