📄 adtrmemu.pas
字号:
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; {!!.04}
procedure TAdEmuCommandParams.SetItem (Index : Integer; Value : TAdEmuCommandParamsItem); {!!.04}
begin {!!.04}
inherited SetItem (Index, Value); {!!.04}
end; {!!.04}
{=====} {!!.04}
// TAdEmuCommandListItem ****************************************************** {!!.04}
constructor TAdEmuCommandListItem.Create (Collection : TCollection); {!!.04}
begin {!!.04}
inherited Create (Collection); {!!.04}
FCollection := TAdEmuCommandList.Create (TAdEmuCommandList (Collection).FOwner); {!!.04}
FParams := TAdEmuCommandParams.Create (Self); {!!.04}
FCommand := ecNone; {!!.04}
end; {!!.04}
destructor TAdEmuCommandListItem.Destroy; {!!.04}
begin {!!.04}
FCollection.Free; {!!.04}
FCollection := nil; {!!.04}
FParams.Free; {!!.04}
inherited Destroy; {!!.04}
end; {!!.04}
procedure TAdEmuCommandListItem.AddBooleanArg (v : Boolean); {!!.04}
var {!!.04}
NewParam : TAdEmuCommandParamsItem; {!!.04}
begin {!!.04}
NewParam := TAdEmuCommandParamsItem (FParams.Add); {!!.04}
if v then {!!.04}
NewParam.Value := 'TRUE' {!!.04}
else {!!.04}
NewParam.Value := 'FALSE'; {!!.04}
end; {!!.04}
procedure TAdEmuCommandListItem.AddIntegerArg (v : Integer); {!!.04}
var {!!.04}
NewParam : TAdEmuCommandParamsItem; {!!.04}
begin {!!.04}
NewParam := TAdEmuCommandParamsItem (FParams.Add); {!!.04}
NewParam.Value := IntToStr (v); {!!.04}
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -