count.pas

来自「还是一个词法分析程序」· PAS 代码 · 共 74 行

PAS
74
字号
{************************************************}
{                                                }
{   Turbo Vision 2.0 Demo                        }
{   Copyright (c) 1992 by Borland International  }
{                                                }
{************************************************}

{$X+,V-}

unit Count;

interface

uses Objects, Drivers, Views;


type
  PCountView = ^TCountView;
  TCountView = object(TView)
    Current: Longint;
    Count: Longint;
    constructor Init(var Bounds: TRect);
    constructor Load(var S: TStream);
    procedure Draw; virtual;
    function GetPalette: PPalette; virtual;
    procedure SetCount(NewCount: Longint);
    procedure IncCount;
    procedure DecCount;
    procedure SetCurrent(NewCurrent: Longint);
    procedure IncCurrent;
    procedure DecCurrent;
    procedure Store(var S: TStream); virtual;
  end;

procedure RegisterCount;

const
  CCountView = #1#2#3#8#9;

  RCountView: TStreamRec = (
    ObjType: 992;
    VmtLink: Ofs(TypeOf(TCountView)^);
    Load: @TCountView.Load;
    Store: @TCountView.Store
  );

implementation

{ TCountView  }
constructor TCountView.Init(var Bounds:TRect);
begin
  inherited Init(Bounds);
  SetCount(0);
  SetCurrent(1);
end;

constructor TCountView.Load(var S: TStream);
begin
  inherited Load(S);
  S.Read(Current, SizeOf(Current));
  S.Read(Count, SizeOf(Count));
end;

procedure TCountView.Draw;
var
  B: TDrawBuffer;
  C: Word;
  Params: array[0..1] of Longint;
  Start: Word;
  First: String[10];
  Display: String[20];
begin
  C := GetColor(2);  { Uses same color as frame }
  MoveChar(B, '

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?