mirror of https://gitlab.com/basile.b/dexed.git
implemented file/project MRU
This commit is contained in:
parent
35f137497e
commit
3676f5acea
|
@ -5,7 +5,7 @@ unit ce_common;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, ActnList, dialogs, forms;
|
Classes, SysUtils, ActnList, dialogs, forms, controls;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ type
|
||||||
TMRUList = class(TStringList)
|
TMRUList = class(TStringList)
|
||||||
private
|
private
|
||||||
fMaxCount: Integer;
|
fMaxCount: Integer;
|
||||||
|
fObj: TObject;
|
||||||
protected
|
protected
|
||||||
procedure setMaxCount(aValue: Integer);
|
procedure setMaxCount(aValue: Integer);
|
||||||
function checkItem(const S: string): boolean; virtual;
|
function checkItem(const S: string): boolean; virtual;
|
||||||
|
@ -28,6 +29,7 @@ type
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
procedure Insert(Index: Integer; const S: string); override;
|
procedure Insert(Index: Integer; const S: string); override;
|
||||||
|
property objectTag: TObject read fObj write fObj;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(**
|
(**
|
||||||
|
@ -81,6 +83,12 @@ type
|
||||||
*)
|
*)
|
||||||
function uniqueObjStr(const aObject: Tobject): string;
|
function uniqueObjStr(const aObject: Tobject): string;
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Reduce a filename if its length is over the threshold defined by charThresh.
|
||||||
|
* Even if the result is not usable anymore, it avoids any "visually-overloaded" MRU menus.
|
||||||
|
*)
|
||||||
|
function displayShortFilename(const aPath: string; charThresh: Word = 80): string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
constructor TMRUList.Create;
|
constructor TMRUList.Create;
|
||||||
|
@ -291,4 +299,27 @@ begin
|
||||||
{$HINTS ON}{$WARNINGS ON}
|
{$HINTS ON}{$WARNINGS ON}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function displayShortFilename(const aPath: string; charThresh: Word = 80): string;
|
||||||
|
var
|
||||||
|
i: NativeInt;
|
||||||
|
sepCnt: NativeInt;
|
||||||
|
drv: string;
|
||||||
|
pth1: string;
|
||||||
|
begin
|
||||||
|
sepCnt := 0;
|
||||||
|
if length(aPath) <= charThresh then
|
||||||
|
exit(aPath);
|
||||||
|
|
||||||
|
drv := extractFileDrive(aPath);
|
||||||
|
i := length(aPath);
|
||||||
|
while(i <> length(drv)+1) do
|
||||||
|
begin
|
||||||
|
Inc(sepCnt, Byte(aPath[i] = directorySeparator));
|
||||||
|
if sepCnt = 2 then break;
|
||||||
|
Dec(i);
|
||||||
|
end;
|
||||||
|
pth1 := aPath[i..length(aPath)];
|
||||||
|
exit( format('%s%s...%s',[drv,directorySeparator,pth1]) );
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -97,7 +97,7 @@ type
|
||||||
(*****************************************************************************
|
(*****************************************************************************
|
||||||
* Encapsulates the options/args related to the analysis & the code gen.
|
* Encapsulates the options/args related to the analysis & the code gen.
|
||||||
*)
|
*)
|
||||||
TOutputOpts= class(TOptsGroup)
|
TOutputOpts = class(TOptsGroup)
|
||||||
private
|
private
|
||||||
fTrgKind: TTargetSystem;
|
fTrgKind: TTargetSystem;
|
||||||
fBinKind: TBinaryKind;
|
fBinKind: TBinaryKind;
|
||||||
|
|
|
@ -135,6 +135,10 @@ object CEMainForm: TCEMainForm
|
||||||
D0FF3C94D1FF3E97D3EE000000000000000000000000FFFFFF00
|
D0FF3C94D1FF3E97D3EE000000000000000000000000FFFFFF00
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
object mnuItemMruFile: TMenuItem
|
||||||
|
Caption = 'Open recent file'
|
||||||
|
ImageIndex = 9
|
||||||
|
end
|
||||||
object MenuItem43: TMenuItem
|
object MenuItem43: TMenuItem
|
||||||
Action = actFileClose
|
Action = actFileClose
|
||||||
Bitmap.Data = {
|
Bitmap.Data = {
|
||||||
|
@ -861,6 +865,10 @@ object CEMainForm: TCEMainForm
|
||||||
D0FF3C94D1FF3E97D3EE000000000000000000000000FFFFFF00
|
D0FF3C94D1FF3E97D3EE000000000000000000000000FFFFFF00
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
object mnuItemMruProj: TMenuItem
|
||||||
|
Caption = 'Open recent project'
|
||||||
|
ImageIndex = 9
|
||||||
|
end
|
||||||
object MenuItem42: TMenuItem
|
object MenuItem42: TMenuItem
|
||||||
Action = actProjClose
|
Action = actProjClose
|
||||||
Bitmap.Data = {
|
Bitmap.Data = {
|
||||||
|
|
|
@ -98,6 +98,8 @@ type
|
||||||
MenuItem52: TMenuItem;
|
MenuItem52: TMenuItem;
|
||||||
MenuItem53: TMenuItem;
|
MenuItem53: TMenuItem;
|
||||||
MenuItem54: TMenuItem;
|
MenuItem54: TMenuItem;
|
||||||
|
mnuItemMruFile: TMenuItem;
|
||||||
|
mnuItemMruProj: TMenuItem;
|
||||||
mnuItemWin: TMenuItem;
|
mnuItemWin: TMenuItem;
|
||||||
MenuItem4: TMenuItem;
|
MenuItem4: TMenuItem;
|
||||||
MenuItem5: TMenuItem;
|
MenuItem5: TMenuItem;
|
||||||
|
@ -151,6 +153,8 @@ type
|
||||||
fPrjCfWidg: TCEProjectConfigurationWidget;
|
fPrjCfWidg: TCEProjectConfigurationWidget;
|
||||||
fStExpWidg: TCEStaticExplorerWidget;
|
fStExpWidg: TCEStaticExplorerWidget;
|
||||||
fFindWidg: TCESearchWidget;
|
fFindWidg: TCESearchWidget;
|
||||||
|
fProjMru: TMruFileList;
|
||||||
|
fFileMru: TMruFileList;
|
||||||
|
|
||||||
// widget interfaces subroutines
|
// widget interfaces subroutines
|
||||||
procedure checkWidgetActions(const aWidget: TCEWidget);
|
procedure checkWidgetActions(const aWidget: TCEWidget);
|
||||||
|
@ -178,6 +182,12 @@ type
|
||||||
procedure closeProj;
|
procedure closeProj;
|
||||||
procedure addSource(const aFilename: string);
|
procedure addSource(const aFilename: string);
|
||||||
|
|
||||||
|
// mru
|
||||||
|
procedure mruChange(Sender: TObject);
|
||||||
|
procedure mruFileItemClick(Sender: TObject);
|
||||||
|
procedure mruProjItemClick(Sender: TObject);
|
||||||
|
procedure mruClearClick(Sender: TObject);
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor create(aOwner: TComponent); override;
|
constructor create(aOwner: TComponent); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
|
@ -210,6 +220,13 @@ var
|
||||||
begin
|
begin
|
||||||
inherited create(aOwner);
|
inherited create(aOwner);
|
||||||
//
|
//
|
||||||
|
fProjMru := TMruFileList.Create;
|
||||||
|
fFileMru := TMruFileList.Create;
|
||||||
|
fProjMru.objectTag := mnuItemMruProj;
|
||||||
|
fFileMru.objectTag := mnuItemMruFile;
|
||||||
|
fProjMru.OnChange := @mruChange;
|
||||||
|
fFileMru.OnChange := @mruChange;
|
||||||
|
//
|
||||||
fWidgList := TCEWidgetList.Create;
|
fWidgList := TCEWidgetList.Create;
|
||||||
fMesgWidg := TCEMessagesWidget.create(nil);
|
fMesgWidg := TCEMessagesWidget.create(nil);
|
||||||
fEditWidg := TCEEditorWidget.create(nil);
|
fEditWidg := TCEEditorWidget.create(nil);
|
||||||
|
@ -270,6 +287,8 @@ begin
|
||||||
fStExpWidg.Free;
|
fStExpWidg.Free;
|
||||||
fFindWidg.Free;
|
fFindWidg.Free;
|
||||||
fProject.Free;
|
fProject.Free;
|
||||||
|
fProjMru.Free;
|
||||||
|
fFileMru.Free;
|
||||||
//
|
//
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
@ -370,6 +389,60 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEMainForm.mruChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
srcLst: TMruFileList;
|
||||||
|
trgMnu: TMenuItem;
|
||||||
|
itm: TMenuItem;
|
||||||
|
fname: string;
|
||||||
|
clickTrg: TNotifyEvent;
|
||||||
|
begin
|
||||||
|
srcLst := TMruFileList(Sender);
|
||||||
|
if srcLst = nil then exit;
|
||||||
|
trgMnu := TMenuItem(srcLst.objectTag);
|
||||||
|
if trgMnu = nil then exit;
|
||||||
|
|
||||||
|
if fUpdateCount > 0 then exit;
|
||||||
|
Inc(fUpdateCount);
|
||||||
|
try
|
||||||
|
if srcLst = fFileMru then
|
||||||
|
clickTrg := @mruFileItemClick
|
||||||
|
else if srcLst = fProjMru then
|
||||||
|
clickTrg := @mruProjItemClick;
|
||||||
|
|
||||||
|
trgMnu.Clear;
|
||||||
|
|
||||||
|
itm := TMenuItem.Create(trgMnu);
|
||||||
|
itm.Caption := 'Clear';
|
||||||
|
itm.OnClick := @mruClearClick;
|
||||||
|
itm.Tag := PtrInt(srcLst);
|
||||||
|
trgMnu.Add(itm);
|
||||||
|
trgMnu.AddSeparator;
|
||||||
|
|
||||||
|
for fname in srcLst do
|
||||||
|
begin
|
||||||
|
itm := TMenuItem.Create(trgMnu);
|
||||||
|
itm.Hint := fname;
|
||||||
|
itm.Caption := displayShortFilename(fname, 50);
|
||||||
|
itm.OnClick := clickTrg;
|
||||||
|
trgMnu.Add(itm);
|
||||||
|
end;
|
||||||
|
|
||||||
|
finally
|
||||||
|
Dec(fUpdateCount);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEMainForm.mruClearClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
srcLst: TMruFileList;
|
||||||
|
begin
|
||||||
|
srcLst := TMruFileList(TmenuItem(Sender).Tag);
|
||||||
|
if srcLst = nil then exit;
|
||||||
|
//
|
||||||
|
srcLst.Clear;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.FormShow(Sender: TObject);
|
procedure TCEMainForm.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
@ -429,6 +502,7 @@ begin
|
||||||
fEditWidg.editor[i].Lines.LoadFromFile(aFilename);
|
fEditWidg.editor[i].Lines.LoadFromFile(aFilename);
|
||||||
fEditWidg.editor[i].fileName := aFilename;
|
fEditWidg.editor[i].fileName := aFilename;
|
||||||
fEditWidg.focusedEditorChanged;
|
fEditWidg.focusedEditorChanged;
|
||||||
|
fFileMru.Insert(0,aFilename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.saveFile(const edIndex: NativeInt);
|
procedure TCEMainForm.saveFile(const edIndex: NativeInt);
|
||||||
|
@ -468,6 +542,7 @@ begin
|
||||||
finally
|
finally
|
||||||
fEditWidg.editor[edIndex].fileName := aFilename;
|
fEditWidg.editor[edIndex].fileName := aFilename;
|
||||||
fEditWidg.editor[edIndex].modified := false;
|
fEditWidg.editor[edIndex].modified := false;
|
||||||
|
fFileMru.Insert(0,aFilename);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -489,6 +564,11 @@ begin
|
||||||
fWidgList.widget[i].docFocused(fEditWidg.editor[aIndex]);
|
fWidgList.widget[i].docFocused(fEditWidg.editor[aIndex]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEMainForm.mruFileItemClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
openFile(TMenuItem(Sender).Hint);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.actFileOpenExecute(Sender: TObject);
|
procedure TCEMainForm.actFileOpenExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if fEditWidg = nil then exit;
|
if fEditWidg = nil then exit;
|
||||||
|
@ -999,6 +1079,7 @@ procedure TCEMainForm.saveProjAs(const aFilename: string);
|
||||||
begin
|
begin
|
||||||
fProject.fileName := aFilename;
|
fProject.fileName := aFilename;
|
||||||
fProject.saveToFile(fProject.fileName);
|
fProject.saveToFile(fProject.fileName);
|
||||||
|
fProjMru.Insert(0,fProject.fileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.openProj(const aFilename: string);
|
procedure TCEMainForm.openProj(const aFilename: string);
|
||||||
|
@ -1006,6 +1087,12 @@ begin
|
||||||
closeProj;
|
closeProj;
|
||||||
newProj;
|
newProj;
|
||||||
fProject.loadFromFile(aFilename);
|
fProject.loadFromFile(aFilename);
|
||||||
|
fProjMru.Insert(0,aFilename);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEMainForm.mruProjItemClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
openProj(TMenuItem(Sender).Hint);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjNewExecute(Sender: TObject);
|
procedure TCEMainForm.actProjNewExecute(Sender: TObject);
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
inherited CESearchWidget: TCESearchWidget
|
inherited CESearchWidget: TCESearchWidget
|
||||||
Left = 1468
|
Left = 1492
|
||||||
Height = 237
|
Height = 239
|
||||||
Top = 516
|
Top = 468
|
||||||
Width = 394
|
Width = 394
|
||||||
Caption = 'Search & replace'
|
Caption = 'Search & replace'
|
||||||
ClientHeight = 237
|
ClientHeight = 239
|
||||||
ClientWidth = 394
|
ClientWidth = 394
|
||||||
inherited Back: TPanel
|
inherited Back: TPanel
|
||||||
Height = 237
|
Height = 239
|
||||||
Width = 394
|
Width = 394
|
||||||
ClientHeight = 237
|
ClientHeight = 239
|
||||||
ClientWidth = 394
|
ClientWidth = 394
|
||||||
inherited Content: TPanel
|
inherited Content: TPanel
|
||||||
Height = 237
|
Height = 239
|
||||||
Width = 394
|
Width = 394
|
||||||
ClientHeight = 237
|
ClientHeight = 239
|
||||||
ClientWidth = 394
|
ClientWidth = 394
|
||||||
object cbToFind: TComboBox[0]
|
object cbToFind: TComboBox[0]
|
||||||
Left = 4
|
Left = 4
|
||||||
|
@ -30,7 +30,7 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
object btnFind: TBitBtn[1]
|
object btnFind: TBitBtn[1]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 24
|
Height = 24
|
||||||
Top = 153
|
Top = 155
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
|
@ -76,7 +76,7 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
object btnReplace: TBitBtn[2]
|
object btnReplace: TBitBtn[2]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 24
|
Height = 24
|
||||||
Top = 181
|
Top = 183
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
|
@ -121,13 +121,13 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
end
|
end
|
||||||
object grpOpts: TGroupBox[3]
|
object grpOpts: TGroupBox[3]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 88
|
Height = 90
|
||||||
Top = 61
|
Top = 61
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
Caption = 'Options'
|
Caption = 'Options'
|
||||||
ClientHeight = 70
|
ClientHeight = 72
|
||||||
ClientWidth = 382
|
ClientWidth = 382
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
object chkWWord: TCheckBox
|
object chkWWord: TCheckBox
|
||||||
|
@ -176,7 +176,7 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
object btnReplaceAll: TBitBtn[4]
|
object btnReplaceAll: TBitBtn[4]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 24
|
Height = 24
|
||||||
Top = 209
|
Top = 211
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
inherited CEStaticExplorerWidget: TCEStaticExplorerWidget
|
inherited CEStaticExplorerWidget: TCEStaticExplorerWidget
|
||||||
Left = 999
|
Left = 1592
|
||||||
Height = 276
|
Height = 276
|
||||||
Top = 284
|
Top = 609
|
||||||
Width = 261
|
Width = 261
|
||||||
Caption = 'Static explorer'
|
Caption = 'Static explorer'
|
||||||
ClientHeight = 276
|
ClientHeight = 276
|
||||||
|
@ -29,13 +29,14 @@ inherited CEStaticExplorerWidget: TCEStaticExplorerWidget
|
||||||
HideSelection = False
|
HideSelection = False
|
||||||
Images = imgList
|
Images = imgList
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
|
RightClickSelect = True
|
||||||
RowSelect = True
|
RowSelect = True
|
||||||
ScrollBars = ssAutoBoth
|
ScrollBars = ssAutoBoth
|
||||||
SelectionColor = clActiveBorder
|
SelectionColor = clActiveBorder
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnDeletion = TreeDeletion
|
OnDeletion = TreeDeletion
|
||||||
OnKeyPress = TreeKeyPress
|
OnKeyPress = TreeKeyPress
|
||||||
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||||
Items.Data = {
|
Items.Data = {
|
||||||
F9FFFFFF02000A000000000000000000000000000000FFFFFFFF000000000000
|
F9FFFFFF02000A000000000000000000000000000000FFFFFFFF000000000000
|
||||||
00000005000000416C6961730100000001000000FFFFFFFFFFFFFFFF00000000
|
00000005000000416C6961730100000001000000FFFFFFFFFFFFFFFF00000000
|
||||||
|
|
Loading…
Reference in New Issue