
unit CORE5;

interface

uses
  crt, CORE, CORE2, graph;

procedure READLNMCGA (var TEKST : string);
procedure READLNVGA (var TEKST : string);

implementation

procedure READLNMCGA (var TEKST : string);
  var
    Ch    : char;
    X, Y  : integer;
    A, B,C: integer;
(*    LINE  : array[0..8, 0..341] of byte;*)
  var
    FCOLOR, BCOLOR : integer;
    XPOS           : integer;
  begin
    TEKST:= '';
    XPOS:= 1;
    directvideo:= false;
    X:= wherex;
    Y:= wherey;
    A:= X;
    B:= Y;
    for C:= 1 to 39 do
      TEKST:= TEKST + ' ';
    repeat
      directvideo:= false;
(*      for C:= 0 to 7 do
        move (LINE[C, 0], mem[$A000:(B-1)*C*320], 319);
*)
      gotoxy (X, Y);
      PRINTMCGA (copy (TEKST, 1, 37-X+1));
      gotoxy (X+XPOS-1, Y);
      ANIMATECURSORMCGA;
      Ch:= READKEY;
      if Ch <> #0 then begin
        case CH of
          #8: begin
            directvideo:= false;
            BColor:= textattr div 16;
            FCOLOR:= textattr mod 16;
            directvideo:= false;
            textcolor (FCOLOR);
            PRINTMCGA (#8+' ');
            if XPOS > 1 then dec (XPOS, 1);
            delete (TEKST, XPOS, 1);
            TEKST:= TEKST + ' ';
(*            for C:= 0 to 7 do
              move (LINE[C, 0], mem[$A000:(B-1)*C*320], 319);
*)
          end
            else begin
              if XPOS < 37-X+1 then begin
(*                while (length (TEKST) < XPOS) do
                  TEKST:= TEKST + #32;
*)
                  insert (CH, TEKST, XPOS);
                  inc (XPOS, 1);
                  delete (TEKST, length (TEKST), 1);
              end;
            end;
        end;
      end
        else begin
          CH:= READKEY;
          case CH of
            'K': if XPOS > 1 then dec (XPOS, 1);
            'M': if XPOS < 37 then inc (XPOS, 1);
          end;
        end;
    until Ch = #13;
    while (TEKST[length(TEKST)] = ' ') do
      delete (TEKST, length(TEKST), 1);
  end;

procedure READLNVGA (var TEKST : string);
  var
    Ch    : char;
    X, Y  : integer;
    SIZE  : word;
    IMAGE : pointer;
  begin
    X:= wherex;
    Y:= wherey;
    SIZE:= imagesize (0, 0, 639, 8);
    getmem (IMAGE, SIZE);
    TEKST:= '';
    getimage (0, (Y-1)*8, 639, Y*8, IMAGE^);
    repeat
      gotoxy (X, Y);
      PRINTVGA ((X-1)*8, (Y-1)*8, TEKST + #176);
      gotoxy (X, Y);
      Ch:= READKEY;
      if Ch <> #0 then begin
        case CH of
          #8: begin
            delete (TEKST, length (TEKST), 1);
            putimage (0, (Y-1)*8, IMAGE^, NORMALPUT);
            GOTOXY (X, Y);
            PRINTVGA ((X-1)*8, (Y-1)*8, TEKST + #176);
          end
            else begin
              if length (TEKST) < 79-X+1 then
                TEKST:= TEKST + CH;
            end;
        end;
      end
        else CH:= READKEY;
    until Ch = #13;
    freemem (IMAGE, SIZE);
  end;

begin

end.