增加自动换行功能
This commit is contained in:
parent
96d4926abd
commit
d10e1d2609
@ -5,7 +5,6 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import org.jcnc.jnotepad.controller.Controller;
|
||||
|
||||
/**
|
||||
* 该类管理记事本应用程序的视图组件。
|
||||
|
||||
@ -61,6 +61,7 @@ public class Controller {
|
||||
public void handle(ActionEvent event) {
|
||||
wrapText = !wrapText; // 切换自动换行状态
|
||||
textArea.setWrapText(wrapText);
|
||||
Line=!Line;
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,25 +240,6 @@ public class Controller {
|
||||
enCodingLabel.setText("\t编码: " + encoding);
|
||||
}
|
||||
|
||||
/* // 判断编码是否有效
|
||||
public static boolean isEncodingValid(String text, Charset encoding) {
|
||||
byte[] bytes = text.getBytes(encoding);
|
||||
String decodedText = new String(bytes, encoding);
|
||||
return text.equals(decodedText);
|
||||
}*/
|
||||
|
||||
/* // 检测文本编码
|
||||
public static String detectEncoding(String text) {
|
||||
Charset[] possibleEncodings = {StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_16};
|
||||
for (Charset encoding : possibleEncodings) {
|
||||
if (isEncodingValid(text, Charset.forName(String.valueOf(encoding)))) {
|
||||
System.out.println("正在检测编码");
|
||||
return encoding.displayName();
|
||||
}
|
||||
}
|
||||
return "未知";
|
||||
}*/
|
||||
|
||||
// 获取光标所在行数
|
||||
public static int getRow(int caretPosition, String text) {
|
||||
caretPosition = Math.min(caretPosition, text.length());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user