improved the mini explorer

This commit is contained in:
Basile Burg 2014-08-04 04:46:54 +02:00
parent 54d7f8902d
commit ebdc158738
3 changed files with 135 additions and 3 deletions

View File

@ -13,6 +13,7 @@ object CEMainForm: TCEMainForm
LCLVersion = '1.2.4.0'
object mainMenu: TMainMenu
Images = imgList
top = 1
object MenuItem1: TMenuItem
Caption = 'File'
object MenuItem5: TMenuItem
@ -454,6 +455,12 @@ object CEMainForm: TCEMainForm
AEEAB3B3B100B5B5B300B5B5B300B5B5B300B5B5B300B5B5B300
}
end
object MenuItem59: TMenuItem
Caption = '-'
end
object MenuItem60: TMenuItem
Action = actFileOpenContFold
end
end
object MenuItem7: TMenuItem
Caption = 'Edit'
@ -1259,6 +1266,9 @@ object CEMainForm: TCEMainForm
91F4969391FF908D8B00969391FF969391F4979492008D8A8800
}
end
object MenuItem61: TMenuItem
Action = actProjOpenContFold
end
object MenuItem40: TMenuItem
Caption = '-'
end
@ -1751,6 +1761,7 @@ object CEMainForm: TCEMainForm
Images = imgList
OnUpdate = ActionsUpdate
left = 32
top = 1
object actEdCopy: TAction
Category = 'Edit'
Caption = 'Copy'
@ -1976,11 +1987,23 @@ object CEMainForm: TCEMainForm
OnExecute = actEdFindNextExecute
ShortCut = 114
end
object actFileOpenContFold: TAction
Category = 'File'
Caption = 'View in mini explorer'
ImageIndex = 29
OnExecute = actFileOpenContFoldExecute
end
object actProjOpenContFold: TAction
Category = 'Project'
Caption = 'View in mini explorer'
ImageIndex = 29
OnExecute = actProjOpenContFoldExecute
end
end
object imgList: TImageList
left = 64
Bitmap = {
4C691D0000001000000010000000008F4E00008C4AB000965DFF00935AFF0093
4C691E0000001000000010000000008F4E00008C4AB000965DFF00935AFF0093
59FF009359FF009359FF009359FF009359FF00945AFF008743FF008945FF008A
49A8FFFFFF00008F4E00008F4F00008E4E00008A47FF66E2D0FF62DDCAFF62DD
C8FF62DDC8FF62DDC8FF62DDC8FF62DDC8FF62DDC9FF61E0CAFF62DEC8FF3ABA
@ -2908,7 +2931,39 @@ object CEMainForm: TCEMainForm
65FF666362FF5A5756C0605D5C007E7C7A00716F6DC0767472FF706D6CFF6D6A
69FF696765FF666362FF5A5756C0000000000000003300000033000000330000
0033000000330000000000000000000000000000000000000033000000330000
0033000000330000003300000000
0033000000330000003300000000B8A596EFB5A292FFB5A090FFB4A090FFB49F
8FFFB39F8EFFB39F8EFFB39F8EFFB39F8EFFB39F8FFFB4A191FFB6A393FFB5A2
92FFB4A191FFBBA99AFFB8A696B0B5A292FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB19C8BFFFFFF
FFFFFFFFFFFFFFFFFFFFB6A393FFB5A090FFFFFFFFFF50C08BFF51C18BFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFEFDFFFFFFFEFFFFFFFFFFAF9A89FFF6F2
EBFF73706DFFF9F4EEFFB6A393FFB4A090FFFFFFFFFF4FB592FF6AB49BFFAFAA
ADFFA8A8A9FFD2D2D2FFF8F6F5FFFDF9F8FFFDFAF9FFFFFFFFFFB09B8AFFE7DD
D1FFE8DDD1FFE9DED2FFB7A494FFB4A090FFFFFFFFFFFFFFFFFFFFFAFAFFFEFA
F9FFFFFFFFFFFFFEFEFFF8F5F4FFFCF8F7FFFCF9F7FFFFFFFFFFB19D8CFFB4A0
91FFB4A091FFB5A292FFB6A394F3B4A090FFFFFFFFFFAAAAABFFFFFDF9FFFEFC
FAFFDCBC94FFDDBD94FFFEFDFAFFFDFAF6FFFBF9F4FFFFFFFFFFB19C8CFFDFD3
C4FFDED1C3FFE0D4C6FFB7A596FFB4A090FFFFFFFFFFACADAEFFA9AAACFFFEF9
F7FFCCA983FFCFAB85FFA9ACAFFFA8A9AAFFD1D0CEFFFEFEFDFFB09B8BFFE3D8
CCFFE2D6CAFFE5D9CDFFB6A394FFB4A190FFFFFFFFFFACADAEFFFEF8F2FFFDF5
EFFFFFF8F1FFFFF9F2FFFFF7F1FFFBF5F0FFF9F4EEFFFFFFFFFFAF9B8AFFE7DE
D5FFE6DCD2FFE9E0D6FFB5A393FFB4A190FFFFFFFFFFACADAEFFFEF6EEFFFFF4
E9FF45C4FAFF46C5FBFFFFF5EBFFFBF3ECFFF8F1EBFFFFFFFFFFAF9B8AFFEEE6
DEFFECE4DCFFEFE8DFFFB5A393FFB4A191FFFFFFFFFFADAEAFFFACACADFFFFF1
E7FF45ACF9FF47ADFAFFB2ADAAFFAAABACFFCAC8C5FFFCFAF8FFB19C8CFFE5DC
D3FFE3DAD1FFE6DDD5FFB7A494FFB5A191FFFFFFFFFFADAEAFFFFAF0E8FFFAEF
E3FFFFF4E0FFFFF5E1FFFCF1E5FFF7EEE5FFF5ECE5FFFFFEFDFFB19D8CFFB29E
8DFFB19D8CFFB39F8EFFB7A595FFB5A191FFFFFFFDFFACAEAFFFF7EDE3FFF9EF
DFFF8581F1FF8682F2FFFBF1E0FFF5EBE1FFF2E9E0FFF7F2EEFFB09B8BFFFFFF
FFFFFFFFFFFFFFFFFFFFB6A393FFB5A191FFFFFFFBFFACAEB0FFACAEAFFFFAEF
DDFF5B57DEFF5D58DFFFB1B4AEFFACAEAFFFCDCBC6FFF7F2EFFFB19C8BFFF6F2
EBFF73706DFFF9F4EEFFB6A393FFB6A393FFFFFFFDFFF5EBE0FFF5EBE0FFF6EC
DFFFFAF0DEFFFBF1DFFFF8EEE0FFF5EBE1FFF4EAE0FFF5F1EEFFB3A090FFE9DE
D2FFE8DED1FFE9DFD3FFB7A495FFA9988BC0B6A393FFB5A293FFB5A293FFB5A3
93FFB6A392FFB6A393FFB6A393FFB5A393FFB5A293FFB6A394FFB7A596FFB7A4
95FFB7A494FFB7A596FFB7A495F2000000000000003300000033000000330000
0033000000330000003300000033000000330000003300000033000000330000
0033000000330000003300000030
}
end
object ApplicationProperties1: TApplicationProperties

View File

@ -70,6 +70,8 @@ type
actFileCompAndRunWithArgs: TAction;
actEdFind: TAction;
actEdFindNext: TAction;
actFileOpenContFold: TAction;
actProjOpenContFold: TAction;
actProjOptView: TAction;
actProjSource: TAction;
actProjRun: TAction;
@ -148,6 +150,9 @@ type
MenuItem56: TMenuItem;
MenuItem57: TMenuItem;
MenuItem58: TMenuItem;
MenuItem59: TMenuItem;
MenuItem60: TMenuItem;
MenuItem61: TMenuItem;
mnuItemMruFile: TMenuItem;
mnuItemMruProj: TMenuItem;
mnuItemWin: TMenuItem;
@ -164,6 +169,7 @@ type
procedure actFileCloseExecute(Sender: TObject);
procedure actFileCompAndRunExecute(Sender: TObject);
procedure actFileCompAndRunWithArgsExecute(Sender: TObject);
procedure actFileOpenContFoldExecute(Sender: TObject);
procedure actFileSaveAllExecute(Sender: TObject);
procedure actEdIndentExecute(Sender: TObject);
procedure actProjCompAndRunWithArgsExecute(Sender: TObject);
@ -178,6 +184,7 @@ type
procedure actProjNewExecute(Sender: TObject);
procedure actFileNewRunExecute(Sender: TObject);
procedure actFileOpenExecute(Sender: TObject);
procedure actProjOpenContFoldExecute(Sender: TObject);
procedure actProjOpenExecute(Sender: TObject);
procedure actEdPasteExecute(Sender: TObject);
procedure actProjCloseExecute(Sender: TObject);
@ -829,6 +836,15 @@ begin
end;
end;
procedure TCEMainForm.actProjOpenContFoldExecute(Sender: TObject);
begin
if fProject = nil then exit;
if not fileExists(fProject.fileName) then exit;
//
DockMaster.GetAnchorSite(fExplWidg).Show;
fExplWidg.expandPath(extractFilePath(fProject.fileName));
end;
procedure TCEMainForm.actFileNewExecute(Sender: TObject);
begin
newFile;
@ -1305,6 +1321,18 @@ begin
compileAndRunFile(fEditWidg.editorIndex, runargs);
end;
procedure TCEMainForm.actFileOpenContFoldExecute(Sender: TObject);
var
curr: TCESynMemo;
begin
curr := EditWidget.currentEditor;
if curr = nil then exit;
if not fileExists(curr.fileName) then exit;
//
DockMaster.GetAnchorSite(fExplWidg).Show;
fExplWidg.expandPath(extractFilePath(curr.fileName));
end;
procedure TCEMainForm.actProjCompileExecute(Sender: TObject);
begin
compileProject(fProject);

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Menus, StdCtrls, ComCtrls, Buttons, ce_widget, lcltype;
Menus, ComCtrls, Buttons, ce_widget, lcltype, strutils;
type
TCEMiniExplorerWidget = class(TCEWidget)
@ -31,6 +31,7 @@ type
private
fFavorites: TStringList;
fLastFold: string;
procedure lstFavDblClick(Sender: TObject);
procedure optset_LastFold(aReader: TReader);
procedure optget_LastFold(aWriter: TWriter);
procedure optset_Favs(aReader: TReader);
@ -54,6 +55,8 @@ type
destructor destroy; override;
//
procedure declareProperties(aFiler: TFiler); override;
//
procedure expandPath(const aPath: string);
end;
implementation
@ -71,6 +74,7 @@ begin
lstFiles.OnDeletion := @lstDeletion;
lstFav.OnDeletion := @lstDeletion;
lstFav.OnSelectItem := @lstFavSelect;
lstFav.OnDblClick := @lstFavDblClick;
//
Tree.OnClick := @treeClick;
Tree.OnChange := @treeChanged;
@ -197,6 +201,13 @@ begin
if Tree.Selected = nil then exit;
fFavorites.Add(PString(Tree.Selected.Data)^);
end;
procedure TCEMiniExplorerWidget.lstFavDblClick(Sender: TObject);
begin
if lstFav.Selected = nil then exit;
expandPath(lstFav.Selected.Caption);
end;
{$ENDREGION}
{$REGION Files -----------------------------------------------------------------}
@ -343,6 +354,44 @@ begin
if Tree.Selected.Expanded then exit;
treeScanSubFolders(Tree.Selected);
end;
//TODO-cbugfix: it leaks expanded nodes data.
procedure TCEMiniExplorerWidget.expandPath(const aPath: string);
var
i: NativeInt;
node : TTreeNode;
function dig(const aRoot: TTreenode): boolean;
var
i: NativeInt;
str: string;
begin
result := false;
for i := 0 to aRoot.Count-1 do
begin
str := PString(aRoot.Items[i].Data)^;
if LeftStr(aPath, length(str)) = str then
begin
result := true;
Tree.Selected := aRoot.Items[i];
Tree.Selected.Expand(false);
//
if str = aPath then break;
if dig(Tree.Selected) then break;
end;
end;
end;
begin
for i := 0 to Tree.Items.Count-1 do
begin
node := Tree.Items[i];
if node.Level = 0 then
begin
node.Selected := true;
node.Expand(false);
end;
if dig(node) then break;
end;
end;
{$ENDREGION}
end.