@@ -619,7 +619,7 @@ protected JMenu buildSketchMenu() {
619
619
JMenuItem item = newJMenuItem (_ ("Verify / Compile" ), 'R' );
620
620
item .addActionListener (new ActionListener () {
621
621
public void actionPerformed (ActionEvent e ) {
622
- handleRun (false );
622
+ handleRun (false , Editor . this . presentHandler , Editor . this . runHandler );
623
623
}
624
624
});
625
625
sketchMenu .add (item );
@@ -644,7 +644,7 @@ public void actionPerformed(ActionEvent e) {
644
644
item = newJMenuItemAlt (_ ("Export compiled Binary" ), 'S' );
645
645
item .addActionListener (new ActionListener () {
646
646
public void actionPerformed (ActionEvent e ) {
647
- handleRunAndSave ( true );
647
+ handleRun ( false , Editor . this . presentAndSaveHandler , Editor . this . runAndSaveHandler );
648
648
}
649
649
});
650
650
sketchMenu .add (item );
@@ -1531,8 +1531,8 @@ public void setHandlers(Runnable runHandler,
1531
1531
public void resetHandlers () {
1532
1532
runHandler = new BuildHandler ();
1533
1533
presentHandler = new BuildHandler (true );
1534
- runAndSaveHandler = new BuildAndSaveHandler ( );
1535
- presentAndSaveHandler = new BuildAndSaveHandler ( true );
1534
+ runAndSaveHandler = new BuildHandler ( false , true );
1535
+ presentAndSaveHandler = new BuildHandler ( true , true );
1536
1536
stopHandler = new DefaultStopHandler ();
1537
1537
exportHandler = new DefaultExportHandler ();
1538
1538
exportAppHandler = new DefaultExportAppHandler ();
@@ -1999,8 +1999,10 @@ protected void handleFindReference() {
1999
1999
/**
2000
2000
* Implements Sketch → Run.
2001
2001
* @param verbose Set true to run with verbose output.
2002
+ * @param verboseHandler
2003
+ * @param nonVerboseHandler
2002
2004
*/
2003
- public void handleRun (final boolean verbose ) {
2005
+ public void handleRun (final boolean verbose , Runnable verboseHandler , Runnable nonVerboseHandler ) {
2004
2006
internalCloseRunner ();
2005
2007
if (PreferencesData .getBoolean ("editor.save_on_verify" )) {
2006
2008
if (sketch .isModified () && !sketch .isReadOnly ()) {
@@ -2021,49 +2023,32 @@ public void handleRun(final boolean verbose) {
2021
2023
2022
2024
// Cannot use invokeLater() here, otherwise it gets
2023
2025
// placed on the event thread and causes a hang--bad idea all around.
2024
- new Thread (verbose ? presentHandler : runHandler ).start ();
2026
+ new Thread (verbose ? verboseHandler : nonVerboseHandler ).start ();
2025
2027
}
2026
2028
2027
- /**
2028
- * Implements Sketch → Run and Save.
2029
- * @param verbose Set true to run with verbose output.
2030
- */
2031
- public void handleRunAndSave (final boolean verbose ) {
2032
- internalCloseRunner ();
2033
- running = true ;
2034
- toolbar .activate (EditorToolbar .RUN );
2035
- status .progress (_ ("Compiling sketch..." ));
2036
-
2037
- // do this to advance/clear the terminal window / dos prompt / etc
2038
- for (int i = 0 ; i < 10 ; i ++) System .out .println ();
2039
-
2040
- // clear the console on each run, unless the user doesn't want to
2041
- if (Preferences .getBoolean ("console.auto_clear" )) {
2042
- console .clear ();
2043
- }
2044
-
2045
- // Cannot use invokeLater() here, otherwise it gets
2046
- // placed on the event thread and causes a hang--bad idea all around.
2047
- new Thread (verbose ? presentAndSaveHandler : runAndSaveHandler ).start ();
2048
- }
2049
-
2050
2029
class BuildHandler implements Runnable {
2051
2030
2052
2031
private final boolean verbose ;
2032
+ private final boolean saveHex ;
2053
2033
2054
2034
public BuildHandler () {
2055
2035
this (false );
2056
2036
}
2057
2037
2058
2038
public BuildHandler (boolean verbose ) {
2039
+ this (verbose , false );
2040
+ }
2041
+
2042
+ public BuildHandler (boolean verbose , boolean saveHex ) {
2059
2043
this .verbose = verbose ;
2044
+ this .saveHex = saveHex ;
2060
2045
}
2061
2046
2062
2047
@ Override
2063
2048
public void run () {
2064
2049
try {
2065
2050
sketch .prepare ();
2066
- sketch .build (verbose , false );
2051
+ sketch .build (verbose , saveHex );
2067
2052
statusNotice (_ ("Done compiling." ));
2068
2053
} catch (PreferencesMapException e ) {
2069
2054
statusError (I18n .format (
@@ -2078,38 +2063,6 @@ public void run() {
2078
2063
toolbar .deactivate (EditorToolbar .RUN );
2079
2064
}
2080
2065
}
2081
-
2082
- class BuildAndSaveHandler implements Runnable {
2083
-
2084
- private final boolean verbose ;
2085
-
2086
- public BuildAndSaveHandler () {
2087
- this (false );
2088
- }
2089
-
2090
- public BuildAndSaveHandler (boolean verbose ) {
2091
- this .verbose = verbose ;
2092
- }
2093
-
2094
- @ Override
2095
- public void run () {
2096
- try {
2097
- sketch .prepare ();
2098
- sketch .build (verbose , true );
2099
- statusNotice (_ ("Done compiling." ));
2100
- } catch (PreferencesMapException e ) {
2101
- statusError (I18n .format (
2102
- _ ("Error while compiling: missing '{0}' configuration parameter" ),
2103
- e .getMessage ()));
2104
- } catch (Exception e ) {
2105
- status .unprogress ();
2106
- statusError (e );
2107
- }
2108
-
2109
- status .unprogress ();
2110
- toolbar .deactivate (EditorToolbar .RUN );
2111
- }
2112
- }
2113
2066
2114
2067
class DefaultStopHandler implements Runnable {
2115
2068
public void run () {
0 commit comments