📄 adtrmbuf.pas
字号:
end;
{--------}
procedure TAdTerminalBuffer.DeleteLines(aCount : integer);
var
MaxRow : integer;
begin
FBeyondMargin := false;
{deleting lines is equivalent to a scroll up to the current cursor
position; we take account of any scroll region, of course}
{$IFDEF UseRangeCheck}
if (aCount <= 0) then
raise Exception.Create('TAdTerminalBuffer.DeleteLines: count must be positive');
{$ENDIF}
MaxRow := FDisplayOriginRow + FDisplayRowCount - 1;
tbScrollRows(aCount, FCursorRow, MaxRow);
{the cursor does not move}
tbInvalidateRect(FCursorRow, FDisplayOriginCol,
MaxRow, FDisplayOriginCol+FDisplayColCount-1);
end;
{--------}
procedure TAdTerminalBuffer.DeregisterTerminalHandle; {!!.05}
begin {!!.05}
FTerminalHandle := 0; {!!.05}
end; {!!.05}
{--------}
procedure TAdTerminalBuffer.DoBackHorzTab;
var
NewCol : integer;
begin
if (ColCount > 0) then begin
NewCol := FCursorCol;
while (NewCol > FDisplayOriginCol) do begin
dec(NewCol);
if ADTIsBitSet(FHorzTabStops, NewCol) then begin
FCursorMoved := FCursorMoved or (FCursorCol <> NewCol);
FCursorCol := NewCol;
tbFireOnCursorMovedEvent;
Exit;
end;
end;
FCursorMoved := FCursorMoved or (FCursorCol <> FDisplayOriginCol);
FCursorCol := FDisplayOriginCol;
tbFireOnCursorMovedEvent;
end;
end;
{--------}
procedure TAdTerminalBuffer.DoBackVertTab;
var
NewRow : integer;
begin
FBeyondMargin := false;
if (RowCount > 0) then begin
NewRow := FCursorRow;
while (NewRow > FDisplayOriginRow) do begin
dec(NewRow);
if ADTIsBitSet(FVertTabStops, NewRow) then begin
FCursorMoved := FCursorMoved or (FCursorRow <> NewRow);
FCursorRow := NewRow;
tbFireOnCursorMovedEvent;
Exit;
end;
end;
FCursorMoved := FCursorMoved or (FCursorRow <> FDisplayOriginRow);
FCursorRow := FDisplayOriginRow;
tbFireOnCursorMovedEvent;
end;
end;
{--------}
procedure TAdTerminalBuffer.DoBackspace;
begin
FBeyondMargin := false;
if (FCursorCol > FDisplayOriginCol) then begin
FCursorMoved := true;
dec(FCursorCol);
tbFireOnCursorMovedEvent;
end;
end;
{--------}
procedure TAdTerminalBuffer.DoCarriageReturn;
begin
FBeyondMargin := false;
FCursorMoved := FCursorMoved or (FCursorCol <> FDisplayOriginCol);
FCursorCol := FDisplayOriginCol;
tbFireOnCursorMovedEvent;
end;
{--------}
procedure TAdTerminalBuffer.DoHorzTab;
var
NewCol : integer;
MaxCol : integer;
begin
FBeyondMargin := false;
if (ColCount > 0) then begin
NewCol := FCursorCol;
MaxCol := FDisplayOriginCol + FDisplayColCount - 1;
while (NewCol < MaxCol) do begin
inc(NewCol);
if ADTIsBitSet(FHorzTabStops, NewCol) then begin
FCursorMoved := FCursorMoved or (FCursorCol <> NewCol);
FCursorCol := NewCol;
tbFireOnCursorMovedEvent;
Exit;
end;
end;
FCursorMoved := FCursorMoved or (FCursorCol <> MaxCol);
FCursorCol := MaxCol;
tbFireOnCursorMovedEvent;
end;
end;
{--------}
procedure TAdTerminalBuffer.DoLineFeed;
begin
FBeyondMargin := false;
if UseNewLineMode then
DoCarriageReturn;
MoveCursorDown(true);
end;
{--------}
procedure TAdTerminalBuffer.DoVertTab;
var
NewRow : integer;
MaxRow : integer;
begin
FBeyondMargin := false;
if (RowCount > 0) then begin
NewRow := FCursorRow;
MaxRow := FDisplayOriginRow + FDisplayRowCount - 1;
while (NewRow < MaxRow) do begin
inc(NewRow);
if ADTIsBitSet(FVertTabStops, NewRow) then begin
FCursorMoved := FCursorMoved or (FCursorRow <> NewRow);
FCursorRow := NewRow;
tbFireOnCursorMovedEvent;
Exit;
end;
end;
FCursorMoved := FCursorMoved or (FCursorRow <> MaxRow);
FCursorRow := MaxRow;
tbFireOnCursorMovedEvent;
end;
end;
{--------}
procedure TAdTerminalBuffer.EraseAll;
begin
{WARNING: this DOES NOT use the scroll region, if defined, it blanks
out everything in the scrollback buffer}
FBeyondMargin := false;
FCharMatrix.Clear;
FCharSetMatrix.Clear;
FAttrMatrix.Clear;
FForeColorMatrix.Clear;
FBackColorMatrix.Clear;
Row := 1;
Col := 1;
tbInvalidateRect(FCursorRow, 0,
pred(SVRowCount), pred(ColCount));
end;
{--------}
procedure TAdTerminalBuffer.EraseChars(aCount : integer);
var
CharCount : integer;
ToColNum : integer;
CurRow : integer;
CurCol : integer;
MaxCol : integer;
MaxRow : integer;
begin
{WARNING: this uses the scroll region, if defined}
FBeyondMargin := false;
{$IFDEF UseRangeChecks}
if (aCount <= 0) then
raise Exception.Create('TAdTerminalBuffer.EraseChars: Count must be +ve');
{$ENDIF}
{this is complicated by the need to erase chars on individual lines
separately}
CurRow := FCursorRow;
CurCol := FCursorCol;
MaxCol := FDisplayOriginCol + FDisplayColCount - 1;
MaxRow := FDisplayOriginRow + FDisplayRowCount - 1;
while (aCount > 0) and (CurRow <= MaxRow) do begin
{calculate the number of characters to erase in this row}
CharCount := MaxCol - CurCol + 1;
if (CharCount > aCount) then
CharCount := aCount;
{calculate the final column number}
ToColNum := CurCol + CharCount - 1;
{erase}
FCharMatrix.ClearItems(CurRow, CurCol, ToColNum);
FCharSetMatrix.ClearItems(CurRow, CurCol, ToColNum);
FAttrMatrix.ClearItems(CurRow, CurCol, ToColNum);
FForeColorMatrix.ClearItems(CurRow, CurCol, ToColNum);
FBackColorMatrix.ClearItems(CurRow, CurCol, ToColNum);
tbInvalidateRect(CurRow, CurCol,
CurRow, ToColNum);
{set up for the next loop}
dec(aCount, CharCount);
inc(CurRow);
CurCol := FDisplayOriginCol;
end;
end;
{--------}
procedure TAdTerminalBuffer.EraseFromBOL;
begin
{WARNING: this uses the scroll region, if defined}
FBeyondMargin := false;
{set all characters from the beginning of the line, up to and
including the cursor position, to blanks}
FCharMatrix.ClearItems(FCursorRow, FDisplayOriginCol, FCursorCol);
FCharSetMatrix.ClearItems(FCursorRow, FDisplayOriginCol, FCursorCol);
FAttrMatrix.ClearItems(FCursorRow, FDisplayOriginCol, FCursorCol);
FForeColorMatrix.ClearItems(FCursorRow, FDisplayOriginCol, FCursorCol);
FBackColorMatrix.ClearItems(FCursorRow, FDisplayOriginCol, FCursorCol);
tbInvalidateRect(FCursorRow, FDisplayOriginCol,
FCursorRow, FCursorCol);
end;
{--------}
procedure TAdTerminalBuffer.EraseFromBOW;
var
DisplayStartRow : integer;
begin
{WARNING: this DOES NOT use the scroll region, if defined, it blanks
out everything on the window up to and including the
cursor position}
FBeyondMargin := false;
{set all characters from the beginning of the line, up to and
including the cursor position, to blanks}
FCharMatrix.ClearItems(FCursorRow, 0, FCursorCol);
FCharSetMatrix.ClearItems(FCursorRow, 0, FCursorCol);
FAttrMatrix.ClearItems(FCursorRow, 0, FCursorCol);
FForeColorMatrix.ClearItems(FCursorRow, 0, FCursorCol);
FBackColorMatrix.ClearItems(FCursorRow, 0, FCursorCol);
tbInvalidateRect(FCursorRow, 0,
FCursorRow, FCursorCol);
{now erase all previous lines, by scrolling them out of existence}
DisplayStartRow := SVRowCount - RowCount;
if (FCursorRow > DisplayStartRow) then begin
tbScrollRows(FCursorRow - DisplayStartRow,
DisplayStartRow, pred(FCursorRow));
tbInvalidateRect(DisplayStartRow, 0,
pred(FCursorRow), pred(ColCount));
end;
end;
{--------}
procedure TAdTerminalBuffer.EraseLine;
var
MaxCol : integer;
begin
{WARNING: this uses the scroll region, if defined}
FBeyondMargin := false;
{set all characters from the beginning to the end of the line to
blanks}
MaxCol := FDisplayOriginCol + FDisplayColCount - 1;
FCharMatrix.ClearItems(FCursorRow, FDisplayOriginCol, MaxCol);
FCharSetMatrix.ClearItems(FCursorRow, FDisplayOriginCol, MaxCol);
FAttrMatrix.ClearItems(FCursorRow, FDisplayOriginCol, MaxCol);
FForeColorMatrix.ClearItems(FCursorRow, FDisplayOriginCol, MaxCol);
FBackColorMatrix.ClearItems(FCursorRow, FDisplayOriginCol, MaxCol);
tbInvalidateRect(FCursorRow, FDisplayOriginCol,
FCursorRow, MaxCol);
end;
{--------}
procedure TAdTerminalBuffer.EraseScreen;
begin
{WARNING: this DOES NOT use the scroll region, if defined, it blanks
out everything on the window}
FBeyondMargin := false;
{scroll the entire scrollback view by RowCount lines: this will have
the effect of clearing the display view and of setting up the
scrollback buffer with the previous screen}
tbScrollRows(RowCount, 0, pred(SVRowCount));
tbInvalidateRect(SVRowCount - RowCount, 0,
pred(SVRowCount), pred(ColCount));
end;
{--------}
procedure TAdTerminalBuffer.EraseToEOL;
var
MaxCol : integer;
begin
{WARNING: this uses the scroll region, if defined}
FBeyondMargin := false;
{set all characters from and including the cursor position to the
end of the line to blanks}
MaxCol := FDisplayOriginCol + FDisplayColCount - 1;
FCharMatrix.ClearItems(FCursorRow, FCursorCol, MaxCol);
FCharSetMatrix.ClearItems(FCursorRow, FCursorCol, MaxCol);
FAttrMatrix.ClearItems(FCursorRow, FCursorCol, MaxCol);
FForeColorMatrix.ClearItems(FCursorRow, FCursorCol, MaxCol);
FBackColorMatrix.ClearItems(FCursorRow, FCursorCol, MaxCol);
tbInvalidateRect(FCursorRow, FCursorCol,
FCursorRow, MaxCol);
end;
{--------}
procedure TAdTerminalBuffer.EraseToEOW;
begin
{WARNING: this DOES NOT use the scroll region, if defined, it blanks
out everything from and including the cursor position up
to the end of the screen}
FBeyondMargin := false;
{set all characters from and including the cursor position to the
end of the line to blanks}
FCharMatrix.ClearItems(FCursorRow, FCursorCol, pred(ColCount));
FCharSetMatrix.ClearItems(FCursorRow, FCursorCol, pred(ColCount));
FAttrMatrix.ClearItems(FCursorRow, FCursorCol, pred(ColCount));
FForeColorMatrix.ClearItems(FCursorRow, FCursorCol, pred(ColCount));
FBackColorMatrix.ClearItems(FCursorRow, FCursorCol, pred(ColCount));
tbInvalidateRect(FCursorRow, FCursorCol,
FCursorRow, pred(ColCount));
{now erase all succeeding lines, by scrolling them out of existence}
if (FCursorRow < pred(SVRowCount)) then begin
tbScrollRows(pred(SVRowCount) - FCursorRow,
succ(FCursorRow), pred(SVRowCount));
tbInvalidateRect(succ(FCursorRow), 0,
pred(SVRowCount), pred(ColCount));
end;
end;
{--------}
procedure TAdTerminalBuffer.GetCharAttrs(var aValue : TAdTerminalCharAttrs);
begin
aValue := FAttr;
end;
{--------}
procedure TAdTerminalBuffer.GetDefCharAttrs(var aValue : TAdTerminalCharAttrs);
begin
aValue := FDefAttr;
end;
{--------}
function TAdTerminalBuffer.GetInvalidRect(var aRect : TRect) : boolean;
begin
if (FInvRectList = nil) then
Result := false
else begin
{if there is more than one invalid rect, merge them all into one}
if (PInvRect(FInvRectList)^.irNext <> nil) then
ADTMergeInvalidRects(FInvRectList);
{return the first invalid rect}
Result := ADTRemoveInvalidRect(PInvRect(FInvRectList), aRect);
end;
end;
{--------}
function TAdTerminalBuffer.GetLineAttrPtr(aRow : integer) : pointer;
var
OurRow : integer;
begin
{normalize the row number to our internal system}
OurRow := tbCvtToInternalRow(aRow, true);
{$IFDEF UseRangeChecks}
if (OurRow < 0) or
(OurRow >= FSVRowCount) then
raise Exception.Create('TAdTerminalBuffer.GetLineAttrPtr: row number is out of range');
{$ENDIF}
{return the pointer into the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -