Merge branch 'lazarus-IDE/ToolbarsShortCuts'

This commit is contained in:
Juha 2024-10-27 13:00:27 +02:00
commit 7123dc549d
5 changed files with 38 additions and 44 deletions

View File

@ -880,6 +880,9 @@ function RegisterIDECommandScope(const Name: string): TIDECommandScope;
procedure CreateStandardIDECommandScopes;
function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String;
function KeyValuesToCaptionStr(const ShortcutA, ShortcutB: TIDEShortCut; Brackets: Char = '['): String;
function CompareIDEShortCuts(Data1, Data2: Pointer): integer;
function CompareIDEShortCutKey1s(Data1, Data2: Pointer): integer;
function IdentToIDECommand(const Ident: string; var Cmd: longint): boolean;
@ -955,6 +958,37 @@ begin
IDECmdScopeObjectInspectorOnly:=RegisterIDECommandScope('ObjectInspectorOnly');
end;
function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String;
begin
Result := KeyAndShiftStateToKeyString(Key.Key1, Key.Shift1);
if Key.Key2 <> VK_UNKNOWN then
Result := Result + ', ' + KeyAndShiftStateToKeyString(Key.Key2, Key.Shift2);
end;
function KeyValuesToCaptionStr(const ShortcutA, ShortcutB: TIDEShortCut; Brackets: Char): String;
//
function GetShortCut(aShortCut: TIDEShortCut): String;
begin
Result := KeyAndShiftStateToEditorKeyString(aShortCut);
if Brackets = '[' then
Result := '[' + Result + ']'
else if Brackets = '(' then
Result := '(' + Result + ')'
else if Brackets > #0 then
Result := Brackets + Result + Brackets;
end;
//
begin
if (ShortcutA.Key1 = VK_UNKNOWN) and (ShortcutB.Key1 = VK_UNKNOWN) then
Result := ''
else if ShortcutA.Key1 = VK_UNKNOWN then
Result := GetShortCut(ShortcutB)
else if ShortcutB.Key1 = VK_UNKNOWN then
Result := GetShortCut(ShortcutA)
else
Result := GetShortCut(ShortcutA) + ' / ' + GetShortCut(ShortcutB);
end;
type
// in fpc 2.3.1 TShiftState is declared with {$packset 1}
{$IF sizeof(TShiftState)=2}
@ -1732,9 +1766,9 @@ function TIDESpecialCommand.GetShortcut: String;
begin
Result := '';
if Assigned(FCommand) then
Result := ShortCutToText(FCommand.AsShortCut);
Result := KeyValuesToCaptionStr(FCommand.ShortcutA, FCommand.ShortcutB);
if Result <> '' then
Result := ' (' + Result + ')';
Result := ' ' + Result;
end;
procedure TIDESpecialCommand.SetCaption(aCaption: string);

View File

@ -33,7 +33,7 @@ uses
// SynEdit
SynEdit, SynBeautifier, SynHighlighterPas, SynEditKeyCmds, SynEditTypes,
// IdeIntf
IDEOptionsIntf, IDEOptEditorIntf, IDEUtils, SrcEditorIntf,
IDEOptionsIntf, IDEOptEditorIntf, IDEUtils, SrcEditorIntf, IDECommands,
// IDE
EditorOptions, LazarusIDEStrConsts, KeyMapping,
editor_keymapping_options, editor_general_options;

View File

@ -31,7 +31,7 @@ uses
// LazControls
DividerBevel,
// IDEIntf
EditorSyntaxHighlighterDef, IDEOptionsIntf, IDEOptEditorIntf,
EditorSyntaxHighlighterDef, IDEOptionsIntf, IDEOptEditorIntf, IDECommands,
// SynEdit
SynEdit, SynHighlighterPas, SynEditKeyCmds, SynEditHighlighterFoldBase,
// IDE

View File

@ -232,7 +232,6 @@ type
end;
function IDEShortCutEmpty(const Key: TIDEShortCut): boolean;
function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String;
function EditorCommandToDescriptionString(cmd: word): String;
function EditorMouseCommandToDescriptionString(cmd: TSynEditorMouseCommand): String;
function EditorMouseCommandToConfigString(cmd: TSynEditorMouseCommand): String;
@ -241,8 +240,6 @@ function KeySchemeNameToSchemeType(const SchemeName: string): TKeyMapScheme;
function ShiftStateToCfgStr(Shift: TShiftState): string;
function KeyValuesToCfgStr(const ShortcutA, ShortcutB: TIDEShortCut): string;
function KeyValuesToCaptionStr(const ShortcutA, ShortcutB: TIDEShortCut;
Brackets: Char = '['): String;
function CfgStrToShiftState(const s: string): TShiftState;
function CompareLoadedKeyCommands(Data1, Data2: Pointer): integer;
@ -1002,47 +999,11 @@ begin
Result := '';
end;
function KeyValuesToCaptionStr(const ShortcutA, ShortcutB: TIDEShortCut;
Brackets: Char): String;
function AddBrakets(S: String): String;
begin
if Brackets = '[' then
Result := '[' + S + ']'
else if Brackets = '(' then
Result := '(' + S + ')'
else if Brackets > #0 then
Result := Brackets + S + Brackets
else
Result := S;
end;
begin
Result := '';
if (ShortcutA.Key1 = VK_UNKNOWN) and (ShortcutB.Key1 = VK_UNKNOWN) then
Result := Result{ + lisNone2 }
else
if (ShortcutA.Key1 = VK_UNKNOWN) then
Result := Result + AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutB))
else
if (ShortcutB.Key1 = VK_UNKNOWN) then
Result := Result + AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutA))
else
Result := Result + AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutA))
+ ' '+lisOr+' ' +
AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutB));
end;
function IDEShortCutEmpty(const Key: TIDEShortCut): boolean;
begin
Result:=(Key.Key1=VK_UNKNOWN) and (Key.Key2=VK_UNKNOWN);
end;
function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String;
begin
Result := KeyAndShiftStateToKeyString(Key.Key1, Key.Shift1);
if (Key.Key2 <> VK_UNKNOWN) then
Result := Result + ', ' + KeyAndShiftStateToKeyString(Key.Key2, Key.Shift2);
end;
{ TKeyStrokeList }
procedure TKeyStrokeList.Add(aKeyStroke: TSynEditKeyStroke);

View File

@ -336,7 +336,6 @@ resourcestring
lisMenuInsertCVSKeyword = 'Insert CVS Keyword';
lisMenuInsertGeneral = 'Insert General';
lisGeneral = 'General';
lisOr = 'or';
lisUnitPaths = 'Unit paths';
lisIncludePaths = 'Include paths';
lisSourcePaths = 'Source paths';