Skip to content

Commit d5fe343

Browse files
committed
SDL: added -n command line option to run then not pause for back key
1 parent bd10e0c commit d5fe343

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2019-07-27 (0.12.15)
2+
SDL: added -n command line option to run then not pause for back key
3+
14
2019-07-10 (0.12.15)
25
SDL: update editor find and replace
36

src/platform/android/jni/runtime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ void Runtime::runShell() {
485485
if (getBoolean("getUntrusted")) {
486486
opt_file_permitted = 0;
487487
}
488-
runOnce(startupBas.c_str());
488+
runOnce(startupBas.c_str(), true);
489489
} else {
490490
runMain(MAIN_BAS);
491491
}

src/platform/sdl/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static struct option OPTIONS[] = {
4848
{"font", optional_argument, NULL, 'f'},
4949
{"run", optional_argument, NULL, 'r'},
5050
{"run-live", optional_argument, NULL, 'x'},
51+
{"run-n-wait",optional_argument, NULL, 'n'},
5152
{"module", optional_argument, NULL, 'm'},
5253
{"edit", optional_argument, NULL, 'e'},
5354
{"debug", optional_argument, NULL, 'd'},
@@ -291,13 +292,14 @@ int main(int argc, char* argv[]) {
291292
char *fontFamily = NULL;
292293
char *runFile = NULL;
293294
bool debug = false;
295+
bool runWait = true;
294296
int fontScale;
295297
int ide_option = -1;
296298
SDL_Rect rect;
297299

298300
while (1) {
299301
int option_index = 0;
300-
int c = getopt_long(argc, argv, "hvkc:f:r:x:m:e:d:p:", OPTIONS, &option_index);
302+
int c = getopt_long(argc, argv, "hvkc:f:r:x:n:m:e:d:p:", OPTIONS, &option_index);
301303
if (c == -1) {
302304
// no more options
303305
if (!option_index) {
@@ -341,6 +343,11 @@ int main(int argc, char* argv[]) {
341343
runFile = strdup(optarg);
342344
ide_option = IDE_NONE;
343345
break;
346+
case 'n':
347+
runWait = false;
348+
runFile = strdup(optarg);
349+
ide_option = IDE_NONE;
350+
break;
344351
case 'x':
345352
runFile = strdup(optarg);
346353
g_debugPort = 0;
@@ -404,7 +411,7 @@ int main(int argc, char* argv[]) {
404411
loadIcon(window);
405412
Runtime *runtime = new Runtime(window);
406413
runtime->construct(font.c_str(), fontBold.c_str());
407-
fontScale = runtime->runShell(runFile, fontScale, debug ? g_debugPort : 0);
414+
fontScale = runtime->runShell(runFile, runWait, fontScale, debug ? g_debugPort : 0);
408415
rect = runtime->getWindowRect();
409416
delete runtime;
410417
} else {

src/platform/sdl/runtime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ MAEvent *Runtime::popEvent() {
312312
return _eventQueue->pop();
313313
}
314314

315-
int Runtime::runShell(const char *startupBas, int fontScale, int debugPort) {
315+
int Runtime::runShell(const char *startupBas, bool runWait, int fontScale, int debugPort) {
316316
logEntered();
317317

318318
os_graphics = 1;
@@ -359,14 +359,14 @@ int Runtime::runShell(const char *startupBas, int fontScale, int debugPort) {
359359
} else if (opt_ide == IDE_EXTERNAL) {
360360
runLive(bas.c_str());
361361
} else {
362-
runOnce(bas.c_str());
362+
runOnce(bas.c_str(), runWait);
363363
}
364364
while (_state == kRestartState) {
365365
_state = kActiveState;
366366
if (!_loadPath.empty()) {
367367
bas = _loadPath;
368368
}
369-
runOnce(bas.c_str());
369+
runOnce(bas.c_str(), runWait);
370370
}
371371
} else {
372372
runMain(MAIN_BAS);

src/platform/sdl/runtime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct Runtime : public System {
4747
void setWindowTitle(const char *title);
4848
void share(const char *path) {}
4949
void showCursor(CursorType cursorType);
50-
int runShell(const char *startupBas, int fontScale, int debugPort);
50+
int runShell(const char *startupBas, bool once, int fontScale, int debugPort);
5151
char *loadResource(const char *fileName);
5252
void logStack(int line, bool subOrFunc);
5353
void optionsBox(StringList *items);

src/ui/system.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ void System::runMain(const char *mainBasPath) {
694694
}
695695
}
696696

697-
void System::runOnce(const char *startupBas) {
697+
void System::runOnce(const char *startupBas, bool runWait) {
698698
// startupBas must not be _loadPath.c_str()
699699
logEntered();
700700
_mainBas = false;
@@ -705,7 +705,9 @@ void System::runOnce(const char *startupBas) {
705705
if (_state == kActiveState) {
706706
showCompletion(success);
707707
}
708-
waitForBack();
708+
if (runWait) {
709+
waitForBack();
710+
}
709711
restart = isRestart();
710712
}
711713
}

src/ui/system.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct System {
8686
void runEdit(const char *startupBas);
8787
void runLive(const char *startupBas);
8888
void runMain(const char *mainBasPath);
89-
void runOnce(const char *startupBas);
89+
void runOnce(const char *startupBas, bool runWait);
9090
void saveFile(TextEditInput *edit, strlib::String &path);
9191
void setupPath(String &loadpath);
9292
bool setParentPath();

0 commit comments

Comments
 (0)