Add --redirect-console option
This commit is contained in:
@@ -651,4 +651,20 @@ class Console
|
||||
petitcom.graphic.GRPFHeight = GRPF.surface.h;
|
||||
GRPF.createTexture(petitcom.renderer, petitcom.textureScaleMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NativeConsole : Console
|
||||
{
|
||||
File file;
|
||||
this(File file, PetitComputer p)
|
||||
{
|
||||
super(p);
|
||||
this.file = file;
|
||||
}
|
||||
override void printString(wstring text)
|
||||
{
|
||||
super.printString(text);
|
||||
file.write(text);
|
||||
file.flush;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ int main(string[] argv)
|
||||
bool nodirectmode;
|
||||
string inputfile;
|
||||
bool antialiasing;
|
||||
auto helpInformation = getopt(argv, "no-direct-mode", &nodirectmode, "file", &inputfile, "anti-aliasing", "Enable antialiasing.", &antialiasing);
|
||||
bool redirectConsole;
|
||||
auto helpInformation = getopt(argv, "redirect-console", &redirectConsole, "no-direct-mode", &nodirectmode, "file", &inputfile, "anti-aliasing", "Enable antialiasing.", &antialiasing);
|
||||
if (helpInformation.helpWanted)
|
||||
{
|
||||
defaultGetoptPrinter("Some information about the program.",
|
||||
@@ -22,7 +23,7 @@ int main(string[] argv)
|
||||
//try
|
||||
{
|
||||
auto pc = new PetitComputer();
|
||||
pc.run(nodirectmode, inputfile, antialiasing);
|
||||
pc.run(nodirectmode, inputfile, antialiasing, redirectConsole);
|
||||
}
|
||||
/*(Throwable t)
|
||||
{
|
||||
|
||||
@@ -280,6 +280,7 @@ class PetitComputer
|
||||
}
|
||||
int[2] bgpage;
|
||||
Projects project;
|
||||
bool redirectConsole;
|
||||
void init()
|
||||
{
|
||||
random = new Random();
|
||||
@@ -313,7 +314,7 @@ class PetitComputer
|
||||
screenWidthDisplay1 = 320;
|
||||
screenHeightDisplay1 = 240;
|
||||
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]);
|
||||
console = new Console(this);
|
||||
console = redirectConsole ? new NativeConsole(std.stdio.stdout, this) : new Console(this);
|
||||
if(!exists(fontTableFile))
|
||||
{
|
||||
writeln("create font table");
|
||||
@@ -844,7 +845,7 @@ class PetitComputer
|
||||
renderCondition.notify();
|
||||
}
|
||||
|
||||
while(true)
|
||||
while(!quit)
|
||||
{
|
||||
auto profile = SDL_GetTicks();
|
||||
if(console.showCursor)
|
||||
@@ -1127,7 +1128,7 @@ class PetitComputer
|
||||
bool isRunningDirectMode = false;
|
||||
GLenum textureScaleMode;
|
||||
int maincnt;
|
||||
void run(bool nodirectmode = false, string inputfile = "", bool antialiasing = false)
|
||||
void run(bool nodirectmode = false, string inputfile = "", bool antialiasing = false, bool redirectConsole = false)
|
||||
{
|
||||
if (antialiasing)
|
||||
{
|
||||
@@ -1137,6 +1138,7 @@ class PetitComputer
|
||||
{
|
||||
textureScaleMode = GL_NEAREST;
|
||||
}
|
||||
this.redirectConsole = redirectConsole;
|
||||
buttonLock = new Object();
|
||||
program = new Program();
|
||||
keybuffer = new Key[128];
|
||||
@@ -1359,6 +1361,8 @@ class PetitComputer
|
||||
}
|
||||
if(!running || stopflg)
|
||||
{
|
||||
if (nodirectmode)
|
||||
quit = true;
|
||||
if(stopflg)
|
||||
{
|
||||
loc = vm.currentLocation;
|
||||
|
||||
@@ -39,7 +39,7 @@ after_build:
|
||||
|
||||
test_script:
|
||||
- cd c:\projects\otyaSMILEBASIC
|
||||
- c:\projects\dub\dub.exe test -- -h
|
||||
- c:\projects\dub\dub.exe test -- --no-direct-mode --file c:\projects\otyaSMILEBASIC\SMILEBASIC\TEST.TXT --redirect-console
|
||||
|
||||
artifacts:
|
||||
- path: otyasmilebasic.zip
|
||||
|
||||
Reference in New Issue
Block a user