🎨 Updated
This commit is contained in:
@@ -453,11 +453,6 @@ export class HotkeyCombo {
|
|||||||
* KeyBinding 单个快捷键绑定
|
* KeyBinding 单个快捷键绑定
|
||||||
*/
|
*/
|
||||||
export class KeyBinding {
|
export class KeyBinding {
|
||||||
/**
|
|
||||||
* 快捷键唯一标识
|
|
||||||
*/
|
|
||||||
"id": string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快捷键动作
|
* 快捷键动作
|
||||||
*/
|
*/
|
||||||
@@ -490,9 +485,6 @@ export class KeyBinding {
|
|||||||
|
|
||||||
/** Creates a new KeyBinding instance. */
|
/** Creates a new KeyBinding instance. */
|
||||||
constructor($$source: Partial<KeyBinding> = {}) {
|
constructor($$source: Partial<KeyBinding> = {}) {
|
||||||
if (!("id" in $$source)) {
|
|
||||||
this["id"] = "";
|
|
||||||
}
|
|
||||||
if (!("action" in $$source)) {
|
if (!("action" in $$source)) {
|
||||||
this["action"] = ("" as KeyBindingAction);
|
this["action"] = ("" as KeyBindingAction);
|
||||||
}
|
}
|
||||||
|
@@ -17,16 +17,16 @@ import * as models$0 from "../models/models.js";
|
|||||||
/**
|
/**
|
||||||
* DisableKeyBinding 禁用快捷键
|
* DisableKeyBinding 禁用快捷键
|
||||||
*/
|
*/
|
||||||
export function DisableKeyBinding(id: string): Promise<void> & { cancel(): void } {
|
export function DisableKeyBinding(action: models$0.KeyBindingAction): Promise<void> & { cancel(): void } {
|
||||||
let $resultPromise = $Call.ByID(1594003006, id) as any;
|
let $resultPromise = $Call.ByID(1594003006, action) as any;
|
||||||
return $resultPromise;
|
return $resultPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EnableKeyBinding 启用快捷键
|
* EnableKeyBinding 启用快捷键
|
||||||
*/
|
*/
|
||||||
export function EnableKeyBinding(id: string): Promise<void> & { cancel(): void } {
|
export function EnableKeyBinding(action: models$0.KeyBindingAction): Promise<void> & { cancel(): void } {
|
||||||
let $resultPromise = $Call.ByID(1462644129, id) as any;
|
let $resultPromise = $Call.ByID(1462644129, action) as any;
|
||||||
return $resultPromise;
|
return $resultPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,6 @@ export function GetKeyBindingByAction(action: models$0.KeyBindingAction): Promis
|
|||||||
return $typingPromise;
|
return $typingPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* GetKeyBindingByID 根据ID获取快捷键
|
|
||||||
*/
|
|
||||||
export function GetKeyBindingByID(id: string): Promise<models$0.KeyBinding | null> & { cancel(): void } {
|
|
||||||
let $resultPromise = $Call.ByID(1578192526, id) as any;
|
|
||||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
|
||||||
return $$createType2($result);
|
|
||||||
}) as any;
|
|
||||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
|
||||||
return $typingPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetKeyBindingCategories 获取所有快捷键分类
|
* GetKeyBindingCategories 获取所有快捷键分类
|
||||||
*/
|
*/
|
||||||
@@ -157,16 +145,16 @@ export function ResetAllKeyBindings(): Promise<void> & { cancel(): void } {
|
|||||||
/**
|
/**
|
||||||
* ResetKeyBinding 重置快捷键到默认值
|
* ResetKeyBinding 重置快捷键到默认值
|
||||||
*/
|
*/
|
||||||
export function ResetKeyBinding(id: string): Promise<void> & { cancel(): void } {
|
export function ResetKeyBinding(action: models$0.KeyBindingAction): Promise<void> & { cancel(): void } {
|
||||||
let $resultPromise = $Call.ByID(3466323405, id) as any;
|
let $resultPromise = $Call.ByID(3466323405, action) as any;
|
||||||
return $resultPromise;
|
return $resultPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateKeyBinding 更新快捷键
|
* UpdateKeyBinding 更新快捷键
|
||||||
*/
|
*/
|
||||||
export function UpdateKeyBinding(id: string, newKey: string): Promise<void> & { cancel(): void } {
|
export function UpdateKeyBinding(action: models$0.KeyBindingAction, newKey: string): Promise<void> & { cancel(): void } {
|
||||||
let $resultPromise = $Call.ByID(1469368983, id, newKey) as any;
|
let $resultPromise = $Call.ByID(1469368983, action, newKey) as any;
|
||||||
return $resultPromise;
|
return $resultPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@ import "time"
|
|||||||
|
|
||||||
// KeyBinding 单个快捷键绑定
|
// KeyBinding 单个快捷键绑定
|
||||||
type KeyBinding struct {
|
type KeyBinding struct {
|
||||||
ID string `json:"id"` // 快捷键唯一标识
|
|
||||||
Action KeyBindingAction `json:"action"` // 快捷键动作
|
Action KeyBindingAction `json:"action"` // 快捷键动作
|
||||||
Category KeyBindingCategory `json:"category"` // 快捷键分类
|
Category KeyBindingCategory `json:"category"` // 快捷键分类
|
||||||
Scope KeyBindingScope `json:"scope"` // 快捷键作用域
|
Scope KeyBindingScope `json:"scope"` // 快捷键作用域
|
||||||
@@ -116,7 +115,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
return []KeyBinding{
|
return []KeyBinding{
|
||||||
// 搜索相关快捷键
|
// 搜索相关快捷键
|
||||||
{
|
{
|
||||||
ID: "search.show",
|
|
||||||
Action: ActionShowSearch,
|
Action: ActionShowSearch,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeGlobal,
|
Scope: ScopeGlobal,
|
||||||
@@ -125,7 +123,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.hide",
|
|
||||||
Action: ActionHideSearch,
|
Action: ActionHideSearch,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -134,7 +131,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.findNext",
|
|
||||||
Action: ActionFindNext,
|
Action: ActionFindNext,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -143,7 +139,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.findPrevious",
|
|
||||||
Action: ActionFindPrevious,
|
Action: ActionFindPrevious,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -152,7 +147,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.showReplace",
|
|
||||||
Action: ActionShowReplace,
|
Action: ActionShowReplace,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -161,7 +155,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.replaceAll",
|
|
||||||
Action: ActionReplaceAll,
|
Action: ActionReplaceAll,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -170,7 +163,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.toggleCase",
|
|
||||||
Action: ActionToggleCase,
|
Action: ActionToggleCase,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -179,7 +171,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.toggleWholeWord",
|
|
||||||
Action: ActionToggleWholeWord,
|
Action: ActionToggleWholeWord,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -188,7 +179,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "search.toggleRegex",
|
|
||||||
Action: ActionToggleRegex,
|
Action: ActionToggleRegex,
|
||||||
Category: CategorySearch,
|
Category: CategorySearch,
|
||||||
Scope: ScopeSearch,
|
Scope: ScopeSearch,
|
||||||
@@ -199,7 +189,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
|
|
||||||
// 编辑相关快捷键
|
// 编辑相关快捷键
|
||||||
{
|
{
|
||||||
ID: "edit.selectAll",
|
|
||||||
Action: ActionSelectAll,
|
Action: ActionSelectAll,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -208,7 +197,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.copy",
|
|
||||||
Action: ActionCopy,
|
Action: ActionCopy,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -217,7 +205,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.cut",
|
|
||||||
Action: ActionCut,
|
Action: ActionCut,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -226,7 +213,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.paste",
|
|
||||||
Action: ActionPaste,
|
Action: ActionPaste,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -235,7 +221,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.undo",
|
|
||||||
Action: ActionUndo,
|
Action: ActionUndo,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -244,7 +229,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.redo",
|
|
||||||
Action: ActionRedo,
|
Action: ActionRedo,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -253,7 +237,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.duplicateLine",
|
|
||||||
Action: ActionDuplicateLine,
|
Action: ActionDuplicateLine,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -262,7 +245,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.deleteLine",
|
|
||||||
Action: ActionDeleteLine,
|
Action: ActionDeleteLine,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -271,7 +253,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.moveLineUp",
|
|
||||||
Action: ActionMoveLineUp,
|
Action: ActionMoveLineUp,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -280,7 +261,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.moveLineDown",
|
|
||||||
Action: ActionMoveLineDown,
|
Action: ActionMoveLineDown,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -289,7 +269,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.toggleComment",
|
|
||||||
Action: ActionToggleComment,
|
Action: ActionToggleComment,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -298,7 +277,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.indent",
|
|
||||||
Action: ActionIndent,
|
Action: ActionIndent,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -307,7 +285,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "edit.outdent",
|
|
||||||
Action: ActionOutdent,
|
Action: ActionOutdent,
|
||||||
Category: CategoryEdit,
|
Category: CategoryEdit,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -318,7 +295,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
|
|
||||||
// 代码块相关快捷键
|
// 代码块相关快捷键
|
||||||
{
|
{
|
||||||
ID: "codeblock.new",
|
|
||||||
Action: ActionNewCodeBlock,
|
Action: ActionNewCodeBlock,
|
||||||
Category: CategoryCodeBlock,
|
Category: CategoryCodeBlock,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -327,7 +303,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "codeblock.delete",
|
|
||||||
Action: ActionDeleteCodeBlock,
|
Action: ActionDeleteCodeBlock,
|
||||||
Category: CategoryCodeBlock,
|
Category: CategoryCodeBlock,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -336,7 +311,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "codeblock.select",
|
|
||||||
Action: ActionSelectCodeBlock,
|
Action: ActionSelectCodeBlock,
|
||||||
Category: CategoryCodeBlock,
|
Category: CategoryCodeBlock,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -345,7 +319,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "codeblock.format",
|
|
||||||
Action: ActionFormatCode,
|
Action: ActionFormatCode,
|
||||||
Category: CategoryCodeBlock,
|
Category: CategoryCodeBlock,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -354,7 +327,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "codeblock.changeLanguage",
|
|
||||||
Action: ActionChangeLanguage,
|
Action: ActionChangeLanguage,
|
||||||
Category: CategoryCodeBlock,
|
Category: CategoryCodeBlock,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -365,7 +337,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
|
|
||||||
// 导航相关快捷键
|
// 导航相关快捷键
|
||||||
{
|
{
|
||||||
ID: "navigation.goToLine",
|
|
||||||
Action: ActionGoToLine,
|
Action: ActionGoToLine,
|
||||||
Category: CategoryNavigation,
|
Category: CategoryNavigation,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -374,7 +345,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "navigation.foldAll",
|
|
||||||
Action: ActionFoldAll,
|
Action: ActionFoldAll,
|
||||||
Category: CategoryNavigation,
|
Category: CategoryNavigation,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -383,7 +353,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "navigation.unfoldAll",
|
|
||||||
Action: ActionUnfoldAll,
|
Action: ActionUnfoldAll,
|
||||||
Category: CategoryNavigation,
|
Category: CategoryNavigation,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -392,7 +361,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "navigation.toggleFold",
|
|
||||||
Action: ActionToggleFold,
|
Action: ActionToggleFold,
|
||||||
Category: CategoryNavigation,
|
Category: CategoryNavigation,
|
||||||
Scope: ScopeEditor,
|
Scope: ScopeEditor,
|
||||||
@@ -403,7 +371,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
|
|
||||||
// 视图相关快捷键
|
// 视图相关快捷键
|
||||||
{
|
{
|
||||||
ID: "view.zoomIn",
|
|
||||||
Action: ActionZoomIn,
|
Action: ActionZoomIn,
|
||||||
Category: CategoryView,
|
Category: CategoryView,
|
||||||
Scope: ScopeGlobal,
|
Scope: ScopeGlobal,
|
||||||
@@ -412,7 +379,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "view.zoomOut",
|
|
||||||
Action: ActionZoomOut,
|
Action: ActionZoomOut,
|
||||||
Category: CategoryView,
|
Category: CategoryView,
|
||||||
Scope: ScopeGlobal,
|
Scope: ScopeGlobal,
|
||||||
@@ -421,7 +387,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "view.resetZoom",
|
|
||||||
Action: ActionResetZoom,
|
Action: ActionResetZoom,
|
||||||
Category: CategoryView,
|
Category: CategoryView,
|
||||||
Scope: ScopeGlobal,
|
Scope: ScopeGlobal,
|
||||||
@@ -430,7 +395,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "view.toggleMinimap",
|
|
||||||
Action: ActionToggleMinimap,
|
Action: ActionToggleMinimap,
|
||||||
Category: CategoryView,
|
Category: CategoryView,
|
||||||
Scope: ScopeGlobal,
|
Scope: ScopeGlobal,
|
||||||
@@ -439,7 +403,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
IsDefault: true,
|
IsDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "view.toggleLineNumbers",
|
|
||||||
Action: ActionToggleLineNumbers,
|
Action: ActionToggleLineNumbers,
|
||||||
Category: CategoryView,
|
Category: CategoryView,
|
||||||
Scope: ScopeGlobal,
|
Scope: ScopeGlobal,
|
||||||
@@ -450,7 +413,6 @@ func NewDefaultKeyBindings() []KeyBinding {
|
|||||||
|
|
||||||
// 文件相关快捷键
|
// 文件相关快捷键
|
||||||
{
|
{
|
||||||
ID: "file.save",
|
|
||||||
Action: ActionSave,
|
Action: ActionSave,
|
||||||
Category: CategoryFile,
|
Category: CategoryFile,
|
||||||
Scope: ScopeGlobal,
|
Scope: ScopeGlobal,
|
||||||
|
@@ -26,14 +26,14 @@ type KeyBindingService struct {
|
|||||||
// KeyBindingError 快捷键错误
|
// KeyBindingError 快捷键错误
|
||||||
type KeyBindingError struct {
|
type KeyBindingError struct {
|
||||||
Operation string // 操作名称
|
Operation string // 操作名称
|
||||||
KeyID string // 快捷键ID
|
Action string // 快捷键Action
|
||||||
Err error // 原始错误
|
Err error // 原始错误
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error 实现error接口
|
// Error 实现error接口
|
||||||
func (e *KeyBindingError) Error() string {
|
func (e *KeyBindingError) Error() string {
|
||||||
if e.KeyID != "" {
|
if e.Action != "" {
|
||||||
return fmt.Sprintf("keybinding error during %s for key %s: %v", e.Operation, e.KeyID, e.Err)
|
return fmt.Sprintf("keybinding error during %s for action %s: %v", e.Operation, e.Action, e.Err)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("keybinding error during %s: %v", e.Operation, e.Err)
|
return fmt.Sprintf("keybinding error during %s: %v", e.Operation, e.Err)
|
||||||
}
|
}
|
||||||
@@ -245,29 +245,6 @@ func (kbs *KeyBindingService) GetKeyBindingsByScope(scope models.KeyBindingScope
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetKeyBindingByID 根据ID获取快捷键
|
|
||||||
func (kbs *KeyBindingService) GetKeyBindingByID(id string) (*models.KeyBinding, error) {
|
|
||||||
kbs.mu.RLock()
|
|
||||||
defer kbs.mu.RUnlock()
|
|
||||||
|
|
||||||
allKeyBindings, err := kbs.GetAllKeyBindings()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, kb := range allKeyBindings {
|
|
||||||
if kb.ID == id {
|
|
||||||
return &kb, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, &KeyBindingError{
|
|
||||||
Operation: "get_keybinding_by_id",
|
|
||||||
KeyID: id,
|
|
||||||
Err: errors.New("keybinding not found"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetKeyBindingByAction 根据动作获取快捷键
|
// GetKeyBindingByAction 根据动作获取快捷键
|
||||||
func (kbs *KeyBindingService) GetKeyBindingByAction(action models.KeyBindingAction) (*models.KeyBinding, error) {
|
func (kbs *KeyBindingService) GetKeyBindingByAction(action models.KeyBindingAction) (*models.KeyBinding, error) {
|
||||||
kbs.mu.RLock()
|
kbs.mu.RLock()
|
||||||
@@ -291,7 +268,7 @@ func (kbs *KeyBindingService) GetKeyBindingByAction(action models.KeyBindingActi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateKeyBinding 更新快捷键
|
// UpdateKeyBinding 更新快捷键
|
||||||
func (kbs *KeyBindingService) UpdateKeyBinding(id string, newKey string) error {
|
func (kbs *KeyBindingService) UpdateKeyBinding(action models.KeyBindingAction, newKey string) error {
|
||||||
kbs.mu.Lock()
|
kbs.mu.Lock()
|
||||||
defer kbs.mu.Unlock()
|
defer kbs.mu.Unlock()
|
||||||
|
|
||||||
@@ -299,16 +276,16 @@ func (kbs *KeyBindingService) UpdateKeyBinding(id string, newKey string) error {
|
|||||||
if err := kbs.validateKeyFormat(newKey); err != nil {
|
if err := kbs.validateKeyFormat(newKey); err != nil {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "update_keybinding",
|
Operation: "update_keybinding",
|
||||||
KeyID: id,
|
Action: string(action),
|
||||||
Err: fmt.Errorf("invalid key format: %v", err),
|
Err: fmt.Errorf("invalid key format: %v", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查快捷键冲突
|
// 检查快捷键冲突
|
||||||
if err := kbs.checkKeyConflict(id, newKey); err != nil {
|
if err := kbs.checkKeyConflict(action, newKey); err != nil {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "update_keybinding",
|
Operation: "update_keybinding",
|
||||||
KeyID: id,
|
Action: string(action),
|
||||||
Err: fmt.Errorf("key conflict: %v", err),
|
Err: fmt.Errorf("key conflict: %v", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,13 +293,13 @@ func (kbs *KeyBindingService) UpdateKeyBinding(id string, newKey string) error {
|
|||||||
// 获取当前配置
|
// 获取当前配置
|
||||||
config, err := kbs.GetKeyBindingConfig()
|
config, err := kbs.GetKeyBindingConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &KeyBindingError{Operation: "update_keybinding", KeyID: id, Err: err}
|
return &KeyBindingError{Operation: "update_keybinding", Action: string(action), Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找并更新快捷键
|
// 查找并更新快捷键
|
||||||
found := false
|
found := false
|
||||||
for i, kb := range config.KeyBindings {
|
for i, kb := range config.KeyBindings {
|
||||||
if kb.ID == id {
|
if kb.Action == action {
|
||||||
config.KeyBindings[i].Key = newKey
|
config.KeyBindings[i].Key = newKey
|
||||||
config.KeyBindings[i].IsDefault = false // 标记为非默认
|
config.KeyBindings[i].IsDefault = false // 标记为非默认
|
||||||
found = true
|
found = true
|
||||||
@@ -333,7 +310,7 @@ func (kbs *KeyBindingService) UpdateKeyBinding(id string, newKey string) error {
|
|||||||
if !found {
|
if !found {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "update_keybinding",
|
Operation: "update_keybinding",
|
||||||
KeyID: id,
|
Action: string(action),
|
||||||
Err: errors.New("keybinding not found"),
|
Err: errors.New("keybinding not found"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,38 +320,38 @@ func (kbs *KeyBindingService) UpdateKeyBinding(id string, newKey string) error {
|
|||||||
|
|
||||||
// 保存配置
|
// 保存配置
|
||||||
if err := kbs.saveConfig(config); err != nil {
|
if err := kbs.saveConfig(config); err != nil {
|
||||||
return &KeyBindingError{Operation: "update_keybinding", KeyID: id, Err: err}
|
return &KeyBindingError{Operation: "update_keybinding", Action: string(action), Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
kbs.logger.Info("KeyBinding: Updated keybinding", "id", id, "newKey", newKey)
|
kbs.logger.Info("KeyBinding: Updated keybinding", "action", action, "newKey", newKey)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnableKeyBinding 启用快捷键
|
// EnableKeyBinding 启用快捷键
|
||||||
func (kbs *KeyBindingService) EnableKeyBinding(id string) error {
|
func (kbs *KeyBindingService) EnableKeyBinding(action models.KeyBindingAction) error {
|
||||||
return kbs.setKeyBindingEnabled(id, true)
|
return kbs.setKeyBindingEnabled(action, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableKeyBinding 禁用快捷键
|
// DisableKeyBinding 禁用快捷键
|
||||||
func (kbs *KeyBindingService) DisableKeyBinding(id string) error {
|
func (kbs *KeyBindingService) DisableKeyBinding(action models.KeyBindingAction) error {
|
||||||
return kbs.setKeyBindingEnabled(id, false)
|
return kbs.setKeyBindingEnabled(action, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setKeyBindingEnabled 设置快捷键启用状态
|
// setKeyBindingEnabled 设置快捷键启用状态
|
||||||
func (kbs *KeyBindingService) setKeyBindingEnabled(id string, enabled bool) error {
|
func (kbs *KeyBindingService) setKeyBindingEnabled(action models.KeyBindingAction, enabled bool) error {
|
||||||
kbs.mu.Lock()
|
kbs.mu.Lock()
|
||||||
defer kbs.mu.Unlock()
|
defer kbs.mu.Unlock()
|
||||||
|
|
||||||
// 获取当前配置
|
// 获取当前配置
|
||||||
config, err := kbs.GetKeyBindingConfig()
|
config, err := kbs.GetKeyBindingConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &KeyBindingError{Operation: "set_keybinding_enabled", KeyID: id, Err: err}
|
return &KeyBindingError{Operation: "set_keybinding_enabled", Action: string(action), Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找并更新快捷键
|
// 查找并更新快捷键
|
||||||
found := false
|
found := false
|
||||||
for i, kb := range config.KeyBindings {
|
for i, kb := range config.KeyBindings {
|
||||||
if kb.ID == id {
|
if kb.Action == action {
|
||||||
config.KeyBindings[i].Enabled = enabled
|
config.KeyBindings[i].Enabled = enabled
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
@@ -384,7 +361,7 @@ func (kbs *KeyBindingService) setKeyBindingEnabled(id string, enabled bool) erro
|
|||||||
if !found {
|
if !found {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "set_keybinding_enabled",
|
Operation: "set_keybinding_enabled",
|
||||||
KeyID: id,
|
Action: string(action),
|
||||||
Err: errors.New("keybinding not found"),
|
Err: errors.New("keybinding not found"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -394,19 +371,19 @@ func (kbs *KeyBindingService) setKeyBindingEnabled(id string, enabled bool) erro
|
|||||||
|
|
||||||
// 保存配置
|
// 保存配置
|
||||||
if err := kbs.saveConfig(config); err != nil {
|
if err := kbs.saveConfig(config); err != nil {
|
||||||
return &KeyBindingError{Operation: "set_keybinding_enabled", KeyID: id, Err: err}
|
return &KeyBindingError{Operation: "set_keybinding_enabled", Action: string(action), Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
action := "enabled"
|
status := "enabled"
|
||||||
if !enabled {
|
if !enabled {
|
||||||
action = "disabled"
|
status = "disabled"
|
||||||
}
|
}
|
||||||
kbs.logger.Info("KeyBinding: "+action+" keybinding", "id", id)
|
kbs.logger.Info("KeyBinding: "+status+" keybinding", "action", action)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetKeyBinding 重置快捷键到默认值
|
// ResetKeyBinding 重置快捷键到默认值
|
||||||
func (kbs *KeyBindingService) ResetKeyBinding(id string) error {
|
func (kbs *KeyBindingService) ResetKeyBinding(action models.KeyBindingAction) error {
|
||||||
kbs.mu.Lock()
|
kbs.mu.Lock()
|
||||||
defer kbs.mu.Unlock()
|
defer kbs.mu.Unlock()
|
||||||
|
|
||||||
@@ -414,7 +391,7 @@ func (kbs *KeyBindingService) ResetKeyBinding(id string) error {
|
|||||||
defaultKeyBindings := models.NewDefaultKeyBindings()
|
defaultKeyBindings := models.NewDefaultKeyBindings()
|
||||||
var defaultKeyBinding *models.KeyBinding
|
var defaultKeyBinding *models.KeyBinding
|
||||||
for _, kb := range defaultKeyBindings {
|
for _, kb := range defaultKeyBindings {
|
||||||
if kb.ID == id {
|
if kb.Action == action {
|
||||||
defaultKeyBinding = &kb
|
defaultKeyBinding = &kb
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -423,7 +400,7 @@ func (kbs *KeyBindingService) ResetKeyBinding(id string) error {
|
|||||||
if defaultKeyBinding == nil {
|
if defaultKeyBinding == nil {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "reset_keybinding",
|
Operation: "reset_keybinding",
|
||||||
KeyID: id,
|
Action: string(action),
|
||||||
Err: errors.New("default keybinding not found"),
|
Err: errors.New("default keybinding not found"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,13 +408,13 @@ func (kbs *KeyBindingService) ResetKeyBinding(id string) error {
|
|||||||
// 获取当前配置
|
// 获取当前配置
|
||||||
config, err := kbs.GetKeyBindingConfig()
|
config, err := kbs.GetKeyBindingConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &KeyBindingError{Operation: "reset_keybinding", KeyID: id, Err: err}
|
return &KeyBindingError{Operation: "reset_keybinding", Action: string(action), Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找并重置快捷键
|
// 查找并重置快捷键
|
||||||
found := false
|
found := false
|
||||||
for i, kb := range config.KeyBindings {
|
for i, kb := range config.KeyBindings {
|
||||||
if kb.ID == id {
|
if kb.Action == action {
|
||||||
config.KeyBindings[i].Key = defaultKeyBinding.Key
|
config.KeyBindings[i].Key = defaultKeyBinding.Key
|
||||||
config.KeyBindings[i].Enabled = defaultKeyBinding.Enabled
|
config.KeyBindings[i].Enabled = defaultKeyBinding.Enabled
|
||||||
config.KeyBindings[i].IsDefault = true
|
config.KeyBindings[i].IsDefault = true
|
||||||
@@ -449,7 +426,7 @@ func (kbs *KeyBindingService) ResetKeyBinding(id string) error {
|
|||||||
if !found {
|
if !found {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "reset_keybinding",
|
Operation: "reset_keybinding",
|
||||||
KeyID: id,
|
Action: string(action),
|
||||||
Err: errors.New("keybinding not found"),
|
Err: errors.New("keybinding not found"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -459,10 +436,10 @@ func (kbs *KeyBindingService) ResetKeyBinding(id string) error {
|
|||||||
|
|
||||||
// 保存配置
|
// 保存配置
|
||||||
if err := kbs.saveConfig(config); err != nil {
|
if err := kbs.saveConfig(config); err != nil {
|
||||||
return &KeyBindingError{Operation: "reset_keybinding", KeyID: id, Err: err}
|
return &KeyBindingError{Operation: "reset_keybinding", Action: string(action), Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
kbs.logger.Info("KeyBinding: Reset keybinding to default", "id", id, "key", defaultKeyBinding.Key)
|
kbs.logger.Info("KeyBinding: Reset keybinding to default", "action", action, "key", defaultKeyBinding.Key)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,15 +515,15 @@ func (kbs *KeyBindingService) validateKeyFormat(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checkKeyConflict 检查快捷键冲突
|
// checkKeyConflict 检查快捷键冲突
|
||||||
func (kbs *KeyBindingService) checkKeyConflict(excludeID, key string) error {
|
func (kbs *KeyBindingService) checkKeyConflict(excludeAction models.KeyBindingAction, key string) error {
|
||||||
allKeyBindings, err := kbs.GetAllKeyBindings()
|
allKeyBindings, err := kbs.GetAllKeyBindings()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, kb := range allKeyBindings {
|
for _, kb := range allKeyBindings {
|
||||||
if kb.ID != excludeID && kb.Key == key && kb.Enabled {
|
if kb.Action != excludeAction && kb.Key == key && kb.Enabled {
|
||||||
return fmt.Errorf("key %s is already used by %s", key, kb.ID)
|
return fmt.Errorf("key %s is already used by %s", key, kb.Action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,23 +570,23 @@ func (kbs *KeyBindingService) ImportKeyBindings(keyBindings []models.KeyBinding)
|
|||||||
if err := kbs.validateKeyFormat(kb.Key); err != nil {
|
if err := kbs.validateKeyFormat(kb.Key); err != nil {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "import_keybindings",
|
Operation: "import_keybindings",
|
||||||
KeyID: kb.ID,
|
Action: string(kb.Action),
|
||||||
Err: fmt.Errorf("invalid key format for %s: %v", kb.ID, err),
|
Err: fmt.Errorf("invalid key format for %s: %v", kb.Action, err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查重复的快捷键
|
// 检查重复的快捷键
|
||||||
keyMap := make(map[string]string)
|
keyMap := make(map[string]models.KeyBindingAction)
|
||||||
for _, kb := range keyBindings {
|
for _, kb := range keyBindings {
|
||||||
if kb.Enabled {
|
if kb.Enabled {
|
||||||
if existingID, exists := keyMap[kb.Key]; exists {
|
if existingAction, exists := keyMap[kb.Key]; exists {
|
||||||
return &KeyBindingError{
|
return &KeyBindingError{
|
||||||
Operation: "import_keybindings",
|
Operation: "import_keybindings",
|
||||||
Err: fmt.Errorf("duplicate key %s found in %s and %s", kb.Key, existingID, kb.ID),
|
Err: fmt.Errorf("duplicate key %s found in %s and %s", kb.Key, existingAction, kb.Action),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
keyMap[kb.Key] = kb.ID
|
keyMap[kb.Key] = kb.Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user