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:
juha 2013-04-27 11:44:35 +00:00
parent 231283f94b
commit 51a64480ed
2 changed files with 17 additions and 29 deletions

View File

@ -1023,19 +1023,23 @@ end;
function TSynEditKeyStrokes.FindKeycode2(Code1: word; SS1: TShiftState;
Code2: word; SS2: TShiftState): integer;
var
x: integer;
x, Candidate: integer;
begin
Result := -1;
for x := 0 to Count-1 do
// If ShiftMask2 = [ssCtrl] and shortcut is "Ctrl-X, Y", then both
// "Ctrl-X, Y" and "Ctrl-X, Ctrl-Y" are accepted. The second CTRL is ignored.
Candidate := -1;
// Use an exact match if found, then use a ShiftMasked match
for x := 0 to Count-1 do begin
with Items[x] do
if (Key = Code1) and (Shift = SS1 - ShiftMask)
and (Key2 = Code2) and (Shift2 = SS2 - ShiftMask2) then
if (Key = Code1) and (Key2 = Code2) then
begin
Result := x;
break;
if (Shift = SS1) and (Shift2 = SS2) then
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;
Result := Candidate; // Can be -1 or a ShiftMasked match
end;
function TSynEditKeyStrokes.FindKeycode2Start(Code: word; SS: TShiftState): integer;

View File

@ -734,7 +734,7 @@ begin
end;
function FindKeymapConflicts(Keymap: TKeyCommandRelationList;
Protocol: TStrings; out Index1,Index2:integer):integer;
Protocol: TStrings; out Index1,Index2: integer): integer;
// 0 = ok, no errors
// >0 number of errors found
var
@ -749,25 +749,13 @@ var
procedure Check(const ShortCut1, ShortCut2: TIDEShortCut);
// check if ShortCut1 hides ShortCut2
var
sc1EffShift2, sc2EffShift2: TShiftState;
begin
if (ShortCut1.Key1=VK_UNKNOWN) then exit;
if (ShortCut1.Key1<>ShortCut2.Key1) or (ShortCut1.Shift1<>ShortCut2.Shift1)
then exit;
// 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.Key1=VK_UNKNOWN)
or (ShortCut1.Key1<>ShortCut2.Key1)
or (ShortCut1.Shift1<>ShortCut2.Shift1) then exit; // first keys differ
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
// conflict found
if Result=0 then begin
@ -800,10 +788,6 @@ begin
Key1:=Keymap[a];
for b:=a+1 to Keymap.Count-1 do begin
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
continue;
Check(Key1.ShortcutA,Key2.ShortcutA);