1717
1818extern MainWindow *wnd;
1919extern System *g_system;
20+ static auto *onlineUrl = " http://smallbasic.github.io/samples/index.bas" ;
2021
2122#define MIN_WINDOW_SIZE 10
2223#define OPTIONS_BOX_WIDTH_EXTRA 4
@@ -60,9 +61,9 @@ void Runtime::alert(const char *title, const char *message) {
6061int Runtime::ask (const char *title, const char *prompt, bool cancel) {
6162 int result;
6263 if (cancel) {
63- result = fl_choice (prompt, " Yes" , " No" , " Cancel" , NULL );
64+ result = fl_choice (prompt, " Yes" , " No" , " Cancel" , nullptr );
6465 } else {
65- result = fl_choice (prompt, " Yes" , " No" , 0 , NULL );
66+ result = fl_choice (prompt, " Yes" , " No" , 0 , nullptr );
6667 }
6768 return result;
6869}
@@ -76,7 +77,7 @@ void Runtime::enableCursor(bool enabled) {
7677}
7778
7879char *Runtime::getClipboardText () {
79- return NULL ;
80+ return nullptr ;
8081}
8182
8283int Runtime::handle (int e) {
@@ -126,7 +127,7 @@ void Runtime::optionsBox(StringList *items) {
126127 menu[index].labelfont_ = FL_HELVETICA;
127128 menu[index].labelsize_ = FL_NORMAL_SIZE;
128129 menu[index].labelcolor_ = FL_FOREGROUND_COLOR;
129- menu[index].measure (&h, NULL );
130+ menu[index].measure (&h, nullptr );
130131
131132 height += h + 1 ;
132133 w = (strlen (str) * charWidth);
@@ -137,7 +138,7 @@ void Runtime::optionsBox(StringList *items) {
137138 }
138139
139140 menu[index].flags = 0 ;
140- menu[index].text = NULL ;
141+ menu[index].text = nullptr ;
141142 width += (charWidth * OPTIONS_BOX_WIDTH_EXTRA);
142143
143144 int menuX = event_x ();
@@ -201,8 +202,33 @@ void Runtime::resize(int w, int h) {
201202 }
202203}
203204
205+ void Runtime::runSamples () {
206+ logEntered ();
207+ _loadPath = onlineUrl;
208+ _mainBas = true ;
209+
210+ String activePath = _loadPath;
211+ bool started = execute (onlineUrl);
212+
213+ while (started && !wnd->isBreakExec ()) {
214+ if (isBreak () && (activePath.equals (onlineUrl) || activePath.equals (_loadPath))) {
215+ // break from index page OR break with same _loadPath
216+ break ;
217+ }
218+ if (_loadPath.empty ()) {
219+ // return to index page
220+ _loadPath = onlineUrl;
221+ }
222+ activePath = _loadPath;
223+ started = execute (_loadPath);
224+ }
225+ _mainBas = false ;
226+ showCompletion (started);
227+ _output->redraw ();
228+ }
229+
204230void Runtime::setClipboardText (const char *text) {
205- Fl::copy (text, strlen (text), true );
231+ Fl::copy (text, strlen (text), 1 );
206232}
207233
208234void Runtime::setFontSize (int size) {
@@ -347,7 +373,7 @@ int osd_devrestore() {
347373void appLog (const char *format, ...) {
348374 va_list args;
349375 va_start (args, format);
350- unsigned size = vsnprintf (NULL , 0 , format, args);
376+ unsigned size = vsnprintf (nullptr , 0 , format, args);
351377 va_end (args);
352378
353379 if (size) {
0 commit comments