💄 Updated extended management interface style and keybinding management interface style
This commit is contained in:
@@ -79,6 +79,7 @@ type GeneralConfig struct {
|
||||
// 界面设置
|
||||
EnableLoadingAnimation bool `json:"enableLoadingAnimation"` // 是否启用加载动画
|
||||
EnableTabs bool `json:"enableTabs"` // 是否启用标签页模式
|
||||
EnableMemoryMonitor bool `json:"enableMemoryMonitor"` // 是否启用内存监视器
|
||||
}
|
||||
|
||||
// HotkeyCombo 热键组合定义
|
||||
@@ -188,6 +189,7 @@ func NewDefaultAppConfig() *AppConfig {
|
||||
EnableGlobalHotkey: false,
|
||||
EnableLoadingAnimation: true, // 默认启用加载动画
|
||||
EnableTabs: false, // 默认不启用标签页模式
|
||||
EnableMemoryMonitor: true, // 默认启用内存监视器
|
||||
GlobalHotkey: HotkeyCombo{
|
||||
Ctrl: false,
|
||||
Shift: false,
|
||||
|
||||
@@ -106,7 +106,7 @@ const (
|
||||
CopyBlockImage KeyBindingName = "copyBlockImage" // 复制块为图片
|
||||
)
|
||||
|
||||
const defaultExtension = "editor"
|
||||
const DefaultExtension = "editor"
|
||||
|
||||
// NewDefaultKeyBindings 创建默认快捷键配置
|
||||
func NewDefaultKeyBindings() []KeyBinding {
|
||||
@@ -135,7 +135,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockSelectAll,
|
||||
Type: Standard,
|
||||
Key: "Mod-a",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -143,7 +143,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockAddAfterCurrent,
|
||||
Type: Standard,
|
||||
Key: "Mod-Enter",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -151,7 +151,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockAddAfterLast,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-Enter",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -159,7 +159,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockAddBeforeCurrent,
|
||||
Type: Standard,
|
||||
Key: "Alt-Enter",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -167,7 +167,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockGotoPrevious,
|
||||
Type: Standard,
|
||||
Key: "Mod-ArrowUp",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -175,7 +175,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockGotoNext,
|
||||
Type: Standard,
|
||||
Key: "Mod-ArrowDown",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -183,7 +183,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockSelectPrevious,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-ArrowUp",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -191,7 +191,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockSelectNext,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-ArrowDown",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -199,7 +199,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockDelete,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-d",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -207,7 +207,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockMoveUp,
|
||||
Type: Standard,
|
||||
Key: "Shift-Mod-ArrowUp",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -215,7 +215,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockMoveDown,
|
||||
Type: Standard,
|
||||
Key: "Shift-Mod-ArrowDown",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -223,7 +223,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockDeleteLine,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-k",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -231,7 +231,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockMoveLineUp,
|
||||
Type: Standard,
|
||||
Key: "Alt-ArrowUp",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -239,7 +239,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockMoveLineDown,
|
||||
Type: Standard,
|
||||
Key: "Alt-ArrowDown",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -247,7 +247,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockTransposeChars,
|
||||
Type: Standard,
|
||||
Key: "Mod-t",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -255,7 +255,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockFormat,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-f",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -263,7 +263,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockCopy,
|
||||
Type: Standard,
|
||||
Key: "Mod-c",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -271,7 +271,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockCut,
|
||||
Type: Standard,
|
||||
Key: "Mod-x",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -279,7 +279,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockPaste,
|
||||
Type: Standard,
|
||||
Key: "Mod-v",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -335,7 +335,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: HistoryUndo,
|
||||
Type: Standard,
|
||||
Key: "Mod-z",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -344,7 +344,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-z",
|
||||
Windows: "Ctrl-y",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -352,7 +352,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: HistoryUndoSelection,
|
||||
Type: Standard,
|
||||
Key: "Mod-u",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -361,7 +361,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-u",
|
||||
Windows: "Alt-u",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -373,7 +373,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Macos: "Ctrl-ArrowLeft",
|
||||
Windows: "Alt-ArrowLeft",
|
||||
Linux: "Alt-ArrowLeft",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -383,7 +383,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Macos: "Ctrl-ArrowRight",
|
||||
Windows: "Alt-ArrowRight",
|
||||
Linux: "Alt-ArrowRight",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -391,7 +391,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectSyntaxLeft,
|
||||
Type: Standard,
|
||||
Key: "Shift-Alt-ArrowLeft",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -399,7 +399,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectSyntaxRight,
|
||||
Type: Standard,
|
||||
Key: "Shift-Alt-ArrowRight",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -407,7 +407,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CopyLineUp,
|
||||
Type: Standard,
|
||||
Key: "Shift-Alt-ArrowUp",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -415,7 +415,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CopyLineDown,
|
||||
Type: Standard,
|
||||
Key: "Shift-Alt-ArrowDown",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -423,9 +423,9 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: InsertBlankLine,
|
||||
Type: Standard,
|
||||
Key: "Mod-Enter",
|
||||
Extension: defaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: false,
|
||||
PreventDefault: false,
|
||||
},
|
||||
{
|
||||
Name: SelectLine,
|
||||
@@ -433,7 +433,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Macos: "Ctrl-l",
|
||||
Windows: "Alt-l",
|
||||
Linux: "Alt-l",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -441,7 +441,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectParentSyntax,
|
||||
Type: Standard,
|
||||
Key: "Mod-i",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -449,7 +449,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SimplifySelection,
|
||||
Type: Standard,
|
||||
Key: "Escape",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -459,7 +459,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Macos: "Cmd-Alt-ArrowUp",
|
||||
Windows: "Ctrl-Alt-ArrowUp",
|
||||
Linux: "Ctrl-Alt-ArrowUp",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -469,7 +469,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Macos: "Cmd-Alt-ArrowDown",
|
||||
Windows: "Ctrl-Alt-ArrowDown",
|
||||
Linux: "Ctrl-Alt-ArrowDown",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -479,7 +479,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Windows: "Ctrl-ArrowLeft",
|
||||
Linux: "Ctrl-ArrowLeft",
|
||||
Macos: "Alt-ArrowLeft",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -489,7 +489,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Windows: "Ctrl-ArrowRight",
|
||||
Linux: "Ctrl-ArrowRight",
|
||||
Macos: "Alt-ArrowRight",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -499,7 +499,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Windows: "Ctrl-Shift-ArrowLeft",
|
||||
Linux: "Ctrl-Shift-ArrowLeft",
|
||||
Macos: "Alt-Shift-ArrowLeft",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -509,7 +509,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Windows: "Ctrl-Shift-ArrowRight",
|
||||
Linux: "Ctrl-Shift-ArrowRight",
|
||||
Macos: "Alt-Shift-ArrowRight",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -519,7 +519,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Macos: "Ctrl-k",
|
||||
Windows: "Ctrl-k",
|
||||
Linux: "Ctrl-k",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -527,7 +527,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteToLineStart,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-Backspace",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -535,7 +535,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorLineStart,
|
||||
Type: Standard,
|
||||
Key: "Home",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -543,7 +543,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorLineEnd,
|
||||
Type: Standard,
|
||||
Key: "End",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -551,7 +551,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectLineStart,
|
||||
Type: Standard,
|
||||
Key: "Shift-Home",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -559,7 +559,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectLineEnd,
|
||||
Type: Standard,
|
||||
Key: "Shift-End",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -567,7 +567,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorDocStart,
|
||||
Type: Standard,
|
||||
Key: "Mod-Home",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -575,7 +575,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorDocEnd,
|
||||
Type: Standard,
|
||||
Key: "Mod-End",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -583,7 +583,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectDocStart,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-Home",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -591,7 +591,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectDocEnd,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-End",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -599,7 +599,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectMatchingBracket,
|
||||
Type: Standard,
|
||||
Key: "Mod-Shift-p",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -609,7 +609,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Macos: "Ctrl-o",
|
||||
Windows: "Ctrl-o",
|
||||
Linux: "Ctrl-o",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -618,7 +618,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: IndentLess,
|
||||
Type: Standard,
|
||||
Key: "Mod-[",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -626,7 +626,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: IndentMore,
|
||||
Type: Standard,
|
||||
Key: "Mod-]",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -634,7 +634,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: IndentSelection,
|
||||
Type: Standard,
|
||||
Key: "Mod-Alt-\\",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -642,7 +642,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorMatchingBracket,
|
||||
Type: Standard,
|
||||
Key: "Shift-Mod-\\",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -650,7 +650,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: ToggleComment,
|
||||
Type: Standard,
|
||||
Key: "Mod-/",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -658,7 +658,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: ToggleBlockComment,
|
||||
Type: Standard,
|
||||
Key: "Shift-Alt-a",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -667,7 +667,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: InsertNewlineAndIndent,
|
||||
Type: Standard,
|
||||
Key: "Enter",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -675,7 +675,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteCharBackward,
|
||||
Type: Standard,
|
||||
Key: "Backspace",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -683,7 +683,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteCharForward,
|
||||
Type: Standard,
|
||||
Key: "Delete",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: false,
|
||||
},
|
||||
@@ -691,7 +691,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteGroupBackward,
|
||||
Type: Standard,
|
||||
Key: "Mod-Backspace",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -699,7 +699,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteGroupForward,
|
||||
Type: Standard,
|
||||
Key: "Mod-Delete",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -712,7 +712,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorCharLeft,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-b",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -720,7 +720,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectCharLeft,
|
||||
Type: Emacs,
|
||||
Key: "Shift-Ctrl-b",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -728,7 +728,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorCharRight,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-f",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -736,7 +736,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectCharRight,
|
||||
Type: Emacs,
|
||||
Key: "Shift-Ctrl-f",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -746,7 +746,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorLineUp,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-p",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -754,7 +754,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectLineUp,
|
||||
Type: Emacs,
|
||||
Key: "Shift-Ctrl-p",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -762,7 +762,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorLineDown,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-n",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -770,7 +770,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectLineDown,
|
||||
Type: Emacs,
|
||||
Key: "Shift-Ctrl-n",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -780,7 +780,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorLineStart,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-a",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -788,7 +788,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectLineStart,
|
||||
Type: Emacs,
|
||||
Key: "Shift-Ctrl-a",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -796,7 +796,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorLineEnd,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-e",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -804,7 +804,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SelectLineEnd,
|
||||
Type: Emacs,
|
||||
Key: "Shift-Ctrl-e",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -814,7 +814,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorPageDown,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-v",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -822,7 +822,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: CursorPageUp,
|
||||
Type: Emacs,
|
||||
Key: "Alt-v",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -832,7 +832,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteCharForward,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-d",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -840,7 +840,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteCharBackward,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-h",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -848,7 +848,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteToLineEnd,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-k",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -856,7 +856,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: DeleteGroupBackward,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-Alt-h",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -864,7 +864,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: SplitLine,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-o",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -872,7 +872,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockTransposeChars,
|
||||
Type: Emacs,
|
||||
Key: "Ctrl-t",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -882,7 +882,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockSelectAll,
|
||||
Type: Emacs,
|
||||
Key: "Mod-Shift-a",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
@@ -890,7 +890,7 @@ func NewDefaultKeyBindings() []KeyBinding {
|
||||
Name: BlockPaste,
|
||||
Type: Emacs,
|
||||
Key: "Mod-Shift-v",
|
||||
Extension: defaultExtension,
|
||||
Extension: DefaultExtension,
|
||||
Enabled: true,
|
||||
PreventDefault: true,
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"voidraft/internal/models"
|
||||
|
||||
"voidraft/internal/models/ent"
|
||||
"voidraft/internal/models/ent/extension"
|
||||
"voidraft/internal/models/ent/keybinding"
|
||||
"voidraft/internal/models/schema/mixin"
|
||||
|
||||
@@ -112,45 +113,74 @@ func (s *KeyBindingService) SyncKeyBindings(ctx context.Context) error {
|
||||
|
||||
// GetKeyBindings 根据类型获取快捷键
|
||||
func (s *KeyBindingService) GetKeyBindings(ctx context.Context, kbType models.KeyBindingType) ([]*ent.KeyBinding, error) {
|
||||
if kbType == models.Standard {
|
||||
// Standard 模式:只返回 type=standard 且 enabled=true
|
||||
return s.db.Client.KeyBinding.Query().
|
||||
Where(
|
||||
keybinding.Type(string(kbType)),
|
||||
keybinding.Enabled(true),
|
||||
).
|
||||
All(ctx)
|
||||
}
|
||||
|
||||
// Emacs 模式:获取所有 enabled=true 的快捷键
|
||||
allEnabled, err := s.db.Client.KeyBinding.Query().
|
||||
Where(keybinding.Enabled(true)).
|
||||
// 获取启用的扩展名称集合
|
||||
enabledExts, err := s.db.Client.Extension.Query().
|
||||
Where(extension.Enabled(true)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query enabled key bindings error: %w", err)
|
||||
return nil, fmt.Errorf("query enabled extensions error: %w", err)
|
||||
}
|
||||
enabledExtMap := make(map[string]bool, len(enabledExts))
|
||||
for _, ext := range enabledExts {
|
||||
enabledExtMap[ext.Name] = true
|
||||
}
|
||||
|
||||
if kbType == models.Standard {
|
||||
// Standard 模式:返回扩展已启用的快捷键
|
||||
bindings, err := s.db.Client.KeyBinding.Query().
|
||||
Where(keybinding.Type(string(kbType))).
|
||||
Order(ent.Asc(keybinding.FieldID)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return filterByExtension(bindings, enabledExtMap), nil
|
||||
}
|
||||
|
||||
// Emacs 模式:获取所有快捷键
|
||||
allBindings, err := s.db.Client.KeyBinding.Query().
|
||||
Order(ent.Asc(keybinding.FieldID)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query key bindings error: %w", err)
|
||||
}
|
||||
|
||||
// 构建 emacs 快捷键的 name 集合
|
||||
emacsNames := make(map[string]bool)
|
||||
for _, kb := range allEnabled {
|
||||
for _, kb := range allBindings {
|
||||
if kb.Type == string(models.Emacs) {
|
||||
emacsNames[kb.Name] = true
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤:去掉与 emacs 冲突的 standard 快捷键
|
||||
// 过滤:去掉与 emacs 冲突的 standard 快捷键,并过滤扩展未启用的
|
||||
var result []*ent.KeyBinding
|
||||
for _, kb := range allEnabled {
|
||||
// 如果是 standard 类型,且与 emacs 有 name 冲突,则跳过
|
||||
for _, kb := range allBindings {
|
||||
if kb.Type == string(models.Standard) && emacsNames[kb.Name] {
|
||||
continue
|
||||
}
|
||||
// editor 扩展始终包含,不检查启用状态
|
||||
if kb.Extension != models.DefaultExtension && !enabledExtMap[kb.Extension] {
|
||||
continue
|
||||
}
|
||||
result = append(result, kb)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// filterByExtension 过滤出扩展已启用的快捷键
|
||||
func filterByExtension(bindings []*ent.KeyBinding, enabledExtMap map[string]bool) []*ent.KeyBinding {
|
||||
result := make([]*ent.KeyBinding, 0, len(bindings))
|
||||
for _, kb := range bindings {
|
||||
// editor 扩展始终包含,不检查启用状态
|
||||
if kb.Extension == models.DefaultExtension || enabledExtMap[kb.Extension] {
|
||||
result = append(result, kb)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// GetKeyBindingByID 根据ID获取快捷键
|
||||
func (s *KeyBindingService) GetKeyBindingByID(ctx context.Context, id int) (*ent.KeyBinding, error) {
|
||||
kb, err := s.db.Client.KeyBinding.Get(ctx, id)
|
||||
@@ -163,7 +193,7 @@ func (s *KeyBindingService) GetKeyBindingByID(ctx context.Context, id int) (*ent
|
||||
return kb, nil
|
||||
}
|
||||
|
||||
// UpdateKeyBindingKeys 更新快捷键绑定(根据操作系统自动判断更新哪个字段)
|
||||
// UpdateKeyBindingKeys 更新快捷键绑定
|
||||
func (s *KeyBindingService) UpdateKeyBindingKeys(ctx context.Context, id int, key string) error {
|
||||
kb, err := s.GetKeyBindingByID(ctx, id)
|
||||
if err != nil {
|
||||
@@ -204,6 +234,20 @@ func (s *KeyBindingService) UpdateKeyBindingEnabled(ctx context.Context, id int,
|
||||
Exec(ctx)
|
||||
}
|
||||
|
||||
// UpdateKeyBindingPreventDefault 更新快捷键 PreventDefault 状态
|
||||
func (s *KeyBindingService) UpdateKeyBindingPreventDefault(ctx context.Context, id int, preventDefault bool) error {
|
||||
kb, err := s.GetKeyBindingByID(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if kb == nil {
|
||||
return fmt.Errorf("key binding not found: id=%d", id)
|
||||
}
|
||||
return s.db.Client.KeyBinding.UpdateOneID(kb.ID).
|
||||
SetPreventDefault(preventDefault).
|
||||
Exec(ctx)
|
||||
}
|
||||
|
||||
// GetDefaultKeyBindings 获取默认快捷键配置
|
||||
func (s *KeyBindingService) GetDefaultKeyBindings() []models.KeyBinding {
|
||||
return models.NewDefaultKeyBindings()
|
||||
|
||||
Reference in New Issue
Block a user