📄 adtrmemu.pas
字号:
const
BeatInterval = 100;
type
PBlinkNode = ^TBlinkNode;
TBlinkNode = packed record
bnNext : PBlinkNode;
bnRow : integer;
bnStartCh : integer;
bnEndCh : integer;
end;
type
PPaintNode = ^TPaintNode;
TPaintNode = packed record
pnNext : PPaintNode;
pnStart: integer; {start column of range}
pnEnd : integer; {end column of range}
pnFore : TColor; {foreground color for range}
pnBack : TColor; {background color for range}
pnAttr : TAdTerminalCharAttrs; {attributes for range}
pnCSet : byte; {charset for range}
end;
const
VT52DeviceAttrs = #27'/Z'; {"VT100 acting as VT52"}
VT100DeviceAttrs = #27'[?1;0c'; {"Base VT100, no options"}
VT100StatusRpt = #27'[0n'; {"terminal OK"}
VT100CursorPos = #27'[%d;%dR'; {"cursor is at row;col"}
VT100ReportParm = #27'[%d;%d;%d;%d;%d;%d;%dx';
{report terminal parameters}
const
VT100CharSetNames : array [0..4] of string =
('VT100-USASCII', {charset 0}
'VT100-UK', {charset 1}
'VT100-linedraw', {charset 2}
'VT100-ROM1', {charset 3}
'VT100-ROM2'); {charset 4}
{===Terminal/Emulator links==========================================}
type
PTermEmuLink = ^TTermEmuLink;
TTermEmuLink = record
telNext : PTermEmuLink;
telTerm : TAdCustomTerminal;
telEmu : TAdTerminalEmulator;
end;
{--------}
var
TermEmuLink : PTermEmuLink;
TermEmuLinkFreeList : PTermEmuLink;
{--------}
procedure AddTermEmuLink(aTerminal : TAdCustomTerminal;
aEmulator : TAdTerminalEmulator);
var
Node : PTermEmuLink;
begin
{if the link already exists, exit}
Node := TermEmuLink;
while (Node <> nil) do begin
if (Node^.telTerm = aTerminal) then
Exit;
Node := Node^.telNext;
end;
{otherwise, add it}
if (TermEmuLinkFreeList = nil) then
New(Node)
else begin
Node := TermEmuLinkFreeList;
TermEmuLinkFreeList := Node^.telNext;
end;
Node^.telTerm := aTerminal;
Node^.telEmu := aEmulator;
Node^.telNext := TermEmuLink;
TermEmuLink := Node;
{now update each object to point to the other}
aTerminal.Emulator := aEmulator;
aEmulator.Terminal := aTerminal;
end;
{--------}
procedure RemoveTermEmuLink(aTerminal : TAdCustomTerminal;
aNotify : boolean);
var
Dad, Node : PTermEmuLink;
Emulator : TAdTerminalEmulator;
begin
{remove the link}
Emulator := nil;
Dad := nil;
Node := TermEmuLink;
while (Node <> nil) do begin
if (Node^.telTerm = aTerminal) then begin
if (Dad = nil) then
TermEmuLink := Node^.telNext
else
Dad^.telNext := Node^.telNext;
Emulator := Node^.telEmu;
Node^.telNext := TermEmuLinkFreeList;
TermEmuLinkFreeList := Node;
Break;
end;
Dad := Node;
Node := Node^.telNext;
end;
{now update each object to point to nil instead of each other}
if aNotify and (Emulator <> nil) then begin
aTerminal.Emulator := nil;
Emulator.Terminal := nil;
end;
end;
{====================================================================}
// TAdEmuCommandParamsItem **************************************************** {!!.04}
constructor TAdEmuCommandParamsItem.Create (Collection : TCollection); {!!.04}
begin {!!.04}
inherited Create (Collection); {!!.04}
FCollection := TAdEmuCommandParams.Create (TAdEmuCommandParams (Collection).FOwner); {!!.04}
FName := ''; {!!.04}
FValue := ''; {!!.04}
end; {!!.04}
destructor TAdEmuCommandParamsItem.Destroy; {!!.04}
begin {!!.04}
FCollection.Free; {!!.04}
FCollection := nil; {!!.04}
inherited Destroy; {!!.04}
end; {!!.04}
// TAdEmuCommandParams ******************************************************** {!!.04}
constructor TAdEmuCommandParams.Create(AOwner : TPersistent); {!!.04}
begin {!!.04}
inherited Create (TAdEmuCommandParamsItem); {!!.04}
FOwner := AOwner; {!!.04}
end; {!!.04}
{=====} {!!.04}
{$IFNDEF VERSION5} {!!.04}
procedure TAdEmuCommandParams.Delete(Item: integer); {!!.04}
begin {!!.04}
GetItem(Item).Free; {!!.04}
end; {!!.04}
{=====} {!!.04}
{$ENDIF} {!!.04}
function TAdEmuCommandParams.FindName (AName : string) : Integer; {!!.04}
var {!!.04}
i : Integer; {!!.04}
begin {!!.04}
Result := -1; {!!.04}
if AName = '' then {!!.04}
Exit; {!!.04}
for i := 0 to Count - 1 do {!!.04}
if TAdEmuCommandParamsItem (Items[i]).Name = AName then begin {!!.04}
Result := i; {!!.04}
Exit; {!!.04}
end; {!!.04}
end; {!!.04}
function TAdEmuCommandParams.GetItem (Index : Integer) : TAdEmuCommandParamsItem; {!!.04}
begin {!!.04}
Result := TAdEmuCommandParamsItem (inherited GetItem (Index)); {!!.04}
end; {!!.04}
{=====} {!!.04}
function TAdEmuCommandParams.GetBooleanValue (AName : string; {!!.04}
APosition : Integer; {!!.04}
ADefault : Boolean) : Boolean; {!!.04}
var {!!.04}
RealPosition : Integer; {!!.04}
Value : string; {!!.04}
begin {!!.04}
Result := ADefault; {!!.04}
RealPosition := FindName (AName); {!!.04}
if RealPosition < 0 then {!!.04}
RealPosition := APosition; {!!.04}
if (RealPosition >= 0) and (RealPosition < Count) then begin {!!.04}
Value := LowerCase (TAdEmuCommandParamsItem (Items[RealPosition]).Value); {!!.04}
if (Value = 't') or (Value = 'true') or (Value = '1') or (Value = 'on') or {!!.04}
(Value = 'yes') then {!!.04}
Result := True {!!.04}
else if (Value = 'f') or (Value = 'false') or (Value = '0') or {!!.04}
(Value = 'off') or (Value = 'no') then {!!.04}
Result := False; {!!.04}
end; {!!.04}
end; {!!.04}
function TAdEmuCommandParams.GetIntegerValue (AName : string; {!!.04}
APosition : Integer; {!!.04}
ADefault : Integer) : Integer; {!!.04}
var {!!.04}
RealPosition : Integer; {!!.04}
begin {!!.04}
Result := ADefault; {!!.04}
RealPosition := FindName (AName); {!!.04}
if RealPosition < 0 then {!!.04}
RealPosition := APosition; {!!.04}
if (RealPosition >= 0) and (RealPosition < Count) then begin {!!.04}
try {!!.04}
Result := StrToInt (TAdEmuCommandParamsItem (Items[RealPosition]).Value); {!!.04}
except {!!.04}
on EConvertError do {!!.04}
Result := ADefault; {!!.04}
end; {!!.04}
end; {!!.04}
end; {!!.04}
function TAdEmuCommandParams.GetOwner : TPersistent; {!!.04}
begin {!!.04}
Result := FOwner; {!!.04}
end; {!!.04}
{=====} {!!.04}
function TAdEmuCommandParams.GetStringValue (AName : string; {!!.04}
APosition : Integer; {!!.04}
ADefault : string) : string; {!!.04}
var {!!.04}
RealPosition : Integer; {!!.04}
begin {!!.04}
Result := ADefault; {!!.04}
RealPosition := FindName (AName); {!!.04}
if RealPosition < 0 then {!!.04}
RealPosition := APosition; {!!.04}
if (RealPosition >= 0) and (RealPosition < Count) then {!!.04}
Result := TAdEmuCommandParamsItem (Items[RealPosition]).Value; {!!.04}
end; {!!.04}
function TAdEmuCommandParams.GetTColorValue (AName : string; {!!.04}
APosition : Integer; {!!.04}
ADefault : TColor) : TColor; {!!.04}
var {!!.04}
RealPosition : Integer; {!!.04}
begin {!!.04}
Result := ADefault; {!!.04}
RealPosition := FindName (AName); {!!.04}
if RealPosition < 0 then {!!.04}
RealPosition := APosition; {!!.04}
if (RealPosition >= 0) and (RealPosition < Count) then begin {!!.04}
try {!!.04}
Result := StrToInt (TAdEmuCommandParamsItem (Items[RealPosition]).Value); {!!.04}
except {!!.04}
on EConvertError do {!!.04}
Result := ADefault; {!!.04}
end; {!!.04}
end; {!!.04}
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -