Unit Windows;

{***************************************************************************}

interface

{***************************************************************************}

{***************************************************************************}



Procedure DoWindow(Session: integer);

Procedure InitWindows;

Procedure PutOutputs;

Procedure ShowWriters;

Procedure ToWindow(InStr: string);

Procedure ToWindowL(InStr: string);

Function  Writers(Session, writer: integer): string;



implementation

{***************************************************************************}

{***************************************************************************}

Uses

  BBSGlbls,

  Crt,

  Globals,

  IOPorts,

  MiscSubs;



procedure DoWindow(Session: integer);

{***************************************************************************}

begin

  Window(WinX1[Session], WinY1[Session], WinX2[Session], WinY2[Session]);

  GotoXY(SaveX[Session], SaveY[Session]);

end;



Procedure InitWindows;

{***************************************************************************}

var

  alpha,

  bravo: integer;

begin

  ClrScr;

  for alpha := 1 to MaxSessions do

    begin

      SaveX[alpha] := 1;

      SaveY[alpha] := 1;

      WinX1[alpha] := 1;

      WinX2[alpha] := 80;

      WinY1[alpha] := (24 div MaxSessions)*(alpha - 1) + 3;

      WinY2[alpha] := (24 div MaxSessions)*alpha + 1;

    end;

end;



Procedure PutOutputs;

{***************************************************************************}

var

  alpha,

  bravo: integer;

  OutChar: char;

begin

  for alpha := 1 to NumPorts do

    if PortOutStr[alpha] <> '' then

      begin

        OutChar := PortOutStr[alpha, 1];

        PutChar(alpha, OutChar);

        PortOutStr[alpha]

          := copy(PortOutStr[alpha], 2, length(PortOutStr[alpha]) - 1);

      end;

end;



Procedure ShowWriters;

{***************************************************************************}

var

  alpha,

  bravo: integer;

  FrameStr: string;

  Height: integer;

  SelectChar: char;

  ReadersStr: string;

begin

  for alpha := 1 to MaxSessions do

    begin

      FrameStr := '';

      for bravo := 0 to NumPorts do

        FrameStr := FrameStr + Writers(alpha, bravo);

      ReadersStr := '';

      for bravo := 1 to NumPorts do

        if OutputTo[alpha, bravo] then

          ReadersStr := ReadersStr + 'COM' + StrInt(bravo) + ' ';

      SelectChar := '*';

      FrameStr := 'Outputs: ' + ReadersStr + MultiChar(SelectChar,

        62 - length(FrameStr) - length(ReadersStr))

          + ' Inputs: ' + FrameStr;

      Window(1, 1, 80, 25);

      GotoXY(1, WinY1[alpha] - 1);

      Write(FrameStr);

    end;

end;



Procedure ToWindow(InStr: string);

{***************************************************************************}

var

  alpha: integer;

begin

  DoWindow(Now);

  for alpha := 1 to length(InStr) do

    begin

      if (InStr[alpha] = Beep) and not(BeepOn) then

        InStr[alpha] := QuietBeep;

      write(InStr[alpha]);

    end;

  SaveX[Now] := WhereX;

  SaveY[Now] := WhereY;

end;



Procedure ToWindowL(InStr: string);

{***************************************************************************}

begin

  InStr := InStr + Enter + CntrlEntr;

  ToWindow(InStr);

end;



Function Writers(Session, writer: integer): string;

{***************************************************************************}

begin

  if InputFrom[Session, writer] then

    begin

      if writer = 0 then

        Writers := 'KBD '

      else

        Writers := 'COM' + StrInt(writer) + ' ';

    end

  else

    Writers := '';

end;



{***************************************************************************}

{***************************************************************************}

{***************************************************************************}

begin

end.

