Annotation of gforth/dosekey.fs, revision 1.1

1.1     ! pazsan      1: \ dosekey, based on:
        !             2: \ ekey etc.
        !             3: 
        !             4: \ Copyright (C) 2001 Free Software Foundation, Inc.
        !             5: 
        !             6: \ This file is part of Gforth.
        !             7: 
        !             8: \ Gforth is free software; you can redistribute it and/or
        !             9: \ modify it under the terms of the GNU General Public License
        !            10: \ as published by the Free Software Foundation; either version 2
        !            11: \ of the License, or (at your option) any later version.
        !            12: 
        !            13: \ This program is distributed in the hope that it will be useful,
        !            14: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            15: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            16: \ GNU General Public License for more details.
        !            17: 
        !            18: \ You should have received a copy of the GNU General Public License
        !            19: \ along with this program; if not, write to the Free Software
        !            20: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
        !            21: 
        !            22: 
        !            23: \ this implementation of EKEY just translates the KEY values
        !            24: \ received following a null to values between 256 and 511
        !            25: 
        !            26: \ Caveats: It also translates a sequence of two codes beginning with
        !            27: \ 0 if they were not generated by pressing the key.  It does not wait
        !            28: \ for the second value in the sequence to arrive.
        !            29: 
        !            30: \ In a Forth implementation on DOS in which special keys are not 
        !            31: \ available by a second call to KEY following a null value, this
        !            32: \ code will not work.  It has only been used on Gforth 0.5
        !            33: 
        !            34: \ The dos-keycode names are compatible with pfe-0.9.14
        !            35: 
        !            36: : dos-keycode ( c "name" -- ; name execution: -- u ) 256 + constant ;
        !            37: 
        !            38: 75 dos-keycode k-left
        !            39: 77 dos-keycode k-right
        !            40: 72 dos-keycode k-up
        !            41: 80 dos-keycode k-down
        !            42: 71 dos-keycode k-home
        !            43: 79 dos-keycode k-end
        !            44: 115 keycode k-prior \ note: captured by xterm
        !            45: 116 keycode k-next \ note: captured by xterm
        !            46: 82 dos-keycode k-insert \ not in pfe
        !            47: \ function/keypad keys
        !            48: 59 dos-keycode k1
        !            49: 60 dos-keycode k2
        !            50: 61 dos-keycode k3
        !            51: 62 dos-keycode k4
        !            52: 63 dos-keycode k5
        !            53: 64 dos-keycode k6
        !            54: 65 dos-keycode k7
        !            55: 66 dos-keycode k8
        !            56: 67 dos-keycode k9
        !            57: 68 dos-keycode k10
        !            58: 133 dos-keycode k11 \ not in pfe
        !            59: 134 dos-keycode k12 \ not in pfe
        !            60: 
        !            61: \ shifted function/keypad keys have the same key sequences (in
        !            62: \ xterm) and pfe gives the same keycodes; so use of these is
        !            63: \ not portable to gforth outside of DOS
        !            64: 84 dos-keycode s-k1
        !            65: 85 dos-keycode s-k2
        !            66: 86 dos-keycode s-k3
        !            67: 87 dos-keycode s-k4
        !            68: 88 dos-keycode s-k5
        !            69: 89 dos-keycode s-k6
        !            70: 90 dos-keycode s-k7
        !            71: 91 dos-keycode s-k8
        !            72: 92 dos-keycode s-k9
        !            73: 93 dos-keycode s-k10
        !            74: 135 dos-keycode s-k11 \ not in pfe
        !            75: 136 dos-keycode s-k12 \ not in pfe
        !            76: 
        !            77: : ekey ( -- u ) \ facility-ext e-key
        !            78:     key ?dup 0= if key 256 + then
        !            79: ;
        !            80: 
        !            81: : ekey>char ( u -- u false | c true ) \ facility-ext e-key-to-char
        !            82:     dup 256 u<
        !            83: ;
        !            84: 
        !            85: : ekey? ( -- flag ) \ facility-ext e-key-question
        !            86:     \G Return @code{true} if a keyboard event is available (use
        !            87:     \G @code{ekey} to receive the event), @code{false} otherwise.
        !            88:     key?
        !            89: ;
        !            90: 
        !            91: FALSE [IF]
        !            92:    : test-ekey?
        !            93:       begin
        !            94:          begin
        !            95:             begin key? until
        !            96:          ekey? until
        !            97:          .s ekey .s drop
        !            98:       again
        !            99:    ;
        !           100:    test-ekey?
        !           101: [THEN]

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>