new: setting of editor highlight

This commit is contained in:
lollipopkit
2023-10-12 13:28:01 +08:00
parent a43a000c68
commit 7388ad4524
13 changed files with 70 additions and 4 deletions

View File

@@ -212,6 +212,9 @@ class SettingStore extends PersistentStore {
false,
);
/// The performance of highlight is bad
late final editorHighlight = StoreProperty(box, 'editorHighlight', true);
// Never show these settings for users
//
// ------BEGIN------

View File

@@ -62,6 +62,7 @@
"edit": "Bearbeiten",
"editVirtKeys": "Virtuelle Tasten bearbeiten",
"editor": "Editor",
"editorHighlightTip": "Die Leistung der aktuellen Codehervorhebung ist schlechter und kann zur Verbesserung optional ausgeschaltet werden.",
"encode": "Encode",
"error": "Fehler",
"exampleName": "Servername",
@@ -87,6 +88,7 @@
"gettingToken": "Getting token...",
"goBackQ": "Zurückkommen?",
"goto": "Pfad öffnen",
"highlight": "Code highlight",
"homeWidgetUrlConfig": "Home-Widget-Link konfigurieren",
"host": "Host",
"httpFailedWithCode": "Anfrage fehlgeschlagen, Statuscode: {code}",

View File

@@ -62,6 +62,7 @@
"edit": "Edit",
"editVirtKeys": "Edit virtual keys",
"editor": "Editor",
"editorHighlightTip": "The current code highlighting performance is worse and can be optionally turned off to improve.",
"encode": "Encode",
"error": "Error",
"exampleName": "Example name",
@@ -87,6 +88,7 @@
"gettingToken": "Getting token...",
"goBackQ": "Go back?",
"goto": "Go to",
"highlight": "Code highlight",
"homeWidgetUrlConfig": "Config home widget url",
"host": "Host",
"httpFailedWithCode": "request failed, status code: {code}",

View File

@@ -62,6 +62,7 @@
"edit": "Edit",
"editVirtKeys": "Edit kunci virtual",
"editor": "Editor",
"editorHighlightTip": "Performa penyorotan kode saat ini lebih buruk, dan dapat dimatikan secara opsional untuk perbaikan.",
"encode": "Menyandi",
"error": "Kesalahan",
"exampleName": "Nama contoh",
@@ -87,6 +88,7 @@
"gettingToken": "Mendapatkan token ...",
"goBackQ": "Datang kembali?",
"goto": "Pergi ke",
"highlight": "Sorotan kode",
"homeWidgetUrlConfig": "Konfigurasi URL Widget Rumah",
"host": "Host",
"httpFailedWithCode": "Permintaan gagal, kode status: {code}",

View File

@@ -62,6 +62,7 @@
"edit": "编辑",
"editVirtKeys": "编辑虚拟按键",
"editor": "编辑器",
"editorHighlightTip": "目前的代码高亮性能较为糟糕,可以选择关闭以改善。",
"encode": "编码",
"error": "错误",
"exampleName": "名称示例",
@@ -87,6 +88,7 @@
"gettingToken": "正在获取Token...",
"goBackQ": "返回?",
"goto": "前往",
"highlight": "代码高亮",
"homeWidgetUrlConfig": "桌面部件链接配置",
"host": "主机",
"httpFailedWithCode": "请求失败, 状态码: {code}",

View File

@@ -62,6 +62,7 @@
"edit": "編輯",
"editVirtKeys": "編輯虛擬按鍵",
"editor": "編輯器",
"editorHighlightTip": "目前的代碼高亮性能較為糟糕,可以選擇關閉以改善。",
"encode": "編碼",
"error": "錯誤",
"exampleName": "名稱範例",
@@ -87,6 +88,7 @@
"gettingToken": "正在獲取Token...",
"goBackQ": "返回?",
"goto": "前往",
"highlight": "代碼高亮",
"homeWidgetUrlConfig": "桌面部件鏈接配置",
"host": "主機",
"httpFailedWithCode": "請求失敗, 狀態碼: {code}",

View File

@@ -57,10 +57,12 @@ class _EditorPageState extends State<EditorPage> {
super.initState();
/// Higher priority than [path]
_langCode = widget.langCode ?? Highlights.getCode(widget.path);
_controller = CodeController(
language: Highlights.all[_langCode],
);
if (Stores.setting.editorHighlight.fetch()) {
_langCode = widget.langCode ?? Highlights.getCode(widget.path);
}
_controller = CodeController(
language: Highlights.all[_langCode],
);
/// TODO: This is a temporary solution to avoid the loading stuck
Future.delayed(const Duration(milliseconds: 377)).then((value) async {

View File

@@ -245,6 +245,7 @@ class _SettingPageState extends State<SettingPage> {
_buildEditorFontSize(),
_buildEditorTheme(),
_buildEditorDarkTheme(),
_buildEditorHighlight(),
].map((e) => RoundRectCard(e)).toList(),
);
}
@@ -1072,4 +1073,12 @@ class _SettingPageState extends State<SettingPage> {
},
);
}
Widget _buildEditorHighlight() {
return ListTile(
title: Text(l10n.highlight),
subtitle: Text(l10n.editorHighlightTip, style: UIs.textGrey),
trailing: StoreSwitch(prop: _setting.editorHighlight),
);
}
}