diff --git a/icons/book/book.png b/icons/book/book.png new file mode 100644 index 00000000..e48ff95e Binary files /dev/null and b/icons/book/book.png differ diff --git a/icons/book/book_grey.png b/icons/book/book_grey.png new file mode 100644 index 00000000..f7a04e6e Binary files /dev/null and b/icons/book/book_grey.png differ diff --git a/src/ce_icons.inc b/src/ce_icons.inc index f78f4cdd..fd7ac9c2 100644 --- a/src/ce_icons.inc +++ b/src/ce_icons.inc @@ -442,6 +442,47 @@ LazarusResources.Add('book_open','PNG',[ +#213#31#223'Z'#27#22'8'#179'7c'#191#230'm'#158']'#13#246'm'#246#205'?zj'#215 +#225'O'#1#6#0#215#185#17'o'#26'E'#145#174#0#0#0#0'IEND'#174'B`'#130 ]); +LazarusResources.Add('book_grey','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#16#0#0#0#16#8#4#0#0#0#181#250'7' + +#234#0#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#0' cHRM'#0#0'z&'#0#0#128#132#0 + +#0#250#0#0#0#128#232#0#0'u0'#0#0#234'`'#0#0':'#152#0#0#23'p'#156#186'Q<'#0#0 + +#0#2'bKGD'#0#255#135#143#204#191#0#0#0#223'IDAT('#207'm'#209#177'M'#196'0'#24 + +#134#225#231'O"Z'#150'`'#9#26'68'#6#160'f'#2#10'J'#10#26'J'#22'8'#137#142#1 + +'`'#3':V'#0#150'@:'#233#136's'#142')'#226#220#229#16'_e'#201#175'_'#127#191 + +#29#197#221#139#21'YQ'#28#18#26#205#235#253'eGY'#221'xp+'#255#1':'#143'+:F[' + +#217#214#187'l'#172#219#141#214#185#17#29'$!I'#174#22#134'g}E'#133#132#180'?' + +'=e'#148#196'l'#232#133#193'h]{'#132#214#137#225#0'$'#141'^v'#189'0R$'#10':'#162#20#9#138#146#134#226'ZDq'#162#165#2 + +#132't'#5#197'}'#238#238#173#237#199#216#241#238'}'#23'<'#201'k'#175#247#237 + +#204#188'y'#182#18#17#188#251#252#239#23#128']'#14'8'#239#225#189'@'#176'<' + +#20#135#214#26#13#173'~_~'#218#217'3a'#147#249#187#223#143'wp'#240#229#2#167 + +''''#31'`'#157'G'#0'^'#10#160#20#214'L'#3'G_'#255'F'#194#8' '#226#209#205'<' + +#172#245#24#20'%'#206#218'O'#176'T'#226#2#134'L'#168#27#28#134#236#135'o6' + +#168#210#163#6#8'1,%'#202#27#22#130#209'X'#240#237#253#230'R'#5'G'#127#30#153 + +#227'cn'#8']'#213'5'#28's'#147'o'#163#210#177#132'U'#14' ~'#27#133#220#4'a*y' + +#1' '#160'eT'#226'X'#127#243#199#29'J&'#251')'#166'5'#214#240'j]'#147#132'j' + +#147#4'S)'#24'P'#182#230'n'#152'K'#11#156#127#220'Z'#170'`'#255#231#3#201'&' + +#10'M'#229#236'p'#236#8#128'('#143']A'#243#252'>'#206'U3'#2'c'#248#206#246 + +#209'h'#31#215#179#10#10#137#155'}'#2#136'Wt\E'#215#231#131#13#195#160#156 + +#152'X'#3#244#139#255'&'#246#9'dI'#173#19#235#204#207'T'#227'S.f'#20#240'%' + +#183#201'D+'#177#247#162#166#206'@'#5#144#30'Yjy'#221#198#16'ytVqv'#17']'#173 + +'8'#198#225#145#145'L-(p'#146'f'#212'=^u'#23'r+'#179#231' 0'#23'4.\'#146#220 + +'q6&'#22'<'#15'#)7w'#186'6('#2#140#250#189'V'#167'}'#245'V7'#12':7'#215#139 + +#197'/'#168'P'#200#6#189'V\'#135'[G'#212'm'#174'_'#227'e'#209#229#191#183#207 + +#2#12#0'\'#18#219#240#21' '#12#174#0#0#0#0'IEND'#174'B`'#130 +]); LazarusResources.Add('bullet_black','PNG',[ #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#16#0#0#0#16#8#4#0#0#0#181#250'7' +#234#0#0#0#4'gAMA'#0#0#175#200'7'#5#138#233#0#0#0#25'tEXtSoftware'#0'Adobe I' diff --git a/src/ce_libman.pas b/src/ce_libman.pas index ce06059a..80b6e3ff 100644 --- a/src/ce_libman.pas +++ b/src/ce_libman.pas @@ -20,11 +20,15 @@ type fSourcePath: string; fLibFile: string; fProjFile: string; + fEnabled: boolean; published property libAlias: string read fAlias write fAlias; property libSourcePath: string read fSourcePath write fSourcePath; property libFile: string read fLibFile write fLibFile; property projectFile: string read fProjFile write fProjFile; + property enabled: boolean read fEnabled write fEnabled default true; + public + constructor Create(ACollection: TCollection); override; end; (** @@ -33,7 +37,7 @@ type TLibraryManager = class(TWritableLfmTextComponent) private fCol: TCollection; - procedure setCol(const aValue: TCollection); + procedure setCol(value: TCollection); published property libraries: TCollection read fCol write setCol; public @@ -54,6 +58,12 @@ var implementation +constructor TLibraryItem.Create(ACollection: TCollection); +begin + inherited create(ACollection); + fEnabled:=true; +end; + constructor TLibraryManager.create(aOwner: TComponent); var fName: string; @@ -148,9 +158,9 @@ begin inherited; end; -procedure TLibraryManager.setCol(const aValue: TCollection); +procedure TLibraryManager.setCol(value: TCollection); begin - fCol.assign(aValue); + fCol.assign(value); end; procedure TLibraryManager.updateDCD; @@ -166,7 +176,8 @@ begin for i := 0 to fCol.Count-1 do begin itm := TLibraryItem(fCol.Items[i]); - str.Add(itm.libSourcePath); + if itm.enabled then + str.Add(itm.libSourcePath); end; DcdWrapper.addImportFolders(str); finally @@ -188,8 +199,8 @@ begin for i := 0 to fCol.Count-1 do begin itm := TLibraryItem(fCol.Items[i]); - if someAliases.isNotNil then - if someAliases.IndexOf(itm.libAlias) = -1 then + if (not itm.enabled) or + (someAliases.isNotNil and (someAliases.IndexOf(itm.libAlias) = -1)) then continue; // single lib files if fileExists(itm.libFile) then @@ -232,8 +243,8 @@ begin for i := 0 to fCol.Count-1 do begin itm := TLibraryItem(fCol.Items[i]); - if someAliases.isNotNil then - if someAliases.IndexOf(itm.libAlias) = -1 then + if (not itm.enabled) or + (someAliases.isNotNil and (someAliases.IndexOf(itm.libAlias) = -1)) then continue; // if aList.IndexOf(itm.libSourcePath) <> -1 then diff --git a/src/ce_libmaneditor.lfm b/src/ce_libmaneditor.lfm index e587fb7f..732f98b1 100644 --- a/src/ce_libmaneditor.lfm +++ b/src/ce_libmaneditor.lfm @@ -157,6 +157,15 @@ inherited CELibManEditorWidget: TCELibManEditorWidget Spacing = 0 TabOrder = 11 end + object btnEnabled: TSpeedButton + Left = 196 + Height = 26 + Hint = 'disable or enable this library, without removing it from the collection' + Top = 0 + Width = 28 + Align = alLeft + OnClick = btnEnabledClick + end end object List: TListView[1] Left = 4 @@ -184,7 +193,12 @@ inherited CELibManEditorWidget: TCELibManEditorWidget item AutoSize = True Caption = 'project' - Width = 409 + Width = 54 + end + item + AutoSize = True + Caption = 'enabled' + Width = 355 end> GridLines = True HideSelection = False diff --git a/src/ce_libmaneditor.pas b/src/ce_libmaneditor.pas index 74c395bb..5329dd2e 100644 --- a/src/ce_libmaneditor.pas +++ b/src/ce_libmaneditor.pas @@ -8,7 +8,8 @@ uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, Menus, ComCtrls, Buttons, LazFileUtils, strutils, fphttpclient, StdCtrls, ce_widget, ce_interfaces, ce_nativeproject, ce_dmdwrap, ce_common, ce_dialogs, - ce_sharedres, process, ce_dubproject, ce_observer, ce_dlang, ce_stringrange; + ce_sharedres, process, ce_dubproject, ce_observer, ce_dlang, ce_stringrange, + ce_libman; type @@ -39,7 +40,9 @@ type btnSelProj: TBitBtn; List: TListView; Panel1: TPanel; + btnEnabled: TSpeedButton; procedure btnAddLibClick(Sender: TObject); + procedure btnEnabledClick(Sender: TObject); procedure btnDubFetchClick(Sender: TObject); procedure btnEditAliasClick(Sender: TObject); procedure btnOpenProjClick(Sender: TObject); @@ -63,9 +66,10 @@ type procedure projFocused(aProject: ICECommonProject); procedure projCompiling(aProject: ICECommonProject); procedure projCompiled(aProject: ICECommonProject; success: boolean); + function itemForRow(row: TListItem): TLibraryItem; + procedure RowToLibrary(row: TListItem); // procedure dataToGrid; - procedure gridToData; protected procedure DoShow; override; public @@ -76,14 +80,12 @@ type function sourceRoot(project: ICECommonProject): string; implementation - {$R *.lfm} -uses - ce_libman; const notav: string = '< n/a >'; + enableStr: array [boolean] of string = ('false','true'); constructor TCELibManEditorWidget.Create(aOwner: TComponent); begin @@ -100,6 +102,7 @@ begin AssignPng(btnDubFetch, 'dub_small'); AssignPng(btnSelProj, 'script_bricks'); AssignPng(btnOpenProj, 'book_open'); + AssignPng(btnEnabled, 'book'); end; procedure TCELibManEditorWidget.updateButtonsState; @@ -108,6 +111,10 @@ begin fProj.Filename.fileExists; btnOpenProj.Enabled := List.Selected.isNotNil and List.Selected.SubItems[2].fileExists; + if List.Selected.isNotNil and itemForRow(List.Selected).enabled then + AssignPng(btnEnabled, 'book') + else + AssignPng(btnEnabled, 'book_grey'); end; procedure TCELibManEditorWidget.projNew(aProject: ICECommonProject); @@ -146,9 +153,15 @@ procedure TCELibManEditorWidget.projCompiled(aProject: ICECommonProject; success begin end; +function TCELibManEditorWidget.itemForRow(row: TListItem): TLibraryItem; +begin + result := TLibraryItem(row.Data); +end; + procedure TCELibManEditorWidget.ListEdited(Sender: TObject; Item: TListItem; var AValue: string); begin - gridToData; + if Item.isNotNil then + RowToLibrary(item); end; procedure TCELibManEditorWidget.ListSelectItem(Sender: TObject; @@ -162,10 +175,12 @@ var itm: TListItem; begin itm := List.Items.Add; + itm.Data := LibMan.libraries.Add; itm.Caption := notav; itm.SubItems.Add(notav); itm.SubItems.Add(notav); itm.SubItems.Add(notav); + itm.SubItems.Add(enableStr[true]); SetFocus; itm.Selected := True; end; @@ -272,8 +287,8 @@ var err: integer; idx: integer; prj: TCEDubProject; - cdy: string; upd: boolean = false; + row: TListItem; begin if TDubPackageQueryForm.showAndWait(nme) <> mrOk then exit; @@ -374,15 +389,15 @@ begin try for idx := 0 to prj.sourcesCount-1 do str.Add(prj.sourceAbsolute(idx)); - with List.Items.Add do - begin - Caption := nme; - SubItems.Add(prj.outputFilename); - cdy := sourceRoot(prj as ICECommonProject); - SubItems.Add(cdy); - SubItems.Add(prj.filename); - Selected:=true; - end; + row := List.Items.Add; + row.Data := LibMan.libraries.Add; + row.Caption := nme; + row.SubItems.Add(prj.outputFilename); + row.SubItems.Add(sourceRoot(prj as ICECommonProject)); + row.SubItems.Add(prj.filename); + row.SubItems.Add(enableStr[true]); + row.Selected:=true; + RowToLibrary(row); finally str.Free; end; @@ -392,7 +407,6 @@ begin finally prj.Free; EntitiesConnector.endUpdate; - gridToData; end; end; @@ -405,7 +419,20 @@ begin al := List.Selected.Caption; if inputQuery('library alias', '', al) then List.Selected.Caption := al; - gridToData; + RowToLibrary(List.Selected); +end; + +procedure TCELibManEditorWidget.btnEnabledClick(Sender: TObject); +begin + if List.Selected.isNil then + exit; + + if List.Selected.SubItems[3] = 'true' then + List.Selected.SubItems[3] := 'false' + else + List.Selected.SubItems[3] := 'true'; + RowToLibrary(List.Selected); + updateButtonsState; end; procedure TCELibManEditorWidget.btnOpenProjClick(Sender: TObject); @@ -447,6 +474,7 @@ var fname: string; root: string; lalias: string; + row: TListItem; begin if fProj = nil then exit; // @@ -469,21 +497,21 @@ begin end; // fname := fProj.outputFilename; - with List.Items.Add do - begin - Caption := ExtractFileNameOnly(fname); - if fname.extractFileExt <> libExt then - SubItems.add(fname + libExt) - else - SubItems.add(fname); - SubItems.add(root); - SubItems.add(fProj.filename); - if not SubItems[0].fileExists then - dlgOkInfo('the library file does not exist, maybe the project not been already compiled ?'); - Selected:= true; - end; + row := List.Items.Add; + row.Data := LibMan.libraries.Add; + row.Caption := ExtractFileNameOnly(fname); + if fname.extractFileExt <> libExt then + row.SubItems.add(fname + libExt) + else + row.SubItems.add(fname); + row.SubItems.add(root); + row.SubItems.add(fProj.filename); + row.SubItems.add(enableStr[true]); + if not row.SubItems[0].fileExists then + dlgOkInfo('the library file does not exist, maybe the project not been already compiled ?'); + row.Selected:= true; SetFocus; - gridToData; + RowToLibrary(row); finally str.free; end; @@ -493,28 +521,27 @@ procedure TCELibManEditorWidget.btnRemLibClick(Sender: TObject); begin if List.Selected.isNil then exit; + LibMan.libraries.Delete(List.Selected.Index); List.Items.Delete(List.Selected.Index); - gridToData; end; procedure TCELibManEditorWidget.btnSelProjClick(Sender: TObject); var - ini: string = ''; + ini: string; begin if List.Selected.isNil then exit; - if List.Selected.SubItems.Count > 2 then - ini := List.Selected.SubItems[2] - else while List.Selected.SubItems.Count < 3 do - List.Selected.SubItems.Add(ini); - with TOpenDialog.Create(nil) do try + // + ini := List.Selected.SubItems[2]; + with TOpenDialog.Create(nil) do + try FileName := ini; if Execute then List.Selected.SubItems[2] := FileName; finally free; end; - gridToData; + RowToLibrary(List.Selected); end; procedure TCELibManEditorWidget.btnSelFileClick(Sender: TObject); @@ -523,28 +550,26 @@ var begin if List.Selected.isNil then exit; - if List.Selected.SubItems.Count > 0 then - ini := List.Selected.SubItems[0] - else - List.Selected.SubItems.Add(ini); + // + ini := List.Selected.SubItems[0]; with TOpenDialog.Create(nil) do - try - filename := ini; - if Execute then + try + filename := ini; + if Execute then + begin + if not filename.fileExists then + List.Selected.SubItems[0] := filename.extractFilePath + else begin - if not filename.fileExists then - List.Selected.SubItems[0] := filename.extractFilePath - else - begin - List.Selected.SubItems[0] := filename; - if (List.Selected.Caption.isEmpty) or (List.Selected.Caption = notav) then - List.Selected.Caption := ChangeFileExt(filename.extractFileName, ''); - end; + List.Selected.SubItems[0] := filename; + if (List.Selected.Caption.isEmpty) or (List.Selected.Caption = notav) then + List.Selected.Caption := ChangeFileExt(filename.extractFileName, ''); end; - finally - Free; end; - gridToData; + finally + Free; + end; + RowToLibrary(List.Selected); end; procedure TCELibManEditorWidget.btnSelfoldOfFilesClick(Sender: TObject); @@ -553,16 +578,11 @@ var begin if List.Selected.isNil then exit; - if List.Selected.SubItems.Count > 0 then - dir := List.Selected.SubItems[0] - else - begin - dir := ''; - List.Selected.SubItems.Add(dir); - end; + // + dir := List.Selected.SubItems[0]; if selectDirectory('folder of static libraries', dir, outdir, True, 0) then List.Selected.SubItems[0] := outdir; - gridToData; + RowToLibrary(List.Selected); end; procedure TCELibManEditorWidget.btnSelRootClick(Sender: TObject); @@ -571,39 +591,39 @@ var begin if List.Selected.isNil then exit; - if List.Selected.SubItems.Count > 1 then - dir := List.Selected.SubItems[1] - else - begin - dir := ''; - while List.Selected.SubItems.Count < 2 do - List.Selected.SubItems.Add(dir); - end; + // + dir := List.Selected.SubItems[1]; if selectDirectory('sources root', dir, outdir, True, 0) then List.Selected.SubItems[1] := outdir; - gridToData; + RowToLibrary(List.Selected); end; procedure TCELibManEditorWidget.btnMoveUpClick(Sender: TObject); +var + i: integer; begin if list.Selected.isNil then exit; if list.Selected.Index = 0 then exit; // - list.Items.Exchange(list.Selected.Index, list.Selected.Index - 1); - gridToData; + i := list.Selected.Index; + list.Items.Exchange(i, i - 1); + LibMan.libraries.Exchange(i, i - 1); end; procedure TCELibManEditorWidget.btnMoveDownClick(Sender: TObject); +var + i: integer; begin if list.Selected.isNil then exit; if list.Selected.Index = list.Items.Count - 1 then exit; // - list.Items.Exchange(list.Selected.Index, list.Selected.Index + 1); - gridToData; + i := list.Selected.Index; + list.Items.Exchange(i, i + 1); + LibMan.libraries.Exchange(i, i + 1); end; procedure TCELibManEditorWidget.DoShow; @@ -626,32 +646,30 @@ begin begin itm := TLibraryItem(LibMan.libraries.Items[i]); row := List.Items.Add; + row.Data:= itm; row.Caption := itm.libAlias; row.SubItems.Add(itm.libFile); row.SubItems.Add(itm.libSourcePath); row.SubItems.Add(itm.projectFile); + row.SubItems.Add(enableStr[itm.enabled]); end; List.EndUpdate; end; -procedure TCELibManEditorWidget.gridToData; +procedure TCELibManEditorWidget.RowToLibrary(row: TListItem); var itm: TLibraryItem; - row: TListItem; begin - if LibMan.isNil then + itm := itemForRow(row); + if itm.isNil then exit; - LibMan.libraries.BeginUpdate; - LibMan.libraries.Clear; - for row in List.Items do - begin - itm := TLibraryItem(LibMan.libraries.Add); - itm.libAlias := row.Caption; - itm.libFile := row.SubItems[0]; - itm.libSourcePath := row.SubItems[1]; - itm.projectFile:= row.SubItems[2]; - end; - LibMan.libraries.EndUpdate; + + itm.libAlias := row.Caption; + itm.libFile := row.SubItems[0]; + itm.libSourcePath := row.SubItems[1]; + itm.projectFile := row.SubItems[2]; + itm.enabled := row.SubItems[3] = enableStr[true]; + LibMan.updateDCD; end; diff --git a/wiki/wiki.todo.txt b/wiki/wiki.todo.txt index 7e269f06..2856ff71 100644 --- a/wiki/wiki.todo.txt +++ b/wiki/wiki.todo.txt @@ -1,2 +1,7 @@ - new symbolic strings, ENV_XXX, see issue #27 -- fetch DUB package, list of online package can be displayed. \ No newline at end of file +- fetch DUB package, list of online package can be displayed. +- libman, entries can be disabled without removal, example: useful when testing new dmd version with runnable, no need to recompile all libs of the registry. +- support for gdmd +- input process widget: kill process, in case of error, infinite loop, emergency kill +- editor note about usefull commands: comment selection, invert version all/none +- tuto are obsolete \ No newline at end of file