From 7543cb048e225036f6c5a9d8fbed7feaebe796f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Thu, 10 Aug 2023 13:03:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E6=9C=AC=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- src/main/java/org/jcnc/jnotepad/JNotepad.java | 14 ++++++++++---- 打包.txt | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5ff6309..1367b22 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ build/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store +/JNotepad/ diff --git a/src/main/java/org/jcnc/jnotepad/JNotepad.java b/src/main/java/org/jcnc/jnotepad/JNotepad.java index df9509a..989f488 100644 --- a/src/main/java/org/jcnc/jnotepad/JNotepad.java +++ b/src/main/java/org/jcnc/jnotepad/JNotepad.java @@ -65,7 +65,7 @@ public class JNotepad extends Application { root.setCenter(tabPane); // 创建状态栏 - statusLabel = new Label("行: 1 \t列: 1 \t字数: 0 \t编码: 未知"); + statusLabel = new Label("行: 1 \t列: 1 \t字数: 0 \t编码: "); encodingLabel = new Label(); // 创建新的标签用于显示编码信息 HBox statusBox = new HBox(statusLabel, encodingLabel); // 使用 HBox 放置状态标签和编码标签 root.setBottom(statusBox); @@ -86,7 +86,10 @@ public class JNotepad extends Application { textArea.textProperty().addListener((observable, oldValue, newValue) -> { // 更新状态栏信息 updateStatusLabel(textArea); + // 更新编码信息 + //updateEncodingLabel(newValue); updateEncodingLabel(textArea.getText()); // 更新文本编码信息 + }); autoSave(textArea); // 自动保存 @@ -120,6 +123,9 @@ public class JNotepad extends Application { tabPane.getTabs().add(tab); tabPane.getSelectionModel().select(tab); updateStatusLabel(textArea); + // 更新编码信息 + //updateEncodingLabel(newValue); + updateEncodingLabel(textArea.getText()); // 更新文本编码信息 } } @@ -226,7 +232,7 @@ public class JNotepad extends Application { int row = getRow(textArea.getCaretPosition(), textArea.getText()); int column = getColumn(textArea.getCaretPosition(), textArea.getText()); int length = textArea.getLength(); - statusLabel.setText("行: " + row + " \t列: " + column + " \t字数: " + length+"\t"); + statusLabel.setText("行: " + row + " \t列: " + column + " \t字数: " + length+"\t编码: "); }); } @@ -267,7 +273,7 @@ public class JNotepad extends Application { private void updateEncodingLabel(String text) { String[] commonEncodings = {"UTF-8", "ISO-8859-1", "UTF-16", "US-ASCII"}; // 常见编码 - String detectedEncoding = "未知"; // 默认值 + String detectedEncoding = ""; // 默认值 for (String encoding : commonEncodings) { if (isEncodingValid(text, encoding)) { @@ -276,7 +282,7 @@ public class JNotepad extends Application { } } - encodingLabel.setText("编码: " + detectedEncoding); + encodingLabel.setText(detectedEncoding); } private boolean isEncodingValid(String text, String encoding) { diff --git a/打包.txt b/打包.txt index 7b6416d..e73e37b 100644 --- a/打包.txt +++ b/打包.txt @@ -4,5 +4,5 @@ jpackage ` -m org.jcnc.jnotepad/org.jcnc.jnotepad.JNotepad ` --runtime-image .\target\JNotepad\ ` --icon src/main/resources/img/icon.ico ` - --app-version 1.1.4 ` + --app-version 1.1.5 ` --vendor "JCNC"