OSDN Git Service

複数のNGワードファイルを使えるようにした。
authorh677 <h677>
Mon, 18 Aug 2003 12:50:03 +0000 (12:50 +0000)
committerh677 <h677>
Mon, 18 Aug 2003 12:50:03 +0000 (12:50 +0000)
AbonUnit.pas
Giko.dfm
Giko.pas
GikoSystem.pas

index caec68a..c5e2d3f 100644 (file)
@@ -9,6 +9,7 @@ type
   private
     { Private \90é\8c¾ }
     Froot : String;
+    Flistpath : String;
     FNGwordpath : String;
     Ftokens : array of array of string;
     FAbonString : String;
@@ -18,8 +19,13 @@ type
     FReverse : Boolean ;  //NG\83\8f\81[\83h\82Å\82Ì\82 \82Ú\81`\82ñ\82Ì\8c\8b\89Ê\82ð\94½\93]\82³\82¹\82é\82©
     FAbonPopupRes : Boolean; //\83\8c\83X\83|\83b\83v\83A\83b\83v\82Ì\8e\9e\82É\82 \82Ú\81[\82ñ\82·\82é\82©
     FCreateNGwordFile : Boolean; //\8ew\92è\82³\82ê\82½path\82ÉNG\83\8f\81[\83htxt\82ª\96³\82©\82Á\82½\82Æ\82«\82É\8e©\93®\93I\82É\90\90¬\82·\82é\82©
+    FNGwordFileIndex : Integer; //\8c»\8dÝ\93Ç\82Ý\8d\9e\82ñ\82Å\82éNG\83\8f\81[\83h\82ªlist\82Ì\89½\8ds\96Ú\82©
+    FNGwordname : String; //\8c»\8dÝ\93Ç\82Ý\8d\9e\82ñ\82Å\82éNG\83\8f\81[\83h\82Ì\95\\8e¦\96¼
     procedure SetTokens(index: integer ; argline:String);
-
+    function Getlistpath() : String;
+    procedure Setlistpath(const Value : String);
+    function LoadListFile(path :String;listStringList : TStringList) : Boolean;
+    
   public
     { Public \90é\8c¾ }
     constructor Create; // \83R\83\93\83X\83g\83\89\83N\83^
@@ -30,8 +36,13 @@ type
     property CreateNGwordFile: Boolean read FCreateNGwordFile write FCreateNGwordFile;
     property AbonString : String read FAbonString write FAbonString;
     property  AbonPopupRes : Boolean read FAbonPopupRes write FAbonPopupRes default false;
+    property listpath : String read Getlistpath write Setlistpath;
+    property NGwordFileIndex : Integer read FNGwordFileIndex write FNGwordFileIndex default 0;
+    property NGwordname : String read FNGwordname write FNGwordname;
     procedure Setroot(root :String);
     function Getroot() : String;
+
+    function Getfullpath(argpath : String) : String;
     procedure SetNGwordpath(path :String);
     function GetNGwordpath() : String;
     function LoadFromNGwordFile(path :String) : Boolean;
@@ -54,9 +65,15 @@ type
     //--
     procedure EditNGwords();  //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 GoForward() : Boolean; //List\82Ì\88ê\82Â\8e\9f\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\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Þ
   end;
 var
     Abon1 :TAbon;
+const
+    NGwordListFileName : String = 'NGwords.list';
 
 implementation
 
@@ -74,9 +91,24 @@ end;
 
 
 
-//root\82ÍExe\82Ì\82¢\82é\83t\83H\83\8b\83_
+//root\82ÍExe\config\NGwords\83t\83H\83\8b\83_
 procedure TAbon.Setroot(root :String);
+var
+    bufStringList : TStringList;
 begin
+    bufStringList := TStringList.Create;
+    try
+        if not DirectoryExists(root) then begin
+            CreateDir(root);
+        end;
+        if root[Length(root)] <> '\' then begin
+            root := root + '\';
+        end;
+        Flistpath := root + NGwordListFileName;
+        LoadListFile(Flistpath, bufStringList);
+    finally
+        bufStringList.Free;
+    end;
     Froot := root;
 end;
 function TAbon.Getroot() : String;
@@ -86,45 +118,57 @@ end;
 //NGwordpath\82ÍNGword.txt\82Ì\83t\83\8b\83p\83X
 procedure TAbon.SetNGwordpath(path :String);
 begin
-    FNGwordpath := path;
+    FNGwordpath := Getfullpath(path);
     LoadFromNGwordFile(FNGwordpath);
 end;
 function TAbon.GetNGwordpath() : String;
 begin
     Result :=  FNGwordpath;
 end;
-//NGword\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý
-function TAbon.LoadFromNGwordFile(path :String) : boolean;
-var
-    bufstl : TStringList;
-    i : integer;
+//\83t\83\8b\83p\83X\82Å\82È\82¯\82ê\82Î\83t\83\8b\83p\83X\82É\82µ\82Ä\95Ô\82·\81B
+function TAbon.Getfullpath(argpath : String) : String;
 begin
-    if AnsiPos(':\',path) <> 2 then begin  //\83h\83\89\83C\83u\82©\82ç\82Ì\83t\83\8b\83p\83X\82ª\96³\82¯\82ê\82Î
+    if AnsiPos(':\',argpath) <> 2 then begin  //\83h\83\89\83C\83u\82©\82ç\82Ì\83t\83\8b\83p\83X\82ª\96³\82¯\82ê\82Î
         if Getroot() = '' then begin
-            Result := false;    //root\83p\83X\82ª\90Ý\92è\82³\82ê\82Ä\82È\82¢\82©\82çfalse
-            Exit;
+            Result := '';    //root\83p\83X\82ª\90Ý\92è\82³\82ê\82Ä\82È\82¢\82©\8bó\82É\82·\82é
         end else begin
-            if (Froot[Length(Froot)] = '\') and (path[1] = '\') then begin  //\90æ\93ª\82Ì\\82ð\8dí\8f\9c
-                Delete(path,1,1);
+            if (Froot[Length(Froot)] = '\') and (argpath[1] = '\') then begin  //\90æ\93ª\82Ì\\82ð\8dí\8f\9c
+                Delete(argpath,1,1);
             end;
-            Insert( Getroot(), path , 1);//root\83p\83X\82ð\91}\93ü
+            Insert( Getroot(), argpath , 1);//root\83p\83X\82ð\91}\93ü
+            Result := argpath;
         end;
+    end else begin
+        Result := argpath;
     end;
-    bufstl := TStringList.Create;
-    try
-        bufstl.LoadFromFile(path);
-        LoadFromStringList( bufstl );
 
-    except
-        if CreateNGwordFile = true then begin
-            bufstl.SaveToFile(path);
-        end;
-        bufstl.Free;
+end;
+//NGword\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý
+function TAbon.LoadFromNGwordFile(path :String) : boolean;
+var
+    bufstl : TStringList;
+begin
+    path := Getfullpath(path);
+    if path = '' then begin
         Result := false;
-        Exit;
+    end else begin
+        bufstl := TStringList.Create;
+        try
+            try
+                bufstl.LoadFromFile(path);
+                LoadFromStringList( bufstl );
+                Result := true;
+            except
+                if CreateNGwordFile = true then begin
+                    bufstl.SaveToFile(path);
+                end;
+                Result := false;
+            end;
+        finally
+            bufstl.Free;
+        end;
     end;
-    bufstl.Free;
-    Result := true;
+
 end;
 //NGword\83\8a\83X\83g\93Ç\82Ý\8d\9e\82Ý
 procedure TAbon.LoadFromStringList( bufstl : TStringList );
@@ -155,7 +199,14 @@ begin
         Result := LoadFromNGwordFile( GetNGwordpath() );
     end;
 end;
-
+function TAbon.Getlistpath() : String;
+begin
+    Result := Flistpath;
+end;
+procedure TAbon.Setlistpath(const Value : String);
+begin
+    Flistpath := Getfullpath(Value);
+end;
 //\88ê\8ds\82Ì\92\86\82Ì\83g\81[\83N\83\93\82ð\90Ø\82è\95ª\82¯\82Ä\83Z\83b\83g
 procedure TAbon.SetTokens(index: integer ; argline : String);
 var
@@ -243,7 +294,6 @@ end;
 procedure TAbon.Execute(var ThreadStrings : TStringList);
 var
     i : Integer;
-    j : Integer;
     bufline : String;
 begin
     //FRetStrings.Clear;
@@ -489,31 +539,64 @@ begin
     ShellExecute(0 ,nil,PChar(FNGwordpath),nil,nil,SW_SHOW);
 end;
 function TAbon.CheckAbonPopupRes(line : String) :Boolean;
-var
-    i : Integer;
 begin
-    if FCutoffNum  = 0 then begin
-        if AbonPopupRes = true then begin
-            Result := FindNGwords(line);
-        end else begin
-            Result := false;
-        end;
+    if AbonPopupRes = true then begin
+        Result := FindNGwords(line);
     end else begin
-        if AbonPopupRes = true then begin
-            Result := FindNGwords(line);
-            if Result = false then begin
-                for i := 0 to 2 do begin
-                    Delete(line,1,Ansipos('<>',line)+1);
-                end;
-                Delete(line,Ansipos('<>',line),Length(line)-Ansipos('<>',line)+1);
-                Result := Cutoff(line);
+        Result := false;
+    end;
+end;
+//List\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
+function TAbon.LoadListFile(path :String; listStringList : TStringList) : Boolean;
+begin
+    try
+        listStringList.LoadFromFile(path);
+        Result := true;
+    except
+        listStringList.Append('\88ê\94Ê=NGword.txt');
+        listStringList.SaveToFile(path);
+        Result := false;
+    end;
+end;
+//List\82Ì\88ê\82Â\8e\9f\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
+function TAbon.GoForward() : Boolean;
+var
+    liststl : TStringList;
+    linebuf : String;
+begin
+    liststl := TStringList.Create;
+    try
+        if LoadListFile(Flistpath,liststl) = true then begin
+            FNGwordFileIndex := FNGwordFileIndex + 1;
+            if FNGwordFileIndex > liststl.Count -1 then begin
+                FNGwordFileIndex := 0;
             end;
+            linebuf := liststl.Strings[FNGwordFileIndex];
+            FNGwordname := Copy(linebuf,1,AnsiPos('=',linebuf)-1);
+            Delete(linebuf,1,AnsiPos('=',linebuf));
+
+            SetNGwordpath(linebuf);
+            Result := true;
         end else begin
             Result := false;
-        end;
+        end
+    finally
+        liststl.Free;
     end;
-end;
-
 
+end;
+//List\82Ì\88ê\82Â\91O\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\93Ç\82Ý\8d\9e\82Þ
+function TAbon.GoBack() : Boolean;
+begin
+    FNGwordFileIndex := FNGwordFileIndex -2;
+    if FNGwordFileIndex < -1 then FNGwordFileIndex := 0;
+    Result := GoForward()
+end;
+//List\82Ì\82P\8ds\96Ú\82ð\93Ç\82Þ
+procedure TAbon.GoHome();
+begin
+    FNGwordFileIndex := -1;
+    GoForward();
+end;
 end.
 
index de9c61a..d2402a6 100644 (file)
--- a/Giko.dfm
+++ b/Giko.dfm
@@ -39,6 +39,9 @@ object GikoForm: TGikoForm
       end
       item
         Width = 500
+      end
+      item
+        Width = 100
       end>
     SimplePanel = False
   end
@@ -8359,8 +8362,19 @@ object GikoForm: TGikoForm
         OnClick = NG1Click
       end
       object NG2: TMenuItem
-        Caption = 'NG'#12527#12540#12489#20877#35501#12415#36796#12415
-        OnClick = NG2Click
+        Caption = 'NG'#12527#12540#12489#35501#12415#36796#12415
+        object N42: TMenuItem
+          Caption = #19968#12388#21069
+          OnClick = N42Click
+        end
+        object N41: TMenuItem
+          Caption = #20877#35501#12415#36796#12415
+          OnClick = N41Click
+        end
+        object N49: TMenuItem
+          Caption = #19968#12388#24460#12429
+          OnClick = N49Click
+        end
       end
       object N43: TMenuItem
         Caption = '-'
index 015425c..8ed6db4 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -449,6 +449,9 @@ type
     ToolButton16: TToolButton;
     AllResAction: TAction;
     AllResToolButton: TToolButton;
+    N41: TMenuItem;
+    N42: TMenuItem;
+    N49: TMenuItem;
                procedure FormCreate(Sender: TObject);
                procedure FormDestroy(Sender: TObject);
                procedure CabinetPanelHide(Sender: TObject);
@@ -684,7 +687,6 @@ type
       Shift: TShiftState);
     procedure SelectComboBoxExit(Sender: TObject);
     procedure NG1Click(Sender: TObject);
-    procedure NG2Click(Sender: TObject);
     procedure SelectResActionExecute(Sender: TObject);
     procedure SelectResActionUpdate(Sender: TObject);
     procedure FormKeyDown(Sender: TObject; var Key: Word;
@@ -693,6 +695,9 @@ type
       Shift: TShiftState);
     procedure AllResActionExecute(Sender: TObject);
     procedure AllResActionUpdate(Sender: TObject);
+    procedure N41Click(Sender: TObject);
+    procedure N42Click(Sender: TObject);
+    procedure N49Click(Sender: TObject);
        private
                { Private \90é\8c¾ }
 
@@ -1223,6 +1228,8 @@ begin
        end;
 //     SetStdToolBar;
 //     SetLinkBar;
+
+    StatusBar.Panels.Items[2].Text := GikoSys.FAbon.NGwordname;
 end;
 
 //
@@ -6638,21 +6645,6 @@ begin
     GikoSys.FAbon.EditNGwords;
 end;
 //NG\83\8f\81[\83h\83t\83@\83C\83\8b\82ð\8dÄ\93Ç\82Ý\8d\9e\82Ý\82·\82é
-procedure TGikoForm.NG2Click(Sender: TObject);
-var
-        ThreadItem : TThreadItem;
-begin
-    if GikoSys.FAbon.ReLoadFromNGwordFile =false then begin
-               MsgBox(Handle, 'NG\83\8f\81[\83h\83t\83@\83C\83\8b\82Ì\8dÄ\93Ç\82Ý\8d\9e\82Ý\82É\8e¸\94s\82µ\82Ü\82µ\82½', '\83G\83\89\81[', MB_OK or MB_ICONEXCLAMATION);
-    end else begin
-        //\82±\82±\82Å\8c»\8dÝ\95\\8e¦\82³\82ê\82Ä\82¢\82é\83X\83\8c\83b\83h\82Ì\8dÄ\95`\89æ\82ð\8cÄ\82Ñ\8fo\82µ\82½\82¢\82ª\82â\82è\95û\95ª\82©\82ç\82¸¥¥¥\81B
-       ThreadItem := GetActiveContent;
-       if ThreadItem <> nil then
-                SetContent( ThreadItem );
-    end;
-
-end;
-
 procedure TGikoForm.SelectResActionExecute(Sender: TObject);
 var
         Dlg: TListSelectDialog;
@@ -6796,6 +6788,53 @@ begin
        AllResAction.Enabled := GetActiveContent <> nil;
 end;
 
+procedure TGikoForm.N41Click(Sender: TObject);
+var
+        ThreadItem : TThreadItem;
+begin
+    if GikoSys.FAbon.ReLoadFromNGwordFile =false then begin
+               MsgBox(Handle, 'NG\83\8f\81[\83h\83t\83@\83C\83\8b\82Ì\8dÄ\93Ç\82Ý\8d\9e\82Ý\82É\8e¸\94s\82µ\82Ü\82µ\82½', '\83G\83\89\81[', MB_OK or MB_ICONEXCLAMATION);
+    end else begin
+        //\82±\82±\82Å\8c»\8dÝ\95\\8e¦\82³\82ê\82Ä\82¢\82é\83X\83\8c\83b\83h\82Ì\8dÄ\95`\89æ\82ð\8cÄ\82Ñ\8fo\82µ\82½\82¢\82ª\82â\82è\95û\95ª\82©\82ç\82¸¥¥¥\81B
+       ThreadItem := GetActiveContent;
+       if ThreadItem <> nil then
+                SetContent( ThreadItem );
+    end;
+
+end;
+
+procedure TGikoForm.N42Click(Sender: TObject);
+var
+    ThreadItem : TThreadItem;
+begin
+    if GikoSys.FAbon.GoForward =false then begin
+               MsgBox(Handle, '\88ê\82Â\91O\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý\82É\8e¸\94s\82µ\82Ü\82µ\82½', '\83G\83\89\81[', MB_OK or MB_ICONEXCLAMATION);
+    end else begin
+        StatusBar.Panels.Items[2].Text := GikoSys.FAbon.NGwordname;
+        //\82±\82±\82Å\8c»\8dÝ\95\\8e¦\82³\82ê\82Ä\82¢\82é\83X\83\8c\83b\83h\82Ì\8dÄ\95`\89æ\82ð\8cÄ\82Ñ\8fo\82µ\82½\82¢\82ª\82â\82è\95û\95ª\82©\82ç\82¸¥¥¥\81B
+       ThreadItem := GetActiveContent;
+           if ThreadItem <> nil then
+                SetContent( ThreadItem );
+    end;
+
+end;
+
+procedure TGikoForm.N49Click(Sender: TObject);
+var
+    ThreadItem : TThreadItem;
+begin
+    if GikoSys.FAbon.GoBack =false then begin
+               MsgBox(Handle, '\88ê\82Â\8cã\82ë\82ÌNG\83\8f\81[\83h\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý\82É\8e¸\94s\82µ\82Ü\82µ\82½', '\83G\83\89\81[', MB_OK or MB_ICONEXCLAMATION);
+    end else begin
+        //\82±\82±\82Å\8c»\8dÝ\95\\8e¦\82³\82ê\82Ä\82¢\82é\83X\83\8c\83b\83h\82Ì\8dÄ\95`\89æ\82ð\8cÄ\82Ñ\8fo\82µ\82½\82¢\82ª\82â\82è\95û\95ª\82©\82ç\82¸¥¥¥\81B
+        StatusBar.Panels.Items[2].Text := GikoSys.FAbon.NGwordname;
+           ThreadItem := GetActiveContent;
+           if ThreadItem <> nil then
+                SetContent( ThreadItem );
+    end;
+
+end;
+
 initialization
         OleInitialize(nil);
 finalization
index e5e3cb0..43018d7 100644 (file)
@@ -205,6 +205,7 @@ const
        USER_AGENT                    = 'Monazilla';
        APP_NAME                      = 'gikoNavi';
                DEFAULT_NGWORD_FILE_NAME : String = 'NGword.txt';
+        NGWORDs_DIR_NAME : String = 'NGwords';
 
 (*************************************************************************
  *GikoSys\83R\83\93\83X\83g\83\89\83N\83^
@@ -215,10 +216,11 @@ begin
        FDolib := TDolib.Create;
        FAWKStr := TAWKStr.Create(nil);
                FAbon := TAbon.Create;
-               FAbon.Setroot(GetAppDir);
-               FAbon.SetNGwordpath(DEFAULT_NGWORD_FILE_NAME);
+               FAbon.Setroot(GetConfigDir+NGWORDs_DIR_NAME);
+               //FAbon.SetNGwordpath(DEFAULT_NGWORD_FILE_NAME);
+        FAbon.GoHome;
                FSelectResFilter := TAbon.Create;
-               FSelectResFilter.Setroot( GetAppDir );
+               //FSelectResFilter.Setroot( GetAppDir );
                // \8di\82ç\82È\82¢\8fê\8d\87\82Í False \82È\82Ì\82Å\82¢\82ç\82È\82¢
                // FSelectResFilter.Reverse := True;
                // \8di\82è\8d\9e\82Þ\82Æ\82«\82Í\8bÉ\97Í\88ê\97\97\82ª\8c©\82ç\82ê\82é\82Ù\82¤\82ª\82¢\82¢\82Ì\82Å\91¼\82Í\8a®\91S\82É\8dí\8f\9c
@@ -1102,7 +1104,7 @@ begin
        Result.FMailTo := Trim(GetTokenIndex(Line, Delim, 1));
        Result.FDateTime := Trim(GetTokenIndex(Line, Delim, 2));
     bufBody := Trim(GetTokenIndex(Line, Delim, 3));
-    if (AnsiPos('<br> ',bufbody) = 1) or (bufbody = '') then begin
+    if bufbody = '' then begin
         Insert('&nbsp;',bufbody, 1);
     end;
     Result.FBody := bufBody;