OSDN Git Service

NGワードでの透明あぼ〜んの実装
authorh677 <h677>
Wed, 19 Nov 2003 18:29:45 +0000 (18:29 +0000)
committerh677 <h677>
Wed, 19 Nov 2003 18:29:45 +0000 (18:29 +0000)
AbonUnit.pas

index aedbf52..6ddd5f0 100644 (file)
@@ -63,6 +63,7 @@ type
     function CheckAbonPopupRes(line : String) :Boolean;
     function FindNGwords(line : String) : Boolean; overload;//1\83\89\83C\83\93\82¸\82Â\97p\81B
     function FindNGwords(line : String; var NGwordsLineNum : Integer) : Boolean; overload;//1\83\89\83C\83\93\82¸\82Â\97p\81B
+    function FindNGwords(line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; overload;//1\83\89\83C\83\93\82¸\82Â\97p\81B
     function Cutoff(line : String) : Boolean; //CutOff\92l\88È\8fã\8cÂ\82Ì\93¯\82\89p\90\94\82ª\95À\82ñ\82Å\82¢\82½\82çtrue
     //\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;
@@ -247,6 +248,8 @@ begin
                 Delete(argline,1,pos);
                 if Length(buftoken) > 0 then begin
                                bufstl.Append(buftoken);
+                end else if ( bufstl.Count = 0 ) then begin
+                    bufstl.Append('');
                 end;
                    pos := AnsiPos(#9,argline);
            end;
@@ -340,6 +343,46 @@ begin
     end;
     Result := hit;
 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(line : String; var NGwordsLineNum : Integer; var Invisible : Boolean) : Boolean; //1\83\89\83C\83\93\82¸\82Â\97p\81B
+var
+    lines : Integer;
+    cells : Integer;
+    hit : Boolean;
+    bufline : String;
+    start : Integer;
+begin
+    hit := false;
+    if AnsiPos(FAbonString,line) <> 1 then begin
+        for lines := 0 to High(Ftokens) do begin
+               hit := true;
+            bufline := line;
+            if Ftokens[lines][0] <> ''  then begin
+                Invisible := false;
+                start := 0;
+            end else begin
+                Invisible := true;
+                start := 1;
+            end;
+
+            for cells := start to High(Ftokens[lines]) do begin
+                if AnsiPos(Ftokens[lines][cells],bufline) = 0 then begin
+                    hit := false;
+                    break;
+                end else begin
+                    Delete(bufline,AnsiPos(Ftokens[lines][cells],bufline),Length(Ftokens[lines][cells]));
+                end;
+            end;
+            if hit = true then begin
+                NGwordsLineNum := lines + 1;
+               break;
+            end;
+        end;
+    end;
+    Result := hit;
+end;
+
 //CutOff\92l\88È\8fã\8cÂ\82Ì\93¯\82\89p\90\94\82ª\95À\82ñ\82Å\82¢\82½\82çtrue
 function TAbon.Cutoff(line : String) : Boolean;
 var
@@ -367,8 +410,10 @@ var
     i : Integer;
     NGwordsLine : Integer;
     bufline : String;
+    invisi : Boolean;
 begin
     //FRetStrings.Clear;
+{
     if not ReturnNGwordLineNum then begin
     //if ReturnNGwordLineNum then begin
        for i:=0 to ThreadStrings.Count - 1 do begin
@@ -391,13 +436,30 @@ begin
                end;
        end;
     end else begin
+}
        for i:=0 to ThreadStrings.Count - 1 do begin
             NGwordsLine := 0;
-               if FindNGwords(ThreadStrings.Strings[i], NGwordsLine) <> Reverse  then begin
+               if FindNGwords(ThreadStrings.Strings[i], NGwordsLine ,invisi) <> Reverse  then begin
+                if invisi = true then begin
+                       ThreadStrings.Strings[i] := '';
+                end else begin
+                    if not ReturnNGwordLineNum and not SetNGResAnchor then begin
+                        ThreadStrings.Strings[i] := FAbonString;
+                    end else if not ReturnNGwordLineNum then begin
+                        ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<>&gt;%d<><>',[(i+1)]);
+                    end else if not SetNGResAnchor then begin
+                        ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d \8ds\96Ú\82ÌNG\83\8f\81[\83h\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82Ü\82·\81B</B><><>',[NGwordsLine]);
+                    end else begin
+                        ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d \8ds\96Ú\82ÌNG\83\8f\81[\83h\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82Ü\82·\81B</B>&gt;%d <><>',[NGwordsLine,(i+1)]);
+                    end;
+                end;
+
+                {
                 if not SetNGResAnchor then
                     ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d \8ds\96Ú\82ÌNG\83\8f\81[\83h\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82Ü\82·\81B</B><><>',[NGwordsLine])
                 else
                        ThreadStrings.Strings[i] := Format('&nbsp;<>&nbsp;<>&nbsp;<><B> %d \8ds\96Ú\82ÌNG\83\8f\81[\83h\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82Ü\82·\81B</B>&gt;%d <><>',[NGwordsLine,(i+1)]);
+                }
                end else begin
                bufline := ThreadStrings.Strings[i];
                if Deleterlo = true then begin
@@ -412,7 +474,7 @@ begin
                end;
        end;
 
-    end;
+//    end;
 
 end;
 procedure TAbon.Execute(var ThreadStrings : TStringList; NGwords : TStringList);