This commit is contained in:
Basile Burg 2014-07-18 06:36:27 +02:00
parent 3b2b8362fc
commit 305d64f6d9
16 changed files with 720 additions and 305 deletions

View File

@ -114,22 +114,25 @@
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="5">
<RequiredPackages Count="6">
<Item1>
<PackageName Value="FCL"/>
<PackageName Value="AnchorDocking"/>
</Item1>
<Item2>
<PackageName Value="RunTimeTypeInfoControls"/>
<PackageName Value="FCL"/>
</Item2>
<Item3>
<PackageName Value="SynEdit"/>
<PackageName Value="RunTimeTypeInfoControls"/>
</Item3>
<Item4>
<PackageName Value="LazControls"/>
<PackageName Value="SynEdit"/>
</Item4>
<Item5>
<PackageName Value="LCL"/>
<PackageName Value="LazControls"/>
</Item5>
<Item6>
<PackageName Value="LCL"/>
</Item6>
</RequiredPackages>
<Units Count="17">
<Unit0>

View File

@ -6,17 +6,18 @@ uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, ce_widget,
ce_dmdwrap, ce_common, ce_synmemo, ce_main, ce_messages, ce_editor,
ce_projinspect, ce_projconf, jsonparser, ce_project,
ce_widgettypes, ce_staticexplorer, ce_search, ce_dlang, ce_dlangutils;
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, anchordockpkg,
AnchorDocking, AnchorDockStorage, AnchorDockOptionsDlg,
ce_widget, ce_dmdwrap, ce_common, ce_synmemo, ce_main, ce_messages, ce_editor,
ce_projinspect, ce_projconf, jsonparser, ce_project, ce_widgettypes,
ce_staticexplorer, ce_search, ce_dlang, ce_dlangutils;
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TCEMainForm, mainForm);
Application.CreateForm(TCEMainForm, CEMainForm);
Application.Run;
end.

View File

@ -5,7 +5,11 @@ unit ce_common;
interface
uses
Classes, SysUtils, ActnList, dialogs, forms, process;
Classes, SysUtils,
{$IFDEF WINDOWS}
Windows,
{$ENDIF}
ActnList, dialogs, forms, process;
const
@ -40,6 +44,8 @@ type
TMRUFileList = class(TMRUList)
protected
function checkItem(const S: string): boolean; override;
public
procedure assign(src: TPersistent); override;
end;
(**
@ -107,6 +113,11 @@ type
*)
function shortenPath(const aPath: string; charThresh: Word = 80): string;
(**
* Returns the folder Coedit documents and settings.
*)
function getDocPath: string;
implementation
procedure TProcessEx.Assign(aValue: TPersistent);
@ -183,6 +194,15 @@ begin
clearOutOfRange;
end;
procedure TMRUFileList.assign(src: TPersistent);
var
i: NativeInt;
begin
inherited;
for i := Count-1 downto 0 do
if not fileExists(Strings[i]) then Delete(i);
end;
function TMRUFileList.checkItem(const S: string): boolean;
begin
exit( inherited checkItem(S) and fileExists(S));
@ -390,4 +410,24 @@ begin
exit( format('%s%s...%s',[drv,directorySeparator,pth1]) );
end;
function getDocPath: string;
{$IFDEF WINDOWS}
var
PIDL : PItemIDList;
Folder : array[0..MAX_PATH] of Char;
const
CSIDL_APPDATA = $001A;
{$ENDIF}
begin
{$IFDEF WINDOWS}
SHGetSpecialFolderLocation(0, CSIDL_APPDATA, PIDL);
SHGetPathFromIDList(PIDL, Folder);
result:=Folder;
{$ENDIF}
{$IFDEF UNIX}
result := ExpandFileName('~/'));
{$ENDIF}
result += directorySeparator + 'Coedit' + directorySeparator;
end;
end.

View File

@ -8,8 +8,8 @@ uses
Classes, SysUtils, FileUtil, ExtendedNotebook, Forms, Controls, lcltype,
Graphics, SynEditKeyCmds, ComCtrls, SynEditHighlighter, ExtCtrls, Menus,
SynEditHighlighterFoldBase, SynMacroRecorder, SynPluginSyncroEdit, SynEdit,
SynHighlighterLFM, ce_widget, ce_d2syn, ce_synmemo, ce_common, AnchorDocking,
ce_dlang, ce_project;
SynHighlighterLFM, AnchorDocking, ce_widget, ce_d2syn, ce_synmemo, ce_dlang,
ce_project;
type
{ TCEEditorWidget }
@ -67,7 +67,6 @@ var
bmp: TBitmap;
begin
inherited;
fID := 'ID_EDIT';
//
tokLst := TLexTokenList.Create;
errLst := TLexErrorList.Create;
@ -80,7 +79,6 @@ begin
finally
bmp.Free;
end;
DockMaster.GetAnchorSite(Self).Name := ID;
end;
destructor TCEEditorWidget.destroy;
@ -122,7 +120,7 @@ begin
fSyncEdit.Editor := curr;
//
if pageControl.ActivePageIndex <> -1 then
mainForm.docFocusedNotify(Self, pageControl.ActivePageIndex);
CEMainForm.docFocusedNotify(Self, pageControl.ActivePageIndex);
//
if (pageControl.ActivePage.Caption = '') then
begin
@ -139,8 +137,8 @@ end;
procedure TCEEditorWidget.PageControlCloseTabClicked(Sender: TObject);
begin
// closeBtn not implemented
mainForm.actFileClose.Execute;
// closeBtn not implemented (Win.)
CEMainForm.actFileClose.Execute;
end;
procedure TCEEditorWidget.addEditor;
@ -158,9 +156,7 @@ begin
memo.OnKeyUp := @memoKeyDown;
memo.OnKeyPress := @memoKeyPress;
memo.OnMouseDown := @memoMouseDown;
// http://forum.lazarus.freepascal.org/index.php/topic,25213.0.html
//memo.OnChange := @memoChange;
memo.OnChange := @memoChange;
memo.OnMouseMove := @memoMouseMove;
//
@ -172,7 +168,7 @@ end;
procedure TCEEditorWidget.removeEditor(const aIndex: NativeInt);
begin
mainForm.MessageWidget.ClearMessages(msEditor);
CEMainForm.MessageWidget.ClearMessages(msEditor);
editor[aIndex].OnChange:= nil;
pageControl.Pages[aIndex].Free;
end;
@ -249,15 +245,15 @@ begin
if not fKeyChanged then exit;
//
fKeyChanged := false;
mainForm.docChangeNotify(Self, editorIndex);
CEMainForm.docChangeNotify(Self, editorIndex);
if ed.Lines.Count = 0 then exit;
//
mainForm.MessageWidget.ClearMessages(msEditor);
lex( ed.Lines.Text, tokLst );
CEMainForm.MessageWidget.ClearMessages(msEditor);
lex(ed.Lines.Text, tokLst);
checkSyntacticErrors( tokLst, errLst);
checkSyntacticErrors(tokLst, errLst);
for err in errLst do
mainForm.MessageWidget.addMessage(format( '%s (@line:%4.d @char:%.4d)',
CEMainForm.MessageWidget.addMessage(format( '%s (@line:%4.d @char:%.4d)',
[err.msg, err.position.y, err.position.x]), msEditor);
md := '';
@ -266,7 +262,7 @@ begin
if md = '' then md := extractFileName(ed.fileName);
pageControl.ActivePage.Caption := md;
mainForm.MessageWidget.scrollToBack;
CEMainForm.MessageWidget.scrollToBack;
tokLst.Clear;
errLst.Clear;
end;

View File

@ -1,16 +1,14 @@
object CEMainForm: TCEMainForm
Left = 1435
Height = 53
Top = 140
Left = 1071
Height = 49
Top = 187
Width = 745
AllowDropFiles = True
Caption = 'Coedit'
ChildSizing.Layout = cclTopToBottomThenLeftToRight
DockSite = True
ChildSizing.Layout = cclLeftToRightThenTopToBottom
Menu = mainMenu
OnCloseQuery = FormCloseQuery
OnDropFiles = FormDropFiles
Position = poMainFormCenter
ShowHint = True
LCLVersion = '1.2.4.0'
object mainMenu: TMainMenu
@ -824,9 +822,81 @@ object CEMainForm: TCEMainForm
end
object MenuItem57: TMenuItem
Action = actEdFind
Bitmap.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0033000000330000003300000033000000330000000000000000000000000000
0000000000330000003300000033000000330000003300000000716F6DC07674
72FF706D6CFF6D6A69FF696765FF666362FF5A5756C0605D5C007E7C7A00716F
6DC0767472FF706D6CFF6D6A69FF696765FF666362FF5A5756C07A7876FF817E
7DFF9C9996FF898583FF716F6CFF595756FF605D5CFF605D5C007F7D7B007A78
76FF817E7DFF9C9996FF898583FF716F6CFF595756FF615E5DFF777573FFCFCF
CFFFD9D7D6FFD0CFCEFFC8C8C7FFC3C1C1FF5E5A59FF5F5C5B007E7C7A007775
73FFD0CFCFFFD9D7D6FFD0CFCEFFC8C8C7FFC3C1C1FF5E5B5AFF767472FFB3B1
AFFFCAC9C7FFB0AEADFF91908EFF757472FF5E5A59FF00000033000000337775
73FFB3B1AFFFCAC9C7FFB0AEADFF91908EFF757572FF5F5C5BFF767472FFB3B1
AFFFCAC9C7FFB1AEAEFF939290FF777674FF5E5A59FF7A7876FF646260FF7775
73FFB3B1AFFFCAC9C7FFB1AEAEFF939290FF777674FF605D5CFF767472FFB3B0
AEFFCAC9C7FFB0ADADFF91908EFF757472FF5B5857FF767472FF615F5DFF7674
72FFB3B1AFFFCAC9C7FFB0ADADFF91908EFF757573FF5F5C5BFF777472FFDEDD
DDFFEBEBE9FFDBDAD9FFCAC9C8FFBBBAB9FF575453FFD6D5D3FF8C8B89FF7573
71FFDEDDDCFFEBEBE9FFDBDAD9FFCAC9C8FFBCBCBBFF5E5B5AFF7A7876FF6F6D
6BFF666261FF605D5CFF5E5C5AFF5E5A5AFF4946469BD3D2D0FF8A8987FF6261
5F9B6C6A68FF646160FF625F5EFF615F5DFF615E5DFF615E5DA87B7977007774
73FFBCBAB8FFCDCBCAFFA5A3A2FF7E7C7BFF595655FFD6D5D3FF8C8C89FF7673
72FFBCBAB7FFCCCAC9FFA4A2A1FF7E7C7BFF5F5C5BFF625F5E007B7877007774
73FFB9B7B5FFC9C7C6FFA2A09FFF7D7B7AFF5C5858FF777472FF615F5DFF7774
73FFB9B8B5FFC9C7C6FFA2A09FFF7E7C7BFF605D5CFF63605F007C7978007875
74FFBDBBB9FFCECCCBFFA5A3A2FF7E7C7BFF5E5B5AFF7B7977FF646260FF7976
75FFBCBBB8FFCECCCBFFA6A4A3FF807E7DFF605D5CFF63605F007B7977007978
75AE716E6DFF696665FF64605FFF625E5DFF545251AA7B7A7700656361006A69
67AA6F6C6BFF696665FF676463FF656261FF63605FAE646160007B7977007B79
770000000033787574FFCBCAC7FF9B9A99FF625E5DFF625F5E007D7A79007875
74FFCAC8C6FF989796FF605D5CFF0000003364616000646160007B7977007B79
77007A7976FF908D8CFF908E8CFF656461FF615E5DFF615E5D007D7B79007977
75FF8E8B8AFF918F8DFF686664FF63605FFF64616000646160007B7977007B79
77007B7977FF73716FFF6D6B69FF696665FF625F5EFF615E5D007E7C7A007B79
77FF73716FFF6D6B69FF696665FF63605FFF6461600064616000
}
end
object MenuItem58: TMenuItem
Action = actEdFindNext
Bitmap.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0033000000330000003300000033000000330000000000000000000000000000
0000000000330000003300000033000000330000003300000000716F6DC07674
72FF706D6CFF6D6A69FF696765FF666362FF5A5756C0605D5C007E7C7A00716F
6DC0767472FF706D6CFF6D6A69FF696765FF666362FF5A5756C07A7876FF817E
7DFF9C9996FF898583FF716F6CFF595756FF605D5CFF605D5C007F7D7B007A78
76FF817E7DFF9C9996FF898583FF716F6CFF595756FF615E5DFF777573FFCFCF
CFFFD9D7D6FFD0CFCEFFC8C8C7FFC3C1C1FF5E5A59FF5F5C5B007E7C7A007775
73FFD0CFCFFFD9D7D6FFD0CFCEFFC8C8C7FFC3C1C1FF5E5B5AFF767472FFB3B1
AFFFCAC9C7FFB0AEADFF91908EFF757472FF5E5A59FF00000033000000337775
73FFB3B1AFFFCAC9C7FFB0AEADFF91908EFF757572FF5F5C5BFF767472FFB3B1
AFFFCAC9C7FFB1AEAEFF939290FF777674FF5E5A59FF7A7876FF646260FF7775
73FFB3B1AFFFCAC9C7FFB1AEAEFF939290FF777674FF605D5CFF767472FFB3B0
AEFFCAC9C7FFB0ADADFF91908EFF757472FF5B5857FF767472FF615F5DFF7674
72FFB3B1AFFFCAC9C7FFB0ADADFF91908EFF757573FF5F5C5BFF777472FFDEDD
DDFFEBEBE9FFDBDAD9FFCAC9C8FFBBBAB9FF575453FFD6D5D3FF8C8B89FF7573
71FFDEDDDCFFEBEBE9FFDBDAD9FFCAC9C8FFBCBCBBFF5E5B5AFF7A7876FF6F6D
6BFF666261FF605D5CFF5E5C5AFF5E5A5AFF4946469BD3D2D0FF8A8987FF6261
5F9B6C6A68FF646160FF625F5EFF615F5DFF615E5DFF615E5DA87B7977007774
73FFBCBAB8FFCDCBCAFFA5A3A2FF7E7C7BFF595655FFD6D5D3FF8C8C89FF7673
72FFBCBAB7FFCCCAC9FFA4A2A1FF7E7C7BFF5F5C5BFF625F5E007B7877007774
73FFB9B7B5FFC9C7C6FFA2A09FFF7D7B7AFF5C5858FF777472FF615F5DFF7774
73FFB9B8B5FFC9C7C6FFA2A09FFF7E7C7BFF605D5CFF63605F007C7978007875
74FFBDBBB9FFCECCCBFFA5A3A2FF7E7C7BFF5E5B5AFF7B7977FF646260FF7976
75FFBCBBB8FFCECCCBFFA6A4A3FF807E7DFF605D5CFF63605F007B7977007978
75AE716E6DFF696665FF64605FFF625E5DFF545251AA7B7A7700656361006A69
67AA6F6C6BFF696665FF676463FF656261FF63605FAE646160007B7977007B79
770000000033787574FFCBCAC7FF9B9A99FF625E5DFF625F5E007D7A79007875
74FFCAC8C6FF989796FF605D5CFF0000003364616000646160007B7977007B79
77007A7976FF908D8CFF908E8CFF656461FF615E5DFF615E5D007D7B79007977
75FF8E8B8AFF918F8DFF686664FF63605FFF64616000646160007B7977007B79
77007B7977FF73716FFF6D6B69FF696665FF625F5EFF615E5D007E7C7A007B79
77FF73716FFF6D6B69FF696665FF63605FFF6461600064616000
}
end
end
object MenuItem14: TMenuItem
@ -2006,39 +2076,39 @@ object CEMainForm: TCEMainForm
0033000000330000003300000033000000330000003300000033000000330000
00330000002C0000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B9851BB0B781
14FFB57E0FFFB57D0CFFB57C0AFFB57C0AFFB57C0AFFB57D0CFFB57E0FFFB781
14FFB9851BB0FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B78114FFFFEC
CEFFFCE6C4FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCE6C4FFFFEC
CEFFB78114FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B67F12FFFCEA
D1FFD88700FFF1F1EEFFB2AFAAFFB4B0A9FFB2AFAAFFF1F1EEFFD88700FFFCEA
D1FFB67F12FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B68012FFF8E3
BFFFDD9112FFEFEDE9FFF2EBE0FFF4EBDFFFF2EBE0FFEFEDE9FFDD9112FFF8E3
BFFFB68012FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B68014FFF7DB
B0FFE09925FFEEE9E8FFB1AAA4FFB2AAA2FFB1AAA4FFEEE9E8FFE09925FFF7DB
B0FFB68014FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B68114FFF4D5
A2FFE2A237FFE8CCA4FFECE4E0FFEDE3DDFFECE4E0FFE8CCA4FFE2A237FFF4D5
A2FFB68114FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B68115FFF3D1
99FFE5AB47FFE5A840FFE5A538FFE4A435FFE4A538FFE4A840FFE5AA47FFF3D1
99FFB68115FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B68115FFF3CD
90FFE7B052FFEACFABFFFFFFFFFFFCFDFFFFFBFDFFFFE7CDA9FFE7AF52FFF3CD
90FFB68115FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B68116FFF3CB
8AFFECB760FFF2EDECFF7F7977FFF1E8DFFFEDE5DEFFEDE8E8FFEBB65FFFF3CB
8AFFB68116FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B78218FFF6CD
8BFFF2C476FFF9FCFFFF8B8D90FFF8F9F7FFF4F5F5FFF4F7FBFFF2C375FFF6CD
8BFFB78218FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00B7831CF2B782
18FFB68114FFB88010FFB9810FFFB87F0DFFB67E0CFFB67E0EFFB68013FFB782
18FFB7831CF2FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000300000
0033000000330000003300000033000000330000003300000033000000330000
003300000030FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00B3B3B1EFB0B0ADFFAEAEACFFAEAEABFFADAD
FF00FFFFFF00FFFFFF00FFFFFF00B782187CB78114FFB57E0FFFB57C0BFFB57C
09FFB57C09FFB57C09FFB57C09FFB57C09FFB57C09FFB57C09FFB57C09FFB57C
0BFFB57E0FFFB78114FFB782187CB78115FFFFECCDFFFCE7C3FFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFCE7C3FFFFECCDFFB78115FFB68012FFFDECD1FFDA8600FFFFFFFFFFF1E5
D8FFF2E5D8FFF2E5D7FFF0E3D6FFEFE2D5FFF1E4D7FFF1E4D6FFEFE3D6FFFFFF
FFFFDA8600FFFDECD1FFB68012FFB68012FFFEE9C6FF714100FFFFFFFFFF7979
7AFF7A7A7AFFA2A1A1FF9F9F9FFFF6ECDEFF777777FFA1A1A1FF9E9FA0FFFFFF
FFFF704100FFFEE9C6FFB68012FFB68113FFFCE3BCFF9B6104FFFDFCF9FFFDF5
E8FFFEF4E7FFFBF2E5FFFCF2E5FFFBF2E5FFFBF2E5FFFAF1E3FFF9F1E5FFFCFA
F7FF9A6104FFFCE3BCFFB68113FFB68014FFF8DCB0FFE0981CFFFBFBF8FF7978
7BFFA2A0A2FFFCF6EAFF797879FFA3A1A3FFA09FA1FFFAF4E9FF9D9DA0FFF9F9
F6FFE0981CFFF8DCB0FFB68014FFB68014FFF6D8A7FFE09C27FFFBFFFFFFFCFB
F3FFFCF9EFFFFBF8EEFFFCFAF0FFFCFAF0FFFBF9EEFFF9F8EDFFFAF9F1FFFAFE
FEFFE09B27FFF6D8A7FFB68014FFB68114FFF4D4A0FFE1A136FFF2DEB7FFFCFF
FFFFFBFFFDFFFBFFFCFFFBFFFDFFFBFFFDFFFBFFFDFFFBFFFDFFFBFFFFFFF2DE
B7FFE1A136FFF4D4A0FFB68114FFB68115FFF3D09AFFE5A845FFE3A640FFE2A1
36FFE29E2FFFE19D2DFFE19D2CFFE19D2CFFE19D2DFFE29E2FFFE2A136FFE3A6
40FFE5A845FFF3D09AFFB68115FFB68115FFF3CE94FFE6AE51FFE5AB4BFFE6C9
A4FFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFDFFFFFFFEFFFFFFE6C9A4FFE5AC
4BFFE6AE51FFF3CE94FFB68115FFB68116FFF3CC8EFFE8B25AFFE7AE51FFFCFF
FFFFECE0D7FFF1E4DAFFF1E5DAFFEDE0D5FFEADDD3FFE9DED5FFFBFFFFFFE7AE
51FFE8B25AFFF3CC8EFFB68116FFB68116FFF1CB89FFE9B762FFE7B257FFF9F8
FBFFFDF7F2FF877F79FF4A4441FFFEF7F2FFEEE3D8FFEDE2D9FFF8F7FBFFE8B2
57FFE9B762FFF1CB89FFB68116FFB68116FFF3CA87FFEDBC6DFFEBB761FFF8F5
F7FFFFFFFFFF4A4541FF948C88FFFFFFFFFFF1E8E0FFF0E7E0FFF7F4F7FFEBB7
61FFEDBC6DFFF3CA87FFB68116FFB78218FFF6CD8BFFF2C67DFFF0C171FFFAF7
FBFFFFFFFFFF4C4848FF989392FFFFFFFFFFF7EFEAFFF6EFEBFFF9F6FAFFF0C1
71FFF2C67DFFF6CD8BFFB78218FF976C1496B78218FFB68014FFB37A06FFD7CF
D2FFD8CEC9FF6C676653593A0053D9CFCEFFD5CAC3FFD4CAC4FFD6CFD2FFB37A
06FFB68014FFB78218FF976C1496000000000000003300000033000000330000
0033000000330000000800000008000000330000003300000033000000330000
0033000000330000003300000000B3B3B1EFB0B0ADFFAEAEACFFAEAEABFFADAD
ABFFAEAEABFFAFAFADFFB0B0AED5000000000000000000000000000000000000
0000000000000000000000000000AFAFADFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFE9E9E9FFAFAFADA70000000000000000000000000000

View File

@ -7,7 +7,7 @@ interface
uses
Classes, SysUtils, FileUtil, SynEditKeyCmds, SynHighlighterLFM, Forms,
AnchorDocking, AnchorDockStorage, AnchorDockOptionsDlg, Controls, Graphics,
Dialogs, Menus, ActnList, ExtCtrls, process, XMLPropStorage, asyncprocess,
Dialogs, Menus, ActnList, ExtCtrls, process, XMLPropStorage, ComCtrls,
ce_common, ce_dmdwrap, ce_project, ce_synmemo, ce_widget, ce_messages,
ce_editor, ce_projinspect, ce_projconf, ce_staticexplorer, ce_search;
@ -19,17 +19,21 @@ type
//TODO-cwidget: options editor
(**
* Encapsulates the options in a writable component.
* note: likely to change however needed to test correctly Coedit.
*)
TCEOptions = class(TComponent)
private
fFileMru, fProjMru: TMruFileList;
fWidgUpdDel, fWidgUpdPer: Integer;
fLeft, FTop, fWidth, fHeight: Integer;
fErrorFlg: boolean;
procedure setFileMru(aValue: TMruFileList);
procedure setProjMru(aValue: TMruFileList);
procedure saveLayout(str: TStream);
procedure loadLayout(str: TStream);
//
procedure readerPropNoFound(Reader: TReader; Instance: TPersistent;
var PropName: string; IsPath: boolean; var Handled, Skip: Boolean);
procedure readerError(Reader: TReader; const Message: string;
var Handled: Boolean);
published
property APP_Left: Integer read fLeft write fLeft;
property APP_Top: Integer read fTop write fTop;
@ -38,17 +42,16 @@ type
//
property MRU_Files: TMruFileList read fFileMru write setFileMru;
property MRU_Projects: TMruFileList read fProjMru write setProjMru;
//
property WIDG_UpdateDelay: Integer read fWidgUpdDel write fWidgUpdDel;
property WIDG_UpdatePeriod: Integer read fWidgUpdPer write fWidgUpdPer;
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
procedure defineProperties(Filer: TFiler); override;
procedure saveToFile(const aFilename: string);
procedure loadFromFile(const aFilename: string);
procedure beforeSave;
procedure afterLoad;
procedure DefineProperties(Filer: TFiler); override;
//
property hasLoaded: boolean read fErrorFlg;
end;
{ TCEMainForm }
@ -204,6 +207,14 @@ type
fProjMru: TMruFileList;
fFileMru: TMruFileList;
//Init - Fina
procedure InitMRUs;
procedure InitWidgets;
procedure InitDocking;
procedure InitSettings;
procedure SaveSettings;
procedure SaveDocking;
// widget interfaces subroutines
procedure checkWidgetActions(const aWidget: TCEWidget);
procedure widgetShowFromAction(sender: TObject);
@ -239,6 +250,8 @@ type
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
procedure DockMasterCreateControl(Sender: TObject; aName: string; var
AControl: TControl; DoDisableAutoSizing: boolean);
//
procedure openFile(const aFilename: string);
procedure docChangeNotify(Sender: TObject; const aIndex: Integer);
@ -252,7 +265,7 @@ type
end;
var
mainForm: TCEMainForm;
CEMainForm: TCEMainForm;
implementation
{$R *.lfm}
@ -260,23 +273,34 @@ implementation
uses
SynMacroRecorder;
{$REGION std comp methods ******************************************************}
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEMainForm.create(aOwner: TComponent);
var
act: TAction;
itm: TMenuItem;
widg: TCEWidget;
opts: TCEOptions;
begin
inherited create(aOwner);
InitMRUs;
InitWidgets;
InitDocking;
InitSettings;
//
newProj;
end;
procedure TCEMainForm.InitMRUs;
begin
fProjMru := TMruFileList.Create;
fFileMru := TMruFileList.Create;
fProjMru.objectTag := mnuItemMruProj;
fFileMru.objectTag := mnuItemMruFile;
fProjMru.OnChange := @mruChange;
fFileMru.OnChange := @mruChange;
//
end;
procedure TCEMainForm.InitWidgets;
var
widg: TCEWidget;
act: TAction;
itm: TMenuItem;
begin
fWidgList := TCEWidgetList.Create;
fMesgWidg := TCEMessagesWidget.create(nil);
fEditWidg := TCEEditorWidget.create(nil);
@ -304,47 +328,101 @@ begin
itm.Action := act;
itm.Tag := ptrInt(widg);
mnuItemWin.Add(itm);
widg.Show
end;
end;
Height := 0;
DockMaster.MakeDockSite(Self, [akBottom], admrpChild, true);
procedure TCEMainForm.InitDocking;
var
i: NativeInt;
aManager: TAnchorDockManager;
begin
DockMaster.MakeDockSite(Self, [akBottom], admrpChild);
DockMaster.OnCreateControl := @DockMasterCreateControl;
DockMaster.OnShowOptions := @ShowAnchorDockOptions;
DockMaster.HeaderStyle := adhsPoints;
DockMaster.ManualDock(DockMaster.GetAnchorSite(fEditWidg), Self, alBottom);
DockMaster.ManualDock(DockMaster.GetAnchorSite(fMesgWidg), Self, alBottom);
DockMaster.ManualDock(DockMaster.GetAnchorSite(fStExpWidg), Self, alLeft);
if DockManager is TAnchorDockManager then begin
aManager:=TAnchorDockManager(DockManager);
aManager.PreferredSiteSizeAsSiteMinimum:=false;
end;
Height := 0;
for i := 0 to fWidgList.Count-1 do
begin
DockMaster.MakeDockable(fWidgList.widget[i],true);
DockMaster.GetAnchorSite(fWidgList.widget[i]).Header.HeaderPosition := adlhpTop;
end;
DockMaster.ManualDock(DockMaster.GetAnchorSite(fEditWidg), DockMaster.GetSite(Self), alBottom);
DockMaster.ManualDock(DockMaster.GetAnchorSite(fMesgWidg), DockMaster.GetSite(Self), alBottom);
DockMaster.ManualDock(DockMaster.GetAnchorSite(fStExpWidg), DockMaster.GetSite(Self), alLeft);
DockMaster.ManualDock(DockMaster.GetAnchorSite(fFindWidg),
DockMaster.GetAnchorSite(fStExpWidg), alBottom, fStExpWidg);
width := width - fProjWidg.Width;
DockMaster.ManualDock(DockMaster.GetAnchorSite(fProjWidg), Self, alRight);
DockMaster.ManualDock(DockMaster.GetAnchorSite(fProjWidg), DockMaster.GetSite(Self), alRight);
DockMaster.ManualDock(DockMaster.GetAnchorSite(fPrjCfWidg),
DockMaster.GetAnchorSite(fProjWidg), alBottom, fProjWidg);
DockMaster.GetAnchorSite(fEditWidg).Header.HeaderPosition := adlhpTop;
//
SaveDocking;
end;
newProj;
procedure TCEMainForm.InitSettings;
var
fname1: string;
fname2: string;
opts: TCEOptions;
begin
fname1 := getDocPath + 'options.txt';
fname2 := getDocPath + 'options.bak';
opts := TCEOptions.create(nil);
try
if fileExists('temp_coedit_options.txt') then
opts.loadFromFile('temp_coedit_options.txt');
if fileExists(fname1) then
begin
opts.loadFromFile(fname1);
if opts.hasLoaded then
begin
if fileExists(fname2) then
deleteFile(fname2);
if not fileExists(fname2) then
copyFile(fname1, fname2, false);
end;
end;
finally
opts.Free;
end;
end;
destructor TCEMainForm.destroy;
procedure TCEMainForm.SaveSettings;
var
opts: TCEOptions;
begin
opts := TCEOptions.create(nil);
try
opts.saveToFile('temp_coedit_options.txt');
forceDirectory(getDocPath);
opts.saveToFile(getDocPath + 'options.txt');
finally
opts.Free;
end;
end;
procedure TCEMainForm.SaveDocking;
var
xcfg: TXMLConfigStorage;
begin
xcfg := TXMLConfigStorage.Create(getDocPath + 'docking.xml',true);
try
// <Item1 Name="CEMainForm" Type="CustomSite" ChildCount="..."> is always missing
DockMaster.SaveLayoutToConfig(xcfg);
xcfg.WriteToDisk;
finally
xcfg.Free;
end;
end;
destructor TCEMainForm.destroy;
begin
SaveSettings;
SaveDocking;
//
fWidgList.Free;
fMesgWidg.Free;
@ -538,7 +616,7 @@ begin
end;
{$ENDREGION}
{$REGION file ******************************************************************}
{$REGION file ------------------------------------------------------------------}
procedure TCEMainForm.newFile;
begin
if fEditWidg = nil then exit;
@ -740,7 +818,7 @@ begin
end;
{$ENDREGION}
{$REGION edit ******************************************************************}
{$REGION edit ------------------------------------------------------------------}
procedure TCEMainForm.actEdCopyExecute(Sender: TObject);
var
curr: TCESynMemo;
@ -844,7 +922,7 @@ end;
{$ENDREGION}
{$REGION run ******************************************************************}
{$REGION run -------------------------------------------------------------------}
procedure TCEMainForm.ProcessOutputToMsg(const aProcess: TProcess; aCtxt: TMessageContext = msUnknown);
var
str: TMemoryStream;
@ -1157,7 +1235,7 @@ begin
end;
{$ENDREGION}
{$REGION view ******************************************************************}
{$REGION view ------------------------------------------------------------------}
procedure TCEMainForm.widgetShowFromAction(sender: TObject);
var
widg: TCEWidget;
@ -1170,9 +1248,21 @@ begin
win.Show;
win.BringToFront;
end;
procedure TCEMainForm.DockMasterCreateControl(Sender: TObject; aName: string; var
AControl: TControl; DoDisableAutoSizing: boolean);
var
i: NativeInt;
begin
for i := 0 to fWidgList.Count-1 do if fWidgList.widget[i].Name = aName then
begin
AControl := fWidgList.widget[i];
if DoDisableAutoSizing then AControl.DisableAutoSizing;
end;
end;
{$ENDREGION}
{$REGION project ***************************************************************}
{$REGION project ---------------------------------------------------------------}
procedure TCEMainForm.projChange(sender: TObject);
var
widg: TCEWidget;
@ -1323,15 +1413,13 @@ begin
end;
{$ENDREGION}
{$REGION options ***************************************************************}
{$REGION options ---------------------------------------------------------------}
constructor TCEOptions.create(aOwner: TComponent);
begin
inherited;
fFileMru := TMruFileList.Create;
fProjMru := TMruFileList.Create;
//
fWidgUpdDel := 70;
fWidgUpdPer := 1000;
fLeft := 0;
fTop := 0;
fWidth := 800;
@ -1345,6 +1433,20 @@ begin
inherited;
end;
procedure TCEOptions.readerPropNoFound(Reader: TReader; Instance: TPersistent;
var PropName: string; IsPath: boolean; var Handled, Skip: Boolean);
begin
Skip := true;
Handled := true;
end;
procedure TCEOptions.readerError(Reader: TReader; const Message: string;
var Handled: Boolean);
begin
Handled := true;
fErrorFlg := false;
end;
procedure TCEOptions.setFileMru(aValue: TMruFileList);
begin
fFileMru.Assign(aValue);
@ -1388,59 +1490,66 @@ begin
end;
end;
procedure TCEOptions.DefineProperties(Filer: TFiler);
procedure TCEOptions.defineProperties(Filer: TFiler);
begin
//Filer.DefineBinaryProperty('APP_Docking', @loadLayout, @saveLayout, true);
inherited;
// Filer is either a TReader or a TWriter
CEMainForm.fEditWidg.declareProperties(Filer);
CEMainForm.fFindWidg.declareProperties(Filer);
CEMainForm.fMesgWidg.declareProperties(Filer);
CEMainForm.fPrjCfWidg.declareProperties(Filer);
CEMainForm.fProjWidg.declareProperties(Filer);
CEMainForm.fStExpWidg.declareProperties(Filer);
end;
procedure TCEOptions.beforeSave;
begin
fLeft := mainForm.Left;
fTop := mainForm.Top;
fWidth := mainForm.Width;
fHeight := mainForm.Height;
fLeft := CEMainForm.Left;
fTop := CEMainForm.Top;
fWidth := CEMainForm.Width;
fHeight := CEMainForm.Height;
//
fFileMru.Assign(mainForm.fFileMru);
fProjMru.Assign(mainForm.fProjMru);
fFileMru.Assign(CEMainForm.fFileMru);
fProjMru.Assign(CEMainForm.fProjMru);
//
fWidgUpdPer := mainForm.fEditWidg.updaterByLoopInterval;
fWidgUpdDel := mainForm.fEditWidg.updaterByDelayDuration;
CEMainForm.fEditWidg.beforeSave(nil);
CEMainForm.fFindWidg.beforeSave(nil);
CEMainForm.fMesgWidg.beforeSave(nil);
CEMainForm.fPrjCfWidg.beforeSave(nil);
CEMainForm.fProjWidg.beforeSave(nil);
CEMainForm.fStExpWidg.beforeSave(nil);
end;
procedure TCEOptions.saveToFile(const aFilename: string);
begin
fErrorFlg := true;
beforeSave;
saveCompToTxtFile(Self, aFilename);
ce_common.saveCompToTxtFile(self, aFilename);
end;
procedure TCEOptions.loadFromFile(const aFilename: string);
begin
try
loadCompFromTxtFile(Self, aFilename);
except
exit;
end;
fErrorFlg := true;
loadCompFromTxtFile(self, aFilename, @readerPropNoFound, @readerError);
afterLoad;
end;
procedure TCEOptions.afterLoad;
var
widg: TCEWidget;
begin
mainForm.Left := fLeft;
mainForm.Top := fTop;
mainForm.Width := fWidth;
mainForm.Height := fHeight;
CEMainForm.Left := fLeft;
CEMainForm.Top := fTop;
CEMainForm.Width := fWidth;
CEMainForm.Height := fHeight;
//
mainForm.fFileMru.Assign(fFileMru);
mainForm.fProjMru.Assign(fProjMru);
CEMainForm.fFileMru.Assign(fFileMru);
CEMainForm.fProjMru.Assign(fProjMru);
//
for widg in mainForm.fWidgList do
begin
widg.updaterByDelayDuration := fWidgUpdDel;
widg.updaterByLoopInterval := fWidgUpdPer;
end;
CEMainForm.fEditWidg.afterLoad(nil);
CEMainForm.fFindWidg.afterLoad(nil);
CEMainForm.fMesgWidg.afterLoad(nil);
CEMainForm.fPrjCfWidg.afterLoad(nil);
CEMainForm.fProjWidg.afterLoad(nil);
CEMainForm.fStExpWidg.afterLoad(nil);
end;
{$ENDREGION}

View File

@ -7,7 +7,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, ce_project,
ce_synmemo, LMessages;
ce_synmemo;
type
@ -103,11 +103,9 @@ begin
fActSaveMsg.caption := 'Save selected message(s) to...';
//
inherited;
fID := 'ID_MSGS';
//
List.PopupMenu := contextMenu;
List.OnDeletion := @ListDeletion;
DockMaster.GetAnchorSite(Self).Name := ID;
end;
procedure TCEMessagesWidget.clearOutOfRangeMessg;

View File

@ -47,9 +47,7 @@ implementation
constructor TCEProjectConfigurationWidget.create(aOwner: TComponent);
begin
inherited;
fID := 'PROJ_CONF';
Tree.Selected := Tree.Items.GetLastNode;
DockMaster.GetAnchorSite(Self).Name := ID;
end;
procedure TCEProjectConfigurationWidget.projNew(const aProject: TCEProject);
@ -106,7 +104,7 @@ begin
nme := '';
beginUpdateByEvent;
cfg := fProj.addConfiguration;
// note: Cancel is actually related to the conf name not to the adding operation.
// note: Cancel is actually related to the conf. name not to the add operation.
if InputQuery('Configuration name', '', nme) then cfg.name := nme;
fProj.ConfigurationIndex := cfg.Index;
endUpdateByEvent;

View File

@ -240,7 +240,7 @@ begin
for rel in fSrcs do if rel <> '' then
begin
abs := expandFilenameEx(fBasePath,rel);
aList.Add(abs); // process.inc ln 249. double quotes are added anyway if there's a space...
aList.Add(abs); // process.inc ln 249. double quotes are added if there's a space.
end;
TCompilerConfiguration(fOptsColl.Items[fConfIx]).getOpts(aList);
end;

View File

@ -209,7 +209,7 @@ inherited CEProjectInspectWidget: TCEProjectInspectWidget
object btnRemFile: TSpeedButton
Left = 28
Height = 24
Hint = 'remove a source file from the project'
Hint = 'remove selected sources file(s) from the project'
Top = 0
Width = 28
Align = alLeft

View File

@ -65,13 +65,11 @@ begin
fActSelConf.OnUpdate := @actUpdate;
//
inherited;
fID := 'ID_PROJ';
Tree.OnDblClick := @TreeDblClick;
fFileNode := Tree.Items[0];
fConfNode := Tree.Items[1];
//
Tree.PopupMenu := contextMenu;
DockMaster.GetAnchorSite(Self).Name := ID;
end;
function TCEProjectInspectWidget.contextName: string;
@ -137,7 +135,7 @@ begin
begin
fname := fProject.getAbsoluteSourceName(i);
if fileExists(fname) then
mainForm.openFile(fname);
CEMainForm.openFile(fname);
end;
end
else if Tree.Selected.Parent = fConfNode then
@ -195,7 +193,7 @@ begin
if fileExists(fProject.fileName) then
dir := extractFilePath(fProject.fileName)
else dir := '';
if selectDirectory(dir, [], 0) then
if selectDirectory('sources', dir, dir, true, 0) then
begin
if FindFirst(dir + DirectorySeparator + '*.*', faAnyFile, sr ) = 0 then
try
@ -218,19 +216,19 @@ begin
if Tree.Selected = nil then exit;
//
if Tree.Selected.Parent = fFileNode then
begin
fname := Tree.Selected.Text;
i := fProject.Sources.IndexOf(fname);
if i > -1 then fProject.Sources.Delete(i);
UpdateByEvent;
end
begin
fname := Tree.Selected.Text;
i := fProject.Sources.IndexOf(fname);
if i > -1 then fProject.Sources.Delete(i);
UpdateByEvent;
end;
end;
procedure TCEProjectInspectWidget.FormDropFiles(Sender: TObject; const FileNames: array of String);
var
fname: string;
begin
mainForm.FormDropFiles(Sender, Filenames);
CEMainForm.FormDropFiles(Sender, Filenames);
if fProject = nil then exit;
for fname in Filenames do fProject.addSource(fname);
end;

View File

@ -39,9 +39,12 @@ type
fSearchMru, fReplaceMru: TMruList;
fCancelAll: boolean;
fHasSearched: boolean;
procedure optset_SearchMru(aReader: TReader);
procedure optget_SearchMru(aWriter: TWriter);
procedure optset_ReplaceMru(aReader: TReader);
procedure optget_ReplaceMru(aWriter: TWriter);
function getOptions: TSynSearchOptions;
procedure actReplaceAllExecute(sender: TObject);
procedure replaceEvent(Sender: TObject; const ASearch, AReplace:
string; Line, Column: integer; var ReplaceAction: TSynReplaceAction);
protected
@ -57,6 +60,8 @@ type
function contextActionCount: integer; override;
function contextAction(index: integer): TAction; override;
//
procedure declareProperties(aFiler: TFiler); override;
//
procedure actFindNextExecute(sender: TObject);
procedure actReplaceNextExecute(sender: TObject);
end;
@ -64,6 +69,7 @@ type
implementation
{$R *.lfm}
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCESearchWidget.Create(aOwner: TComponent);
begin
fActFindNext := TAction.Create(self);
@ -76,7 +82,6 @@ begin
fActReplaceAll.Caption := 'Replace all';
fActReplaceAll.OnExecute := @actReplaceAllExecute;
inherited;
fID := 'ID_FIND';
//
btnFind.Action := fActFindNext;
btnReplace.Action := fActReplaceNext;
@ -84,7 +89,6 @@ begin
//
fSearchMru := TMruList.Create;
fReplaceMru:= TMruList.Create;
DockMaster.GetAnchorSite(Self).Name := ID;
end;
destructor TCESearchWidget.Destroy;
@ -93,19 +97,39 @@ begin
fReplaceMru.Free;
inherited;
end;
{$ENDREGION}
procedure TCESearchWidget.docFocused(const aDoc: TCESynMemo);
{$REGION ICEWidgetPersist ------------------------------------------------------}
procedure TCESearchWidget.declareProperties(aFiler: TFiler);
begin
fEditor := aDoc;
UpdateByEvent;
inherited;
aFiler.DefineProperty(Name + '_FindMRU', @optset_SearchMru, @optget_SearchMru, true);
aFiler.DefineProperty(Name + '_ReplaceMRU', @optset_ReplaceMru, @optget_ReplaceMru, true);
end;
procedure TCESearchWidget.docClose(const aDoc: TCESynMemo);
procedure TCESearchWidget.optset_SearchMru(aReader: TReader);
begin
if fEditor = aDoc then fEditor := nil;
UpdateByEvent;
fSearchMru.DelimitedText := aReader.ReadString;
cbToFind.Items.DelimitedText := fSearchMru.DelimitedText;
end;
procedure TCESearchWidget.optget_SearchMru(aWriter: TWriter);
begin
aWriter.WriteString(fSearchMru.DelimitedText);
end;
procedure TCESearchWidget.optset_ReplaceMru(aReader: TReader);
begin
fReplaceMru.DelimitedText := aReader.ReadString;
cbReplaceWth.Items.DelimitedText := fReplaceMru.DelimitedText ;
end;
procedure TCESearchWidget.optget_ReplaceMru(aWriter: TWriter);
begin
aWriter.WriteString(fReplaceMru.DelimitedText);
end;
{$ENDREGION}
{$REGION ICEContextualActions---------------------------------------------------}
function TCESearchWidget.contextName: string;
begin
exit('Search');
@ -126,26 +150,6 @@ begin
end;
end;
procedure TCESearchWidget.cbToFindChange(Sender: TObject);
begin
if Updating then exit;
fToFind := cbToFind.Text;
fHasSearched := false;
end;
procedure TCESearchWidget.chkEnableRepChange(Sender: TObject);
begin
if Updating then exit;
UpdateByEvent;
end;
procedure TCESearchWidget.cbReplaceWthChange(Sender: TObject);
begin
if Updating then exit;
fReplaceWth := cbReplaceWth.Text;
fHasSearched := false;
end;
function TCESearchWidget.getOptions: TSynSearchOptions;
begin
result := [ssoRegExpr];
@ -155,6 +159,28 @@ begin
if chkPrompt.Checked then result += [ssoPrompt];
end;
function dlgReplaceAll: TModalResult;
const
Btns = [mbYes, mbNo, mbYesToAll, mbNoToAll];
begin
exit( MessageDlg('Coedit', 'Replace this match ?', mtConfirmation, Btns, ''));
end;
procedure TCESearchWidget.replaceEvent(Sender: TObject; const ASearch, AReplace:
string; Line, Column: integer; var ReplaceAction: TSynReplaceAction);
begin
case dlgReplaceAll of
mrYes: ReplaceAction := raReplace;
mrNo: ReplaceAction := raSkip;
mrYesToAll: ReplaceAction := raReplaceAll;
mrCancel, mrClose, mrNoToAll:
begin
ReplaceAction := raCancel;
fCancelAll := true;
end;
end;
end;
procedure TCESearchWidget.actFindNextExecute(sender: TObject);
begin
if fEditor = nil then exit;
@ -233,27 +259,40 @@ begin
fEditor.OnReplaceText := nil;
UpdateByEvent;
end;
{$ENDREGION}
function dlgReplaceAll: TModalResult;
const
Btns = [mbYes, mbNo, mbYesToAll, mbNoToAll];
{$REGION ICEMultiDocMonitor ----------------------------------------------------}
procedure TCESearchWidget.docFocused(const aDoc: TCESynMemo);
begin
exit( MessageDlg('Coedit', 'Replace this match ?', mtConfirmation, Btns, ''));
fEditor := aDoc;
UpdateByEvent;
end;
procedure TCESearchWidget.replaceEvent(Sender: TObject; const ASearch, AReplace:
string; Line, Column: integer; var ReplaceAction: TSynReplaceAction);
procedure TCESearchWidget.docClose(const aDoc: TCESynMemo);
begin
case dlgReplaceAll of
mrYes: ReplaceAction := raReplace;
mrNo: ReplaceAction := raSkip;
mrYesToAll: ReplaceAction := raReplaceAll;
mrCancel, mrClose, mrNoToAll:
begin
ReplaceAction := raCancel;
fCancelAll := true;
end;
end;
if fEditor = aDoc then fEditor := nil;
UpdateByEvent;
end;
{$ENDREGION}
procedure TCESearchWidget.cbToFindChange(Sender: TObject);
begin
if Updating then exit;
fToFind := cbToFind.Text;
fHasSearched := false;
end;
procedure TCESearchWidget.chkEnableRepChange(Sender: TObject);
begin
if Updating then exit;
UpdateByEvent;
end;
procedure TCESearchWidget.cbReplaceWthChange(Sender: TObject);
begin
if Updating then exit;
fReplaceWth := cbReplaceWth.Text;
fHasSearched := false;
end;
procedure TCESearchWidget.UpdateByEvent;

View File

@ -22,22 +22,37 @@ type
procedure TreeKeyPress(Sender: TObject; var Key: char);
private
fActRefresh: TAction;
fActRefreshOnChange: TAction;
fActRefreshOnFocus: TAction;
fActAutoRefresh: TAction;
fActSelectInSource: TAction;
fDoc: TCESynMemo;
fProj: TCEProject;
fAutoRefresh: boolean;
fRefreshOnChange: boolean;
fRefreshOnFocus: boolean;
ndAlias, ndClass, ndEnum, ndFunc: TTreeNode;
ndImp, ndIntf, ndMix, ndStruct, ndTmp, ndVar: TTreeNode;
procedure Rescan;
procedure TreeDblClick(Sender: TObject);
procedure actRefreshExecute(Sender: TObject);
procedure actAutoRefreshExecute(Sender: TObject);
procedure actRefreshOnChangeExecute(Sender: TObject);
procedure actRefreshOnFocusExecute(Sender: TObject);
procedure updateVisibleCat;
//
procedure optget_AutoRefresh(aWriter: TWriter);
procedure optset_AutoRefresh(aReader: TReader);
procedure optget_RefreshOnChange(aWriter: TWriter);
procedure optset_RefreshOnChange(aReader: TReader);
procedure optget_RefreshOnFocus(aWriter: TWriter);
procedure optset_RefreshOnFocus(aReader: TReader);
protected
procedure UpdateByDelay; override;
published
property autoRefresh: boolean read fAutoRefresh write fAutoRefresh;
property refreshOnChange: boolean read fRefreshOnChange write fRefreshOnChange;
property refreshOnFocus: boolean read fRefreshOnFocus write fRefreshOnFocus;
public
constructor create(aOwner: TComponent); override;
//
@ -54,14 +69,19 @@ type
procedure projClose(const aProject: TCEProject); override;
procedure projCompile(const aProject: TCEProject); override;
procedure projRun(const aProject: TCEProject); override;
//
procedure declareProperties(aFiler: TFiler); override;
end;
implementation
{$R *.lfm}
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEStaticExplorerWidget.create(aOwner: TComponent);
begin
fAutoRefresh := true;
fRefreshOnFocus := true;
fRefreshOnChange := true;
fActRefresh := TAction.Create(self);
fActRefresh.OnExecute := @actRefreshExecute;
fActRefresh.Caption := 'Refresh';
@ -70,12 +90,21 @@ begin
fActAutoRefresh.Caption := 'Auto-refresh';
fActAutoRefresh.AutoCheck := true;
fActAutoRefresh.Checked := fAutoRefresh;
fActRefreshOnChange := TAction.Create(self);
fActRefreshOnChange.OnExecute := @actRefreshOnChangeExecute;
fActRefreshOnChange.Caption := 'Refresh on change';
fActRefreshOnChange.AutoCheck := true;
fActRefreshOnChange.Checked := fRefreshOnChange;
fActRefreshOnFocus := TAction.Create(self);
fActRefreshOnFocus.OnExecute := @actRefreshOnFocusExecute;
fActRefreshOnFocus.Caption := 'Refresh on focused';
fActRefreshOnFocus.AutoCheck := true;
fActRefreshOnFocus.Checked := fRefreshOnFocus;
fActSelectInSource := TAction.Create(self);
fActSelectInSource.OnExecute := @TreeDblClick;
fActSelectInSource.Caption := 'Select in source';
//
inherited;
fID := 'ID_SEXPL';
//
ndAlias := Tree.Items[0];
ndClass := Tree.Items[1];
@ -90,9 +119,53 @@ begin
//
Tree.OnDblClick := @TreeDblClick;
Tree.PopupMenu := contextMenu;
DockMaster.GetAnchorSite(Self).Name := ID;
end;
{$ENDREGION}
{$REGION ICEWidgetPersist ------------------------------------------------------}
procedure TCEStaticExplorerWidget.optget_AutoRefresh(aWriter: TWriter);
begin
aWriter.WriteBoolean(fAutoRefresh);
end;
procedure TCEStaticExplorerWidget.optset_AutoRefresh(aReader: TReader);
begin
fAutoRefresh := aReader.ReadBoolean;
fActAutoRefresh.Checked := fAutoRefresh;
end;
procedure TCEStaticExplorerWidget.optget_RefreshOnChange(aWriter: TWriter);
begin
aWriter.WriteBoolean(fRefreshOnChange);
end;
procedure TCEStaticExplorerWidget.optset_RefreshOnChange(aReader: TReader);
begin
fRefreshOnChange := aReader.ReadBoolean;
fActRefreshOnChange.Checked := fRefreshOnChange;
end;
procedure TCEStaticExplorerWidget.optget_RefreshOnFocus(aWriter: TWriter);
begin
aWriter.WriteBoolean(fRefreshOnFocus);
end;
procedure TCEStaticExplorerWidget.optset_RefreshOnFocus(aReader: TReader);
begin
fRefreshOnFocus := aReader.ReadBoolean;
fActRefreshOnFocus.Checked := fRefreshOnFocus;
end;
procedure TCEStaticExplorerWidget.declareProperties(aFiler: TFiler);
begin
inherited;
aFiler.DefineProperty(Name + '_AutoRefresh', @optset_AutoRefresh, @optget_AutoRefresh, true);
aFiler.DefineProperty(Name + '_RefreshOnChange', @optset_RefreshOnChange, @optget_RefreshOnChange, true);
aFiler.DefineProperty(Name + '_RefreshOnFocus', @optset_RefreshOnFocus, @optget_RefreshOnFocus, true);
end;
{$ENDREGION}
{$REGION ICEContextualActions---------------------------------------------------}
function TCEStaticExplorerWidget.contextName: string;
begin
result := 'Static explorer';
@ -100,15 +173,17 @@ end;
function TCEStaticExplorerWidget.contextActionCount: integer;
begin
result := 3;
result := 5;
end;
function TCEStaticExplorerWidget.contextAction(index: integer): TAction;
begin
case index of
0: result := fActSelectInSource;
1: result := fActRefresh;
2: result := fActAutoRefresh;
0: exit(fActSelectInSource);
1: exit(fActRefresh);
2: exit(fActAutoRefresh);
3: exit(fActRefreshOnChange);
4: exit(fActRefreshOnFocus);
else result := nil;
end;
end;
@ -121,9 +196,44 @@ end;
procedure TCEStaticExplorerWidget.actAutoRefreshExecute(Sender: TObject);
begin
AutoRefresh := not AutoRefresh;
autoRefresh := not autoRefresh;
end;
procedure TCEStaticExplorerWidget.actRefreshOnChangeExecute(Sender: TObject);
begin
refreshOnChange := not refreshOnChange;
end;
procedure TCEStaticExplorerWidget.actRefreshOnFocusExecute(Sender: TObject);
begin
refreshOnFocus := not refreshOnFocus;
end;
{$ENDREGION}
{$REGION ICEMultiDocMonitor ----------------------------------------------------}
procedure TCEStaticExplorerWidget.docFocused(const aDoc: TCESynMemo);
begin
fDoc := aDoc;
if fAutoRefresh then beginUpdateByDelay
else if fRefreshOnFocus then Rescan;
end;
procedure TCEStaticExplorerWidget.docChanged(const aDoc: TCESynMemo);
begin
if fDoc <> aDoc then exit;
if fAutoRefresh then beginUpdateByDelay
else if fRefreshOnChange then Rescan;
end;
procedure TCEStaticExplorerWidget.docClose(const aDoc: TCESynMemo);
begin
if fDoc <> aDoc then exit;
fDoc := nil;
beginUpdateByDelay;
end;
{$ENDREGION}
{$REGION ICEProjectMonitor -----------------------------------------------------}
procedure TCEStaticExplorerWidget.projNew(const aProject: TCEProject);
begin
fProj := aProject;
@ -139,25 +249,6 @@ begin
fProj := nil;
end;
procedure TCEStaticExplorerWidget.docFocused(const aDoc: TCESynMemo);
begin
fDoc := aDoc;
beginUpdateByDelay;
end;
procedure TCEStaticExplorerWidget.docChanged(const aDoc: TCESynMemo);
begin
if fDoc <> aDoc then exit;
beginUpdateByDelay;
end;
procedure TCEStaticExplorerWidget.docClose(const aDoc: TCESynMemo);
begin
if fDoc <> aDoc then exit;
fDoc := nil;
beginUpdateByDelay;
end;
procedure TCEStaticExplorerWidget.projCompile(const aProject: TCEProject);
begin
stopUpdateByDelay;
@ -167,6 +258,7 @@ procedure TCEStaticExplorerWidget.projRun(const aProject: TCEProject);
begin
stopUpdateByDelay;
end;
{$ENDREGION}
procedure TCEStaticExplorerWidget.UpdateByDelay;
begin

View File

@ -5,9 +5,8 @@ unit ce_synmemo;
interface
uses
Classes, SysUtils, SynEdit, SynMemo, ce_d2syn, SynEditTextBuffer,
SynEditHighlighter, controls, LazSynEditText, SynPluginSyncroEdit,
SynEditKeyCmds, ce_project, ce_common;
Classes, SysUtils, SynEdit, SynMemo, ce_d2syn, SynEditHighlighter, controls,
LazSynEditText, SynPluginSyncroEdit, SynEditKeyCmds, ce_project, ce_common;
type
@ -78,9 +77,7 @@ begin
fFilename := '<new document>';
fModified := false;
// http://forum.lazarus.freepascal.org/index.php/topic,25213.0.html
//TSynEditStringList(Lines).AddNotifyHandler(senrUndoRedoAdded, @changeNotify);
onChange := @changeNotify;
TextBuffer.AddNotifyHandler(senrUndoRedoAdded, @changeNotify);
end;
procedure TCESynMemo.setFocus;
@ -102,7 +99,7 @@ procedure TCESynMemo.SetHighlighter(const Value: TSynCustomHighlighter);
begin
inherited;
fIsDSource := Highlighter = D2Syn;
fIsConfig := Highlighter = mainForm.LfmSyn;
fIsConfig := Highlighter = CEMainForm.LfmSyn;
end;
procedure TCESynMemo.identifierToD2Syn;

View File

@ -17,7 +17,7 @@ type
PTCEWidget = ^TCEWidget;
{ TCEWidget }
TCEWidget = class(TForm, ICEContextualActions, ICEProjectMonitor, ICEMultiDocMonitor)
TCEWidget = class(TForm, ICEContextualActions, ICEProjectMonitor, ICEMultiDocMonitor, ICEWidgetPersist)
Content: TPanel;
Back: TPanel;
contextMenu: TPopupMenu;
@ -32,6 +32,11 @@ type
procedure setLoopInt(aValue: Integer);
procedure updaterAutoProc(Sender: TObject);
procedure updaterLatchProc(Sender: TObject);
//
procedure optget_LoopInterval(aWriter: TWriter);
procedure optset_LoopInterval(aReader: TReader);
procedure optget_UpdaterDelay(aWriter: TWriter);
procedure optset_UpdaterDelay(aReader: TReader);
protected
fID: string;
// a descendant overrides to implementi a periodic update.
@ -78,9 +83,13 @@ type
function contextName: string; virtual;
function contextActionCount: integer; virtual;
function contextAction(index: integer): TAction; virtual;
//
procedure beforeSave(sender: TObject); virtual;
procedure declareProperties(aFiler: TFiler); virtual;
procedure afterLoad(sender: TObject); virtual;
//
// returns true if one of the three updater is processing.
property updating: boolean read fUpdating;
property ID: string read fID write fID;
end;
(**
@ -110,14 +119,14 @@ implementation
(*******************************************************************************
* TCEWidget
*)
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEWidget.create(aOwner: TComponent);
var
i: NativeInt;
itm: TmenuItem;
begin
inherited;
fID := 'ID_XXXX';
fUpdaterAuto := TTimer.Create(self);
fUpdaterAuto.Interval := 70;
fUpdaterAuto.OnTimer := @updaterAutoProc;
@ -126,10 +135,6 @@ begin
updaterByLoopInterval := 70;
updaterByDelayDuration := 1250;
DockMaster.MakeDockable(Self, true, true, true);
DockMaster.GetAnchorSite(Self).Header.HeaderPosition := adlhpTop;
DockMaster.GetAnchorSite(Self).Name := ID;
for i := 0 to contextActionCount-1 do
begin
itm := TMenuItem.Create(self);
@ -144,7 +149,107 @@ destructor TCEWidget.destroy;
begin
inherited;
end;
{$ENDREGION}
{$REGION ICEWidgetPersist ------------------------------------------------------}
procedure TCEWidget.beforeSave(sender: TObject);
begin
end;
procedure TCEWidget.declareProperties(aFiler: TFiler);
begin
// override rules: inhertied must be called. No dots in the property name, property name prefixed with the widget Name
aFiler.DefineProperty(Name + '_updaterByLoopInterval', @optset_LoopInterval, @optget_LoopInterval, true);
aFiler.DefineProperty(Name + '_updaterByDelayDuration', @optset_UpdaterDelay, @optget_UpdaterDelay, true);
end;
procedure TCEWidget.afterLoad(sender: TObject);
begin
end;
procedure TCEWidget.optget_LoopInterval(aWriter: TWriter);
begin
aWriter.WriteInteger(fLoopInter);
end;
procedure TCEWidget.optset_LoopInterval(aReader: TReader);
begin
updaterByLoopInterval := aReader.ReadInteger;
end;
procedure TCEWidget.optget_UpdaterDelay(aWriter: TWriter);
begin
aWriter.WriteInteger(fDelayDur);
end;
procedure TCEWidget.optset_UpdaterDelay(aReader: TReader);
begin
updaterByDelayDuration := aReader.ReadInteger;
end;
{$ENDREGION}
{$REGION ICEContextualActions---------------------------------------------------}
function TCEWidget.contextName: string;
begin
result := '';
end;
function TCEWidget.contextActionCount: integer;
begin
result := 0;
end;
function TCEWidget.contextAction(index: integer): TAction;
begin
result := nil;
end;
{$ENDREGION}
{$REGION ICEMultiDocMonitor ----------------------------------------------------}
procedure TCEWidget.docNew(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docFocused(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docChanged(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docClose(const aDoc: TCESynMemo);
begin
end;
{$ENDREGION}
{$REGION ICEProjectMonitor -----------------------------------------------------}
procedure TCEWidget.projNew(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projChange(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projClose(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projCompile(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projRun(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projFocused(const aProject: TCEProject);
begin
end;
{$ENDREGION}
{$REGION Updaters---------------------------------------------------------------}
procedure TCEWidget.setDelayDur(aValue: Integer);
begin
if aValue < 100 then aValue := 100;
@ -227,61 +332,7 @@ end;
procedure TCEWidget.UpdateByDelay;
begin
end;
procedure TCEWidget.projNew(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projChange(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projClose(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projCompile(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projRun(const aProject: TCEProject);
begin
end;
procedure TCEWidget.projFocused(const aProject: TCEProject);
begin
end;
function TCEWidget.contextName: string;
begin
result := '';
end;
function TCEWidget.contextActionCount: integer;
begin
result := 0;
end;
function TCEWidget.contextAction(index: integer): TAction;
begin
result := nil;
end;
procedure TCEWidget.docNew(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docFocused(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docChanged(const aDoc: TCESynMemo);
begin
end;
procedure TCEWidget.docClose(const aDoc: TCESynMemo);
begin
end;
{$ENDREGION}
(*******************************************************************************
* TCEWidgetList

View File

@ -12,36 +12,59 @@ type
// TODO-cinterface: document content access/modification
(**
* An implementer is informed when a new document is added, focused or closed.
* An implementer can save and load some stuffs on application start/quit
*)
ICEMultiDocMonitor = interface
procedure docNew(const aDoc: TCESynMemo);
procedure docFocused(const aDoc: TCESynMemo); // docSelected or docActivated
procedure docChanged(const aDoc: TCESynMemo);
procedure docClose(const aDoc: TCESynMemo);
ICEWidgetPersist = interface
// Coedit options are about to be saved.
procedure beforeSave(sender: TObject);
// some custom properties can be declared to aFiler.
procedure declareProperties(aFiler: TFiler);
// Coedit options has just been reloaded.
procedure afterLoad(sender: TObject);
end;
(**
* An implementer declares some actions on demand.
*)
ICEContextualActions = interface
// declares a context name for the actions
function contextName: string;
// action count, called before contextAction()
function contextActionCount: integer;
// declares actions, called in loop, from 0 to contextActionCount-1
function contextAction(index: integer): TAction;
end;
(**
* An implementer is informed when a new document is added, focused or closed.
*)
ICEMultiDocMonitor = interface
// the new document aDoc has been created (empty, runnable, project source, ...).
procedure docNew(const aDoc: TCESynMemo);
// aDoc is the document being edited.
procedure docFocused(const aDoc: TCESynMemo); // rename to: docSelected or docActivated
// aDoc content has just been modified (edited, saved).
procedure docChanged(const aDoc: TCESynMemo);
// aDoc is about to be closed.
procedure docClose(const aDoc: TCESynMemo);
end;
(**
* An implementer is informed when a project changes.
*)
ICEProjectMonitor = interface
// the new project aProject has been created/opened
procedure projNew(const aProject: TCEProject);
// aProject has been modified: switches, source name, ...
procedure projChange(const aProject: TCEProject);
// aProject is about to be closed.
procedure projClose(const aProject: TCEProject);
// aProject is about to be compiled.
procedure projCompile(const aProject: TCEProject);
// aProject is about to be executed.
procedure projRun(const aProject: TCEProject);
// not used yet: (project group)
procedure projFocused(const aProject: TCEProject); // projSelected or projActivated
// not used yet: the active project is now aProject
procedure projFocused(const aProject: TCEProject); // rename: projSelected or projActivated
end;
implementation