File tree 4 files changed +39
-2
lines changed
4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ public class Base {
117
117
private List <JMenu > boardsCustomMenus ;
118
118
private List <JMenuItem > programmerMenus ;
119
119
120
- private final PdeKeywords pdeKeywords ;
120
+ private PdeKeywords pdeKeywords ;
121
121
private final List <JMenuItem > recentSketchesMenuItems ;
122
122
123
123
static public void main (String args []) throws Exception {
@@ -1250,9 +1250,25 @@ public void rebuildExamplesMenu(JMenu menu) {
1250
1250
}
1251
1251
}
1252
1252
1253
+ private static String priorPlatformFolder ;
1254
+
1253
1255
public void onBoardOrPortChange () {
1254
1256
BaseNoGui .onBoardOrPortChange ();
1255
1257
1258
+ // reload keywords when package/platform changes
1259
+ TargetPlatform tp = BaseNoGui .getTargetPlatform ();
1260
+ if (tp != null ) {
1261
+ String platformFolder = tp .getFolder ().getAbsolutePath ();
1262
+ if (priorPlatformFolder == null || !priorPlatformFolder .equals (platformFolder )) {
1263
+ pdeKeywords = new PdeKeywords ();
1264
+ pdeKeywords .reload ();
1265
+ priorPlatformFolder = platformFolder ;
1266
+ for (Editor editor : editors ) {
1267
+ editor .updateKeywords (pdeKeywords );
1268
+ }
1269
+ }
1270
+ }
1271
+
1256
1272
// Update editors status bar
1257
1273
for (Editor editor : editors ) {
1258
1274
editor .onBoardOrPortChange ();
Original file line number Diff line number Diff line change 40
40
import processing .app .helpers .OSUtils ;
41
41
import processing .app .helpers .PreferencesMapException ;
42
42
import processing .app .legacy .PApplet ;
43
+ import processing .app .syntax .PdeKeywords ;
43
44
import processing .app .syntax .ArduinoTokenMakerFactory ;
44
45
import processing .app .syntax .SketchTextArea ;
45
46
import processing .app .tools .DiscourseFormat ;
@@ -1060,6 +1061,15 @@ public void caretUpdate(CaretEvent e) {
1060
1061
return textArea ;
1061
1062
}
1062
1063
1064
+ public void updateKeywords (PdeKeywords keywords ) {
1065
+ // update GUI for "Find In Reference"
1066
+ textarea .setKeywords (keywords );
1067
+ // update document for syntax highlighting
1068
+ RSyntaxDocument document = (RSyntaxDocument ) textarea .getDocument ();
1069
+ document .setTokenMakerFactory (new ArduinoTokenMakerFactory (keywords ));
1070
+ document .setSyntaxStyle (RSyntaxDocument .SYNTAX_STYLE_CPLUSPLUS );
1071
+ }
1072
+
1063
1073
private JMenuItem createToolMenuItem (String className ) {
1064
1074
try {
1065
1075
Class <?> toolClass = Class .forName (className );
Original file line number Diff line number Diff line change 31
31
import processing .app .Base ;
32
32
import processing .app .BaseNoGui ;
33
33
import processing .app .legacy .PApplet ;
34
+ import processing .app .debug .TargetPlatform ;
34
35
35
36
import java .io .BufferedReader ;
36
37
import java .io .File ;
@@ -84,6 +85,11 @@ public PdeKeywords() {
84
85
public void reload () {
85
86
try {
86
87
parseKeywordsTxt (new File (BaseNoGui .getContentFile ("lib" ), "keywords.txt" ));
88
+ TargetPlatform tp = BaseNoGui .getTargetPlatform ();
89
+ if (tp != null ) {
90
+ File platformKeywords = new File (tp .getFolder (), "keywords.txt" );
91
+ if (platformKeywords .exists ()) parseKeywordsTxt (platformKeywords );
92
+ }
87
93
for (ContributedLibrary lib : Base .getLibraries ()) {
88
94
File keywords = new File (lib .getInstalledFolder (), "keywords.txt" );
89
95
if (keywords .exists ()) {
Original file line number Diff line number Diff line change @@ -74,13 +74,18 @@ public class SketchTextArea extends RSyntaxTextArea {
74
74
75
75
private EditorListener editorListener ;
76
76
77
- private final PdeKeywords pdeKeywords ;
77
+ private PdeKeywords pdeKeywords ;
78
78
79
79
public SketchTextArea (PdeKeywords pdeKeywords ) throws IOException {
80
80
this .pdeKeywords = pdeKeywords ;
81
81
installFeatures ();
82
82
}
83
83
84
+ public void setKeywords (PdeKeywords keywords ) {
85
+ pdeKeywords = keywords ;
86
+ setLinkGenerator (new DocLinkGenerator (pdeKeywords ));
87
+ }
88
+
84
89
private void installFeatures () throws IOException {
85
90
setTheme (PreferencesData .get ("editor.syntax_theme" , "default" ));
86
91
You can’t perform that action at this time.
0 commit comments