Unit Edit; Interface Type TEditBox = object Caption: string; Text: string; BgColor: byte; TxtColor: byte; X, Y, PanelSize: byte; constructor init(pX, pY, pWidth: integer); destructor done; function Execute: boolean; function GetCurPos: byte; procedure SetFilter(filt: byte); private buffer: pointer; size: integer; CursorPos: byte; filter: array[1..8] of boolean; OldBgColor, OldTxtColor: byte; procedure Show; procedure Hide; procedure PrintText; end; Implementation uses Crt; {????????? ??????? ?????} procedure TEditBox.SetFilter(filt: byte); begin filter[1]:= (128 AND filt) <> 0;{?????} filter[2]:= (64 AND filt) <> 0;{????? a..z} filter[3]:= (32 AND filt) <> 0;{????? A..Z} filter[4]:= (16 AND filt) <> 0;{???????? ?????? ???? ????? (???? ?????????? ?????)} filter[5]:= (8 AND filt) <> 0;{??????} filter[6]:= (4 AND filt) <> 0;{????? ?????????? ? ??. ???????} filter[7]:= (2 AND filt) <> 0;{?????? ????? ?? ??????????? ??? ????? ??????} filter[8]:= true;{???? ????, ??? ?????? ??? ???????? ?????????????} end; {?????? ?????? ????? ? ??????? ?????, ???????????? ? ???????? text} procedure TEditBox.PrintText; var i: byte; begin GotoXY(X,Y); TextBackground(BgColor); For i:= 1 to PanelSize do Write(' '); GotoXY(X,Y); TextColor(TxtColor); if filter[7] then for i:= 1 to length(text) do write('*') else Write(Text); GotoXY(X + CursorPos, Y); end; {??????? ????????? ?????? (Caption) ? ???????? ????????? ?????? ??????} procedure TEditBox.Show; begin if Caption<> '' then begin GotoXY(X, Y-1); Write(Caption); end; CursorPos:= Length(text); PrintText; end; {????? ??? ?????? ????: ???????????? ??????? ?????? ? ?????????? True ??? ??????? Enter} function TEditBox.Execute: boolean; var ch: char; begin if not filter[8] then SetFilter(253); Show; Repeat ch:= ReadKey; case ch of #0: case readkey of {,®›r} #75: if CursorPos > 0 then dec(CursorPos); {,_… ›r} #77: if (CursorPos < PanelSize) and (CursorPos < Length(text)) then inc(CursorPos); end; {,›r ‘"„…} #48..#57: if (Length(Text) < PanelSize) and filter[1] then begin Insert(ch, Text, CursorPos+1); Inc(CursorPos); end; {,›r  ƒ…r‡-‰† ­a¦›} #97..#122: if (Length(Text) < PanelSize) and filter[2] then begin Insert(ch, Text, CursorPos+1); Inc(CursorPos); end; {,›r  œ® ›-‰† ­a¦›} #65..#90: if (Length(Text) < PanelSize) and filter[3] then begin Insert(ch, Text, CursorPos+1); Inc(CursorPos); end; {,›r ƒr‡¦". . ®" ƒr‡¦ aİ a ƒ -r›®- , ƒr - ››r"ª -"‡œr.} #46: if (Length(Text) < PanelSize) and filter[4] and (pos('.',Text)=0) then begin Insert(ch, Text, CursorPos+1); Inc(CursorPos); end; {,›r _…r­® .} #32: if (Length(Text) < PanelSize) and filter[5] then begin Insert(ch, Text, CursorPos+1); Inc(CursorPos); end; {,›r - ¦r› _…_"- -"‹ " ….  _‘ "ª›r®r›.} #33..#45, #47, #58..#64, #91..#96, #123..#126: if (Length(Text) < PanelSize) and filter[6] then begin Insert(ch, Text, CursorPos+1); Inc(CursorPos); end; {" ®-"  "›r® (Backspace)} #8: If CursorPos > 0 then begin Delete(Text, CursorPos, 1); dec(CursorPos); end; #27: begin Execute:= false; Hide; Exit; end; end; PrintText; until ch = #13; Execute:= true; Hide; end; {?????????? ??????? ??????? ?????? ???? ????? ???????????? ?????? ??????} function TEditBox.GetCurPos: byte; begin GetCurPos:= CursorPos; end; type VM = record sym: char; attr: byte; end; VMemArray = array[1 .. 50 * 80] of VM; var VMem: VMemArray absolute $B800:$0000; ScrWidth: Byte absolute $0:$44A; constructor TEditBox.init(pX, pY, pWidth: integer); var iX, iY, k: integer; begin X := pX; y := pY; PanelSize := pWidth; size := 3 * (panelsize + 3) * sizeof(VM); getmem(buffer, size); k := 0; for iY := Y - 1 to Y + 1 do for iX := X to X + PanelSize + 3 do begin inc(k); VMemArray(buffer^)[k] := VMem[ScrWidth * (iY - 1) + iX]; end; end; destructor TEditBox.Done; begin freemem(buffer, size); end; {?????? ??????? ???? ?????. ??????????, ? ???? ? ????? ??????: ??? ??????? ?????? ??? ????? ? ????????? ? ???????????? ??????? ??????} procedure TEditBox.Hide; var iX, iY, k: integer; begin k := 0; for iY := Y - 1 to Y + 1 do for iX := X to X + PanelSize + 3 do begin inc(k); VMem[ScrWidth * (iY - 1) + iX] := VMemArray(buffer^)[k]; end; end; end.