11import type { IArcTerminal } from "$interfaces/IArcTerminal" ;
2- import { ArcOSVersion , Env } from "$ts/env" ;
3- import { ArcBuild } from "$ts/metadata/build" ;
4- import { ArcMode } from "$ts/metadata/mode" ;
2+ import { ArcOSVersion } from "$ts/env" ;
53import { BRRED , RESET } from "$ts/terminal/colors" ;
64import { unescapeEscapeChars } from "$ts/util" ;
75import { arrayBufferToText } from "$ts/util/convert" ;
8- import { UUID } from "$ts/util/uuid" ;
96import type { BasicLang } from "$types/system/basic" ;
10- import { evaluate } from "mathjs" ;
11- import { GostartCommand } from "../commands/gostart" ;
12- import { GosubCommand } from "../commands/gosub" ;
13- import { IfCommand } from "../commands/if" ;
14- import { KillCommand } from "../commands/kill" ;
15- import { PrintCommand } from "../commands/print" ;
16- import { StopCommand } from "../commands/stop" ;
17- import { SubCommand } from "../commands/sub" ;
18- import { VarCommand } from "../commands/var" ;
19- import { WhileCommand } from "../commands/while" ;
20- import { SoundbusCommand } from "../commands/soundbus" ;
7+ import { BasicCommandSet } from "./commandset" ;
8+ import { BasicTerminalFunctions } from "./functions/terminal" ;
9+ import { BasicBuiltinVariables } from "./variables" ;
2110
2211export function ArcTermBasicConfig ( term : IArcTerminal ) : BasicLang . Config {
2312 return {
2413 version : ArcOSVersion ,
2514 stdin : async ( ) => {
15+ // TODO: FIND SOMETHING BETTER
2616 return new Promise ( ( resolve ) => {
2717 let val = "" ;
2818 const disposer = term . term . onKey ( ( e ) => {
@@ -45,46 +35,10 @@ export function ArcTermBasicConfig(term: IArcTerminal): BasicLang.Config {
4535 stderr : ( msg : string ) => {
4636 term . rl ?. write ( `${ BRRED } ${ msg } ${ RESET } ` ) ;
4737 } ,
48- functions : {
49- env : ( val ) => {
50- return Env . get ( val ) ?? "" ;
51- } ,
52- input : async ( val , interpreter ) => {
53- interpreter . sendToStdout ( `\n${ val } ` ) ;
54- return await interpreter . getFromStdin ( ) ;
55- } ,
56- math : ( val ) => {
57- return `${ evaluate ( val ) } ` ;
58- } ,
59- fsread : async ( path , interpreter ) => {
60- const content = await term . readFile ( path ) ;
61- if ( ! content ) {
62- interpreter . error ( "FILE NOT FOUND" , true ) ;
63- return "" ;
64- }
65-
66- return arrayBufferToText ( content ) ?? "" ;
67- } ,
68- uuid : ( ) => UUID ( ) ,
69- len : ( s ) => s ?. length ?? 0 ,
70- } ,
38+ functions : BasicTerminalFunctions ( term ) ,
7139 slowdown : 10 ,
72- commands : [
73- PrintCommand ,
74- IfCommand ,
75- VarCommand ,
76- GosubCommand ,
77- SubCommand ,
78- StopCommand ,
79- KillCommand ,
80- GostartCommand ,
81- WhileCommand ,
82- SoundbusCommand ,
83- ] ,
84- builtinVariables : {
85- mode : ( ) => ArcMode ( ) ,
86- build : ( ) => ArcBuild ( ) ,
87- } ,
40+ commands : BasicCommandSet ,
41+ builtinVariables : BasicBuiltinVariables ,
8842 readScriptFile : async ( path ) => {
8943 const content = await term . readFile ( path ) ;
9044 return content ? arrayBufferToText ( content ) : undefined ;
0 commit comments