diff --git a/src/main/java/com/zhangmeng/tools/controller/FileEditController.java b/src/main/java/com/zhangmeng/tools/controller/FileEditController.java index 63994b9..a5fb65f 100644 --- a/src/main/java/com/zhangmeng/tools/controller/FileEditController.java +++ b/src/main/java/com/zhangmeng/tools/controller/FileEditController.java @@ -83,11 +83,7 @@ public class FileEditController { private RecursiveFileList recursiveFileList = null; private TabPane tabPane = null; - - private static String path = null; private final ObservableList filePaths_list = FXCollections.observableArrayList(); - private final SimpleIntegerProperty index = new SimpleIntegerProperty(0); - private final SimpleIntegerProperty text_size = new SimpleIntegerProperty(15); private final SimpleIntegerProperty icon_size = new SimpleIntegerProperty(15); private static final Map map = new HashMap<>(); @@ -99,9 +95,6 @@ public class FileEditController { save.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCodeCombination.CONTROL_DOWN)); open_file.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCodeCombination.CONTROL_DOWN)); open_dir.setAccelerator(new KeyCodeCombination(KeyCode.D, KeyCodeCombination.CONTROL_DOWN)); - - //读取本地加载记录 - Properties s = config_path(false); recursiveFileList = new RecursiveFileList(null); init_file_list(); tabPane = new TabPane(); @@ -160,9 +153,9 @@ public class FileEditController { HBox hBox = new HBox(10); ImageView iv = null; if (this.getTreeItem().isExpanded()) { - iv = new ImageView(new Image("image/向下.png")); + iv = new ImageView(new Image("image/close.png")); } else { - iv = new ImageView(new Image("image/向右.png")); + iv = new ImageView(new Image("image/open.png")); } iv.setPreserveRatio(true); iv.setFitWidth(icon_size.get()); @@ -245,7 +238,7 @@ public class FileEditController { if (filePaths_list.contains(path)) {//size -1 ,szie -2 //切换到一打开的tab Tab tab = map.get(path); - if (!tabPane.getTabs().contains(tab)){ + if (!tabPane.getTabs().contains(tab)) { tabPane.getTabs().add(tab); } tabPane.getSelectionModel().select(tab); @@ -287,9 +280,9 @@ public class FileEditController { }); tab.setContent(new VirtualizedScrollPane<>(codeArea)); filePaths_list.add(path); - tabPane.getTabs().add( tab); + tabPane.getTabs().add(tab); tabPane.getSelectionModel().select(tab); - map.put(path,tab); + map.put(path, tab); } } @@ -381,19 +374,53 @@ public class FileEditController { int lastKwEnd = 0; StyleSpansBuilder> spansBuilder = new StyleSpansBuilder<>(); while (matcher.find()) { - String styleClass = - matcher.group("KEYWORD") != null ? "keyword" : - matcher.group("PAREN") != null ? "paren" : - matcher.group("BRACE") != null ? "brace" : - matcher.group("BRACKET") != null ? "bracket" : - matcher.group("SEMICOLON") != null ? "semicolon" : - matcher.group("STRING") != null ? "string" : - matcher.group("COMMENT") != null ? "comment" : - matcher.group("ANNOTATION") != null ? "annotation" : - matcher.group("PARAMS") != null ? "parameter" : - matcher.group("METHOD") != null ? "method" : - matcher.group("KEYWORD2") != null ? "method2" : - null; /* never happens */ + String styleClass = ""; + + if (type.equals(Type.JAVA)) { + styleClass = matcher.group("KEYWORD") != null ? "keyword" : + matcher.group("PAREN") != null ? "paren" : + matcher.group("BRACE") != null ? "brace" : + matcher.group("BRACKET") != null ? "bracket" : + matcher.group("SEMICOLON") != null ? "semicolon" : + matcher.group("STRING") != null ? "string" : + matcher.group("COMMENT") != null ? "comment" : + matcher.group("ANNOTATION") != null ? "annotation" : + matcher.group("PARAMS") != null ? "parameter" : + matcher.group("METHOD") != null ? "method" : + matcher.group("KEYWORD2") != null ? "method2" : + null; /* never happens */ + } + if (type.equals(Type.GO)) { + styleClass = matcher.group("KEYWORD") != null ? "keyword" : + matcher.group("PAREN") != null ? "paren" : + matcher.group("BRACE") != null ? "brace" : + matcher.group("BRACKET") != null ? "bracket" : + matcher.group("SEMICOLON") != null ? "semicolon" : + matcher.group("STRING") != null ? "string" : + matcher.group("COMMENT") != null ? "comment" : + matcher.group("ANNOTATION") != null ? "annotation" : + matcher.group("PARAMS") != null ? "parameter" : + matcher.group("METHOD") != null ? "method" : + matcher.group("KEYWORD2") != null ? "method2" : + null; /* never happens */ + } + + if (type.equals(Type.HTML)) { + styleClass = matcher.group("PAREN") != null ? "paren" : + matcher.group("BRACE") != null ? "brace" : + matcher.group("BRACKET") != null ? "bracket" : + matcher.group("SEMICOLON") != null ? "semicolon" : + matcher.group("STRING") != null ? "string" : + matcher.group("COMMENT") != null ? "comment" : + matcher.group("ANNOTATION") != null ? "annotation" : + matcher.group("PARAMS") != null ? "parameter" : + matcher.group("METHOD") != null ? "method" : + matcher.group("HTMLKEYWORDS") != null ? "html-keyword" : //html 标签 + matcher.group("HTMLKEYWORDS2") != null ? "html-keyword2" : //html 属性 + null; /* never happens */ + } + + assert styleClass != null; spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd); spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start()); diff --git a/src/main/java/com/zhangmeng/tools/languages/ProcessHtml.java b/src/main/java/com/zhangmeng/tools/languages/ProcessHtml.java index b8db767..e098ea3 100644 --- a/src/main/java/com/zhangmeng/tools/languages/ProcessHtml.java +++ b/src/main/java/com/zhangmeng/tools/languages/ProcessHtml.java @@ -9,20 +9,20 @@ import java.util.regex.Pattern; */ public class ProcessHtml { - public static final String[] KEYWORDS = new String[] { + public static final String[] HTMLKEYWORDS = new String[] { "DOCTYPE","doctype", "html", "head", "body", "h1", "h2","h3","h4","h5","h6", "p", "br","meta", "title","img", "hr", "a", "table","div","span", "ul", "dl","dd","i","script","li","link" }; - public static final String[] KEYWORDS2 = new String[] { + public static final String[] HTMLKEYWORDS2 = new String[] { "href", "name", "style", "rel", "id", "src","media","content","http-equiv", - "return","class","target","charset","lay-filter","window","global","document" + "return","class","target","charset","lay-filter","window","global","document","var" }; - public static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b"; - public static final String KEYWORD_PATTERN2 = "\\b(" + String.join("|", KEYWORDS2) + ")\\b"; + public static final String HTMLKEYWORDS_PATTERN = "\\b(" + String.join("|", HTMLKEYWORDS) + ")\\b"; + public static final String HTMLKEYWORDS_PATTERN2 = "\\b(" + String.join("|", HTMLKEYWORDS2) + ")\\b"; public static final String PAREN_PATTERN = "\\(|\\)"; public static final String BRACE_PATTERN = "\\{|\\}"; public static final String BRACKET_PATTERN = "\\[|\\]"; @@ -34,7 +34,7 @@ public class ProcessHtml { public static final String METHOD_PATTERN = "\\w+\\((\\w+,\\s*)*\\w*\\)"; public static final Pattern PATTERN = Pattern.compile( - "(?" + KEYWORD_PATTERN + ")" + "(?" + HTMLKEYWORDS_PATTERN + ")" + "|(?" + PAREN_PATTERN + ")" + "|(?" + BRACE_PATTERN + ")" + "|(?" + BRACKET_PATTERN + ")" @@ -44,7 +44,7 @@ public class ProcessHtml { + "|(?" + ANNOTATION_PATTERN + ")" + "|(?" + PARAMS_PATTERN + ")" + "|(?" + METHOD_PATTERN + ")" - + "|(?" + KEYWORD_PATTERN2 + ")" + + "|(?" + HTMLKEYWORDS_PATTERN2 + ")" ); diff --git a/src/main/resources/css/code.css b/src/main/resources/css/code.css index ffe2291..a27f1d1 100644 --- a/src/main/resources/css/code.css +++ b/src/main/resources/css/code.css @@ -69,7 +69,7 @@ /*-*/ /*信息文本的样式*/ .code-area .keyword { - -fx-fill: #10ADEBFF + -fx-fill: #d12746 } /*-*/ @@ -119,7 +119,7 @@ /*-*/ /*参数的样式*/ .code-area .annotation { - -fx-fill: #eeee07; + -fx-fill: #b76bd5; } /*-*/ @@ -151,12 +151,12 @@ /*-*/ /*字段的样式*/ .code-area .method { - -fx-fill: red; + -fx-fill: #8841c0; -fx-text-fill: red; } .code-area .method2 { - -fx-fill: #699f45; + -fx-fill: #10adeb; -fx-text-fill: red; } @@ -188,5 +188,14 @@ /*-*/ /*抽象的样式*/ .code-area .deprecated { - -fx-fill: #d12746; + -fx-fill: #03e921; } + +.code-area .html-keyword{ + -fx-fill: #66af22; +} + +.code-area .html-keyword2{ + -fx-fill: #1097eb; +} + diff --git a/src/main/resources/image/close.png b/src/main/resources/image/close.png new file mode 100644 index 0000000..10f606c Binary files /dev/null and b/src/main/resources/image/close.png differ diff --git a/src/main/resources/image/open.png b/src/main/resources/image/open.png new file mode 100644 index 0000000..437fecc Binary files /dev/null and b/src/main/resources/image/open.png differ