📄 syneditkeycmdseditor.pas
字号:
else TmpCommand := EditorCommandToCodeString(TSynEditKeyStrokes(NewStroke.Collection).Items[KeyLoc].Command);
{$IFDEF SYN_CLX}
Result := MessageDlg(Format(SYNS_DuplicateShortcutMsg,
[QMenus.ShortCutToText(AForm.Keystroke), TmpCommand]),
mtError, [mbOK, mbCancel], 0) = mrOK;
{$ELSE}
Result := MessageDlg(Format(SYNS_DuplicateShortcutMsg,
[Menus.ShortCutToText(AForm.Keystroke), TmpCommand]),
mtError, [mbOK, mbCancel], 0) = mrOK;
{$ENDIF}
NewStroke.Free;
if Result then
Result := AddKeyStroke;
end;
// Some other kind of exception, we don't deal with it...
end;
end;
end;
begin
AForm := TSynEditKeystrokeEditorForm.Create(Self);
with AForm do
try
Caption := 'Add Keystroke';
ExtendedString := self.ExtendedString;
Command := ecNone;
Keystroke := 0;
Keystroke2 := 0;
if AddKeyStroke then
begin
with KeyCmdList.Items.Add do
begin
if FExtended then
Caption := ConvertCodeStringToExtended(EditorCommandToCodeString(NewStroke.Command))
else Caption := EditorCommandToCodeString(NewStroke.Command);
if NewStroke.ShortCut = 0 then
SubItems.Add(SYNS_ShortcutNone)
else
if NewStroke.ShortCut2 = 0 then
{$IFDEF SYN_CLX}
SubItems.Add(QMenus.ShortCutToText(NewStroke.ShortCut))
{$ELSE}
SubItems.Add(Menus.ShortCutToText(NewStroke.ShortCut))
{$ENDIF}
else
{$IFDEF SYN_CLX}
SubItems.Add(QMenus.ShortCutToText(NewStroke.ShortCut)+ ' '+
QMenus.ShortCutToText(NewStroke.ShortCut2));
{$ELSE}
SubItems.Add(Menus.ShortCutToText(NewStroke.ShortCut)+ ' '+
Menus.ShortCutToText(NewStroke.ShortCut2));
{$ENDIF}
end;
end;
finally
AForm.Free;
end;
end;
procedure TSynEditKeystrokesEditorForm.btnEditClick(Sender: TObject);
var
SelItem: TListItem;
OldShortcut: TShortcut;
OldShortcut2: TShortcut;
AForm : TSynEditKeystrokeEditorForm;
function EditKeyStroke: Boolean;
VAR KeyLoc : Integer;
TmpCommand: String;
begin
Result := False;
KeyLoc := 0;
if AForm.ShowModal = mrOK then
begin
Result := True;
OldShortCut := FKeystrokes[SelItem.Index].ShortCut;
OldShortCut2 := FKeystrokes[SelItem.Index].ShortCut2;
try
KeyLoc := TSynEditKeyStrokes(FKeystrokes[SelItem.Index].Collection).FindShortcut2(AForm.Keystroke, AForm.Keystroke2);
FKeystrokes[SelItem.Index].Command := AForm.Command;
FKeystrokes[SelItem.Index].ShortCut := AForm.Keystroke;
FKeystrokes[SelItem.Index].ShortCut2 := AForm.Keystroke2;
except
on ESynKeyError do
begin
// Shortcut already exists in the collection!
if FExtended then
TmpCommand := ConvertCodeStringToExtended(EditorCommandToCodeString(TSynEditKeyStrokes(FKeystrokes[SelItem.Index].Collection).Items[KeyLoc].Command))
else TmpCommand := EditorCommandToCodeString(TSynEditKeyStrokes(FKeystrokes[SelItem.Index].Collection).Items[KeyLoc].Command);
{$IFDEF SYN_CLX}
Result := MessageDlg(Format(SYNS_DuplicateShortcutMsg,
[QMenus.ShortCutToText(AForm.Keystroke), TmpCommand]),
mtError, [mbOK, mbCancel], 0) = mrOK;
{$ELSE}
Result := MessageDlg(Format(SYNS_DuplicateShortcutMsg,
[Menus.ShortCutToText(AForm.Keystroke), TmpCommand]),
mtError, [mbOK, mbCancel], 0) = mrOK;
{$ENDIF}
FKeystrokes[SelItem.Index].ShortCut := OldShortCut;
FKeystrokes[SelItem.Index].ShortCut2 := OldShortCut2;
if Result then
Result := EditKeyStroke;
end;
// Some other kind of exception, we don't deal with it...
end;
end;
(*
if ShowModal = mrOK then
begin
try
except
on ESynKeyError do
begin
// Shortcut already exists in the collection!
{$IFDEF SYN_KYLIX}
MessageDlg(Format(SYNS_DuplicateShortcutMsg2,
[QMenus.ShortCutToText(Keystroke)]), mtError, [mbOK], 0);
{$ELSE}
MessageDlg(Format(SYNS_DuplicateShortcutMsg2,
[Menus.ShortCutToText(Keystroke)]), mtError, [mbOK], 0);
{$ENDIF}
end;
// Some other kind of exception, we don't deal with it...
end;
*)
end;
begin
SelItem := KeyCmdList.Selected;
if SelItem = NIL then
begin
{$IFDEF SYN_CLX}
QControls.Beep;
{$ELSE}
MessageBeep(1);
{$ENDIF}
exit;
end;
AForm := TSynEditKeystrokeEditorForm.Create(Self);
with AForm do
try
ExtendedString := self.ExtendedString;
Command := FKeystrokes[SelItem.Index].Command;
Keystroke := FKeystrokes[SelItem.Index].Shortcut;
Keystroke2 := FKeystrokes[SelItem.Index].Shortcut2;
if EditKeyStroke then
begin
KeyCmdList.Items.BeginUpdate;
try
with SelItem do
begin
if FExtended then
Caption := ConvertCodeStringToExtended(EditorCommandToCodeString(FKeystrokes[Index].Command))
else Caption := EditorCommandToCodeString(FKeystrokes[Index].Command);
if FKeystrokes[Index].ShortCut = 0 then
SubItems[0] := SYNS_ShortcutNone
else
if FKeystrokes[Index].ShortCut2 = 0 then
{$IFDEF SYN_CLX}
SubItems[0] := QMenus.ShortCutToText(FKeystrokes[Index].ShortCut)
{$ELSE}
SubItems[0] := Menus.ShortCutToText(FKeystrokes[Index].ShortCut)
{$ENDIF}
else
{$IFDEF SYN_CLX}
SubItems[0] := QMenus.ShortCutToText(FKeystrokes[Index].ShortCut)
+ ' ' + QMenus.ShortCutToText(FKeystrokes[Index].ShortCut2);
{$ELSE}
SubItems[0] := Menus.ShortCutToText(FKeystrokes[Index].ShortCut)
+ ' ' + Menus.ShortCutToText(FKeystrokes[Index].ShortCut2);
{$ENDIF}
end;
finally
KeyCmdList.Items.EndUpdate;
end;
end;
finally
AForm.Free;
end;
end; //DDH 10/16/01 End (reworked procs)
procedure TSynEditKeystrokesEditorForm.btnDeleteClick(Sender: TObject);
var
SelItem: TListItem;
begin
SelItem := KeyCmdList.Selected;
if SelItem = NIL then
begin
{$IFDEF SYN_CLX}
QControls.Beep;
{$ELSE}
MessageBeep(1);
{$ENDIF}
exit;
end;
FKeystrokes[SelItem.Index].Free;
KeyCmdList.Items.Delete(SelItem.Index);
end;
procedure TSynEditKeystrokesEditorForm.btnClearClick(Sender: TObject);
begin
FKeystrokes.Clear;
KeyCmdList.Items.Clear;
end;
procedure TSynEditKeystrokesEditorForm.btnResetClick(Sender: TObject);
begin
FKeystrokes.ResetDefaults;
UpdateKeystrokesList;
end;
procedure TSynEditKeystrokesEditorForm.FormCreate(Sender: TObject);
begin
{$IFDEF SYN_COMPILER_3_UP}
KeyCmdList.RowSelect := True;
{$ENDIF}
end;
procedure TSynEditKeystrokesEditorForm.btnOKClick(Sender: TObject);
begin
ModalResult := mrOK;
end;
procedure TSynEditKeystrokesEditorForm.btnCancelClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TSynEditKeystrokesEditorForm.KeyCmdListClick(Sender: TObject);
begin
btnEdit.Enabled := Assigned(KeyCmdList.Selected);
btnDelete.Enabled := btnEdit.Enabled;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -