diff --git a/lazproj/coedit.lpi b/lazproj/coedit.lpi index 7c5fd891..939bf6be 100644 --- a/lazproj/coedit.lpi +++ b/lazproj/coedit.lpi @@ -143,6 +143,7 @@ + @@ -156,10 +157,12 @@ + + @@ -168,6 +171,7 @@ + @@ -185,6 +189,7 @@ + @@ -207,6 +212,7 @@ + @@ -214,6 +220,7 @@ + @@ -223,6 +230,7 @@ + @@ -230,6 +238,7 @@ + @@ -237,10 +246,12 @@ + + @@ -256,6 +267,7 @@ + @@ -263,10 +275,12 @@ + + @@ -281,6 +295,7 @@ + @@ -288,7 +303,6 @@ - @@ -300,11 +314,11 @@ + - @@ -324,6 +338,7 @@ + @@ -333,6 +348,7 @@ + @@ -340,6 +356,7 @@ + diff --git a/src/ce_editor.pas b/src/ce_editor.pas index b0fa9742..747a76ea 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -256,7 +256,7 @@ begin end; {$ENDREGION} -{$REGION ICEEDitableSHortcut ---------------------------------------------------} +{$REGION ICEEDitableShortcut ---------------------------------------------------} function TCEEditorWidget.scedWantFirst: boolean; begin result := fDoc <> nil; @@ -267,16 +267,13 @@ function TCEEditorWidget.scedWantNext(out category, identifier: string; out aSho var shrct: TSynEditKeyStroke; begin - result := false; - if fShortcutCount > fDoc.Keystrokes.Count-1 then exit; - // shrct := fDoc.Keystrokes.Items[fShortcutCount]; category := 'Editor'; identifier:= shrct.DisplayName; aShortcut := Shortcut(shrct.Key, shrct.Shift); // fShortcutCount += 1; - result := true; + result := fShortcutCount < fDoc.Keystrokes.Count; end; procedure TCEEditorWidget.scedSendItem(const category, identifier: string; aShortcut: TShortcut); diff --git a/src/ce_main.pas b/src/ce_main.pas index 09a04788..382c833f 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -916,16 +916,13 @@ function TCEMainForm.scedWantNext(out category, identifier: string; out aShortcu var act: TCustomAction; begin - result := false; - if fScCollectCount > actions.ActionCount -1 then exit; - // act := TCustomAction(Actions.Actions[fScCollectCount]); category := act.Category; identifier := act.Caption; aShortcut := act.ShortCut; // fScCollectCount += 1; - result := true; + result := fScCollectCount < actions.ActionCount; end; procedure TCEMainForm.scedSendItem(const category, identifier: string; aShortcut: TShortcut); diff --git a/src/ce_optionseditor.lfm b/src/ce_optionseditor.lfm index 6c27f181..1c17a44d 100644 --- a/src/ce_optionseditor.lfm +++ b/src/ce_optionseditor.lfm @@ -40,6 +40,7 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget HideSelection = False ReadOnly = True ScrollBars = ssAutoBoth + SortType = stText TabOrder = 0 OnDeletion = selCatDeletion OnSelectionChanged = selCatSelectionChanged diff --git a/src/ce_optionseditor.pas b/src/ce_optionseditor.pas index 61988ec5..38810c0c 100644 --- a/src/ce_optionseditor.pas +++ b/src/ce_optionseditor.pas @@ -41,6 +41,7 @@ type private fEdOptsSubj: TCEEditableOptionsSubject; procedure updateCategories; + function sortCategories(Cat1, Cat2: TTreeNode): integer; public constructor create(aOwner: TComponent); override; destructor destroy; override; @@ -100,6 +101,12 @@ begin dt^.kind := ed.optionedWantEditorKind; dt^.observer := ed; end; + selCat.Items.SortTopLevelNodes(@sortCategories); +end; + +function TCEOptionEditorWidget.sortCategories(Cat1, Cat2: TTreeNode): integer; +begin + result := CompareText(Cat1.Text, Cat2.Text); end; procedure TCEOptionEditorWidget.selCatDeletion(Sender: TObject; Node: TTreeNode); diff --git a/src/ce_shortcutseditor.lfm b/src/ce_shortcutseditor.lfm index 0e0e543b..eb406df6 100644 --- a/src/ce_shortcutseditor.lfm +++ b/src/ce_shortcutseditor.lfm @@ -44,6 +44,7 @@ object CEShortcutEditor: TCEShortcutEditor HideSelection = False ReadOnly = True ScrollBars = ssAutoBoth + SortType = stText TabOrder = 1 OnSelectionChanged = treeSelectionChanged Options = [tvoAutoExpand, tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] diff --git a/src/ce_shortcutseditor.pas b/src/ce_shortcutseditor.pas index 2ebfce79..0b781e04 100644 --- a/src/ce_shortcutseditor.pas +++ b/src/ce_shortcutseditor.pas @@ -65,6 +65,7 @@ type procedure optionedEvent(anEvent: TOptionEditorEvent); // function findCategory(const aName: string; aData: Pointer): TTreeNode; + function sortCategories(Cat1, Cat2: TTreeNode): integer; procedure updateFromObservers; procedure updateEditCtrls; protected @@ -253,15 +254,37 @@ begin exit(tree.Items[i]); end; +function TCEShortcutEditor.sortCategories(Cat1, Cat2: TTreeNode): integer; +begin + result := CompareText(Cat1.Text, Cat2.Text); +end; + procedure TCEShortcutEditor.updateFromObservers; var i: Integer; obs: ICEEditableShortCut; cat: string; - prt: TTreeNode; sht: word; idt: string; itm: TShortcutItem; +procedure addItem(); +var + prt: TTreeNode; +begin + // root category + if cat = '' then exit; + if idt = '' then exit; + prt := findCategory(cat, obs); + if prt = nil then + prt := tree.Items.AddObject(nil, cat, obs); + // item as child + itm := TShortcutItem(fShortcuts.items.Add); + itm.identifier := idt; + itm.data:= sht; + tree.Items.AddChildObject(prt, idt, itm); + cat := ''; + idt := ''; +end; begin tree.Items.Clear; fShortcuts.items.Clear; @@ -271,25 +294,14 @@ begin for i:= 0 to fObservers.observersCount-1 do begin obs := fObservers.observers[i] as ICEEditableShortCut; - if obs.scedWantFirst then while obs.scedWantNext(cat, idt, sht) do + if obs.scedWantFirst then begin - // root category - if cat = '' then - continue; - if idt = '' then - continue; - prt := findCategory(cat, obs); - if prt = nil then - prt := tree.Items.AddObject(nil, cat, obs); - // item as child - itm := TShortcutItem(fShortcuts.items.Add); - itm.identifier := idt; - itm.data:= sht; - tree.Items.AddChildObject(prt, idt, itm); - cat := ''; - idt := ''; + while obs.scedWantNext(cat, idt, sht) do + addItem(); + addItem(); end; end; + tree.Items.SortTopLevelNodes(@sortCategories); end; {$ENDREGION} diff --git a/src/ce_tools.pas b/src/ce_tools.pas index 733fb034..a2a87aa5 100644 --- a/src/ce_tools.pas +++ b/src/ce_tools.pas @@ -10,8 +10,6 @@ uses type - //TODO-cfeature: declare tools shortcuts, set TCETools ICEEditableShortcut - TCEToolItem = class(TCollectionItem) private fProcess: TCheckedAsyncProcess; @@ -24,7 +22,7 @@ type fQueryParams: boolean; fChainBefore: TStringList; fChainAfter: TStringList; - //fShortcut: TShortcut; + fShortcut: TShortcut; fMsgs: ICEMessagesDisplay; procedure setParameters(aValue: TStringList); procedure setChainBefore(aValue: TStringList); @@ -41,21 +39,26 @@ type property queryParameters: boolean read fQueryParams write fQueryParams; property chainBefore: TStringList read fChainBefore write setchainBefore; property chainAfter: TStringList read fChainAfter write setChainAfter; - //property shortcut: TShortcut read fShortcut write fShortcut; + property shortcut: TShortcut read fShortcut write fShortcut; public constructor create(ACollection: TCollection); override; destructor destroy; override; end; - TCETools = class(TWritableLfmTextComponent, ICEMainMenuProvider) + TCETools = class(TWritableLfmTextComponent, ICEMainMenuProvider, ICEEditableShortcut) private fTools: TCollection; + fShctCount: Integer; function getTool(index: Integer): TCEToolItem; procedure setTools(const aValue: TCollection); // procedure menuDeclare(item: TMenuItem); procedure menuUpdate(item: TMenuItem); procedure executeToolFromMenu(sender: TObject); + // + function scedWantFirst: boolean; + function scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean; + procedure scedSendItem(const category, identifier: string; aShortcut: TShortcut); published property tools: TCollection read fTools write setTools; public @@ -81,6 +84,7 @@ uses const toolsFname = 'tools.txt'; +{$REGION TCEToolItem -----------------------------------------------------------} constructor TCEToolItem.create(ACollection: TCollection); begin inherited; @@ -164,7 +168,9 @@ begin lst.Free; end; end; +{$ENDREGION --------------------------------------------------------------------} +{$REGION Standard Comp/Obj -----------------------------------------------------} constructor TCETools.create(aOwner: TComponent); var fname: string; @@ -186,7 +192,9 @@ begin fTools.Free; inherited; end; +{$ENDREGION} +{$REGION ICEMainMenuProvider ---------------------------------------------------} procedure TCETools.executeToolFromMenu(sender: TObject); begin executeTool(TCEToolItem(TMenuItem(sender).tag)); @@ -225,7 +233,32 @@ begin item.Items[i].Caption := tool[i].toolAlias; end; end; +{$ENDREGION} +{$REGION ICEEditableShortcut ---------------------------------------------------} +function TCETools.scedWantFirst: boolean; +begin + result := fTools.Count > 0; + fShctCount := 0; +end; + +function TCETools.scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean; +begin + category := 'Tools'; + identifier:= tool[fShctCount].toolAlias; + aShortcut := tool[fShctCount].shortcut; + // + fShctCount += 1; + result := fShctCount < fTools.Count; +end; + +procedure TCETools.scedSendItem(const category, identifier: string; aShortcut: TShortcut); +begin + +end; +{$ENDREGION} + +{$REGION Tools things ----------------------------------------------------------} procedure TCETools.setTools(const aValue: TCollection); begin fTools.Assign(aValue); @@ -271,6 +304,7 @@ begin // executeTool(tool[aToolIndex]); end; +{$ENDREGION} initialization RegisterClasses([TCEToolItem, TCETools]);