Size form dynamically from terminal dimensions; fix signed/unsigned mismatch

Expose CellWidth/CellHeight properties on TKPAnsi and remove hardcoded
Width/Height from both the TKPAnsi constructor and TMainForm constructor.
TESTMAIN now computes form size from FAnsi.Width/Height after handle
allocation triggers RecalcCellSize.  Fix bytesRead in reccom() from
int16_t to uint16_t to match avail/chunk types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Duensing 2026-03-03 17:30:34 -06:00
parent eebcf100ad
commit 3c5b57c6b5
3 changed files with 7 additions and 5 deletions

View file

@ -150,6 +150,8 @@ type
procedure Write(const S: string); procedure Write(const S: string);
procedure WriteDeferred(const S: string); procedure WriteDeferred(const S: string);
procedure WriteDeferredBuf(Buf: PChar; Len: Integer); procedure WriteDeferredBuf(Buf: PChar; Len: Integer);
property CellWidth: Integer read FCellWidth;
property CellHeight: Integer read FCellHeight;
property CursorCol: Integer read FCursorCol; property CursorCol: Integer read FCursorCol;
property CursorRow: Integer read FCursorRow; property CursorRow: Integer read FCursorRow;
published published
@ -316,8 +318,6 @@ var
Line: PTermLine; Line: PTermLine;
begin begin
inherited Create(AOwner); inherited Create(AOwner);
Width := 660;
Height := 450;
Color := clBlack; Color := clBlack;
TabStop := True; TabStop := True;
FCols := 80; FCols := 80;

View file

@ -87,8 +87,6 @@ begin
inherited CreateNew(AOwner); inherited CreateNew(AOwner);
Caption := 'KPComm ANSI Terminal'; Caption := 'KPComm ANSI Terminal';
Width := 780;
Height := 560;
BorderStyle := bsSingle; BorderStyle := bsSingle;
{ Serial component } { Serial component }
@ -153,6 +151,10 @@ begin
FAnsi.Top := 38; FAnsi.Top := 38;
FAnsi.OnKeyData := AnsiKeyData; FAnsi.OnKeyData := AnsiKeyData;
{ Size form to fit terminal + toolbar }
ClientWidth := FAnsi.Width;
ClientHeight := FAnsi.Top + FAnsi.Height;
{ Font diagnostic: write known CP437 box-drawing characters. } { Font diagnostic: write known CP437 box-drawing characters. }
{ If the OEM font is working, you should see: } { If the OEM font is working, you should see: }
{ Line 1: single-line box top +---+ } { Line 1: single-line box top +---+ }

View file

@ -1252,7 +1252,7 @@ int16_t FAR PASCAL _export reccom(int16_t commId, void FAR *buf, int16_t len)
{ {
PortStateT *port; PortStateT *port;
uint8_t FAR *dst; uint8_t FAR *dst;
int16_t bytesRead; uint16_t bytesRead;
dbgInt16("KPCOMM: reccom Id", commId); dbgInt16("KPCOMM: reccom Id", commId);