@@ -17,9 +17,6 @@ interface
1717 AboutForm,
1818 NppSimpleObjects, L_VersionInfoW;
1919
20- const
21- EntitiesConf: nppString = ' HTMLTag-entities.ini' ;
22-
2320type
2421 TDecodeCmd = (dcAuto = -1 , dcEntity, dcUnicode);
2522 TCmdMenuPosition = (cmpUnicode = 3 , cmpEntities);
@@ -37,6 +34,9 @@ TNppPluginHTMLTag = class(TNppPlugin)
3734 FOptions: TPluginOptions;
3835 function GetOptionsFilePath : nppString;
3936 function GetEntitiesFilePath : nppString;
37+ function GetDefaultEntitiesPath : nppString;
38+ function PluginNameFromModule : nppString;
39+ function GetConfigDir : nppString;
4040 procedure LoadOptions ;
4141 procedure SaveOptions ;
4242 procedure FindAndDecode (const KeyCode: Integer; Cmd: TDecodeCmd = dcAuto);
@@ -63,6 +63,8 @@ TNppPluginHTMLTag = class(TNppPlugin)
6363 property Version: nppString read FVersionStr;
6464 property OptionsConfig: nppString read GetOptionsFilePath;
6565 property Entities: nppString read GetEntitiesFilePath;
66+ property DefaultEntitiesPath: nppString read GetDefaultEntitiesPath;
67+ property PluginConfigDir: nppString read GetConfigDir;
6668 end ;
6769
6870procedure _commandFindMatchingTag (); cdecl;
@@ -85,7 +87,6 @@ procedure _commandAbout(); cdecl;
8587implementation
8688
8789uses
88- Strutils,
8990 ShellAPI,
9091 L_SpecialFolders,
9192 Utf8IniFiles,
@@ -207,11 +208,7 @@ constructor TNppPluginHTMLTag.Create;
207208
208209 try
209210 FVersionInfo := TFileVersionInfo.Create(TSpecialFolders.DLLFullName);
210- { $IFDEF FPC}
211- FVersionStr := UTF8ToString(ChangeFileExt(ExtractFileName(UTF8Encode(TSpecialFolders.DLLFullName)), ' ' ));
212- { $ELSE}
213- FVersionStr := ChangeFileExt(ExtractFileName(TSpecialFolders.DLLFullName), ' ' );
214- { $ENDIF}
211+ FVersionStr := PluginNameFromModule();
215212 FVersionStr :=
216213 Concat(FVersionStr,
217214 WideFormat(' %d.%d.%d (%s bit)' ,
@@ -220,10 +217,6 @@ constructor TNppPluginHTMLTag.Create;
220217 except
221218 FreeAndNil(FVersionInfo);
222219 end ;
223-
224- { $IFNDEF CPUX64}
225- FVersionStr := UTF8ToString(ReplaceStr(UTF8Encode(FVersionStr), ' _unicode' , ' ' ));
226- { $ENDIF}
227220end ;
228221
229222{ ------------------------------------------------------------------------------------------------ }
@@ -242,7 +235,7 @@ procedure TNppPluginHTMLTag.SetInfo(NppData: TNppData);
242235begin
243236 inherited SetInfo(NppData);
244237 if not FileExists(Entities) then
245- CopyFileW(PWChar(ChangeFilePath(Entities, TSpecialFolders.DLL) ), PWChar(Entities), True);
238+ CopyFileW(PWChar(DefaultEntitiesPath ), PWChar(Entities), True);
246239
247240 LoadOptions;
248241end ;
@@ -433,17 +426,35 @@ procedure TNppPluginHTMLTag.commandAbout;
433426{ ------------------------------------------------------------------------------------------------ }
434427function TNppPluginHTMLTag.GetEntitiesFilePath : nppString;
435428begin
436- Result := IncludeTrailingPathDelimiter(Self.ConfigDir ) + EntitiesConf ;
429+ Result := IncludeTrailingPathDelimiter(Self.PluginConfigDir ) + ' entities.ini ' ;
437430end { TNppPluginHTMLTag.GetEntitiesFilePath} ;
438431
439432{ ------------------------------------------------------------------------------------------------ }
440433function TNppPluginHTMLTag.GetOptionsFilePath : nppString;
434+ begin
435+ Result := IncludeTrailingPathDelimiter(Self.PluginConfigDir) + ' options.ini' ;
436+ end ;
437+
438+ { ------------------------------------------------------------------------------------------------ }
439+ function TNppPluginHTMLTag.GetDefaultEntitiesPath : nppString;
440+ begin
441+ Result := IncludeTrailingPathDelimiter(TSpecialFolders.DLL) + PluginNameFromModule() + ' -entities.ini' ;
442+ end ;
443+
444+ { ------------------------------------------------------------------------------------------------ }
445+ function TNppPluginHTMLTag.PluginNameFromModule : nppString;
441446var
442447 PluginName: WideString;
443448begin
444449 PluginName := ChangeFileExt(ExtractFileName(TSpecialFolders.DLLFullName), EmptyWideStr);
445- PluginName := WideStringReplace(PluginName, ' _unicode' , EmptyWideStr, []);
446- Result := IncludeTrailingPathDelimiter(Self.ConfigDir) + PluginName + ' .ini' ;
450+ Result := WideStringReplace(PluginName, ' _unicode' , EmptyWideStr, []);
451+ end ;
452+
453+ { ------------------------------------------------------------------------------------------------ }
454+ function TNppPluginHTMLTag.GetConfigDir : nppString;
455+ begin
456+ Result := IncludeTrailingPathDelimiter(Self.ConfigDir) + PluginNameFromModule();
457+ if (not DirectoryExists(Result)) then CreateDir(Result);
447458end ;
448459
449460{ ------------------------------------------------------------------------------------------------ }
0 commit comments