Class TConsole (unit DConsole)

Inherits from

TCustomControl

Constructors


constructor Create(AnOwner: TComponent);



Functions

procedure AssignCrt(var F: Text);

Assign text file to CRT device

procedure ClrEol;

Clear to end of line

procedure ClrScr;


procedure CursorTo(X, Y: Integer);

Set cursor position

procedure DefaultProcessControlCodes(Buffer: PChar; Count: Cardinal);


destructor Destroy;


procedure HideCursor;

Hide caret

function KeyPressed: Boolean;

Return keyboard status

function ReadBuf(Buffer: PChar; Count: Cardinal): Cardinal;

Read text buffer from CRT window

function ReadKey: Char;

Read key from CRT window

procedure ScrollTo(X, Y: Integer);

Scroll window to given origin } { If font has overlapping cells (ie, italic), additional work is done to remove the residual overlapped pixels from the leftmost column.

procedure ShowCursor;

Show caret

procedure TrackCursor;

Scroll to make cursor visible (synchronous - immediate update

procedure WriteChar(Ch: Char);

Write character to CRT window

procedure WriteCodedBuf(Buffer: PChar; Count: Cardinal);


procedure WriteFill(X,Y: Integer; Ch: Char; Count: Cardinal);


procedure WriteString(const S: String);


procedure CreateParams(var P: TCreateParams);

Cursor location

procedure DoCtrlBreak;


procedure FontChanged(Sender: TObject);


procedure KeyDown(var Key: Word; Shift: TShiftState);


procedure KeyPress(var Key: Char);


procedure LazyScrollBy(dx, dy: Integer);

Request asynchronous (lazy) ScrollBy, or update pending request

procedure LazyTrackCursor;

Request asynchronous (lazy) TrackCursor, if not already pending

procedure Loaded;

close files

procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);


procedure Paint;

wm_Paint message handler

procedure RecalcSizeAndRange;


procedure RecalibrateFont;


procedure ResizeBuffer;

don't ClrScr, because text may already be in buffer

function ScreenPtr(X, Y: Integer): PChar;

Return pointer to text location in screen buffer } { Always call ScreenPtr to get the next line you want, since the circular text buffer may wrap around between lines N and N+1.

procedure SetMetrics(const Metrics: TTextMetric);

If the character cell is different, accept changes and redraw

procedure SetName(const NewName: TComponentName);


procedure SetScrollbars;

Update scroll bars

procedure ShowText(L, R: Integer);

Update text on cursor line

procedure WriteBlock(X,Y: Integer; Buffer: PChar; Count: Cardinal);


procedure WriteBuf(Buffer: PChar; Count: Cardinal);

Write text buffer to CRT window - Process any special characters in buffer - Insert line breaks

procedure CMScrollBy(var M: TCMScrollBy);

Respond to asynchronous (lazy) ScrollBy request

procedure CMTrackCursor(var M);

Respond to asynchronous (lazy) TrackCursor request

procedure DoScroll(Which, Action, Thumb: Integer);


procedure InternalClrScr;

CR/LF/CRLF translation

Clear screen


procedure SetCols(N: Integer);


procedure SetFont(F: TFixedFont);


procedure SetOptions(NewOptions: TConsoleOptions);


procedure SetRows(N: Integer);


procedure WMCreate(var M);


procedure WMEraseBkgnd(var M: TWMEraseBkgnd);


procedure WMGetDlgCode(var M: TWMGetDlgCode);


procedure WMHScroll(var M: TWMHScroll);


procedure WMKillFocus(var M: TWMKillFocus);


procedure WMSetFocus(var M: TWMSetFocus);


procedure WMSize(var M: TWMSize);

Draw subsequent lines without any background fill or clipping rect

procedure WMVScroll(var M: TWMVScroll);


Properties

property Align :


property Color :


property Cols : Integer


property Font : TFixedFont


property LineBreak : TConsoleLineBreak


property Options : TConsoleOptions


property ParentColor :


property ProcessControlCodes : TProcessControlCodes


property Rows : Integer


Events

Variables

Cursor : TPoint;

Keyboard type-ahead buffer

FBuffer : PChar;

Count of keys in KeyBuffer

FCharAscent : Integer;

Character cell size

FCharSize : TPoint;

Number of visible whole cells

FClientSize : TPoint;

Client/scroll origin

FFirstLine : Integer;


FKeyBuffer : array[0..63] of Char;

Extra space needed for chars

FKeyCount : Integer;

First visible line in circular buffer

FOldFont : TFixedFont;

Reading from CRT window?

FOrigin : TPoint;

Scroll bar ranges

FOverhang : Integer;

Baseline location (for caret)

FRange : TPoint;

Screen buffer pointer

FReading : Boolean;


FCols : Integer;


FFocused : Boolean;


FFont : TFixedFont;


FLineBreak : TConsoleLineBreak;


FOptions : TConsoleOptions;


FProcessControlCodes : TProcessControlCodes;


FRows : Integer;

Screen buffer dimensions


Constructors


constructor Create(AnOwner: TComponent);


Functions


procedure AssignCrt(var F: Text);

Assign text file to CRT device


procedure ClrEol;

Clear to end of line


procedure ClrScr;


procedure CursorTo(X, Y: Integer);

Set cursor position


procedure DefaultProcessControlCodes(Buffer: PChar; Count: Cardinal);


destructor Destroy;


procedure HideCursor;

Hide caret


function KeyPressed: Boolean;

Return keyboard status


function ReadBuf(Buffer: PChar; Count: Cardinal): Cardinal;

Read text buffer from CRT window


function ReadKey: Char;

Read key from CRT window


procedure ScrollTo(X, Y: Integer);

Scroll window to given origin } { If font has overlapping cells (ie, italic), additional work is done to remove the residual overlapped pixels from the leftmost column. Using the clip rect with ScrollWindowEx helps eliminate pixel flicker in the left column.


procedure ShowCursor;

Show caret


procedure TrackCursor;

Scroll to make cursor visible (synchronous - immediate update


procedure WriteChar(Ch: Char);

Write character to CRT window


procedure WriteCodedBuf(Buffer: PChar; Count: Cardinal);


procedure WriteFill(X,Y: Integer; Ch: Char; Count: Cardinal);


procedure WriteString(const S: String);


procedure CreateParams(var P: TCreateParams);

Cursor location


procedure DoCtrlBreak;


procedure FontChanged(Sender: TObject);


procedure KeyDown(var Key: Word; Shift: TShiftState);


procedure KeyPress(var Key: Char);


procedure LazyScrollBy(dx, dy: Integer);

Request asynchronous (lazy) ScrollBy, or update pending request


procedure LazyTrackCursor;

Request asynchronous (lazy) TrackCursor, if not already pending


procedure Loaded;

close files


procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);


procedure Paint;

wm_Paint message handler


procedure RecalcSizeAndRange;


procedure RecalibrateFont;


procedure ResizeBuffer;

don't ClrScr, because text may already be in buffer


function ScreenPtr(X, Y: Integer): PChar;

Return pointer to text location in screen buffer } { Always call ScreenPtr to get the next line you want, since the circular text buffer may wrap around between lines N and N+1. For the same reason, do not do pointer arithmetic between rows.


procedure SetMetrics(const Metrics: TTextMetric);

If the character cell is different, accept changes and redraw


procedure SetName(const NewName: TComponentName);


procedure SetScrollbars;

Update scroll bars


procedure ShowText(L, R: Integer);

Update text on cursor line


procedure WriteBlock(X,Y: Integer; Buffer: PChar; Count: Cardinal);


procedure WriteBuf(Buffer: PChar; Count: Cardinal);

Write text buffer to CRT window - Process any special characters in buffer - Insert line breaks


procedure CMScrollBy(var M: TCMScrollBy);

Respond to asynchronous (lazy) ScrollBy request


procedure CMTrackCursor(var M);

Respond to asynchronous (lazy) TrackCursor request


procedure DoScroll(Which, Action, Thumb: Integer);


procedure InternalClrScr;

CR/LF/CRLF translation

Clear screen


procedure SetCols(N: Integer);


procedure SetFont(F: TFixedFont);


procedure SetOptions(NewOptions: TConsoleOptions);


procedure SetRows(N: Integer);


procedure WMCreate(var M);


procedure WMEraseBkgnd(var M: TWMEraseBkgnd);


procedure WMGetDlgCode(var M: TWMGetDlgCode);


procedure WMHScroll(var M: TWMHScroll);


procedure WMKillFocus(var M: TWMKillFocus);


procedure WMSetFocus(var M: TWMSetFocus);


procedure WMSize(var M: TWMSize);

Draw subsequent lines without any background fill or clipping rect


procedure WMVScroll(var M: TWMVScroll);


Properties


property Align :


property Color :


property Cols : Integer


property Font : TFixedFont


property LineBreak : TConsoleLineBreak


property Options : TConsoleOptions


property ParentColor :


property ProcessControlCodes : TProcessControlCodes


property Rows : Integer


Events


Variables


Cursor : TPoint;

Keyboard type-ahead buffer


FBuffer : PChar;

Count of keys in KeyBuffer


FCharAscent : Integer;

Character cell size


FCharSize : TPoint;

Number of visible whole cells


FClientSize : TPoint;

Client/scroll origin


FFirstLine : Integer;


FKeyBuffer : array[0..63] of Char;

Extra space needed for chars


FKeyCount : Integer;

First visible line in circular buffer


FOldFont : TFixedFont;

Reading from CRT window?


FOrigin : TPoint;

Scroll bar ranges


FOverhang : Integer;

Baseline location (for caret)


FRange : TPoint;

Screen buffer pointer


FReading : Boolean;


FCols : Integer;


FFocused : Boolean;


FFont : TFixedFont;


FLineBreak : TConsoleLineBreak;


FOptions : TConsoleOptions;


FProcessControlCodes : TProcessControlCodes;


FRows : Integer;

Screen buffer dimensions