mirror of https://gitlab.com/basile.b/dexed.git
Merge branch 'a12_2_a13'
This commit is contained in:
commit
8ecd0221d3
Binary file not shown.
After Width: | Height: | Size: 662 B |
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1288,6 +1288,34 @@ LazarusResources.Add('information','PNG',[
|
|||
+#129's'#255'?'#166'w'#209#11#168'?'#130'{Y'#182'!'#185#0#0#0#0'IEND'#174'B`'
|
||||
+#130
|
||||
]);
|
||||
LazarusResources.Add('keyboard_pencil','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#2'8IDATx'#218#164'R'
|
||||
+'M'#136'RQ'#24'='#239#169#185#24#245#197'@'#14#8#17#211'"'#8'l'#147#141#137
|
||||
+#13'Q'#193#12#181')'#220'8'#208#166#141'A'#251'fQ'#8#193',dp;+'#131' h1'#19
|
||||
+#22#204'*'#132'6'#25#131#191#208'B'#210#16'kB#'#18'-'#234#233'c'#242#223#219
|
||||
+#253#174#189#199#163#149#208#133#239#221#159#247#157#243#157'{'#190'+1'#198
|
||||
+#240'?'#195'J'#159'p8|'#154'O'#23'y8'#231#196'i<'#10#188#248'gA0'#157'N'#3
|
||||
+#209'h'#244#161#219#237#246#206#131'n'#183#219#229'X,'#182#205#151'3'#130#201
|
||||
+'d'#162'p6'#175','#203's'#149#167'\'#194#24'W'#224#27#137#188#168'V'#171#240
|
||||
+#251#253#176#217'l'#176'X,"'#254'*'#196'x<'#198'h4B'#177'X'#132#203#229#18#24
|
||||
+'3'#129'L'#213#9'@s&'#147'A'#165'RA '#16#128#207#231#19#224#193'``'#16'S'#14
|
||||
+'a'#8'+><A'#162'C'#171#213'J'#242#144#203#229#16#137'D'#144#207#231#197#158
|
||||
+#130'T'#208'L9'#148'K'#152#203#181#218'L'#1#223#200#196#172#19#12#135'C$'#147
|
||||
+'IQ'#149#128#230#16#4#229'2'#30'e'#179'w'#229#163#163#247#186#2'YW@ID'#16#10
|
||||
+#133#4#129'^'#157'K'#22'kM'#211'Pm4pis'#243#220'w`K'#28#6#131#193#251#220'@V'
|
||||
+'*'#149'X'#167#211'a'#205'fS'#204#253'~_D'#183#219'e'#173'V'#139'5>'#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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue