~ubuntu-branches/ubuntu/vivid/lazarus/vivid

« back to all changes in this revision

Viewing changes to ide/frames/editor_keymapping_options.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Paul Gevers
  • Date: 2014-02-22 10:25:57 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140222102557-ors9d31r84nz31jq
Tags: 1.2~rc2+dfsg-1
[ Abou Al Montacir ]
* New upstream pre-release.
  + Moved ideintf to components directory.
  + Added new package cairocanvas.
* Remove usage of depreciated parameters form of find. (Closes: Bug#724776)
* Bumped standard version to 3.9.5.
* Clean the way handling make files generation and removal.

[ Paul Gevers ]
* Remove nearly obsolete bzip compression for binary packages
  (See https://lists.debian.org/debian-devel/2014/01/msg00542.html)
* Update d/copyright for newly added dir in examples and components
* Update Vcs-* fields with new packaging location
* Update d/watch file to properly (Debian way) change upstreams versions
* Prevent 46MB of package size by sym linking duplicate files
* Patches
  - refresh to remove fuzz
  - add more Lintian found spelling errors
  - new patch to add shbang to two scripts in lazarus-src
* Drop lcl-# from Provides list of lcl-units-#
* Make lazarus-ide-qt4-# an arch all until it really contains stuff
* Make all metapackages arch all as the usecase for arch any doesn't
  seem to warrant the addition archive hit
* Fix permissions of non-scripts in lazarus-src-#

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
  Controls, Dialogs, LCLType, LCLProc, Menus, Buttons, Clipbrd, EditorOptions,
30
30
  LazarusIDEStrConsts, IDEOptionsIntf, IDEImagesIntf, editor_general_options,
31
31
  KeymapSchemeDlg, KeyMapping, IDECommands, KeyMapShortCutDlg, SrcEditorIntf,
32
 
  EditBtn;
 
32
  EditBtn, ExtCtrls;
33
33
 
34
34
type
35
35
 
36
36
  { TEditorKeymappingOptionsFrame }
37
37
 
38
38
  TEditorKeymappingOptionsFrame = class(TAbstractIDEOptionsEditor)
 
39
    BtnPanel: TPanel;
39
40
    ChooseSchemeButton: TBitBtn;
40
41
    ClearButton: TBitBtn;
41
42
    EditButton: TBitBtn;
42
 
    ConsistencyCheckButton: TBitBtn;
43
43
    FilterEdit: TTreeFilterEdit;
44
44
    FindKeyButton: TBitBtn;
45
45
    CommandLabel: TLabel;
 
46
    ConflictsTreeView: TTreeView;
 
47
    KeyMapSplitter: TSplitter;
 
48
    KeyMapTreePanel: TPanel;
46
49
    SchemeLabel: TLabel;
47
50
    ResetKeyFilterBtn: TSpeedButton;
48
51
    TreeView: TTreeView;
50
53
    ClearMenuItem: TMenuItem;
51
54
    PopupMenu1: TPopupMenu;
52
55
    procedure ClearMenuItemClick(Sender: TObject);
 
56
    procedure ConflictsTreeViewMouseDown(Sender: TObject; Button: TMouseButton;
 
57
      Shift: TShiftState; X, Y: Integer);
53
58
    procedure EditButtonClick(Sender: TObject);
54
59
    procedure EditMenuItemClick(Sender: TObject);
55
60
    procedure ChooseSchemeButtonClick(Sender: TObject);
56
61
    procedure ClearButtonClick(Sender: TObject);
57
 
    procedure ConsistencyCheckButtonClick(Sender: TObject);
58
62
    function FilterEditFilterItem(Item: TObject; out Done: Boolean): Boolean;
59
63
    procedure FilterEditKeyPress(Sender: TObject; var Key: char);
60
64
    procedure FindKeyButtonClick(Sender: TObject);
 
65
    procedure OnIdle(Sender: TObject; var Done: Boolean);
61
66
    procedure ResetKeyFilterBtnClick(Sender: TObject);
62
67
    procedure TreeViewDblClick(Sender: TObject);
63
68
    procedure TreeViewKeyPress(Sender: TObject; var Key: char);
65
70
    procedure PopupMenu1Popup(Sender: TObject);
66
71
  private
67
72
    FDialog: TAbstractOptionsEditorDialog;
68
 
    EditingKeyMap: TKeyCommandRelationList;
 
73
    FEditingKeyMap: TKeyCommandRelationList;
 
74
    FIdleConnected: boolean;
69
75
    KeyMapKeyFilter: TIDEShortCut;
70
76
    fModified: Boolean;
71
77
    function GeneralPage: TEditorGeneralOptionsFrame; inline;
72
78
    procedure FillKeyMappingTreeView;
73
79
    procedure EditCommandMapping(ANode: TTreeNode);
 
80
    procedure EditConflict(ANode: TTreeNode);
 
81
    procedure EditCommandRelation(ARelation: TKeyCommandRelation);
74
82
    procedure ClearCommandMapping(ANode: TTreeNode);
75
 
    function KeyMappingRelationToString(Index: Integer): String;
76
 
    function KeyMappingRelationToString(KeyRelation: TKeyCommandRelation): String;
 
83
    procedure ClearConflict(ANode: TTreeNode);
 
84
    procedure ClearCommandRelation(ARelation: TKeyCommandRelation);
 
85
    function KeyMappingRelationToCaption(Index: Integer): String;
 
86
    function KeyMappingRelationToCaption(KeyRelation: TKeyCommandRelation): String;
 
87
    function KeyShortCutToCaption(const aKey: TKeyCommandRelation;
 
88
      const aShortCut: TIDEShortCut): string;
 
89
    function CaptionToKeyMappingRelation(aCaption: string): TKeyCommandRelation;
 
90
    procedure SetIdleConnected(AValue: boolean);
77
91
    procedure UpdateKeyFilterButton;
78
92
    procedure UpdateSchemeLabel;
79
93
  public
85
99
    procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
86
100
    procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
87
101
    class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
 
102
    procedure SelectByIdeCommand(ACmd: word);
 
103
    procedure UpdateTree;
 
104
    procedure UpdateConflictTree;
 
105
    property EditingKeyMap: TKeyCommandRelationList read FEditingKeyMap;
 
106
    property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
88
107
  end;
89
108
 
90
109
implementation
163
182
constructor TEditorKeymappingOptionsFrame.Create(AOwner: TComponent);
164
183
begin
165
184
  inherited Create(AOwner);
166
 
  EditingKeyMap := TKeyCommandRelationList.Create;
 
185
  FEditingKeyMap := TKeyCommandRelationList.Create;
167
186
  EditButton.Enabled:=false;
168
187
  ClearButton.Enabled:=false;
169
188
  fModified:=False;
171
190
 
172
191
destructor TEditorKeymappingOptionsFrame.Destroy;
173
192
begin
174
 
  EditingKeyMap.Free;
 
193
  IdleConnected:=false;
 
194
  FEditingKeyMap.Free;
175
195
  inherited Destroy;
176
196
end;
177
197
 
182
202
  NewScheme := EditorOpts.KeyMappingScheme;
183
203
  if ShowChooseKeySchemeDialog(NewScheme) = mrOk then begin
184
204
    EditorOpts.KeyMappingScheme := NewScheme;
185
 
    EditingKeyMap.LoadScheme(NewScheme);
 
205
    FEditingKeyMap.LoadScheme(NewScheme);
186
206
    FillKeyMappingTreeView;
187
207
    fModified:=False;
188
208
    UpdateSchemeLabel;
 
209
    UpdateConflictTree;
189
210
  end;
190
211
end;
191
212
 
192
213
procedure TEditorKeymappingOptionsFrame.EditButtonClick(Sender: TObject);
193
214
begin
194
 
  EditCommandMapping(TreeView.Selected);
 
215
  EditCommandMapping(TreeView.Selected)
195
216
end;
196
217
 
197
218
procedure TEditorKeymappingOptionsFrame.ClearButtonClick(Sender: TObject);
198
219
begin
199
 
  ClearCommandMapping(TreeView.Selected);
200
 
end;
201
 
 
202
 
procedure TEditorKeymappingOptionsFrame.ConsistencyCheckButtonClick(Sender: TObject);
203
 
var
204
 
  Protocol: TStringList;
205
 
  ErrorCount, Index1, Index2: Integer;
206
 
  ACaption, AText: String;
207
 
  KeyMapErrorsForm: TKeyMapErrorsForm;
208
 
begin
209
 
  Protocol := TStringList.Create;
210
 
  try
211
 
    ErrorCount := FindKeymapConflicts(EditingKeyMap, Protocol, Index1, Index2);
212
 
    if ErrorCount > 0 then
213
 
    begin
214
 
      KeyMapErrorsForm := TKeyMapErrorsForm.Create(nil);
215
 
      try
216
 
        KeyMapErrorsForm.ListBox.Items.Assign(Protocol);
217
 
        KeyMapErrorsForm.ShowModal;
218
 
      finally
219
 
        KeyMapErrorsForm.Free;
220
 
      end;
221
 
    end
222
 
    else
223
 
    begin
224
 
      ACaption := dlgReport;
225
 
      AText    := dlgEdNoErr;
226
 
      MessageDlg(ACaption, AText, mtInformation, [mbOk], 0);
227
 
    end;
228
 
  finally
229
 
    Protocol.Free;
230
 
  end;
 
220
  ClearCommandMapping(TreeView.Selected)
231
221
end;
232
222
 
233
223
function TEditorKeymappingOptionsFrame.FilterEditFilterItem(Item: TObject; out Done: Boolean): Boolean;
255
245
 
256
246
procedure TEditorKeymappingOptionsFrame.FindKeyButtonClick(Sender: TObject);
257
247
var
258
 
  KeyFilter: TIDEShortCut;
 
248
  ShortCutDialog: TShortCutDialog;
259
249
begin
260
 
  if ShowKeyMappingGrabForm(KeyFilter) = mrOK then begin
261
 
    KeyMapKeyFilter := KeyFilter;
262
 
    UpdateKeyFilterButton;
263
 
    FilterEdit.Filter:='';         // Allow only one of the filters to be active.
264
 
    FilterEdit.InvalidateFilter;
 
250
  ShortCutDialog := TShortCutDialog.Create(nil);
 
251
  try
 
252
    ShortCutDialog.ShowSecondary:=False;
 
253
    ShortCutDialog.ShowSequence:=False;
 
254
    ShortCutDialog.Caption:=lisChooseAKey;
 
255
    ShortCutDialog.PrimaryShortCut := KeyMapKeyFilter;
 
256
    if ShortCutDialog.ShowModal = mrOK then begin
 
257
      KeyMapKeyFilter := ShortCutDialog.PrimaryShortCut;
 
258
      UpdateKeyFilterButton;
 
259
      FilterEdit.Filter:='';       // Allow only one of the filters to be active.
 
260
      FilterEdit.InvalidateFilter;
 
261
    end;
 
262
  finally
 
263
    ShortCutDialog.Free;
265
264
  end;
266
265
end;
267
266
 
 
267
procedure TEditorKeymappingOptionsFrame.OnIdle(Sender: TObject;
 
268
  var Done: Boolean);
 
269
begin
 
270
  IdleConnected:=false;
 
271
  UpdateConflictTree;
 
272
end;
 
273
 
268
274
procedure TEditorKeymappingOptionsFrame.ResetKeyFilterBtnClick(Sender: TObject);
269
275
begin
270
276
  KeyMapKeyFilter.Key1 := VK_UNKNOWN;
303
309
procedure TEditorKeymappingOptionsFrame.PopupMenu1Popup(Sender: TObject);
304
310
var
305
311
  ANode: TTreeNode;
 
312
  pop: TPopupMenu;
306
313
begin
307
 
  ANode := TreeView.Selected;
308
 
  EditMenuItem.Enabled:=
309
 
    (ANode<>nil) and (ANode.Data<>nil) and (TObject(ANode.Data) is TKeyCommandRelation);
 
314
  pop := Sender as TPopupMenu;
 
315
  if pop.PopupComponent = TreeView then begin
 
316
    ANode := TreeView.Selected;
 
317
    EditMenuItem.Enabled:=
 
318
      (ANode<>nil) and (ANode.Data<>nil) and (TObject(ANode.Data) is TKeyCommandRelation);
 
319
  end else if pop.PopupComponent=ConflictsTreeView then begin
 
320
    ANode:=ConflictsTreeView.Selected;
 
321
    EditMenuItem.Enabled := (ANode<>nil) and (CaptionToKeyMappingRelation(ANode.Text)<>nil);
 
322
  end else
 
323
    EditMenuItem.Enabled := False;
310
324
  ClearMenuItem.Enabled := EditMenuItem.Enabled;
311
325
end;
312
326
 
313
327
procedure TEditorKeymappingOptionsFrame.EditMenuItemClick(Sender: TObject);
314
328
begin
315
 
  EditCommandMapping(TreeView.Selected);
 
329
  if PopupMenu1.PopupComponent=TreeView then
 
330
    EditCommandMapping(TreeView.Selected)
 
331
  else
 
332
    EditConflict(ConflictsTreeView.Selected);
316
333
end;
317
334
 
318
335
procedure TEditorKeymappingOptionsFrame.ClearMenuItemClick(Sender: TObject);
319
336
begin
320
 
  ClearCommandMapping(TreeView.Selected);
 
337
  if PopupMenu1.PopupComponent=TreeView then
 
338
    ClearCommandMapping(TreeView.Selected)
 
339
  else
 
340
    ClearConflict(ConflictsTreeView.Selected);
 
341
end;
 
342
 
 
343
procedure TEditorKeymappingOptionsFrame.ConflictsTreeViewMouseDown(
 
344
  Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
 
345
var
 
346
  Node: TTreeNode;
 
347
begin
 
348
  if (Button=mbLeft) and (ssDouble in Shift) then begin
 
349
    Node:=ConflictsTreeView.GetNodeAt(X,Y);
 
350
    EditConflict(Node);
 
351
  end;
321
352
end;
322
353
 
323
354
function TEditorKeymappingOptionsFrame.GeneralPage: TEditorGeneralOptionsFrame; inline;
334
365
begin
335
366
  FDialog := ADialog;
336
367
  ChooseSchemeButton.Caption := lisEdOptsLoadAScheme;
337
 
  ConsistencyCheckButton.Caption := dlgCheckConsistency;
338
368
  FindKeyButton.Caption := lisFindKeyCombination;
339
369
  CommandLabel.Caption := lisSelectedCommandsMapping;
340
370
  EditButton.Caption := lisEdit;
343
373
  ClearMenuItem.Caption := lisClear;
344
374
 
345
375
  TreeView.Images := IDEImages.Images_16;
 
376
  ConflictsTreeView.Images := IDEImages.Images_16;
346
377
  imgKeyCategory := IDEImages.LoadImage(16, 'item_keyboard');
347
378
  imgKeyItem := IDEImages.LoadImage(16, 'item_character');
348
379
  ChooseSchemeButton.LoadGlyphFromLazarusResource('item_keyboard'); // keymapcategory
349
 
  ConsistencyCheckButton.LoadGlyphFromLazarusResource('menu_tool_check_lfm');
350
380
  FindKeyButton.LoadGlyphFromLazarusResource('menu_search_find');
351
381
  EditButton.LoadGlyphFromLazarusResource('laz_edit');
352
382
  ClearButton.LoadGlyphFromLazarusResource('menu_clean');
366
396
  i: integer;
367
397
begin
368
398
  with AOptions as TEditorOptions do
369
 
    EditingKeyMap.Assign(KeyMap);
 
399
    FEditingKeyMap.Assign(KeyMap);
370
400
  FillKeyMappingTreeView;
371
401
  UpdateSchemeLabel;
372
402
  with GeneralPage do
373
403
    for i := Low(PreviewEdits) to High(PreviewEdits) do
374
404
      if PreviewEdits[i] <> nil then
375
 
        EditingKeyMap.AssignTo(PreviewEdits[i].KeyStrokes, TSourceEditorWindowInterface);
 
405
        FEditingKeyMap.AssignTo(PreviewEdits[i].KeyStrokes, TSourceEditorWindowInterface);
 
406
  IdleConnected:=true;
376
407
end;
377
408
 
378
409
procedure TEditorKeymappingOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
379
410
begin
380
411
  with AOptions as TEditorOptions do
381
 
    KeyMap.Assign(EditingKeyMap);
 
412
    KeyMap.Assign(FEditingKeyMap);
382
413
end;
383
414
 
384
415
class function TEditorKeymappingOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
400
431
  begin
401
432
    BeginUpdate;
402
433
    CategoryNodeIndex:=0;
403
 
    for i := 0 to EditingKeyMap.CategoryCount - 1 do
 
434
    for i := 0 to FEditingKeyMap.CategoryCount - 1 do
404
435
    begin
405
 
      CurCategory := EditingKeyMap.Categories[i];
 
436
      CurCategory := FEditingKeyMap.Categories[i];
406
437
      if Items.TopLvlCount > CategoryNodeIndex then
407
438
      begin
408
439
        NewCategoryNode := Items.TopLvlItems[CategoryNodeIndex];
417
448
      for j := 0 to CurCategory.Count - 1 do
418
449
      begin
419
450
        CurKeyRelation := TKeyCommandRelation(CurCategory[j]);
420
 
        ItemCaption:=KeyMappingRelationToString(CurKeyRelation);
 
451
        ItemCaption:=KeyMappingRelationToCaption(CurKeyRelation);
421
452
        if NewCategoryNode.Count > ChildNodeIndex then
422
453
        begin
423
454
          NewKeyNode := NewCategoryNode.Items[ChildNodeIndex];
442
473
  end;
443
474
end;
444
475
 
445
 
function TEditorKeymappingOptionsFrame.KeyMappingRelationToString(Index: Integer): String;
 
476
function TEditorKeymappingOptionsFrame.KeyMappingRelationToCaption(Index: Integer): String;
446
477
begin
447
 
  Result := KeyMappingRelationToString(EditingKeyMap.Relations[Index]);
 
478
  Result := KeyMappingRelationToCaption(FEditingKeyMap.Relations[Index]);
448
479
end;
449
480
 
450
 
function TEditorKeymappingOptionsFrame.KeyMappingRelationToString(
 
481
function TEditorKeymappingOptionsFrame.KeyMappingRelationToCaption(
451
482
  KeyRelation: TKeyCommandRelation): String;
452
483
const
453
484
  MaxLength = 60;
480
511
  end;
481
512
end;
482
513
 
 
514
function TEditorKeymappingOptionsFrame.KeyShortCutToCaption(
 
515
  const aKey: TKeyCommandRelation; const aShortCut: TIDEShortCut): string;
 
516
begin
 
517
  Result:=aKey.Category.Description+'/'
 
518
        +EditorCommandToDescriptionString(aKey.Command)
 
519
        +'->'+KeyAndShiftStateToEditorKeyString(aShortCut);
 
520
end;
 
521
 
 
522
function TEditorKeymappingOptionsFrame.CaptionToKeyMappingRelation(
 
523
  aCaption: string): TKeyCommandRelation;
 
524
var
 
525
  c: Integer;
 
526
  aCategory: TIDECommandCategory;
 
527
  CatStr: String;
 
528
  i: Integer;
 
529
  aKey: TKeyCommandRelation;
 
530
  s: String;
 
531
begin
 
532
  for c:=0 to FEditingKeyMap.CategoryCount-1 do begin
 
533
    aCategory:=FEditingKeyMap.Categories[c];
 
534
    CatStr:=aCategory.Description+'/';
 
535
    if LeftStr(aCaption,length(CatStr))<>CatStr then continue;
 
536
    for i:=0 to aCategory.Count-1 do begin
 
537
      aKey:=TObject(aCategory[i]) as TKeyCommandRelation;
 
538
      s:=CatStr+EditorCommandToDescriptionString(aKey.Command);
 
539
      if LeftStr(aCaption,length(s))<>s then continue;
 
540
      Result:=aKey;
 
541
      exit;
 
542
    end;
 
543
  end;
 
544
  Result:=nil;
 
545
end;
 
546
 
 
547
procedure TEditorKeymappingOptionsFrame.SetIdleConnected(AValue: boolean);
 
548
begin
 
549
  if FIdleConnected=AValue then Exit;
 
550
  FIdleConnected:=AValue;
 
551
  if IdleConnected then
 
552
    Application.AddOnIdleHandler(@OnIdle)
 
553
  else
 
554
    Application.RemoveOnIdleHandler(@OnIdle);
 
555
end;
 
556
 
483
557
procedure TEditorKeymappingOptionsFrame.UpdateKeyFilterButton;
484
558
begin
485
559
  if IDEShortCutEmpty(KeyMapKeyFilter) then
486
 
    FindKeyButton.Caption:=lisFindKeyCombination
 
560
    FindKeyButton.Caption := lisFindKeyCombination
487
561
  else
488
562
    FindKeyButton.Caption:=
489
563
      Format(lisFilter3, [KeyAndShiftStateToEditorKeyString(KeyMapKeyFilter)]);
500
574
  SchemeLabel.Caption:=s;
501
575
end;
502
576
 
 
577
procedure TEditorKeymappingOptionsFrame.SelectByIdeCommand(ACmd: word);
 
578
var
 
579
  Node: TTreeNode;
 
580
begin
 
581
  Node := TreeView.Items.GetFirstNode;
 
582
  while node <> nil do begin
 
583
    if (node.Data <> nil) and (TObject(Node.Data) is TKeyCommandRelation) and
 
584
       (TKeyCommandRelation(Node.Data).Command = ACmd)
 
585
    then
 
586
      break;
 
587
    node := Node.GetNext;
 
588
  end;
 
589
  if node <> nil then begin
 
590
    Node.MakeVisible;
 
591
    Node.Selected := True;
 
592
  end;
 
593
end;
 
594
 
 
595
procedure TEditorKeymappingOptionsFrame.UpdateTree;
 
596
begin
 
597
  FillKeyMappingTreeView;
 
598
end;
 
599
 
 
600
procedure TEditorKeymappingOptionsFrame.UpdateConflictTree;
 
601
var
 
602
  ConflictCount: integer;
 
603
  Key1: TKeyCommandRelation;
 
604
  Key2: TKeyCommandRelation;
 
605
 
 
606
  procedure Check(const ShortCut1, ShortCut2: TIDEShortCut);
 
607
  // check if ShortCut1 hides ShortCut2
 
608
  var
 
609
    ConflictNode: TTreeNode;
 
610
    KeyNode: TTreeNode;
 
611
  begin
 
612
    if (ShortCut1.Key1=VK_UNKNOWN)
 
613
    or (ShortCut1.Key1<>ShortCut2.Key1)
 
614
    or (ShortCut1.Shift1<>ShortCut2.Shift1) then
 
615
      exit;    // first keys differ
 
616
 
 
617
    if (ShortCut1.Key2=VK_UNKNOWN) or (ShortCut2.Key2=VK_UNKNOWN)
 
618
    or ((ShortCut1.Key2=ShortCut2.Key2) and (ShortCut1.Shift2=ShortCut2.Shift2))
 
619
    then begin
 
620
      // conflict found, add node with a sub node for each key
 
621
      inc(ConflictCount);
 
622
      ConflictNode:=ConflictsTreeView.Items.Add(nil,srkmConflic+IntToStr(ConflictCount));
 
623
      ConflictNode.ImageIndex:=imgKeyItem;
 
624
      ConflictNode.StateIndex:=imgKeyItem;
 
625
      KeyNode:=ConflictsTreeView.Items.AddChild(ConflictNode,
 
626
                                          KeyShortCutToCaption(Key1,ShortCut1));
 
627
      KeyNode.ImageIndex := imgKeyItem;
 
628
      KeyNode.SelectedIndex := imgKeyItem;
 
629
      KeyNode:=ConflictsTreeView.Items.AddChild(ConflictNode,
 
630
                                          KeyShortCutToCaption(Key2,ShortCut2));
 
631
      KeyNode.ImageIndex := imgKeyItem;
 
632
      KeyNode.SelectedIndex := imgKeyItem;
 
633
      ConflictNode.Expanded:=true;
 
634
    end;
 
635
  end;
 
636
 
 
637
var
 
638
  i: Integer;
 
639
  j: Integer;
 
640
begin
 
641
  ConflictsTreeView.BeginUpdate;
 
642
  ConflictsTreeView.Items.Clear;
 
643
 
 
644
  ConflictCount:=0;
 
645
  for i:=0 to FEditingKeyMap.Count-1 do begin
 
646
    Key1:=FEditingKeyMap[i];
 
647
    for j:=i+1 to FEditingKeyMap.Count-1 do begin
 
648
      Key2:=FEditingKeyMap[j];
 
649
      if (not Key1.Category.ScopeIntersects(Key2.Category.Scope)) then
 
650
        continue;
 
651
      Check(Key1.ShortcutA,Key2.ShortcutA);
 
652
      Check(Key1.ShortcutA,Key2.ShortcutB);
 
653
      Check(Key1.ShortcutB,Key2.ShortcutA);
 
654
      Check(Key1.ShortcutB,Key2.ShortcutB);
 
655
    end;
 
656
  end;
 
657
 
 
658
  if ConflictsTreeView.Items.Count=0 then
 
659
    ConflictsTreeView.Items.Add(nil,'There are no conflicting keys.');
 
660
 
 
661
  ConflictsTreeView.EndUpdate;
 
662
end;
 
663
 
503
664
procedure TEditorKeymappingOptionsFrame.EditCommandMapping(ANode: TTreeNode);
 
665
begin
 
666
  if ANode=nil then exit;
 
667
  EditCommandRelation(TKeyCommandRelation(ANode.Data));
 
668
end;
 
669
 
 
670
procedure TEditorKeymappingOptionsFrame.EditConflict(ANode: TTreeNode);
504
671
var
505
 
  i: integer;
506
672
  ARelation: TKeyCommandRelation;
507
673
begin
508
 
  ARelation := TKeyCommandRelation(ANode.Data);
509
 
  i := EditingKeyMap.IndexOf(ARelation);
510
 
  if (i >= 0) and (ShowKeyMappingEditForm(i, EditingKeyMap) = mrOk) then
511
 
  begin
512
 
    FillKeyMappingTreeView;
513
 
    fModified:=True;
514
 
    UpdateSchemeLabel;
515
 
    with GeneralPage do
516
 
      for i := Low(PreviewEdits) to High(PreviewEdits) do
517
 
        if PreviewEdits[i] <> nil then
518
 
          EditingKeyMap.AssignTo(PreviewEdits[i].KeyStrokes, TSourceEditorWindowInterface);
519
 
  end;
 
674
  if ANode=nil then exit;
 
675
  ARelation:=CaptionToKeyMappingRelation(ANode.Text);
 
676
  EditCommandRelation(ARelation);
 
677
end;
 
678
 
 
679
procedure TEditorKeymappingOptionsFrame.EditCommandRelation(
 
680
  ARelation: TKeyCommandRelation);
 
681
var
 
682
  i: Integer;
 
683
begin
 
684
  if ARelation=nil then exit;
 
685
  i := FEditingKeyMap.IndexOf(ARelation);
 
686
  if (i < 0) or (ShowKeyMappingEditForm(i, FEditingKeyMap) <> mrOk) then exit;
 
687
  FillKeyMappingTreeView;
 
688
  fModified:=True;
 
689
  UpdateSchemeLabel;
 
690
  with GeneralPage do
 
691
    for i := Low(PreviewEdits) to High(PreviewEdits) do
 
692
      if PreviewEdits[i] <> nil then
 
693
        FEditingKeyMap.AssignTo(PreviewEdits[i].KeyStrokes, TSourceEditorWindowInterface);
 
694
  UpdateConflictTree;
520
695
end;
521
696
 
522
697
procedure TEditorKeymappingOptionsFrame.ClearCommandMapping(ANode: TTreeNode);
 
698
begin
 
699
  if ANode=nil then exit;
 
700
  ClearCommandRelation(TKeyCommandRelation(ANode.Data));
 
701
end;
 
702
 
 
703
procedure TEditorKeymappingOptionsFrame.ClearConflict(ANode: TTreeNode);
523
704
var
524
 
  i: integer;
525
705
  ARelation: TKeyCommandRelation;
526
706
begin
527
 
  ARelation := TKeyCommandRelation(ANode.Data);
528
 
  i := EditingKeyMap.IndexOf(ARelation);
529
 
  if (i >= 0) {and (ShowKeyMappingEditForm(i, EditingKeyMap) = mrOk)} then
530
 
  begin
531
 
    ARelation.ShortcutA := IDEShortCut(VK_UNKNOWN, []);
532
 
    ARelation.ShortcutB := IDEShortCut(VK_UNKNOWN, []);
533
 
    FillKeyMappingTreeView;
534
 
    fModified:=True;
535
 
    UpdateSchemeLabel;
536
 
    with GeneralPage do
537
 
      for i := Low(PreviewEdits) to High(PreviewEdits) do
538
 
        if PreviewEdits[i] <> nil then
539
 
          EditingKeyMap.AssignTo(PreviewEdits[i].KeyStrokes, TSourceEditorWindowInterface);
540
 
  end;
 
707
  if ANode=nil then exit;
 
708
  ARelation:=CaptionToKeyMappingRelation(ANode.Text);
 
709
  ClearCommandRelation(ARelation);
 
710
end;
 
711
 
 
712
procedure TEditorKeymappingOptionsFrame.ClearCommandRelation(
 
713
  ARelation: TKeyCommandRelation);
 
714
var
 
715
  i: Integer;
 
716
begin
 
717
  if ARelation=nil then exit;
 
718
  i := FEditingKeyMap.IndexOf(ARelation);
 
719
  if (i < 0) then exit;
 
720
  ARelation.ShortcutA := IDEShortCut(VK_UNKNOWN, []);
 
721
  ARelation.ShortcutB := IDEShortCut(VK_UNKNOWN, []);
 
722
  FillKeyMappingTreeView;
 
723
  fModified:=True;
 
724
  UpdateSchemeLabel;
 
725
  with GeneralPage do
 
726
    for i := Low(PreviewEdits) to High(PreviewEdits) do
 
727
      if PreviewEdits[i] <> nil then
 
728
        FEditingKeyMap.AssignTo(PreviewEdits[i].KeyStrokes, TSourceEditorWindowInterface);
 
729
  UpdateConflictTree;
541
730
end;
542
731
 
543
732
initialization