unit historyWin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ListViewEx;

type
  THistoryFrm = class(TForm)
    StatusBar1: TStatusBar;
    lvHistory: TListViewEx;
    procedure lvHistorySelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure lvHistoryKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    FEditor: TObject;
  public
    property Editor: TObject read FEditor write FEditor;
  end;

implementation

uses
  TextEditor;

{$R *.dfm}

procedure THistoryFrm.lvHistoryKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key in [VK_ESCAPE, VK_RETURN] then
    Close;
end;

procedure THistoryFrm.lvHistorySelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
begin
  if FEditor is TTextEditor then
    TTextEditor(FEditor).GotoHistoryVersion(TTextEditor(FEditor).TextFile.HistoryManager.FirstItem + Item.Index);
end;

end.
