From 9de423baedf4518507fd5c68b3fbe6bb6875c2a8 Mon Sep 17 00:00:00 2001 From: n7800 <14154601-n7800@users.noreply.gitlab.com> Date: Sat, 26 Oct 2024 02:03:49 +0500 Subject: [PATCH] IDE: Refactoring the KeyValuesToCaptionStr function of the IdeCommands unit --- components/ideintf/idecommands.pas | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/components/ideintf/idecommands.pas b/components/ideintf/idecommands.pas index e60a967a70..71566ac14c 100644 --- a/components/ideintf/idecommands.pas +++ b/components/ideintf/idecommands.pas @@ -966,31 +966,27 @@ begin end; function KeyValuesToCaptionStr(const ShortcutA, ShortcutB: TIDEShortCut; Brackets: Char): String; - function AddBrakets(S: String): String; + // + function GetShortCut(aShortCut: TIDEShortCut): String; begin + Result := KeyAndShiftStateToEditorKeyString(aShortCut); if Brackets = '[' then - Result := '[' + S + ']' + Result := '[' + Result + ']' else if Brackets = '(' then - Result := '(' + S + ')' + Result := '(' + Result + ')' else if Brackets > #0 then - Result := Brackets + S + Brackets - else - Result := S; + Result := Brackets + Result + Brackets; end; + // begin - Result := ''; if (ShortcutA.Key1 = VK_UNKNOWN) and (ShortcutB.Key1 = VK_UNKNOWN) then - Result := Result{ + lisNone2 } + Result := '' + else if ShortcutA.Key1 = VK_UNKNOWN then + Result := GetShortCut(ShortcutB) + else if ShortcutB.Key1 = VK_UNKNOWN then + Result := GetShortCut(ShortcutA) 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)) - + ' / ' + - AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutB)); + Result := GetShortCut(ShortcutA) + ' / ' + GetShortCut(ShortcutB); end; type