mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 14:35:56 +02:00
SynEdit and IDE: handle correctly sequential keymappings where 2nd part is with or without Ctrl modifier
git-svn-id: trunk@40899 -
This commit is contained in:
parent
231283f94b
commit
51a64480ed
@ -1023,19 +1023,23 @@ end;
|
|||||||
function TSynEditKeyStrokes.FindKeycode2(Code1: word; SS1: TShiftState;
|
function TSynEditKeyStrokes.FindKeycode2(Code1: word; SS1: TShiftState;
|
||||||
Code2: word; SS2: TShiftState): integer;
|
Code2: word; SS2: TShiftState): integer;
|
||||||
var
|
var
|
||||||
x: integer;
|
x, Candidate: integer;
|
||||||
begin
|
begin
|
||||||
Result := -1;
|
Result := -1;
|
||||||
for x := 0 to Count-1 do
|
Candidate := -1;
|
||||||
// If ShiftMask2 = [ssCtrl] and shortcut is "Ctrl-X, Y", then both
|
// Use an exact match if found, then use a ShiftMasked match
|
||||||
// "Ctrl-X, Y" and "Ctrl-X, Ctrl-Y" are accepted. The second CTRL is ignored.
|
for x := 0 to Count-1 do begin
|
||||||
with Items[x] do
|
with Items[x] do
|
||||||
if (Key = Code1) and (Shift = SS1 - ShiftMask)
|
if (Key = Code1) and (Key2 = Code2) then
|
||||||
and (Key2 = Code2) and (Shift2 = SS2 - ShiftMask2) then
|
|
||||||
begin
|
begin
|
||||||
Result := x;
|
if (Shift = SS1) and (Shift2 = SS2) then
|
||||||
break;
|
Exit(x) // Found exact match
|
||||||
|
else
|
||||||
|
if (Shift = SS1-ShiftMask) and (Shift2 = SS2-ShiftMask2) and (Candidate = -1) then
|
||||||
|
Candidate := x; // Found ShiftMasked match
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
Result := Candidate; // Can be -1 or a ShiftMasked match
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynEditKeyStrokes.FindKeycode2Start(Code: word; SS: TShiftState): integer;
|
function TSynEditKeyStrokes.FindKeycode2Start(Code: word; SS: TShiftState): integer;
|
||||||
|
@ -734,7 +734,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function FindKeymapConflicts(Keymap: TKeyCommandRelationList;
|
function FindKeymapConflicts(Keymap: TKeyCommandRelationList;
|
||||||
Protocol: TStrings; out Index1,Index2:integer):integer;
|
Protocol: TStrings; out Index1,Index2: integer): integer;
|
||||||
// 0 = ok, no errors
|
// 0 = ok, no errors
|
||||||
// >0 number of errors found
|
// >0 number of errors found
|
||||||
var
|
var
|
||||||
@ -749,25 +749,13 @@ var
|
|||||||
|
|
||||||
procedure Check(const ShortCut1, ShortCut2: TIDEShortCut);
|
procedure Check(const ShortCut1, ShortCut2: TIDEShortCut);
|
||||||
// check if ShortCut1 hides ShortCut2
|
// check if ShortCut1 hides ShortCut2
|
||||||
var
|
|
||||||
sc1EffShift2, sc2EffShift2: TShiftState;
|
|
||||||
begin
|
begin
|
||||||
if (ShortCut1.Key1=VK_UNKNOWN) then exit;
|
if (ShortCut1.Key1=VK_UNKNOWN)
|
||||||
if (ShortCut1.Key1<>ShortCut2.Key1) or (ShortCut1.Shift1<>ShortCut2.Shift1)
|
or (ShortCut1.Key1<>ShortCut2.Key1)
|
||||||
then exit;
|
or (ShortCut1.Shift1<>ShortCut2.Shift1) then exit; // first keys differ
|
||||||
// first key fits
|
|
||||||
|
|
||||||
// Make CTRL-Q S into CTRL-Q CTRL-S for check, since both work the same
|
|
||||||
sc1EffShift2:= ShortCut1.Shift2;
|
|
||||||
if( (ShortCut1.Shift1=[ssCtrl]) and (sc1EffShift2 = [])) then
|
|
||||||
sc1EffShift2:= [ssCtrl];
|
|
||||||
|
|
||||||
sc2EffShift2:= ShortCut2.Shift2;
|
|
||||||
if( (ShortCut2.Shift1=[ssCtrl]) and (sc2EffShift2 = [])) then
|
|
||||||
sc2EffShift2:= [ssCtrl];
|
|
||||||
|
|
||||||
if (ShortCut1.Key2=VK_UNKNOWN) or (ShortCut2.Key2=VK_UNKNOWN)
|
if (ShortCut1.Key2=VK_UNKNOWN) or (ShortCut2.Key2=VK_UNKNOWN)
|
||||||
or ((ShortCut1.Key2=ShortCut2.Key2) and (sc1EffShift2=sc2EffShift2))
|
or ((ShortCut1.Key2=ShortCut2.Key2) and (ShortCut1.Shift2=ShortCut2.Shift2))
|
||||||
then begin
|
then begin
|
||||||
// conflict found
|
// conflict found
|
||||||
if Result=0 then begin
|
if Result=0 then begin
|
||||||
@ -800,10 +788,6 @@ begin
|
|||||||
Key1:=Keymap[a];
|
Key1:=Keymap[a];
|
||||||
for b:=a+1 to Keymap.Count-1 do begin
|
for b:=a+1 to Keymap.Count-1 do begin
|
||||||
Key2:=Keymap[b];
|
Key2:=Keymap[b];
|
||||||
{if (Key2.Command=ecConfigBuildLazarus)
|
|
||||||
and (Key1.Command=ecFindNext) then begin
|
|
||||||
debugln('FindKeymapConflicts ',dbgs(Key1.Category.ScopeIntersects(Key2.Category.Scope)),' ',dbgsName(Key1.Category.Scope),' ',dbgsName(Key2.Category.Scope));
|
|
||||||
end;}
|
|
||||||
if (not Key1.Category.ScopeIntersects(Key2.Category.Scope)) then
|
if (not Key1.Category.ScopeIntersects(Key2.Category.Scope)) then
|
||||||
continue;
|
continue;
|
||||||
Check(Key1.ShortcutA,Key2.ShortcutA);
|
Check(Key1.ShortcutA,Key2.ShortcutA);
|
||||||
|
Loading…
Reference in New Issue
Block a user