Category : Pascal Source Code
Archive   : TEDIT.ZIP
Filename : ASCIITAB.PAS

 
Output of file : ASCIITAB.PAS contained in archive : TEDIT.ZIP
unit ASCIITab;

{$F+,O+,X+,S-,D-}
interface

uses Objects, App, Views, Drivers;

type
PTable = ^TTable;
TTable = object(TView)
procedure Draw; virtual;
procedure HandleEvent(var Event:TEvent); virtual;
end;

PReport = ^TReport;
TReport = object(TView)
ASCIIChar: LongInt;
procedure Draw; virtual;
procedure HandleEvent(var Event:TEvent); virtual;
end;

PASCIIChart = ^TASCIIChart;
TASCIIChart = object(TWindow)
constructor Init;
destructor done; virtual;
end;

const
AsciiTableCommandBase: Word = 910;
AsciiCount : Byte = 0;

implementation

const
cmCharacterFocused = 0;

procedure TTable.Draw;
var
Buf: TDrawBuffer;
X, Y: Integer;
Color: Byte;
begin
Color := GetColor(6);
for Y := 0 to Size.Y - 1 do
begin
MoveChar(Buf, ' ', Color, Size.X);
for X := 0 to Size.X - 1 do
MoveChar(Buf[x], Chr(32 * y + x), Color, 1);
WriteLine(0, y, Size.X, 1, Buf);
end;
end;

procedure TTable.HandleEvent(var Event:TEvent);
var
CurrentSpot: TPoint;
procedure CharFocused;
begin
Message(Owner, evBroadcast, AsciiTableCommandBase + cmCharacterFocused,
Pointer(Cursor.X + 32 * Cursor.Y));
end;

begin
inherited HandleEvent(Event);
if Event.What = evMouseDown then
begin
repeat
if MouseInView(Event.Where) then
begin
MakeLocal(Event.Where, CurrentSpot);
SetCursor(CurrentSpot.X, CurrentSpot.Y);
CharFocused;
end;
until not MouseEvent(Event, evMouseMove);
ClearEvent(Event);
end;
end;

{ TReport }

procedure TReport.Draw;
var
TempStr: string;
begin
FormatStr(TempStr, ' Char: %c Decimal: %0#%3d Hex: %0#%02x ', ASCIIChar);
WriteStr(0, 0, TempStr, 7);
end;

procedure TReport.HandleEvent(var Event: TEvent);
var
Table: PTable;
begin
inherited HandleEvent(Event);
if (Event.What = evBroadcast) or (Event.what =evKeyDown) then
if Event.Command = AsciiTableCommandBase + cmCharacterFocused then
begin
ASCIIChar := Event.InfoLong;
DrawView;
end;
end;

constructor TASCIIChart.Init;
var
R: TRect;
Control: PVIew;
begin
R.Assign(42, 10, 76, 22);
TWindow.Init(R, 'ASCII Chart', wnNoNumber);
Flags := Flags and not (wfGrow + wfZoom);
Palette := wpCyanWindow;
R.Grow(-1,-1);
Dec(R.A.X, R.A.X - 1);
Dec(R.B.X, R.B.X - 33);
Dec(R.A.Y, R.A.Y );
Dec(R.B.Y, R.B.Y - 11);
R.A.Y := R.B.Y - 1;
Control := New(PReport, Init(R));
with Control^ do
begin
Options := Options or ofFramed;
EventMask := EventMask or evBroadcast;
end;
Insert(Control);
GetExtent(R);
R.Grow(-1,-1);
R.B.Y := R.B.Y - 2;
Control := New(PTable, Init(R));
Insert(Control);
Control^.Select;
Inc(AsciiCount);
end;

destructor TASCIIChart.Done;
begin
inherited done;
dec(AsciiCount);
end;

end.


  3 Responses to “Category : Pascal Source Code
Archive   : TEDIT.ZIP
Filename : ASCIITAB.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/