ADD: Detect string

This commit is contained in:
Alexander Koblov 2016-04-17 09:15:20 +00:00
commit e09b5995d0
2 changed files with 12 additions and 12 deletions

View file

@ -8,13 +8,11 @@ You can select line number and text encoding, you can replace one substring
by another.
Settings are stored in textline.ini.
Without settings file plugin handles all files, and doesn't replace anything.
Without settings file plugin don't skip empty lines and doesn't replace anything.
textline.ini example:
[Options]
;list of supported extensions, separated by a space, if empty - all files
Extensions=txt ini inf
;skip empty lines
SkipEmpty=0

View file

@ -26,13 +26,15 @@ library TextLine;
{$include calling.inc}
uses
SysUtils, Classes, StreamEx, WdxPlugin, LazUTF8,
DCClassesUtf8, DCConvertEncoding, DCStrUtils, DCBasicTypes;
SysUtils, Classes, StreamEx, LazUTF8,
WdxPlugin, DCClassesUtf8, DCConvertEncoding;
const
DETECT_STRING = '(EXT="TXT") | (EXT="LOG") | (EXT="INI") | (EXT="XML")';
var
FReplace: Boolean = False;
FSkipEmpty: Boolean = False;
FExtensions: TDynamicStringArray;
FReplaces: array[1..10, 1..2] of String;
function ContentGetSupportedField(FieldIndex: Integer;
@ -71,11 +73,6 @@ begin
Result:= ft_fileerror;
Exit;
end;
if Length(FExtensions) > 0 then
begin
Value:= ExtractOnlyFileExt(FileNameU);
if not Contains(FExtensions, Value) then Exit(ft_fileerror);
end;
Result:= ft_fieldempty;
try
Stream:= TFileStreamEx.Create(FileNameU, fmOpenRead or fmShareDenyNone);
@ -132,7 +129,6 @@ begin
try
Ini:= TIniFileEx.Create(FileName, fmOpenRead);
try
FExtensions:= SplitString(Ini.ReadString('Options', 'Extensions', EmptyStr), ' ');
FSkipEmpty:= Ini.ReadBool('Options', 'SkipEmpty', FSkipEmpty);
for Index:= Low(FReplaces) to High(FReplaces) do
begin
@ -149,9 +145,15 @@ begin
end;
end;
procedure ContentGetDetectString(DetectString: PAnsiChar; MaxLen: Integer); dcpcall;
begin
StrPLCopy(DetectString, DETECT_STRING, MaxLen - 1);
end;
exports
ContentGetSupportedField,
ContentGetValueW,
ContentGetDetectString,
ContentSetDefaultParams;
begin