From 94b186201479300a77795e8bba8712bfa25975c8 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 21 Feb 2015 13:57:13 +0100 Subject: [PATCH 1/5] updated icons --- icons/other/keyboard_pencil.png | Bin 0 -> 662 bytes src/ce_icons.inc | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 icons/other/keyboard_pencil.png diff --git a/icons/other/keyboard_pencil.png b/icons/other/keyboard_pencil.png new file mode 100644 index 0000000000000000000000000000000000000000..9bb2920f42ba17c1099180c28efde43f444f3938 GIT binary patch literal 662 zcmV;H0%`q;P)S#Xt@S z5z`_FY?F<(58(+`({xH!7OBOJ1c`AXfYEO%qoO78H2yjLedaxLL(9_ z>gi+h-`oAJy~m@K(1q{apZA^foqN73F~;ye!%ClUIDDE<7kN16#A!SVy!dB9Fr7{V z(P;Fc+wJzwgKoFm3YK_C!-&*u~1!C+tzQx0JWD?U6yqC>0I zO7f7)#H;@3cVJ5#27|%-+(1?;l~||KVa;Y!%>8~} zM7P^ztyYUQKE7g!M1u8tJ$8M0`R!9+T`1u0%4QFAx#s(8KeA|i*ukBf4aDPdd|g<0 zSMYdV%l~@7tHa@Nz;3r2t^BPP(L8*Nm6h|@-+zPkt7oVqt-{jM%tU@yK~Uqa(x}(# z#-ou&6%2p9z}nh1?Cz$ZcsAfU6%-hwjjF2l(&_Xky+wLV``--k-d+leCvQVJaRHP| z7#^lq5-ILEv;cMVrin wjN>xdy<5^t;AfBpzC0L'#190'b' + +#137'D'#130#245'z=v}y'#249#237'S`]('#224#238#202'f'#15't'#185#230#251'k?'#178 + +'h|'#216#193#157#155#13#196#227'q|]XxW'#240'x^'#203#255'z'#192#171#195#225'p' + +#192'n'#183#27#173#252#173#22#209'<|'#140#149#149#243#216#223#127#131#245#171 + +'g'#168'#'#173#194#210#210#204'D~WAP'#227#174#210#168#215#235#198#163#145'F' + +#21#12#127#189#192#218#218'5'#236#238#166#160'x6'#224'9'#21#20#24#163#141#170 + +#170#246#210#233#244''''#189'EzL'#251#223#12#240#222'^'#10#139'''oC9q'#1#148 + +'K'#24#30#16'/PQ'#20'/'#191#231#13#206#181'h~'#178#27'W'#6#171'O'#158#151'W' + +#183#30#156#253#146':8'#150#173#28'Zui?y'#129#148'$IeA'#224't:E'#155#204#131 + +#140#227'2'#217#189'['#210'K'#229'8v'#158#165#236#7#170'&'#25#255'u'#127#254 + +#8'0'#0#204#231'b U<'#159'Q'#0#0#0#0'IEND'#174'B`'#130 +]); LazarusResources.Add('link','PNG',[ #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#16#0#0#0#16#8#6#0#0#0#31#243#255'a' +#0#0#0#25'tEXtSoftware'#0'Adobe ImageReadyq'#201'e<'#0#0#0#219'IDATx'#218#236 From 9e5278f22151c2d2e3ab55fecf512cbac59add02 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 21 Feb 2015 13:57:59 +0100 Subject: [PATCH 2/5] found bug, Synedit related --- src/ce_editoroptions.pas | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ce_editoroptions.pas b/src/ce_editoroptions.pas index 5d82cf08..9832bb4f 100644 --- a/src/ce_editoroptions.pas +++ b/src/ce_editoroptions.pas @@ -19,6 +19,9 @@ type end; + // attributes frameedges are not stored because of: + //TODO-cLCL&LAZ-specific: remove this comment once http://bugs.freepascal.org/view.php?id=27513 merged/fixed + (** * Container for the editor and highlither options. * The base class is also used to backup the settings From 3ff19f5160d837709f8cabb686ab5a115f32c42d Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 21 Feb 2015 13:58:34 +0100 Subject: [PATCH 3/5] test editable editor shortcut --- src/ce_editor.pas | 59 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/src/ce_editor.pas b/src/ce_editor.pas index 42f9c753..753061df 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -7,8 +7,8 @@ interface uses Classes, SysUtils, FileUtil, ExtendedNotebook, Forms, Controls, lcltype, Graphics, SynEditKeyCmds, ComCtrls, SynEditHighlighter, ExtCtrls, Menus, - SynMacroRecorder, SynPluginSyncroEdit, SynEdit, SynCompletion, ce_widget, - ce_interfaces, ce_synmemo, ce_dlang, ce_common, ce_dcd, ce_observer; + SynMacroRecorder, SynPluginSyncroEdit, SynEdit, SynCompletion, + ce_widget, ce_interfaces, ce_synmemo, ce_dlang, ce_common, ce_dcd, ce_observer; type @@ -19,7 +19,7 @@ type procedure SetVisible(Value: Boolean); override; end; - TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler) + TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler, ICEEditableShortCut) PageControl: TExtendedNotebook; macRecorder: TSynMacroRecorder; editorStatus: TStatusBar; @@ -36,9 +36,10 @@ type fDoc: TCESynMemo; // TODO-cbugfix: syncro-edit partially broken, undetermined condition fSyncEdit: TSynPluginSyncroEdit; - tokLst: TLexTokenList; - errLst: TLexErrorList; + fTokList: TLexTokenList; + fErrList: TLexErrorList; fModStart: boolean; + fShortcutCount: Integer; {$IFDEF LINUX} procedure pageCloseBtnClick(Sender: TObject); {$ENDIF} @@ -64,6 +65,10 @@ type function findDocument(aFilename: string): TCESynMemo; procedure openDocument(aFilename: string); function closeDocument(index: Integer): boolean; + // + function scedWantFirst: boolean; + function scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean; + procedure scedSendItem(const category, identifier: string; aShortcut: TShortcut); public constructor create(aOwner: TComponent); override; destructor destroy; override; @@ -88,8 +93,8 @@ var begin inherited; // - tokLst := TLexTokenList.Create; - errLst := TLexErrorList.Create; + fTokList := TLexTokenList.Create; + fErrList := TLexErrorList.Create; // completion.OnPaintItem := @completionItemPaint; fSyncEdit := TSynPluginSyncroEdit.Create(self); @@ -120,8 +125,8 @@ begin if PageControl.Page[i].ControlCount > 0 then if (PageControl.Page[i].Controls[0] is TCESynMemo) then PageControl.Page[i].Controls[0].Free; - tokLst.Free; - errLst.Free; + fTokList.Free; + fErrList.Free; inherited; end; @@ -252,6 +257,34 @@ begin end; {$ENDREGION} +{$REGION ICEEDitableSHortcut ---------------------------------------------------} +function TCEEditorWidget.scedWantFirst: boolean; +begin + result := fDoc <> nil; + fShortcutCount := 0; +end; + +function TCEEditorWidget.scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean; +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; +end; + +procedure TCEEditorWidget.scedSendItem(const category, identifier: string; aShortcut: TShortcut); +begin + +end; +{$ENDREGION} {$REGION PageControl/Editor things ---------------------------------------------} {$IFDEF LINUX} @@ -411,15 +444,15 @@ begin fKeyChanged := false; if fDoc.Lines.Count = 0 then exit; // - lex(fDoc.Lines.Text, tokLst, @lexFindToken); + lex(fDoc.Lines.Text, fTokList, @lexFindToken); md := ''; if fDoc.isDSource then - md := getModuleName(tokLst); + md := getModuleName(fTokList); if md = '' then md := extractFileName(fDoc.fileName); pageControl.ActivePage.Caption := md; // - tokLst.Clear; - errLst.Clear; + fTokList.Clear; + fErrList.Clear; // when a widget saves a temp file & syncro mode is on: // - editor is saved // - gutter is updated (green bar indicating a saved block) From 4bcb2c6dcf841710c364c68ee4e3e0eb92881307 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 21 Feb 2015 13:58:56 +0100 Subject: [PATCH 4/5] tweaked option editor options --- src/ce_optionseditor.lfm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ce_optionseditor.lfm b/src/ce_optionseditor.lfm index a0debcb0..6c27f181 100644 --- a/src/ce_optionseditor.lfm +++ b/src/ce_optionseditor.lfm @@ -35,11 +35,15 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget Top = 0 Width = 140 Align = alLeft + AutoExpand = True DefaultItemHeight = 18 + HideSelection = False + ReadOnly = True ScrollBars = ssAutoBoth TabOrder = 0 OnDeletion = selCatDeletion OnSelectionChanged = selCatSelectionChanged + Options = [tvoAutoExpand, tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] end object pnlEd: TPanel Left = 146 From 8bd0bcae684defa1e0a9b475bae6cf309c63cc81 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 21 Feb 2015 13:59:41 +0100 Subject: [PATCH 5/5] added support for catching new shortcut value --- src/ce_shortcutseditor.lfm | 70 ++++++++++++++++++++++------- src/ce_shortcutseditor.pas | 90 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 141 insertions(+), 19 deletions(-) diff --git a/src/ce_shortcutseditor.lfm b/src/ce_shortcutseditor.lfm index b942dcbe..4317e8fe 100644 --- a/src/ce_shortcutseditor.lfm +++ b/src/ce_shortcutseditor.lfm @@ -1,28 +1,28 @@ object CEShortcutEditor: TCEShortcutEditor Left = 0 - Height = 471 + Height = 463 Top = 0 - Width = 431 - ClientHeight = 471 - ClientWidth = 431 + Width = 424 + ClientHeight = 463 + ClientWidth = 424 TabOrder = 0 DesignLeft = 796 DesignTop = 213 object Panel1: TPanel Left = 0 - Height = 471 + Height = 463 Top = 0 - Width = 431 + Width = 424 Align = alClient BevelOuter = bvNone - ClientHeight = 471 - ClientWidth = 431 + ClientHeight = 463 + ClientWidth = 424 TabOrder = 0 object fltItems: TTreeFilterEdit Left = 0 Height = 23 Top = 0 - Width = 407 + Width = 400 ButtonWidth = 23 NumGlyphs = 1 Align = alCustom @@ -33,24 +33,64 @@ object CEShortcutEditor: TCEShortcutEditor end object tree: TTreeView Left = 1 - Height = 389 + Height = 400 Top = 28 - Width = 430 + Width = 423 Align = alCustom Anchors = [akTop, akLeft, akRight, akBottom] + AutoExpand = True DefaultItemHeight = 18 + HideSelection = False + ReadOnly = True ScrollBars = ssAutoBoth TabOrder = 1 + OnSelectionChanged = treeSelectionChanged + Options = [tvoAutoExpand, tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] end object Panel2: TPanel Left = 0 - Height = 50 - Top = 421 - Width = 431 + Height = 31 + Top = 432 + Width = 424 Align = alBottom BevelOuter = bvNone - Caption = 'Controls to edit the shortcut...' + ClientHeight = 31 + ClientWidth = 424 TabOrder = 2 + object schrtText: TStaticText + Left = 4 + Height = 23 + Top = 4 + Width = 277 + Align = alClient + Alignment = taCenter + BorderSpacing.Around = 4 + BorderStyle = sbsSunken + TabOrder = 0 + end + object shcCatch: TEdit + Left = 312 + Height = 25 + Top = 3 + Width = 112 + Align = alRight + BorderSpacing.Top = 3 + BorderSpacing.Bottom = 3 + Enabled = False + OnExit = shcCatchExit + OnKeyDown = LabeledEdit1KeyDown + OnMouseLeave = shcCatchMouseLeave + TabOrder = 1 + end + object btnActivate: TSpeedButton + Left = 285 + Height = 23 + Top = 4 + Width = 23 + Align = alRight + BorderSpacing.Around = 4 + OnClick = btnActivateClick + end end end end diff --git a/src/ce_shortcutseditor.pas b/src/ce_shortcutseditor.pas index 73fd4f3f..d2cf7ea9 100644 --- a/src/ce_shortcutseditor.pas +++ b/src/ce_shortcutseditor.pas @@ -5,8 +5,8 @@ unit ce_shortcutseditor; interface uses - Classes, SysUtils, FileUtil, TreeFilterEdit, Forms, Controls, Menus, - ExtCtrls, LCLProc, ComCtrls, + Classes, SysUtils, FileUtil, TreeFilterEdit, Forms, Controls, Menus, Graphics, + ExtCtrls, LCLProc, ComCtrls, StdCtrls, LMessages, Buttons, LCLType, ce_observer, ce_interfaces, ce_common, ce_writableComponent; type @@ -41,11 +41,21 @@ type property item[index: Integer]: TShortcutItem read getShortcut; default; end; + { TCEShortcutEditor } + TCEShortcutEditor = class(TFrame, ICEEditableOptions) + shcCatch: TEdit; Panel1: TPanel; fltItems: TTreeFilterEdit; Panel2: TPanel; + schrtText: TStaticText; + btnActivate: TSpeedButton; tree: TTreeView; + procedure btnActivateClick(Sender: TObject); + procedure LabeledEdit1KeyDown(Sender: TObject; var Key: Word;Shift: TShiftState); + procedure shcCatchExit(Sender: TObject); + procedure shcCatchMouseLeave(Sender: TObject); + procedure treeSelectionChanged(Sender: TObject); private fObservers: TCEEditableShortCutSubject; fShortcuts: TShortCutCollection; @@ -58,6 +68,9 @@ type // function findCategory(const aName: string; aData: Pointer): TTreeNode; procedure updateFromObservers; + procedure updateEditCtrls; + protected + procedure UpdateShowing; override; public constructor create(TheOwner: TComponent); override; destructor destroy; override; @@ -139,6 +152,22 @@ begin fObservers.Free; inherited; end; + +procedure TCEShortcutEditor.UpdateShowing; +var + png : TPortableNetworkGraphic; +begin + inherited; + if not visible then exit; + // + png := TPortableNetworkGraphic.Create; + try + png.LoadFromLazarusResource('keyboard_pencil'); + btnActivate.Glyph.Assign(png); + finally + png.free; + end; +end; {$ENDREGION} {$REGION ICEEditableOptions ----------------------------------------------------} @@ -165,6 +194,57 @@ end; {$ENDREGION} {$REGION shortcut editor things ------------------------------------------------} +procedure TCEShortcutEditor.treeSelectionChanged(Sender: TObject); +begin + updateEditCtrls; +end; + +procedure TCEShortcutEditor.shcCatchExit(Sender: TObject); +begin + shcCatch.Enabled := false; + updateEditCtrls; +end; + +procedure TCEShortcutEditor.shcCatchMouseLeave(Sender: TObject); +begin + shcCatch.Enabled := false; + updateEditCtrls; +end; + +procedure TCEShortcutEditor.btnActivateClick(Sender: TObject); +begin + if tree.Selected = nil then exit; + if tree.Selected.Level = 0 then exit; + if tree.Selected.Data = nil then exit; + // + shcCatch.Enabled := not shcCatch.Enabled; +end; + +procedure TCEShortcutEditor.LabeledEdit1KeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if tree.Selected = nil then exit; + if tree.Selected.Level = 0 then exit; + if tree.Selected.Data = nil then exit; + // + if Key = VK_RETURN then shcCatch.Enabled := false + else TShortcutItem(tree.Selected.Data).data := Shortcut(Key, Shift); + // + updateEditCtrls; +end; + +procedure TCEShortcutEditor.updateEditCtrls; +begin + schrtText.Caption := ''; + // + if tree.Selected = nil then exit; + if tree.Selected.Level = 0 then exit; + if tree.Selected.Data = nil then exit; + // + schrtText.Caption := TShortcutItem(tree.Selected.Data).combination; + shcCatch.Text:= ''; +end; + function TCEShortcutEditor.findCategory(const aName: string; aData: Pointer): TTreeNode; var i: Integer; @@ -197,11 +277,13 @@ begin if obs.scedWantFirst then while obs.scedWantNext(cat, idt, sht) do 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); - if idt = '' then - continue; // item as child itm := TShortcutItem(fShortcuts.items.Add); itm.identifier := idt;