use of org.fife.ui.rsyntaxtextarea.folding.CurlyFoldParser in project maptool by RPTools.
the class MacroButtonDialog method initCommandTextArea.
private void initCommandTextArea() {
AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory) TokenMakerFactory.getDefaultInstance();
atmf.putMapping("text/MapToolScript", "net.rptools.maptool.client.ui.syntax.MapToolScriptSyntax");
// Expanding use of tooltip - already accepts HTML so lets show it
getToolTipTextField().setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HTML);
getToolTipTextField().setLineWrap(true);
getToolTipTextField().setWrapStyleWord(true);
getToolTipTextField().setTabSize(2);
// Macro Editor setup
macroEditorRSyntaxTextArea.setSyntaxEditingStyle("text/MapToolScript");
macroEditorRSyntaxTextArea.setEditable(true);
macroEditorRSyntaxTextArea.setCodeFoldingEnabled(true);
macroEditorRSyntaxTextArea.setLineWrap(true);
macroEditorRSyntaxTextArea.setWrapStyleWord(true);
macroEditorRSyntaxTextArea.setTabSize(4);
FoldParserManager.get().addFoldParserMapping("text/MapToolScript", new CurlyFoldParser());
// https://stackoverflow.com/questions/39613186/how-to-add-keywords-for-rsyntaxtextarea-for-syntax-highlighting
CompletionProvider provider = new MapToolScriptAutoComplete().get();
AutoCompletion ac = new AutoCompletion(provider);
ac.setAutoCompleteEnabled(true);
ac.setAutoActivationEnabled(true);
ac.setAutoActivationDelay(500);
ac.setShowDescWindow(true);
ac.setAutoCompleteSingleChoices(false);
ac.install(macroEditorRSyntaxTextArea);
// Set the color style via Theme
try {
File themeFile = new File(AppConstants.THEMES_DIR, AppPreferences.getDefaultMacroEditorTheme() + ".xml");
Theme theme = Theme.load(new FileInputStream(themeFile));
theme.apply(macroEditorRSyntaxTextArea);
theme.apply(getToolTipTextField());
macroEditorRSyntaxTextArea.revalidate();
} catch (IOException e) {
e.printStackTrace();
}
// Listen for changes in the text
macroEditorRSyntaxTextArea.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
status.setText(READY);
}
@Override
public void removeUpdate(DocumentEvent e) {
status.setText(READY);
}
@Override
public void insertUpdate(DocumentEvent e) {
status.setText(READY);
}
});
csp = new CollapsibleSectionPanel();
((GridView) panel.getComponentByName("macroEditorPanel")).add(csp);
csp.add(new ErrorStrip(macroEditorRSyntaxTextArea), BorderLayout.LINE_END);
RTextScrollPane macroEditorRTextScrollPane = new RTextScrollPane(macroEditorRSyntaxTextArea);
macroEditorRTextScrollPane.setLineNumbersEnabled(true);
// replaceComponent("macroEditorPanel", "macroEditorRTextScrollPane",
// macroEditorRTextScrollPane);
csp.add(new ErrorStrip(getToolTipTextField()), BorderLayout.LINE_END);
// RTextScrollPane macroEditorRTextScrollPane = new
// RTextScrollPane(macroEditorRSyntaxTextArea);
// macroEditorRTextScrollPane.setLineNumbersEnabled(true);
csp.add(macroEditorRTextScrollPane);
}
Aggregations