home *** CD-ROM | disk | FTP | other *** search
- Unit JRKBD201 ;
-
- (*╔═════════════════════════════════════════════════════════════════════════╗*)
- (*║ ║*)
- (*║ JR Unit Library - Version 2.01 - June xxrd 1988 ║*)
- (*║ ║*)
- (*║ Keyboard functions and procedures ║*)
- (*║ ║*)
- (*╚═════════════════════════════════════════════════════════════════════════╝*)
-
- Interface
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Uses Crt , JRBIT201 , JRSCR201 ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Const
- _Nul = 0 ; _Bs = 8 ; _Tab = 9 ; _Lf = 10 ; _Cr = 13 ; _Esc = 27 ;
- _ShTab = 271 ;
- _F1 = 315 ; _F2 = 316 ; _F3 = 317 ; _F4 = 318 ; _F5 = 319 ;
- _F6 = 320 ; _F7 = 321 ; _F8 = 322 ; _F9 = 323 ; _F10 = 324 ;
- _Home = 327 ; _Up = 328 ; _PgUp = 329 ; _Left = 331 ; _Right = 333 ;
- _End = 335 ; _Down = 336 ; _PgDn = 337 ; _Ins = 338 ; _Del = 339 ;
-
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Var
- _KbdStatus1 : Byte Absolute $0000:$0417 ;
- _KbdStatus2 : Byte Absolute $0000:$0418 ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Function _GetKey : Integer ;
- Procedure _Lined(Var txt : String ;
- x,y,txtlength : Integer ;
- esclist : Integer ;
- options : Integer ;
- Var key : Integer) ;
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Implementation
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Function _GetKey ;
- (* Version 2.00 *)
- Const NUL = #0 ;
- Var ch : Char ;
- Begin ;
- ch:=ReadKey ;
- If (ch=NUL) Then Begin ;
- ch:=ReadKey ; _GetKey:=Ord(ch)+256 ;
- End Else _GetKey:=Ord(ch) ;
- End (* Procedure _GetKey *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- Procedure _Lined ;
- (* Version 2.00 *)
- (*╔═════════════════════════════════════════════════════════════════╗*)
- (*║ (* = Ej klar) Esclist ║*)
- (*╠═════════════════════════════════════════════════════════════════╣*)
- (*║ Hög byte Låg byte ║*)
- (*║ 76543210 76543210 ║*)
- (*║ 1 - 1 End ║*)
- (*║ 1 Fyllt fält 1 Home ║*)
- (*║ 1 ShTab 1 PgDn ║*)
- (*║ 1 Tab 1 PgUp ║*)
- (*║ 1 Right (vid radstart) 1 Down ║*)
- (*║ 1 Right (alltid) 1 Up ║*)
- (*║ 1 Left (vid radslut) 1 Esc ║*)
- (*║ 1 Left (alltid) 1 Enter ║*)
- (*╠═════════════════════════════════════════════════════════════════╣*)
- (*║ Options ║*)
- (*╠═════════════════════════════════════════════════════════════════╣*)
- (*║ Hög byte Låg byte ║*)
- (*║ 76543210 ║*)
- (*║ Färgkod 1 - ║*)
- (*║ 1 - ║*)
- (*║ 1 - ║*)
- (*║ 1 - ║*)
- (*║ 1 *Chr(32)-Chr(255) ║*)
- (*║ 1 *A-Ö,a-ö ║*)
- (*║ 1 *Numeriskt fält ║*)
- (*║ 1 Entré från höger ║*)
- (*╚═════════════════════════════════════════════════════════════════╝*)
-
- Var i,xpos : Integer ;
- leave : Boolean ;
- Begin ;
- TextColor(Hi(options) Mod 16) ;
- TextBackground(Hi(options) Div 16) ;
- leave:=False ; _Cursor(5,7) ;
- If (_Bit(Lo(options),0)) Then xpos:=txtlength Else xpos:=1 ;
- Repeat ;
- GotoXY(x,y) ; Write(txt) ;
- GotoXY(x+xpos-1,y) ;
- key:=_GetKey ;
- Case key Of
- _Cr : leave:=_Bit(Lo(esclist),0) ;
- _Esc : leave:=_Bit(Lo(esclist),1) ;
- _Up : leave:=_Bit(Lo(esclist),2) ;
- _Down : leave:=_Bit(Lo(esclist),3) ;
- _PgUp : leave:=_Bit(Lo(esclist),4) ;
- _PgDn : leave:=_Bit(Lo(esclist),5) ;
- _Home : Begin ; xpos:=1 ; leave:=_Bit(Lo(esclist),6) ; End ;
- _Left : Begin ;
- Dec(xpos) ;
- If xpos<1 Then Begin ;
- xpos:=1 ; leave:=_Bit(Hi(esclist),1) ;
- End Else leave:=_Bit(Hi(esclist),0) ;
- End ;
- _Right: Begin ;
- Inc(xpos) ;
- If xpos>txtlength Then Begin ;
- xpos:=txtlength ; leave:=_Bit(Hi(esclist),3) ;
- End Else leave:=_Bit(Hi(esclist),2) ;
- End ;
- _End : Begin ; xpos:=txtlength ; leave:=_Bit(Lo(esclist),7) ; End ;
- _Ins : Begin ;
- For i:=txtlength DownTo xpos Do txt(.i.):=txt(.i-1.) ;
- txt(.xpos.):=' ' ;
- End ;
- _Del : Begin ;
- For i:=xpos To txtlength Do txt(.i.):=txt(.i+1.) ;
- txt(.txtlength.):=' ' ;
- End ;
- _Bs : Begin ;
- If (xpos>1) Then Begin ;
- For i:=xpos-1 To txtlength-1 Do txt(.i.):=txt(.i+1.) ;
- txt(.txtlength.):=' ' ;
- Dec(xpos) ;
- End ;
- End ;
- _Tab : leave:=_Bit(Hi(esclist),4) ;
- _ShTab:leave:=_Bit(Hi(esclist),5) ;
- Else Begin ;
- If ((key In (.48..57.)) And _Bit(Lo(options),1)) Or
- ((key>=32) And (key<=255) And _Bit(Lo(options),3)) Or
- (((key>=65) And (key<=90)) Or ((key>=97) And (key<=122))
- Or (key=143) Or (key=142) Or (key=153) Or (key=134) Or
- (key=132) Or (key=148)) And _Bit(Lo(options),2) Then
- Begin ;
- txt(.xpos.):=Chr(key) ;
- Inc(xpos) ;
- If xpos>txtlength Then Begin ;
- xpos:=txtlength ; leave:=_Bit(Hi(esclist),6) ;
- End ;
- End ;
- End ;
- End ;
- Until leave ;
- GotoXY(x,y) ; Write(txt) ;
- _Cursor(0,0) ;
- End (* Procedure _Lined *) ;
-
- (*───────────────────────────────────────────────────────────────────────────*)
-
- End (* Of Unit JRKBD201 *).
-