diff --git a/.vscode/settings.json b/.vscode/settings.json
index 317e419..dd0d365 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -6,5 +6,6 @@
"jdk.*",
"org.graalvm.*",
"io.micrometer.shaded.*"
- ]
+ ],
+ "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable"
}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4cc034c..e23b7f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
info.istlab.IoTP
IoTP
jar
- 0.39
+ 0.40
IoTP
http://maven.apache.org
diff --git a/src/main/java/info/istlab/IoTP/Editor.java b/src/main/java/info/istlab/IoTP/Editor.java
index 9dc910b..e0c54fc 100644
--- a/src/main/java/info/istlab/IoTP/Editor.java
+++ b/src/main/java/info/istlab/IoTP/Editor.java
@@ -1,12 +1,15 @@
package info.istlab.IoTP;
import java.awt.BorderLayout;
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.BufferedReader;
@@ -45,7 +48,8 @@
JButton compileB;
JButton execB;
JButton fixIndentB;
- JTextField comlineOption;
+ JTextField searchTF;
+ // JTextField comlineOption;
ScriptRunner runner;
public Editor(File f) {
@@ -128,33 +132,41 @@
execB.addActionListener(this);
// topP.add(compileB);
topP.add(execB);
- // comlineOption = new JTextField("arg1 arg2 ...", 15);
- // comlineOption.setForeground(Color.GRAY);
- // comlineOption.addFocusListener(new FocusListener() {
- // @Override
- // public void focusGained(FocusEvent e) {
- // if (comlineOption.getText().equals("arg1 arg2 ...")) {
- // comlineOption.setText("");
- // comlineOption.setForeground(Color.BLACK);
- // }
- // }
-
- // @Override
- // public void focusLost(FocusEvent e) {
- // if (comlineOption.getText().isEmpty()) {
- // comlineOption.setForeground(Color.GRAY);
- // comlineOption.setText("arg1 arg2 ...");
- // }
- // }
- // });
-
- // topP.add(comlineOption);
}
fixIndentB = new JButton("インデント調整");
- fixIndentB.setToolTipText("ソースコードの自動フォーマット (CTRL+F or CTRL+T)");
+ fixIndentB.setToolTipText("ソースコードの自動フォーマット (CTRL+I or CTRL+T)");
topP.add(fixIndentB);
fixIndentB.addActionListener(e -> fixIndent());
+
+ // searchTF = new JTextField(10);
+ searchTF = new JTextField("search (CTRL+F)", 11);
+ searchTF.setToolTipText("ソースコードの検索(CTRL+F) 入力してEnter Escで終了");
+
+ searchTF.setForeground(Color.GRAY);
+ searchTF.addFocusListener(new FocusListener() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ if (searchTF.getText().equals("search (CTRL+F)")) {
+ searchTF.setText("");
+ searchTF.setForeground(Color.BLACK);
+ }
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ if (searchTF.getText().isEmpty()) {
+ searchTF.setForeground(Color.GRAY);
+ searchTF.setText("search (CTRL+F)");
+ }
+ }
+ });
+ SearchTFKeyListener searchAgent = new SearchTFKeyListener(textArea, searchTF);
+ searchTF.addActionListener(searchAgent);
+ searchTF.addKeyListener(searchAgent);
+
+ topP.add(searchTF);
+
getContentPane().add(topP, BorderLayout.NORTH);
setVisible(true);
@@ -164,6 +176,9 @@
lastOpened = this;
}
+ // private void searchTFaction(ActionEvent e) {
+ // }
+
private void fixIndent() {
int lineNo = textArea.getCaretPosition();
String src = textArea.getText();
@@ -179,6 +194,7 @@
saveB.setEnabled(!src.equals(out)); // ソースが変化していたら保存ボタンをEnable
// System.out.println(out);
+
}
public static String loadFile(File f) {
@@ -263,9 +279,12 @@
if (e.getKeyCode() == 87) { // W (Close)
setVisible(false);
}
- if (e.getKeyCode() == 70 || e.getKeyCode() == 84) { // F (format:70) or T(84)
+ if (e.getKeyCode() == KeyEvent.VK_I || e.getKeyCode() == 84) { // F (format:70) or T(84)
fixIndent();
}
+ if (e.getKeyCode() == KeyEvent.VK_F){
+ searchTF.requestFocus();
+ }
}
}
diff --git a/src/main/java/info/istlab/IoTP/Launcher.java b/src/main/java/info/istlab/IoTP/Launcher.java
index 9e89631..aee5eb9 100644
--- a/src/main/java/info/istlab/IoTP/Launcher.java
+++ b/src/main/java/info/istlab/IoTP/Launcher.java
@@ -28,7 +28,7 @@
public class Launcher extends JFrame implements MouseInputListener, KeyListener, Runnable {
public static Launcher theapp;
- public static String version = "0.39";
+ public static String version = "0.40";
static int reboot_msec = 2000;
// JPanel mainP;
File root;
diff --git a/src/main/java/info/istlab/IoTP/MyTreeCellRenderer.java b/src/main/java/info/istlab/IoTP/MyTreeCellRenderer.java
index fbae666..2100774 100644
--- a/src/main/java/info/istlab/IoTP/MyTreeCellRenderer.java
+++ b/src/main/java/info/istlab/IoTP/MyTreeCellRenderer.java
@@ -18,7 +18,7 @@
String node = (String) ((File) value).toString();
// If the node is a leaf and ends with "xxx"
- if (leaf && node.endsWith(".class")) {
+ if (leaf && !node.endsWith(".ino")) {
// Paint the node in blue
setForeground(new Color(200, 200,230));
// setBackground(new Color(30, 30,50));
diff --git a/src/main/java/info/istlab/IoTP/SearchTFKeyListener.java b/src/main/java/info/istlab/IoTP/SearchTFKeyListener.java
new file mode 100644
index 0000000..759f414
--- /dev/null
+++ b/src/main/java/info/istlab/IoTP/SearchTFKeyListener.java
@@ -0,0 +1,83 @@
+package info.istlab.IoTP;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.JTextField;
+
+import org.fife.ui.rsyntaxtextarea.DocumentRange;
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
+import org.fife.ui.rtextarea.SearchContext;
+import org.fife.ui.rtextarea.SearchEngine;
+import org.fife.ui.rtextarea.SearchResult;
+
+public class SearchTFKeyListener implements KeyListener, ActionListener {
+ RSyntaxTextArea textArea;
+ JTextField searchTF;
+
+ SearchTFKeyListener(RSyntaxTextArea _ed, JTextField tf) {
+ textArea = _ed;
+ searchTF = tf;
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+
+ System.out.println("escape");
+ searchTF.setText("");
+ textArea.requestFocus();
+ // マーカの消し方がわからないので、空もじれつで検索する
+ SearchContext context = new SearchContext();
+ context.setSearchFor("");
+ context.setMatchCase(true); // 大文字と小文字を区別する場合はtrueに設定
+ context.setRegularExpression(false); // 正規表現を使用する場合はtrueに設定
+ SearchEngine.find(textArea, context);
+ } else if (e.isControlDown() || e.isAltDown() || e.isAltGraphDown() || e.isMetaDown()){
+ if (e.getKeyCode() == KeyEvent.VK_F){
+ searchForward(true);
+ }
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ searchForward(true);
+ }
+
+ void searchForward(boolean isforward){
+ // System.out.println(e.getActionCommand());
+ String searchText = searchTF.getText(); // 検索フィールドからテキストを取得
+
+ // テキストを検索
+ SearchContext context = new SearchContext();
+ context.setSearchFor(searchText);
+ context.setSearchForward(isforward);
+ context.setMatchCase(true); // 大文字と小文字を区別する場合はtrueに設定
+ context.setRegularExpression(false); // 正規表現を使用する場合はtrueに設定
+ SearchResult found = SearchEngine.find(textArea, context);
+
+ if (found.wasFound()) {
+ DocumentRange range = found.getMatchRange();
+ textArea.setSelectionStart(range.getStartOffset());
+ textArea.setSelectionEnd(range.getEndOffset());
+ textArea.setCaretPosition(range.getEndOffset());
+ } else {
+ // System.out.println("");
+ if (searchText.length() > 0)
+ textArea.setCaretPosition(0);
+ }
+
+ }
+
+}