Added syntax highlighting, and auto complete (doesn't seem to work though)
This commit is contained in:
parent
20469eec97
commit
9976b96c18
9 changed files with 87 additions and 7 deletions
22
.classpath
22
.classpath
|
@ -1,10 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/rsyntaxtextarea-3.2.1-20220312.195807-1.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/autocomplete-3.2.1-20220313.002528-1.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/languagesupport-3.2.0-20220626.210742-1.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/rhino-1.7.14.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
BIN
lib/autocomplete-3.2.1-20220313.002528-1.jar
Normal file
BIN
lib/autocomplete-3.2.1-20220313.002528-1.jar
Normal file
Binary file not shown.
BIN
lib/languagesupport-3.2.0-20220626.210742-1.jar
Normal file
BIN
lib/languagesupport-3.2.0-20220626.210742-1.jar
Normal file
Binary file not shown.
BIN
lib/rhino-1.7.14.jar
Normal file
BIN
lib/rhino-1.7.14.jar
Normal file
Binary file not shown.
BIN
lib/rsyntaxtextarea-3.2.1-20220312.195807-1.jar
Normal file
BIN
lib/rsyntaxtextarea-3.2.1-20220312.195807-1.jar
Normal file
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
package com.okseby.io;
|
||||
|
||||
public class Open {
|
||||
public Open() {
|
||||
public void readFile(String path) {
|
||||
|
||||
}
|
||||
}
|
38
src/com/okseby/utils/Providers.java
Normal file
38
src/com/okseby/utils/Providers.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package com.okseby.utils;
|
||||
|
||||
import org.fife.ui.autocomplete.*;
|
||||
|
||||
public class Providers {
|
||||
public static CompletionProvider createCompletionProvider() {
|
||||
|
||||
// A DefaultCompletionProvider is the simplest concrete implementation
|
||||
// of CompletionProvider. This provider has no understanding of
|
||||
// language semantics. It simply checks the text entered up to the
|
||||
// caret position for a match against known completions. This is all
|
||||
// that is needed in the majority of cases.
|
||||
DefaultCompletionProvider provider = new DefaultCompletionProvider();
|
||||
|
||||
// Add completions for all Java keywords. A BasicCompletion is just
|
||||
// a straightforward word completion.
|
||||
provider.addCompletion(new BasicCompletion(provider, "abstract"));
|
||||
provider.addCompletion(new BasicCompletion(provider, "assert"));
|
||||
provider.addCompletion(new BasicCompletion(provider, "break"));
|
||||
provider.addCompletion(new BasicCompletion(provider, "case"));
|
||||
// ... etc ...
|
||||
provider.addCompletion(new BasicCompletion(provider, "transient"));
|
||||
provider.addCompletion(new BasicCompletion(provider, "try"));
|
||||
provider.addCompletion(new BasicCompletion(provider, "void"));
|
||||
provider.addCompletion(new BasicCompletion(provider, "volatile"));
|
||||
provider.addCompletion(new BasicCompletion(provider, "while"));
|
||||
|
||||
// Add a couple of "shorthand" completions. These completions don't
|
||||
// require the input text to be the same thing as the replacement text.
|
||||
provider.addCompletion(new ShorthandCompletion(provider, "sysout",
|
||||
"System.out.println(", "System.out.println("));
|
||||
provider.addCompletion(new ShorthandCompletion(provider, "syserr",
|
||||
"System.err.println(", "System.err.println("));
|
||||
|
||||
return provider;
|
||||
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import java.awt.Color;
|
|||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
|
@ -13,10 +12,17 @@ import javax.swing.JMenu;
|
|||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
|
||||
import org.fife.rsta.ac.LanguageSupportFactory;
|
||||
import org.fife.ui.autocomplete.*;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||
|
||||
import com.okseby.utils.Providers;
|
||||
|
||||
public class Window implements Runnable {
|
||||
JFrame window;
|
||||
JMenuBar menuBar;
|
||||
|
@ -26,7 +32,10 @@ public class Window implements Runnable {
|
|||
JMenuItem fileMenuItem1, fileMenuItem2, fileMenuItem3;
|
||||
JPanel fileExplorer;
|
||||
JPanel mainPanel;
|
||||
JTextArea textArea;
|
||||
RSyntaxTextArea textArea;
|
||||
RTextScrollPane scrollPane;
|
||||
CompletionProvider completionProvider;
|
||||
AutoCompletion autoComplete;
|
||||
|
||||
String title;
|
||||
double version;
|
||||
|
@ -71,7 +80,14 @@ public class Window implements Runnable {
|
|||
|
||||
mainPanel.setLayout(new BorderLayout());
|
||||
mainPanel.setBorder(new EtchedBorder());
|
||||
mainPanel.add(textArea);
|
||||
mainPanel.add(scrollPane);
|
||||
|
||||
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
textArea.setCodeFoldingEnabled(true);
|
||||
|
||||
LanguageSupportFactory.get().register(textArea);
|
||||
|
||||
autoComplete.install(textArea);
|
||||
|
||||
window.add(fileExplorer, BorderLayout.WEST);
|
||||
window.add(mainPanel);
|
||||
|
@ -95,7 +111,10 @@ public class Window implements Runnable {
|
|||
fileMenuItem3 = new JMenuItem("Close File");
|
||||
fileExplorer = new JPanel();
|
||||
mainPanel = new JPanel();
|
||||
textArea = new JTextArea();
|
||||
textArea = new RSyntaxTextArea();
|
||||
scrollPane = new RTextScrollPane(textArea);
|
||||
completionProvider = Providers.createCompletionProvider();
|
||||
autoComplete = new AutoCompletion(completionProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,4 +4,7 @@
|
|||
*/
|
||||
module scrypt {
|
||||
requires java.desktop;
|
||||
requires org.fife.RSyntaxTextArea;
|
||||
requires autocomplete;
|
||||
requires languagesupport;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue