Skip to content

Commit fc53d2a

Browse files
author
Chris Warren-Smith
committed
SDL: support console based execution
1 parent f7c71d6 commit fc53d2a

8 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/platform/android/jni/runtime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct Runtime : public System {
8686

8787
private:
8888
void editSource(String loadPath, bool restoreOnExit) override;
89+
void externalExecute(const char *bas) const override {}
8990

9091
bool _keypadActive;
9192
bool _hasFocus;

src/platform/emcc/runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ struct Runtime : public System {
2222
char *getClipboardText();
2323
int getFontSize() { return _output->getFontSize(); }
2424
void editSource(String loadPath, bool restoreOnExit) override;
25+
void externalExecute(const char *bas) const override {}
2526
void enableCursor(bool enabled) {}
2627
int handle(int event);
2728
char *loadResource(const char *fileName);
29+
void openFolder() override {}
2830
void onRunCompleted() {}
2931
void saveWindowRect() {}
3032
bool handleKeyboard(int eventType, const EmscriptenKeyboardEvent *e);

src/platform/fltk/MainWindow.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,9 @@ void MainWindow::editor_plugin(Fl_Widget *w, void *eventData) {
558558
editWidget->getRowCol(&row, &col);
559559
editWidget->getSelStartRowCol(&s1r, &s1c);
560560
editWidget->getSelEndRowCol(&s2r, &s2c);
561-
strlcpy(opt_command, filename, PATH_MAX);
561+
strlcpy(opt_command, filename, OPT_CMD_SZ);
562562
snprintf(path, sizeof(path), "|%d|%d|%d|%d|%d|%d", row - 1, col, s1r - 1, s1c, s2r - 1, s2c);
563-
strlcat(opt_command, path, PATH_MAX);
563+
strlcat(opt_command, path, OPT_CMD_SZ);
564564
runMode = run_state;
565565
editWidget->runState(rs_run);
566566
snprintf(path, sizeof(path), "%s/%s", packageHome, (const char *)eventData);

src/platform/fltk/runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ struct Runtime : public System {
2121
int ask(const char *title, const char *prompt, bool cancel=true);
2222
void browseFile(const char *url);
2323
void editSource(String loadPath, bool restoreOnExit) override {}
24+
void externalExecute(const char *bas) const override {}
2425
char *getClipboardText();
2526
int getFontSize() { return _output->getFontSize(); }
2627
void enableCursor(bool enabled);
2728
int handle(int event);
2829
void optionsBox(StringList *items);
30+
void openFolder() override {}
2931
void onRunCompleted() {}
3032
void saveWindowRect() {}
3133
MAEvent processEvents(int waitFlag);

src/platform/sdl/runtime.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ void Runtime::exportRun(const char *file) const {
262262
SDL_RaiseWindow(_window);
263263
}
264264

265+
void Runtime::externalExecute(const char *bas) const {
266+
launchConsole(bas);
267+
}
268+
265269
bool Runtime::toggleFullscreen() {
266270
if (!_fullscreen) {
267271
setWindowRect(_windowRect);

src/platform/sdl/runtime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct Runtime final : System {
6464

6565
private:
6666
void editSource(String loadPath, bool restoreOnExit) override;
67+
void externalExecute(const char *bas) const override;
6768

6869
bool _fullscreen;
6970
SDL_Rect _windowRect{};

src/ui/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool System::execute(const char *bas) {
176176
String path(bas);
177177
saveFile(_editor, path);
178178
}
179-
//executeConsole(bas); TODO
179+
externalExecute(bas);
180180
}
181181

182182
if (_editor == nullptr) {

src/ui/system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct System {
7777
static bool setParentPath();
7878

7979
virtual void editSource(strlib::String loadPath, bool restoreOnExit) = 0;
80+
virtual void externalExecute(const char *bas) const = 0;
8081
bool execute(const char *bas);
8182
MAEvent getNextEvent() { return processEvents(1); }
8283
uint32_t getModifiedTime() const;

0 commit comments

Comments
 (0)