OSDN Git Service

リンクで飛んだときの履歴をとって移動できるような機能を追加
authorh677 <h677>
Sun, 30 Jul 2006 17:25:32 +0000 (17:25 +0000)
committerh677 <h677>
Sun, 30 Jul 2006 17:25:32 +0000 (17:25 +0000)
(バタ54に既になっています)

Giko.dfm
Giko.pas
GikoDataModule.dfm
GikoDataModule.pas
GikoSystem.pas
MoveHistoryItem.pas [new file with mode: 0644]
gikoNavi.dpr
gikoNavi.res

index 4b8d7f5..fdedcd6 100644 (file)
--- a/Giko.dfm
+++ b/Giko.dfm
@@ -159,7 +159,7 @@ object GikoForm: TGikoForm
           object ToolBar1: TToolBar
             Left = 2
             Top = 4
-            Width = 15
+            Width = 16
             Height = 18
             Align = alNone
             AutoSize = True
@@ -971,7 +971,7 @@ object GikoForm: TGikoForm
           OnResize = AddressToolBarResize
           object AddressComboBox: TComboBox
             Left = 0
-            Top = 0
+            Top = 1
             Width = 177
             Height = 20
             DropDownCount = 20
index 6a905a3..e244c08 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -18,7 +18,7 @@ uses
        Editor, RoundData, GikoPanel, Favorite, HTMLDocumentEvent,
        HintWindow, GikoCoolBar, GikoListView, Search, ExternalBoardManager,
        ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection,
-       IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord;
+       IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord, MoveHistoryItem;
 
 const
        NGWORDNAME_PANEL = 3;
@@ -594,6 +594,7 @@ type
                FOrigenCaption: String;                         //\82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83A\83C\83e\83\80\95Ò\8fW\8e\9e\82Ì\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ
                FPreviewBrowserRect: TRect;                     ///< \83v\83\8c\83r\83\85\81[\82Ì\95\\8e¦\88Ê\92u\82ð\8bL\89¯\82·\82é
                FActionListGroupIndexes: array of Integer;      ///<GikoDM\8fã\82Ì\83A\83N\83V\83\87\83\93\83\8a\83X\83g\82Ì\8ae\83A\83N\83V\83\87\83\93\82É\90Ý\92è\82³\82ê\82½GroupIndex\82ð\95Û\91\82·\82é\94z\97ñ
+
                procedure DownloadEnd(Sender: TObject; Item: TDownloadItem);
                procedure DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
                procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
@@ -1287,6 +1288,7 @@ begin
 
        //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\8f\89\8aú\89»
        InputAssistDM.Init(GikoSys.GetInputAssistFileName);
+
 end;
 
 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
@@ -3884,15 +3886,17 @@ var
        wkIntTo: Integer;
     BNum, BRes: string;
     threadItem: TThreadItem;
+    aElement : IHTMLElement;
 begin
-
        Cancel := True;
-       if (IHTMLDocument2(TWebBrowser(Sender).Document).activeElement <> nil) then begin
-               Text := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerText;
-               Html := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerHTML;
+    aElement := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement;
+       if ( aElement <> nil) then begin
+               Text := aElement.Get_outerText;
+               Html := aElement.Get_outerHTML;
                if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
                        or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
                        if GikoSys.Setting.ResAnchorJamp then begin
+
                                Text := ZenToHan(Trim(Text));
 
                                if(AnsiPos('>>', Text) = 1) then begin
@@ -3915,6 +3919,7 @@ begin
 
                                if wkIntSt <> 0 then begin
                                        FActiveContent.IDAnchorPopup('');
+                    MoveHisotryManager.pushItem(FActiveContent);
                                        BrowserMovement(IntToStr(wkIntSt));
                                end;
 
@@ -3948,6 +3953,7 @@ begin
                                                AddressComboBox.Items.Insert(0, URL);
                                        end;
                                end;
+                MoveHisotryManager.pushItem(FActiveContent);
                                MoveToURL( URL );
                        end;
                end;
index d0e31f8..04ffb06 100644 (file)
@@ -1235,6 +1235,20 @@ object GikoDM: TGikoDM
       OnExecute = CloseAllEditorActionExecute
       OnUpdate = CloseAllEditorActionUpdate
     end
+    object PrevMoveHistory: TAction
+      Category = #12473#12524#12483#12489
+      Caption = #12522#12531#12463#23653#27508#12434#25147#12427
+      Hint = #12522#12531#12463#23653#27508#12434#25147#12427
+      OnExecute = PrevMoveHistoryExecute
+      OnUpdate = PrevMoveHistoryUpdate
+    end
+    object NextMoveHistory: TAction
+      Category = #12473#12524#12483#12489
+      Caption = #12522#12531#12463#23653#27508#12434#36914#12416
+      Hint = #12522#12531#12463#23653#27508#12434#36914#12416
+      OnExecute = NextMoveHistoryExecute
+      OnUpdate = NextMoveHistoryUpdate
+    end
   end
   object ToobarImageList: TImageList
     Left = 44
index 789a651..097d739 100644 (file)
@@ -12,7 +12,7 @@ uses
        MSHTML_TLB,
 {$IFEND}
   ComCtrls, BrowserRecord, Graphics, Messages, Setting, Dialogs,
-  ActiveX;
+  ActiveX, MoveHistoryItem;
 
 const
        CAPTION_NAME: string = '\83M\83R\83i\83r';
@@ -219,6 +219,8 @@ type
     LiveItemAction: TAction;
     FavoriteTreeViewItemNameCopyAction: TAction;
     CloseAllEditorAction: TAction;
+    PrevMoveHistory: TAction;
+    NextMoveHistory: TAction;
        procedure EditNGActionExecute(Sender: TObject);
        procedure ReloadActionExecute(Sender: TObject);
        procedure GoFowardActionExecute(Sender: TObject);
@@ -406,6 +408,10 @@ type
     procedure FavoriteTreeViewItemNameCopyActionExecute(Sender: TObject);
     procedure CloseAllEditorActionExecute(Sender: TObject);
     procedure CloseAllEditorActionUpdate(Sender: TObject);
+    procedure PrevMoveHistoryUpdate(Sender: TObject);
+    procedure PrevMoveHistoryExecute(Sender: TObject);
+    procedure NextMoveHistoryUpdate(Sender: TObject);
+    procedure NextMoveHistoryExecute(Sender: TObject);
   private
        { Private \90é\8c¾ }
        procedure ClearResFilter;
@@ -421,6 +427,8 @@ type
        procedure ClearSelectComboBox;
     procedure ClearMailAllEditor();
     procedure ClearNameTextAllEditor();
+    procedure MoveURLWithHistory(URL : String);
+    procedure BackToHistory(item: TMoveHistoryItem);
   public
        { Public \90é\8c¾ }
        procedure RepaintStatusBar;
@@ -554,24 +562,10 @@ end;
 //! \83A\83h\83\8c\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83A\83h\83\8c\83X\82Ö\88Ú\93®\82·\82é
 // *************************************************************************
 procedure TGikoDM.MoveToActionExecute(Sender: TObject);
-var
-       URL: string;
-       idx: Integer;
 begin
        //\83A\83h\83\8c\83X\83R\83\93\83{\83{\83b\83N\83X\82©\82çURL\82ð\8eæ\93¾
-       URL := Trim(GikoForm.AddressComboBox.Text);
        //URL\82É\88Ú\93®
-       GikoForm.MoveToURL(URL);
-       //\88È\89º\81A\97\9a\97ð\82Ì\8f\88\97\9d
-       idx := GikoForm.AddressComboBox.Items.IndexOf(URL);
-       if idx = -1 then begin
-               GikoForm.AddressComboBox.Items.Insert(0, URL);
-               if GikoForm.AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
-                       GikoForm.AddressComboBox.Items.Delete(GikoForm.AddressComboBox.Items.Count - 1);
-       end else begin
-               GikoForm.AddressComboBox.Items.Delete(idx);
-               GikoForm.AddressComboBox.Items.Insert(0, URL);
-       end;
+    MoveURLWithHistory( Trim(GikoForm.AddressComboBox.Text) );
 end;
 // *************************************************************************
 //! \82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á\83_\83C\83A\83\8d\83O\82ð\8aJ\82­
@@ -2235,7 +2229,8 @@ begin
         URLs.Free;
        end;
 
-    if (GikoForm.BrowserTab.Tabs.Count = 0) then  begin
+    if (GikoForm.BrowserTab.Tabs.Count = 0) and
+        (TabsOpenAction.Tag <> 1) then  begin
         ShowMessage('\95\\8e¦\82·\82é\83^\83u\82ª\82 \82è\82Ü\82¹\82ñ\81B');
     end;
 end;
@@ -4038,5 +4033,83 @@ begin
        end;
 end;
 
+// *************************************************************************
+//! \83\8a\83\93\83N\97\9a\97ð\82ð\96ß\82é\82Ì\8dX\90V\8f\88\97\9d
+// *************************************************************************
+procedure TGikoDM.PrevMoveHistoryUpdate(Sender: TObject);
+begin
+      PrevMoveHistory.Enabled :=
+          (MoveHisotryManager.HisotryIndex > 0)
+end;
+// *************************************************************************
+//! \83\8a\83\93\83N\97\9a\97ð\82ð\96ß\82é
+// *************************************************************************
+procedure TGikoDM.PrevMoveHistoryExecute(Sender: TObject);
+begin
+    if ( GikoForm.BrowserTab.TabIndex >= 0 ) then begin
+        BackToHistory(MoveHisotryManager.getPrevItem
+            (TBrowserRecord(GikoForm.BrowserTab.Tabs
+                    .Objects[GikoForm.BrowserTab.TabIndex])));
+    end else begin
+        BackToHistory(MoveHisotryManager.getPrevItem( nil ) );
+    end;
+end;
+//! \83\8a\83\93\83N\97\9a\97ð\8f\88\97\9d
+procedure TGikoDM.BackToHistory(item: TMoveHistoryItem);
+var
+    browser : TWebBrowser;
+    doc : OleVariant;
+begin
+    if ( item <> nil ) then begin
+        if ( GikoForm.GetActiveContent = item.ThreadItem ) then begin
+            browser := TBrowserRecord(GikoForm.BrowserTab.Tabs
+                .Objects[GikoForm.BrowserTab.TabIndex]).Browser;
+            if (browser <> nil) then begin
+                try
+                    doc := Idispatch( olevariant(browser.ControlInterface).Document) as IHTMLDocument2;
+                    doc.Body.ScrollTop := item.ScrollTop;
+                except
+                end;
+            end;
+        end else begin
+            //URL\82É\88Ú\93®
+            MoveURLWithHistory(item.ThreadItem.URL);
+        end;
+    end;
+end;
+//! \97\9a\97ð\8f\88\97\9d\82Â\82«URL\88Ú\93®
+procedure TGikoDM.MoveURLWithHistory(URL : String);
+var
+    idx : Integer;
+begin
+    //URL\82É\88Ú\93®
+    GikoForm.MoveToURL(URL);
+    //\88È\89º\81A\97\9a\97ð\82Ì\8f\88\97\9d
+    idx := GikoForm.AddressComboBox.Items.IndexOf(URL);
+    if idx = -1 then begin
+        GikoForm.AddressComboBox.Items.Insert(0, URL);
+        if GikoForm.AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
+            GikoForm.AddressComboBox.Items.Delete(GikoForm.AddressComboBox.Items.Count - 1);
+    end else begin
+        GikoForm.AddressComboBox.Items.Delete(idx);
+        GikoForm.AddressComboBox.Items.Insert(0, URL);
+    end;
+end;
+// *************************************************************************
+//! \83\8a\83\93\83N\97\9a\97ð\82ð\90i\82Þ\82Ì\8dX\90V\8f\88\97\9d
+// *************************************************************************
+procedure TGikoDM.NextMoveHistoryUpdate(Sender: TObject);
+begin
+    NextMoveHistory.Enabled :=
+          (MoveHisotryManager.HisotryIndex < MoveHisotryManager.Count - 1);
+end;
+// *************************************************************************
+//! \83\8a\83\93\83N\97\9a\97ð\82ð\90i\82Þ
+// *************************************************************************
+procedure TGikoDM.NextMoveHistoryExecute(Sender: TObject);
+begin
+    BackToHistory(MoveHisotryManager.getNextItem);
+end;
+
 end.
 
index 2157255..a096d1a 100644 (file)
@@ -256,7 +256,7 @@ const
        ZERO_DATE: Integer      = 25569;
        BETA_VERSION_NAME_E = 'beta';
        BETA_VERSION_NAME_J = 'ÊÞÀ';
-       BETA_VERSION                            = 53;
+       BETA_VERSION                            = 54;
        BETA_VERSION_BUILD      = '';                           //!< debug\94Å\82È\82Ç
        APP_NAME                                                = 'gikoNavi';
        BE_PHP_URL = 'http://be.2ch.net/test/p.php?i=';
diff --git a/MoveHistoryItem.pas b/MoveHistoryItem.pas
new file mode 100644 (file)
index 0000000..7682c5c
--- /dev/null
@@ -0,0 +1,154 @@
+unit MoveHistoryItem;
+
+interface
+uses
+    SysUtils, Classes, BoardGroup, BrowserRecord,
+{$IF Defined(DELPRO) }
+       SHDocVw,
+       MSHTML,
+{$ELSE}
+       SHDocVw_TLB,
+       MSHTML_TLB,
+{$IFEND}
+    OleCtrls, ActiveX;
+type
+
+    TMoveHistoryItem = class(TObject)
+    private
+        FThreadItem : TThreadItem;
+        FScrollTop  : Integer;
+    public
+        property ThreadItem : TThreadItem read FThreadItem write FThreadItem;
+        property ScrollTop : Integer read FScrollTop write FScrollTop;
+    end;
+
+    TMoveHistory = class(TList)
+    private
+        FHistoryMax : Integer;
+        FIndex : Integer;
+    public
+        constructor Create( max : Integer ); overload;
+        function pushItem( item: TMoveHistoryItem): Integer; overload;
+        function pushItem( item: TBrowserRecord): Integer; overload;
+        function getPrevItem( item: TBrowserRecord): TMoveHistoryItem;
+        function getNextItem: TMoveHistoryItem;
+        procedure clear; override;
+        property HistoryMax : Integer read FHistoryMax write FHistoryMax;
+        property HisotryIndex: Integer read FIndex;
+    end;
+
+var
+    MoveHisotryManager : TMoveHistory;
+
+implementation
+
+//! \83R\83\93\83X\83g\83\89\83N\83^
+constructor TMoveHistory.Create( max : Integer );
+begin
+    inherited Create;
+
+    FIndex := 0;
+    FHistoryMax := max;
+    if (FHistoryMax < 0) then begin
+        FHistoryMax := 20;
+    end;
+end;
+//! \88Ú\93®\97\9a\97ð\82Ì\83A\83C\83e\83\80\92Ç\89Á
+function TMoveHistory.pushItem( item: TMoveHistoryItem): Integer;
+var
+    i : Integer;
+    top: TMoveHistoryItem;
+begin
+    Result := -1;
+    if (Self.Count > 0) then begin
+        top := TMoveHistoryItem( Self.Items[Self.Count - 1] );
+        if (top.FThreadItem = item.FThreadItem) and
+            (top.FScrollTop = item.FScrollTop) then begin
+            Exit;
+        end;
+    end;
+    // \95Û\8e\9d\90\94\82Ì\8dÅ\91å\92l\82ð\92´\82¦\82é\8fê\8d\87\90æ\93ª\82ð\8dí\8f\9c
+    if (FIndex + 1 > FHistoryMax) then begin
+        if ( Self.Items[0] <> nil ) then begin
+            TMoveHistoryItem( Self.Items[0] ).Free;
+        end;
+        Self.Delete(0);
+        Dec(Findex);
+    end;
+    // FIndex\82æ\82è\8cã\82ë\82Ì\83A\83C\83e\83\80\82ð\8dí\8f\9c\82·\82é
+    for i := Self.Count - 1 downto Findex do begin
+        if (Self.Items [i] <> nil) then begin
+            TMoveHistoryItem( Self.Items[i] ).Free;
+        end;
+        Self.Delete(i);
+    end;
+    Inc(FIndex);
+    Result := Self.Add( item );
+end;
+//! \88Ú\93®\97\9a\97ð\82Ì\83A\83C\83e\83\80\92Ç\89Á
+function TMoveHistory.pushItem( item: TBrowserRecord): Integer;
+var
+    history : TMoveHistoryItem;
+    doc : OleVariant;
+begin
+    Result := -1;
+    if ( item <> nil ) and ( item.Thread <> nil )
+        and ( item.Browser <> nil) then begin
+        history := TMoveHistoryItem.Create;
+        history.FThreadItem := item.Thread;
+        doc := Idispatch( olevariant(item.Browser.ControlInterface).Document) as IHTMLDocument2;
+        history.ScrollTop := doc.Body.ScrollTop;
+
+        Result := pushItem( history );
+    end;
+end;
+//! \88ê\82Â\91O\82Ì\97\9a\97ð\83A\83C\83e\83\80\8eæ\93¾
+function TMoveHistory.getPrevItem(item: TBrowserRecord): TMoveHistoryItem;
+begin
+    Result := nil;
+    if (FIndex = Self.Count) and (item <> nil) then begin
+        pushItem( item );
+        Dec(FIndex);
+    end;
+    if ( FIndex > 0 ) then begin
+        Dec( FIndex );
+        Result := TMoveHistoryItem( Self.items[ FIndex  ] );
+    end;
+end;
+//! \88ê\82Â\8cã\82ë\82Ì\97\9a\97ð\83A\83C\83e\83\80\8eæ\93¾
+function TMoveHistory.getNextItem: TMoveHistoryItem;
+begin
+    Result := nil;
+    if ( FIndex < Self.Count - 1 ) then begin
+        Inc( FIndex );
+        Result := TMoveHistoryItem( Self.items[ FIndex ] );
+    end;
+end;
+//! \97\9a\97ð\82Ì\91S\8fÁ\8b\8e
+procedure TMoveHistory.clear;
+var
+    i : Integer;
+begin
+    // FIndex\82æ\82è\8cã\82ë\82Ì\83A\83C\83e\83\80\82ð\8dí\8f\9c\82·\82é
+    for i := Self.Count - 1 downto 0 do begin
+        if (Self.Items [i] <> nil) then begin
+            TMoveHistoryItem( Self.Items[i] ).Free;
+        end;
+        Self.Delete(i);
+    end;
+    Self.Capacity := 0;
+
+    inherited;
+end;
+
+initialization
+       MoveHisotryManager := TMoveHistory.Create( 20 );
+
+finalization
+       if MoveHisotryManager <> nil then begin
+               MoveHisotryManager.clear;
+        MoveHisotryManager.Free;
+               MoveHisotryManager := nil;
+       end;
+end.
index 50ad56e..188a7b7 100644 (file)
@@ -72,7 +72,8 @@ uses
   GikoMessage in 'GikoMessage.pas',
   InputAssist in 'InputAssist.pas' {InputAssistForm},
   InputAssistDataModule in 'InputAssistDataModule.pas' {InputAssistDM: TDataModule},
-  DefaultFileManager in 'DefaultFileManager.pas';
+  DefaultFileManager in 'DefaultFileManager.pas',
+  MoveHistoryItem in 'MoveHistoryItem.pas';
 
 {$R *.RES}
 {$R gikoResource.res}
index 4b6ad47..aa17619 100644 (file)
Binary files a/gikoNavi.res and b/gikoNavi.res differ