interface
uses
- Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils;
+ Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils,
+ Forms, Controls, AbonInfo;
type
TIndiviAbon = class( TObject )
function LoadFromNGwordFile(path :String) : Boolean;
function ReLoadFromNGwordFile() : Boolean;
procedure LoadFromStringList( bufstl : TStringList );
- function CheckAbonPopupRes(line : String) :Boolean;
- function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean;//1\83\89\83C\83\93\82¸\82Â\97p\81B
+ function CheckAbonPopupRes(line : String; ThreadInfo: TAbonThread) :Boolean;
+ function FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean; ThreadInfo: TAbonThread) : Boolean;//1\83\89\83C\83\93\82¸\82Â\97p\81B
//\82 \82Ú\81`\82ñ\8f\88\97\9d(NG\83\8f\81[\83h\82Å\82Ì\83t\83B\83\8b\83^\83\8a\83\93\83O)
- procedure Execute(var ThreadStrings : TStringList); overload;
- procedure Execute(var ResString : String; ResNumber : Integer); overload; //\8eå\82Éplugin\82©\82ç\82ÌDat To HTML \97p
+ procedure Execute(var ThreadStrings : TStringList; ThreadInfo: TAbonThread); overload;
+ procedure Execute(var ResString : String; ResNumber : Integer; ThreadInfo: TAbonThread); overload; //\8eå\82Éplugin\82©\82ç\82ÌDat To HTML \97p
{$IFDEF SPAM_FILTER_ENABLED}
//! \83X\83p\83\80\83t\83B\83\8b\83^\82Ì\8aw\8fK
procedure AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String);
function CheckIndividualAbonList(ResNum : Integer) : Boolean;
- procedure EditNGwords(); //NGword.txt\82ð\8aJ\82\81B
+ function EditNGwords(Owner: TForm): Boolean; //NGword.txt\82ð\8aJ\82\81B
function ShowAllTokens() : String; //\83f\83o\83b\83O\97p
//--
procedure GoHome();//List\82Ì\82P\8ds\96Ú\82ð\93Ç\82Þ
function GoBack() : Boolean; //List\82Ì\88ê\82Â\91O\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
//--
function TreatSyria(AString: string): string;
+ //--
+ function AddToken(AString: string; Invisible: Boolean): Boolean;
end;
var
Abon1 :TAbon;
implementation
-uses MojuUtils, GikoSystem, GikoBayesian, Setting;
+uses MojuUtils, GikoSystem, GikoBayesian, Setting,
+ NgEditor,
+ bmRegExp;
function InvidiAbonListSort( item1, item2 : Pointer ) : Integer;
begin
i : Integer;
pos : Integer;
buftoken : String;
+ RegExp: Boolean;
+ Target: String;
begin
- pos := 0;
bufstl := TStringList.Create;
+ RegExp := False;
try
if Length(argline) > 0 then begin
pos := AnsiPos(#9,argline);
buftoken := Copy(argline,1,pos-1);
Delete(argline,1,pos);
if Length(buftoken) > 0 then begin
- bufstl.Append(buftoken);
+ // \90³\8bK\95\\8c»
+ if (buftoken = DEF_REGEXP) then begin
+ RegExp := True;
+ // \94Â\81E\83X\83\8c\8ew\92è
+ end else if ((AnsiPos(DEF_THREAD, buftoken) = 1) or
+ (AnsiPos(DEF_BOARD, buftoken) = 1)) and
+ (AnsiPos(DEF_END, buftoken) > 1) then begin
+ Target := buftoken;
+ // >> \82Å\8en\82Ü\82é\83g\81[\83N\83\93\82Í\83R\83\81\83\93\83g\88µ\82¢\82Å\96³\8e\8b\82·\82é
+ end else if AnsiPos('>>', buftoken) <> 1 then begin
+ bufstl.Append(buftoken);
+ end;
end else if ( bufstl.Count = 0 ) then begin
bufstl.Append('');
end;
pos := AnsiPos(#9,argline);
end;
if Length(argline) > 0 then begin
- bufstl.Append(argline);
+ // >> \82Å\8en\82Ü\82é\83g\81[\83N\83\93\82Í\83R\83\81\83\93\83g\88µ\82¢\82Å\96³\8e\8b\82·\82é
+ if AnsiPos('>>', argline) <> 1 then begin
+ bufstl.Append(argline);
+ end;
end;
+ // \8ae\8eí\8ew\92è\82Ì\8f\87\88Ê\81F\93§\96¾\81¨\94Â\81E\83X\83\8c\81¨\90³\8bK\95\\8c»
+ if (RegExp = True) then begin
+ if (bufstl.Count > 0) and (bufstl.Strings[0] = '') then
+ bufstl.Insert(1, DEF_REGEXP) // \93§\96¾\8ew\92è\82Ì\8cã\82É\90³\8bK\95\\8c»\8ew\92è\82ð\92u\82
+ else
+ bufstl.Insert(0, DEF_REGEXP); // \90³\8bK\95\\8c»\8ew\92è\82Í\90æ\93ª\82É\92u\82
+ end;
+ if (Target <> '') then begin
+ if (bufstl.Count > 0) and (bufstl.Strings[0] = '') then
+ bufstl.Insert(1, Target) // \93§\96¾\8ew\92è\82Ì\8cã\82É\94Â\81E\83X\83\8c\8ew\92è\82ð\92u\82
+ else
+ bufstl.Insert(0, Target); // \94Â\81E\83X\83\8c\8ew\92è\82Í\90æ\93ª\82É\92u\82
+ end;
ret := bufstl.Count;
SetLength(Ftokens[index],ret);
- for i := 0 to bufstl.Count - 1 do begin
- if IgnoreKana then
- Ftokens[index][i] := ZenToHan(bufstl.Strings[i])
- else
+ for i := 0 to ret - 1 do begin
+ if IgnoreKana then
+ Ftokens[index][i] := ZenToHan(bufstl.Strings[i])
+ else
Ftokens[index][i] := bufstl.Strings[i];
end;
end;
end;
//NG\83\8f\81[\83h\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82½\82çtrue\82ð\95Ô\82µ\81A\82»\82ÌNG\83\8f\81[\83h\82Ì\8ds\90\94\82ðNGwordsLineNum\82É\93ü\82ê\82Ä\95Ô\82·\81B
//\82à\82µ\82à\93§\96¾\82 \82Ú\81`\82ñ\82É\82·\82é\82È\82çInbisible\82ðtrue\82É\82µ\82Ä\95Ô\82·
-function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1\83\89\83C\83\93\82¸\82Â\97p\81B
+function TAbon.FindNGwords(const line : String; var NGwordsLineNum : Integer; var Invisible : Boolean; ThreadInfo: TAbonThread) : Boolean; //1\83\89\83C\83\93\82¸\82Â\97p\81B
var
lines : Integer;
cells : Integer;
pos : PChar;
pts, pte : PChar;
trgLen : Integer;
+ RegExp: Boolean;
+ AWKStr: TAWKStr;
+ RStart: Integer;
+ RLength: Integer;
+ TokenCnt: Integer;
+ Chk: Integer;
+ CheckTarget: Boolean;
begin
hit := false;
if AnsiStrPosEx(PChar(line), PChar(line)+Length(line), FpAbons, FpAbone) = nil then begin
target := line;
trgLen := Length(target);
+ AWKStr := nil;
for lines := 0 to High(Ftokens) do begin
- hit := true;
+ if Length(Ftokens[lines]) = 0 then begin
+ Continue;
+ end;
+ hit := False;
bufline := target;
pts := PChar(bufline);
pte := pts + trgLen;
+ RegExp := False;
+ Invisible := False;
+ start := 0;
+ CheckTarget := True;
+
+ TokenCnt := Length(Ftokens[lines]);
+ for Chk := 0 to 2 do begin
+ if (Chk >= TokenCnt) then
+ Break;
+ if (Chk = 0) and (Ftokens[lines][0] = '') then begin
+ Invisible := True;
+ start := 1;
+ end else if ((AnsiPos(DEF_THREAD, Ftokens[lines][Chk]) = 1) or
+ (AnsiPos(DEF_BOARD, Ftokens[lines][Chk]) = 1))
+ and (AnsiPos(DEF_END, Ftokens[lines][Chk]) > 1) then begin
+ CheckTarget := ThreadInfo.IsTarget(Ftokens[lines][Chk]);
+ if (CheckTarget = False) then
+ Break;
+ Inc(start); // \91Î\8fÛ\82Ì\94Â\81E\83X\83\8c
+ end else if (Ftokens[lines][Chk] = DEF_REGEXP) then begin
+ RegExp := True; // \90³\8bK\95\\8c»
+ Inc(start);
+ end else begin
+ Break;
+ end;
+ end;
+ if (CheckTarget = False) then begin // \91Î\8fÛ\82Ì\94Â\81E\83X\83\8c\82Å\82Í\82È\82¢
+ Continue;
+ end;
- if Ftokens[lines][0] <> '' then begin
- Invisible := false;
- start := 0;
- end else begin
- Invisible := true;
- start := 1;
- end;
+ hit := True;
+ if (RegExp = True) and (AWKStr = nil) then begin
+ AWKStr := TAWKStr.Create(nil);
+ end;
for cells := start to High(Ftokens[lines]) do begin
- pos := AnsiStrPosEx(pts, pte,
- PChar(Ftokens[lines][cells]), PChar(Ftokens[lines][cells]) + Length(Ftokens[lines][cells]));
- if pos = nil then begin
- hit := false;
- break;
- end else begin
- Delete(bufline, pos - pte + 1, Length(Ftokens[lines][cells]));
- pts := PChar(bufline);
- pte := pts + Length(bufline);
- end;
+ if (RegExp = False) then begin
+ pos := AnsiStrPosEx(pts, pte,
+ PChar(Ftokens[lines][cells]), PChar(Ftokens[lines][cells]) + Length(Ftokens[lines][cells]));
+ if pos = nil then begin
+ hit := false;
+ break;
+ end else begin
+ Delete(bufline, pos - pte + 1, Length(Ftokens[lines][cells]));
+ pts := PChar(bufline);
+ pte := pts + Length(bufline);
+ end;
+ end else begin
+ try
+ AWKStr.RegExp := Ftokens[lines][cells];
+ if (AWKStr.Match(AWKStr.ProcessEscSeq(target), RStart, RLength) < 1) then
+ hit := False; // \83}\83b\83`\82µ\82È\82¢
+ except
+ hit := False;
+ end;
+ if (hit = False) then
+ Break; // 1\82Â\82Å\82à\83}\83b\83`\82µ\82È\82¢\8fê\8d\87\82Í\82 \82Ú\81[\82ñ\82µ\82È\82¢
+ end;
end;
if hit = true then begin
NGwordsLineNum := lines + 1;
break;
end;
end;
+
+ if (AWKStr <> nil) then
+ FreeAndNil(AWKStr);
end;
Result := hit;
end;
//\96\96\94ö\82Ì\83u\81[\83\8b\92l\82Ítrue\82¾\82Æ\81ANG\83\8f\81[\83h\82ð\8aÜ\82Þ\82à\82Ì\82¾\82¯\82ð\95Ô\82·\81B
-procedure TAbon.Execute(var ThreadStrings : TStringList);
+procedure TAbon.Execute(var ThreadStrings : TStringList; ThreadInfo: TAbonThread);
var
i : Integer;
NGwordsLine : Integer;
begin
for i:=0 to ThreadStrings.Count - 1 do begin
NGwordsLine := 0;
- if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse then begin
+ if FindNGwords(ThreadStrings.Strings[i], NGwordsLine, invisi, ThreadInfo) <> Reverse then begin
if invisi = true then begin
ThreadStrings.Strings[i] := '';
end else begin
end;
end;
end;
-procedure TAbon.Execute(var ResString : String; ResNumber : Integer);
+procedure TAbon.Execute(var ResString : String; ResNumber : Integer; ThreadInfo: TAbonThread);
var
NGwordsLine : Integer;
bufline : String;
invisi : Boolean;
begin
NGwordsLine := 0;
- if FindNGwords(ResString, NGwordsLine ,invisi) <> Reverse then begin
+ if FindNGwords(ResString, NGwordsLine, invisi, ThreadInfo) <> Reverse then begin
if invisi = true then begin
ResString := '';
end else begin
//****************************************************************************//
//\8c»\8dÝ\83Z\83b\83g\82³\82ê\82Ä\82¢\82éNGword.txt\82ð\8aJ\82
-procedure TAbon.EditNGwords();
+function TAbon.EditNGwords(Owner: TForm): Boolean;
+var
+ Dlg: TNgEdit;
+ ReLoad: Boolean;
begin
- ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
+ ReLoad := False;
+
+ if (GikoSys.Setting.NGTextEditor = False) then begin
+ Dlg := TNgEdit.Create(Owner);
+
+ Dlg.SetFilePath(FNGwordpath);
+ if (Dlg.ShowModal = mrOk) then begin
+ if (Dlg.GetReload = True) then
+ ReLoad := True;
+ end;
+
+ Dlg.Free;
+ end else begin
+ ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
+ end;
+
+ Result := ReLoad;
end;
//\83|\83b\83v\83A\83b\83v\97p\94»\92è\8aÖ\90\94
-function TAbon.CheckAbonPopupRes(line : String) :Boolean;
+function TAbon.CheckAbonPopupRes(line : String; ThreadInfo: TAbonThread) :Boolean;
var
i: Integer;
v: boolean;
begin
if AbonPopupRes = true then begin
- Result := FindNGwords(line, i ,v);
+ Result := FindNGwords(line, i, v, ThreadInfo);
end else begin
Result := false;
end;
Dec(ps);
//\83V\83\8a\83A\8cê\83u\83\89\83N\83\89\82Ì\82Å\82È\82¢
- if (icode <1792) or (icode > 1871) then
- Result := Result + Copy(AString, 1, ps - PChar(AString) + 1);
+ if ( icode < 1758) or
+ ((icode > 1871) and (icode < 1958)) or
+ (icode > 1968) then begin
+ Result := Result + Copy(AString, 1, ps - PChar(AString) + 1);
+ end;
Delete(AString, 1, ps - PChar(AString) + 1);
end else begin
Result := Result + AString;
end;
+// NG\83\8f\81[\83h\83t\83@\83C\83\8b\82É\92Ç\89Á \92Ç\89Á\82³\82ê\82½\8fê\8d\87\81ATrue\82ª\82©\82¦\82é
+function TAbon.AddToken(AString: string; Invisible: Boolean): Boolean;
+var
+ bufStringList : TStringList;
+ ngword: String;
+begin
+ Result := False;
+ if FileExists(GetNGwordpath) then begin
+ bufStringList := TStringList.Create;
+ try
+ bufStringList.LoadFromFile(GetNGwordpath);
+ if (Invisible) then begin
+ ngword := #9 + AString;
+ end else begin
+ ngword := AString;
+ end;
+ if (bufStringList.IndexOf(ngword) = -1) then begin
+ bufStringList.Add(ngword);
+ bufStringList.SaveToFile(GetNGwordpath);
+ Result := True;
+ end;
+ finally
+ bufStringList.Free;
+ end;
+ end;
+end;
end.