diff --git a/components/ideintf/ideintf.lpk b/components/ideintf/ideintf.lpk index fc8dc25848..c24bdbb647 100644 --- a/components/ideintf/ideintf.lpk +++ b/components/ideintf/ideintf.lpk @@ -328,6 +328,10 @@ + + + + diff --git a/components/ideintf/ideintf.pas b/components/ideintf/ideintf.pas index d82fab5700..a174766310 100644 --- a/components/ideintf/ideintf.pas +++ b/components/ideintf/ideintf.pas @@ -21,7 +21,7 @@ uses PropEdits, PropEditUtils, SrcEditorIntf, StatusBarPropEdit, StringsPropEditDlg, TextTools, ToolBarIntf, TreeViewPropEdit, UnitResources, bufdatasetdsgn, selectdatasetdlg, SelEdits, IdeIntfStrConsts, - LazarusPackageIntf; + PropEditConfig, LazarusPackageIntf; implementation diff --git a/components/ideintf/languages/objinspstrconsts.ca.po b/components/ideintf/languages/objinspstrconsts.ca.po index c67c6b147f..c1f09beab2 100644 --- a/components/ideintf/languages/objinspstrconsts.ca.po +++ b/components/ideintf/languages/objinspstrconsts.ca.po @@ -1330,6 +1330,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Desconegut" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "" diff --git a/components/ideintf/languages/objinspstrconsts.cs.po b/components/ideintf/languages/objinspstrconsts.cs.po index c3aa7d586a..24a9c21d94 100644 --- a/components/ideintf/languages/objinspstrconsts.cs.po +++ b/components/ideintf/languages/objinspstrconsts.cs.po @@ -1294,6 +1294,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Neznámý" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Nevybrat nic" diff --git a/components/ideintf/languages/objinspstrconsts.de.po b/components/ideintf/languages/objinspstrconsts.de.po index 7d092bbfe1..e23cc92773 100644 --- a/components/ideintf/languages/objinspstrconsts.de.po +++ b/components/ideintf/languages/objinspstrconsts.de.po @@ -1292,6 +1292,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Unbekannt" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "Alles abwählen" diff --git a/components/ideintf/languages/objinspstrconsts.es.po b/components/ideintf/languages/objinspstrconsts.es.po index 152cb6ce45..eea61875a0 100644 --- a/components/ideintf/languages/objinspstrconsts.es.po +++ b/components/ideintf/languages/objinspstrconsts.es.po @@ -1295,6 +1295,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Desconocido" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "Deseleccionar todo" diff --git a/components/ideintf/languages/objinspstrconsts.fi.po b/components/ideintf/languages/objinspstrconsts.fi.po index 4b6b9a30ca..fe507e973c 100644 --- a/components/ideintf/languages/objinspstrconsts.fi.po +++ b/components/ideintf/languages/objinspstrconsts.fi.po @@ -1286,6 +1286,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Tuntematon" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Poista valinta kaikista" diff --git a/components/ideintf/languages/objinspstrconsts.fr.po b/components/ideintf/languages/objinspstrconsts.fr.po index d6ba3ff0c8..3c18e8372e 100644 --- a/components/ideintf/languages/objinspstrconsts.fr.po +++ b/components/ideintf/languages/objinspstrconsts.fr.po @@ -1290,6 +1290,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Inconnu" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Tout désélectionner" diff --git a/components/ideintf/languages/objinspstrconsts.he.po b/components/ideintf/languages/objinspstrconsts.he.po index 300825d4d5..d175c7fdf2 100644 --- a/components/ideintf/languages/objinspstrconsts.he.po +++ b/components/ideintf/languages/objinspstrconsts.he.po @@ -1336,6 +1336,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "לא ידוע " +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "בטל את כל הבחירות" diff --git a/components/ideintf/languages/objinspstrconsts.hu.po b/components/ideintf/languages/objinspstrconsts.hu.po index e1a76bdd4b..7fb444d95b 100644 --- a/components/ideintf/languages/objinspstrconsts.hu.po +++ b/components/ideintf/languages/objinspstrconsts.hu.po @@ -1293,6 +1293,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Ismeretlen" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "Kijelölések megszüntetése" diff --git a/components/ideintf/languages/objinspstrconsts.id.po b/components/ideintf/languages/objinspstrconsts.id.po index 5181cf3fa9..4d4182b066 100644 --- a/components/ideintf/languages/objinspstrconsts.id.po +++ b/components/ideintf/languages/objinspstrconsts.id.po @@ -1334,6 +1334,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Tidak dikenal" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "" diff --git a/components/ideintf/languages/objinspstrconsts.it.po b/components/ideintf/languages/objinspstrconsts.it.po index 769d1d8a4b..12bd801bc1 100644 --- a/components/ideintf/languages/objinspstrconsts.it.po +++ b/components/ideintf/languages/objinspstrconsts.it.po @@ -1296,6 +1296,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Sconosciuto" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Deseleziona tutto" diff --git a/components/ideintf/languages/objinspstrconsts.ja.po b/components/ideintf/languages/objinspstrconsts.ja.po index ed390c95f7..1e1e8abb04 100644 --- a/components/ideintf/languages/objinspstrconsts.ja.po +++ b/components/ideintf/languages/objinspstrconsts.ja.po @@ -1301,6 +1301,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "不明" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "すべての選択を解除(&U)" diff --git a/components/ideintf/languages/objinspstrconsts.lt.po b/components/ideintf/languages/objinspstrconsts.lt.po index 4bef17f7b6..53ac6d77c8 100644 --- a/components/ideintf/languages/objinspstrconsts.lt.po +++ b/components/ideintf/languages/objinspstrconsts.lt.po @@ -1294,6 +1294,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Nežinoma" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Naikinti visą žymėjimą" diff --git a/components/ideintf/languages/objinspstrconsts.nl.po b/components/ideintf/languages/objinspstrconsts.nl.po index 4cfd7a545b..bf00e0287e 100644 --- a/components/ideintf/languages/objinspstrconsts.nl.po +++ b/components/ideintf/languages/objinspstrconsts.nl.po @@ -1321,6 +1321,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Onbekend" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "" diff --git a/components/ideintf/languages/objinspstrconsts.pl.po b/components/ideintf/languages/objinspstrconsts.pl.po index 9970e2ee94..31822fd9c4 100644 --- a/components/ideintf/languages/objinspstrconsts.pl.po +++ b/components/ideintf/languages/objinspstrconsts.pl.po @@ -1288,6 +1288,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Nieznany" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "Odznacz wszystko" diff --git a/components/ideintf/languages/objinspstrconsts.pot b/components/ideintf/languages/objinspstrconsts.pot index fe88089a44..480ea0a52b 100644 --- a/components/ideintf/languages/objinspstrconsts.pot +++ b/components/ideintf/languages/objinspstrconsts.pot @@ -1280,6 +1280,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "" diff --git a/components/ideintf/languages/objinspstrconsts.pt_BR.po b/components/ideintf/languages/objinspstrconsts.pt_BR.po index df501f8b71..d932845955 100644 --- a/components/ideintf/languages/objinspstrconsts.pt_BR.po +++ b/components/ideintf/languages/objinspstrconsts.pt_BR.po @@ -1289,6 +1289,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Desconhecido" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Desmarcar tudo" diff --git a/components/ideintf/languages/objinspstrconsts.ru.po b/components/ideintf/languages/objinspstrconsts.ru.po index 2e3edacefa..e9ed6eec48 100644 --- a/components/ideintf/languages/objinspstrconsts.ru.po +++ b/components/ideintf/languages/objinspstrconsts.ru.po @@ -1289,6 +1289,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Неизвестный" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Снять выделение" diff --git a/components/ideintf/languages/objinspstrconsts.sk.po b/components/ideintf/languages/objinspstrconsts.sk.po index a0bd657199..475df7fe1d 100644 --- a/components/ideintf/languages/objinspstrconsts.sk.po +++ b/components/ideintf/languages/objinspstrconsts.sk.po @@ -1303,6 +1303,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Neznámy" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Odznačiť všetko" diff --git a/components/ideintf/languages/objinspstrconsts.tr.po b/components/ideintf/languages/objinspstrconsts.tr.po index 05408c4381..dcfa8cdaa5 100644 --- a/components/ideintf/languages/objinspstrconsts.tr.po +++ b/components/ideintf/languages/objinspstrconsts.tr.po @@ -1289,6 +1289,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Bilinmeyen" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Tüm seçimleri kaldır" diff --git a/components/ideintf/languages/objinspstrconsts.uk.po b/components/ideintf/languages/objinspstrconsts.uk.po index 12d2e75697..1df6fa6706 100644 --- a/components/ideintf/languages/objinspstrconsts.uk.po +++ b/components/ideintf/languages/objinspstrconsts.uk.po @@ -1292,6 +1292,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "Невідомий" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "&Зняти вибір з всіх" diff --git a/components/ideintf/languages/objinspstrconsts.zh_CN.po b/components/ideintf/languages/objinspstrconsts.zh_CN.po index a046b0e841..06044eb58f 100644 --- a/components/ideintf/languages/objinspstrconsts.zh_CN.po +++ b/components/ideintf/languages/objinspstrconsts.zh_CN.po @@ -1290,6 +1290,14 @@ msgctxt "objinspstrconsts.oisunknown" msgid "Unknown" msgstr "未知" +#: objinspstrconsts.oisunload +msgid "Unload" +msgstr "" + +#: objinspstrconsts.oisunloadhint +msgid "Unloads the current sample file" +msgstr "" + #: objinspstrconsts.oisunselectall msgid "&Unselect all" msgstr "不选择所有(&U)" diff --git a/components/ideintf/maskpropedit.lfm b/components/ideintf/maskpropedit.lfm index 0b352cdaeb..08b1cba289 100644 --- a/components/ideintf/maskpropedit.lfm +++ b/components/ideintf/maskpropedit.lfm @@ -84,7 +84,7 @@ object MaskEditorForm: TMaskEditorForm Constraints.MinWidth = 300 ItemHeight = 0 Style = lbOwnerDrawFixed - TabOrder = 6 + TabOrder = 7 OnClick = SampleMasksListBoxClick OnDrawItem = SampleMasksListBoxDrawItem end @@ -199,7 +199,7 @@ object MaskEditorForm: TMaskEditorForm CloseButton.DefaultCaption = True CancelButton.Name = 'CancelButton' CancelButton.DefaultCaption = True - TabOrder = 7 + TabOrder = 8 ShowButtons = [pbOK, pbCancel, pbHelp] end object EnableSetsCheckBox: TCheckBox @@ -219,6 +219,21 @@ object MaskEditorForm: TMaskEditorForm TabOrder = 3 OnClick = EnableSetsCheckBoxClick end + object UnloadSampleMasksButton: TButton + AnchorSideLeft.Control = LoadSampleMasksButton + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = LoadSampleMasksButton + Left = 87 + Height = 25 + Top = 222 + Width = 75 + BorderSpacing.Left = 6 + Caption = 'Unload' + ParentShowHint = False + ShowHint = True + TabOrder = 6 + OnClick = UnloadSampleMasksButtonClick + end object OpenDialog1: TOpenDialog Title = 'Open mask file (*.dem)' DefaultExt = '.dem' diff --git a/components/ideintf/maskpropedit.pas b/components/ideintf/maskpropedit.pas index 73567c3932..20c4d5451a 100644 --- a/components/ideintf/maskpropedit.pas +++ b/components/ideintf/maskpropedit.pas @@ -24,7 +24,7 @@ uses // LazUtils LazUTF8, LazFileUtils, // IdeIntf - LazIDEIntf, PropEdits, ComponentEditors, ObjInspStrConsts, IDEWindowIntf; + LazIDEIntf, PropEdits, ComponentEditors, ObjInspStrConsts, IDEWindowIntf, PropEditConfig; type @@ -41,6 +41,7 @@ type ButtonPanel1: TButtonPanel; EnableSetsCheckBox: TCheckBox; LoadSampleMasksButton: TButton; + UnloadSampleMasksButton: TButton; SaveLiteralCheckBox: TCheckBox; InputMaskEdit: TEdit; CharactersForBlanksEdit: TEdit; @@ -55,6 +56,7 @@ type procedure EnableSetsCheckBoxClick(Sender: TObject); procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction); procedure LoadSampleMasksButtonClick(Sender: TObject); + procedure UnloadSampleMasksButtonClick(Sender: TObject); procedure SampleMasksListBoxDrawItem(Control: TWinControl; Index: Integer; ARect: TRect; {%H-}State: TOwnerDrawState); procedure SaveLiteralCheckBoxClick(Sender: TObject); @@ -65,13 +67,13 @@ type private FEnableSets: Boolean; ParsedSamples: TParsedSamples; + FSampleEditMaskFilename: String; function ConstructEditmask: String; function GetEditMask: string; function MaskDoFormatText(const EditMask: string; const Value: string; EnableSets: Boolean): String; function ParseMaskLineDelphi(Line: String; EnableSets: Boolean; out aCaption, aExample, aFormattedExample, aMask: String): Boolean; function ParseMaskLineLazarus(Line: String; EnableSets: Boolean; out aCaption, aExample, aFormattedExample, aMask: String): Boolean; procedure LoadAndCleanSampleFile(Fn: String; EnableSets: Boolean; List: TStrings; out AParsedSamples: TParsedSamples); //out list of record? - procedure LoadDEMFile(AFileName: string); procedure ReConstructEditmask; procedure SetEditMask(AValue: string); procedure SetEnableSets(AValue: Boolean); @@ -102,6 +104,8 @@ type function MaskEdit: TCustomMaskEditAccess; virtual; end; + + implementation {$R *.lfm} @@ -110,11 +114,11 @@ implementation { TMaskEditorForm } procedure TMaskEditorForm.MaskEditorFormCreate(Sender: TObject); -var - aDemFile: string; begin Caption := oisInputMaskEditor; LoadSampleMasksButton.Caption := oisMasks; + UnloadSampleMasksButton.Caption := oisUnload; + UnloadSampleMasksButton.Hint := oisUnloadHint; // alternatively have a longer caption? SaveLiteralCheckBox.Caption := oisSaveLiteralCharacters; InputMaskLabel.Caption := oisInputMask; SampleMasksLabel.Caption := oisSampleMasks; @@ -125,21 +129,30 @@ begin OpenDialog1.Filter := oisMaskSampleFilter; OpenDialog1.Title := oisSelectInputMaskSample; - if LazarusIDE<>nil then - aDemFile:=LazarusIDE.GetPrimaryConfigPath - else - aDemFile:=ExtractFileDir(ParamStrUTF8(0)); - aDemFile:=CleanAndExpandDirectory(aDemFile)+'maskeditmasks.txt'; - if FileExistsUTF8(aDemFile) then - LoadDEMFile(aDemFile); + if not Assigned(PropEditConfigs) then + PropEditConfigs := TPropEditConfigs.Create; + PropEditConfigs.Load; + FSampleEditMaskFilename := PropEditConfigs.SampleEditMaskFilename; + FSampleEditMaskFilename := CleanAndExpandFilename(FSampleEditMaskFilename); + if (FSampleEditMaskFilename <> '') and FileExistsUTF8(FSampleEditMaskFilename) then + LoadAndCleanSampleFile(FSampleEditMaskFilename, FEnableSets, SampleMasksListBox.Items, ParsedSamples); IDEDialogLayoutList.ApplyLayout(Self); end; procedure TMaskEditorForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin + PropEditConfigs.SampleEditMaskFilename := FSampleEditMaskFilename; + PropEditConfigs.Save; IDEDialogLayoutList.SaveLayout(Self); end; +procedure TMaskEditorForm.UnloadSampleMasksButtonClick(Sender: TObject); +begin + SampleMasksListBox.Clear; + ParsedSamples := nil; + FSampleEditMaskFilename := ''; +end; + procedure TMaskEditorForm.EnableSetsCheckBoxClick(Sender: TObject); begin SetEnableSets(EnableSetsCheckBox.Checked); @@ -147,9 +160,9 @@ end; procedure TMaskEditorForm.LoadSampleMasksButtonClick(Sender: TObject); begin - OpenDialog1.InitialDir:=ExtractFileDir(ParamStrUTF8(0)); + OpenDialog1.InitialDir:=ExtractFileDir(FSampleEditMaskFilename); if OpenDialog1.Execute then - LoadDEMFile(OpenDialog1.FileName); + LoadAndCleanSampleFile(OpenDialog1.Filename, FEnableSets, SampleMasksListBox.Items, ParsedSamples); end; procedure TMaskEditorForm.SampleMasksListBoxDrawItem(Control: TWinControl; @@ -374,6 +387,7 @@ var SL: TStringList; ParseFunc: TParseFunc; begin + FSampleEditMaskFilename := ''; AParsedSamples := nil; if (CompareText(ExtractFileExt(Fn),'.dem') = 0) then ParseFunc := @ParseMaskLineDelphi @@ -403,11 +417,13 @@ begin end; end; SetLength(AParsedSamples, Index); + FSampleEditMaskFilename := Fn; except on ESTreamError do begin List.Clear; AParsedSamples := nil; + FSampleEditMaskFilename := ''; MessageDlg(Format(oisErrorReadingSampleFile,[Fn]), mtError, [mbOk], 0); end; end; @@ -417,10 +433,6 @@ begin end; end; -procedure TMaskEditorForm.LoadDEMFile(AFileName: string); -begin - LoadAndCleanSampleFile(AFilename, FEnableSets, SampleMasksListBox.Items, ParsedSamples); -end; procedure TMaskEditorForm.SetEditMask(AValue: string); diff --git a/components/ideintf/objinspstrconsts.pas b/components/ideintf/objinspstrconsts.pas index 19ec73bd60..d2e24ab3a1 100644 --- a/components/ideintf/objinspstrconsts.pas +++ b/components/ideintf/objinspstrconsts.pas @@ -257,6 +257,8 @@ resourcestring // Mask Editor sccsMaskEditor = 'Edit Mask Editor ...'; oisMasks = 'Masks ...'; + oisUnload = 'Unload'; + oisUnloadHint = 'Unloads the current sample file'; oisInputMaskEditor = 'Input Mask Editor'; oisSaveLiteralCharacters = 'Save Literal Characters'; oisInputMask = 'Input Mask:'; diff --git a/components/ideintf/propeditconfig.pp b/components/ideintf/propeditconfig.pp new file mode 100644 index 0000000000..df1bf56106 --- /dev/null +++ b/components/ideintf/propeditconfig.pp @@ -0,0 +1,140 @@ +{ +/*************************************************************************** + propeditconfig.pp + ----------------- + + ***************************************************************************/ + + *************************************************************************** + * * + * This source is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This code is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * General Public License for more details. * + * * + * A copy of the GNU General Public License is available on the World * + * Wide Web at . You can also * + * obtain it by writing to the Free Software Foundation, * + * Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. * + * * + *************************************************************************** + + Author: Bart Broersma + + Abstract: + Miscellaneous config settings for property editors. + Currently just for MaskEdit property editor. + +} +unit PropEditConfig; + +{$mode objfpc}{$H+} + +interface + +uses + // RTL + LCL + Classes, SysUtils, + // LazUtils + LazFileUtils, LazLoggerBase, LazUTF8, Laz2_XMLCfg, + // IdeIntf + LazIDEIntf; + +const + DefaultFilename = 'propeditconfig.xml'; + PropEditConfigVersion = 0; + pSampleMaskEditFile = 'MaskEdit/SampleEditMaskFile'; + +type + + { TPropEditConfigs } + + TPropEditConfigs = class + private + FFilename: String; + FSampleEditMaskFilename: String; + protected + procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); + procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); + public + constructor Create; + procedure Load; + procedure Save; + + property Filename: String read FFilename; + property SampleEditMaskFilename: string read FSampleEditMaskFilename write FSampleEditMaskFilename; + end; + + +var + PropEditConfigs: TPropEditConfigs = nil; // do NOT free yourself, it'll be auto-destroyed at finalization + +implementation + +{ TPropEditConfigs } + +procedure TPropEditConfigs.LoadFromXMLConfig(XMLConfig: TXMLConfig; + const Path: string); +begin + FSampleEditMaskFilename := XMLConfig.GetValue(Path + pSampleMaskEditFile,''); +end; + +procedure TPropEditConfigs.SaveToXMLConfig(XMLConfig: TXMLConfig; + const Path: string); +begin + XMLConfig.SetValue(Path + pSampleMaskEditFile,FSampleEditMaskFilename); +end; + +constructor TPropEditConfigs.Create; +begin + if Assigned(LazarusIDE) then + FFilename := AppendPathDelim(LazarusIDE.GetPrimaryConfigPath) + DefaultFilename; + //if IDE does not exist, FFilename will be empty string, in effect making Load and Save silently fail +end; + +procedure TPropEditConfigs.Load; +var + XMLConfig: TXMLConfig; +begin + try + XMLConfig := TXMLConfig.Create(FFileName); + LoadFromXMLConfig(XMLConfig,'PropEditConfig/'); + XMLConfig.Free; + except + on E: Exception do + begin + DebugLn('[TPropEditConfigs.Load] error reading "',FFilename,'" ',E.Message); + end; + end; +end; + +procedure TPropEditConfigs.Save; +var + XMLConfig: TXMLConfig; +begin + try + InvalidateFileStateCache; + XMLConfig:=TXMLConfig.CreateClean(FFileName); + + XMLConfig.SetDeleteValue('PropEditConfig/PropEditConfigVersion/',PropEditConfigVersion,0); + SaveToXMLConfig(XMLConfig,'PropEditConfig/'); + XMLConfig.Flush; + XMLConfig.Free; + except + on E: Exception do + begin + DebugLn('[TInputHistories.Save] error writing "',FFilename,'" ',E.Message); + end; + end; +end; + +finalization + if Assigned(PropEditConfigs) then + FreeandNil(PropEditConfigs); + +end.