@@ -376,7 +376,9 @@ protected StringList getSketchParams(boolean present, String[] args) {
376376 } else {
377377 params .append ("processing.core.PApplet" );
378378
379- // get the stored device index (starts at 1)
379+ // Get the stored device index (starts at 1)
380+ // By default, set to -1, meaning 'the default display',
381+ // which is the same display as the one being used by the Editor.
380382 int runDisplay = Preferences .getInteger ("run.display" );
381383
382384 // If there was a saved location (this guy has been run more than once)
@@ -395,23 +397,26 @@ protected StringList getSketchParams(boolean present, String[] args) {
395397
396398 // Make sure the display set in Preferences actually exists
397399 GraphicsDevice runDevice = editorDevice ;
398- if (runDisplay > 0 && runDisplay <= devices .length ) {
399- runDevice = devices [runDisplay -1 ];
400- } else {
401- // If a bad display is selected, use the same display as the editor
402- if (runDisplay > 0 ) { // don't complain about -1 or 0
403- System .err .println ("Display " + runDisplay + " not available." );
404- }
405- runDevice = editorDevice ;
406- for (int i = 0 ; i < devices .length ; i ++) {
407- if (devices [i ] == runDevice ) {
408- // Wasn't setting the pref to avoid screwing things up with
409- // something temporary. But not setting it makes debugging one's
410- // setup just too damn weird, so changing that behavior.
411- runDisplay = i + 1 ;
412- System .err .println ("Setting 'Run Sketches on Display' preference to display " + runDisplay );
413- Preferences .setInteger ("run.display" , runDisplay );
414- break ;
400+ if (runDisplay > 0 ) {
401+ if (runDisplay <= devices .length ) {
402+ runDevice = devices [runDisplay -1 ];
403+
404+ } else {
405+ // If a bad display is selected, use the same display as the editor
406+ if (runDisplay > 0 ) { // don't complain about -1 or 0
407+ System .err .println ("Display " + runDisplay + " not available." );
408+ }
409+ runDevice = editorDevice ;
410+ for (int i = 0 ; i < devices .length ; i ++) {
411+ if (devices [i ] == runDevice ) {
412+ // Wasn't setting the pref to avoid screwing things up with
413+ // something temporary. But not setting it makes debugging one's
414+ // setup just too damn weird, so changing that behavior.
415+ runDisplay = i + 1 ;
416+ System .err .println ("Setting 'Run Sketches on Display' preference to display " + runDisplay );
417+ Preferences .setInteger ("run.display" , runDisplay );
418+ break ;
419+ }
415420 }
416421 }
417422 }
0 commit comments