@@ -58,16 +58,18 @@ function writefile(Uri: Uri, Content: string) {
5858 * class for configurations
5959 */
6060export class Config {
61- private readonly _toolspackaged : boolean = true ; //如果打包时没有包含汇编工具(tools)改为false 废弃
62- private readonly _exturi : Uri ;
63- private _BOXrun : string | undefined ;
64- private emulator : string | undefined ;
6561 public toolsUri : Uri ;
6662 public customToolInfo : ToolInfo | undefined = undefined ;
67- public readonly resolution : string | undefined ;
6863 public readonly savefirst : boolean | undefined ;
6964 public readonly MASMorTASM : string | undefined ;
70- public readonly _console : string | undefined ;
65+ //
66+ private readonly _toolspackaged : boolean = true ; //如果打包时没有包含汇编工具(tools)改为false 废弃
67+ private readonly _exturi : Uri ;
68+ private readonly _BOXrun : string | undefined ;
69+ private readonly emulator : string | undefined ;
70+ private readonly resolution : string | undefined ;
71+ private readonly _console : string | undefined ;
72+ private readonly _command : string | undefined ;
7173 constructor ( content : ExtensionContext ) {
7274 let configuration = workspace . getConfiguration ( 'masmtasm' ) ;
7375 this . MASMorTASM = configuration . get ( 'ASM.MASMorTASM' ) ;
@@ -76,6 +78,7 @@ export class Config {
7678 this . resolution = configuration . get ( 'dosbox.CustomResolution' ) ;
7779 this . _BOXrun = configuration . get ( 'dosbox.run' ) ;
7880 this . _console = configuration . get ( "dosbox.console" ) ;
81+ this . _command = configuration . get ( "dosbox.command" ) ;
7982 this . _exturi = content . extensionUri ;
8083 //the tools' Uri
8184 let toolpath : string | undefined = configuration . get ( 'ASM.toolspath' ) ;
@@ -92,12 +95,20 @@ export class Config {
9295 //写dosbox配置信息
9396 this . writeBoxconfig ( ) ;
9497 }
98+ /**
99+ * @returns a string can be send to terminal, to open dosbox according to different system and configration
100+ */
95101 public get OpenDosbox ( ) {
96- //command for open
97- let boxUri = Uri . joinPath ( this . _exturi , './tools/dosbox/dosbox.exe' ) ;
98- if ( this . customToolInfo ?. hasDosbox ) { boxUri = Uri . joinPath ( this . customToolInfo . uri , './dosbox/dosbox.exe' ) ; }
102+ //command for open dosbox
99103 let command : string = "dosbox" ;
104+ //First, use the user-defined command;
105+ if ( this . _command ) {
106+ return this . _command + " " ;
107+ }
108+ //for windows,using different command according to dosbox's path and the choice of the console window
100109 if ( process . platform === "win32" ) {
110+ let boxUri = Uri . joinPath ( this . _exturi , './tools/dosbox/dosbox.exe' ) ;
111+ if ( this . customToolInfo ?. hasDosbox ) { boxUri = Uri . joinPath ( this . customToolInfo . uri , './dosbox/dosbox.exe' ) ; }
101112 let path = '"' + boxUri . fsPath + '"' ;
102113 switch ( this . _console ) {
103114 case "min" : command = 'start/min/wait "" ' + path ; break ;
@@ -106,10 +117,15 @@ export class Config {
106117 default : command = path ;
107118 }
108119 }
120+ //for darwin
121+ else if ( process . platform === "darwin" ) {
122+ command = "open -a DOSBox --args " ;
123+ }
124+ //for other system, temporarily use command `dosbox`
109125 return command ;
110126 }
111127 /**
112- * file path of scripts packaged inside
128+ * @return Uri of scripts packaged inside
113129 */
114130 public get extScriptsUri ( ) : Uri {
115131 let path = Uri . joinPath ( this . _exturi , './scripts' ) ;
0 commit comments