Re: [cc65] Escape keys

Date view Thread view Subject view

From: Greg King (gngking_at_erols.com)
Date: 2002-12-13 19:47:41


-----Original Message-----
From: Ullrich von Bassewitz
Date: Thursday, December 12, 2002 02:26 PM
>
> On Thu, Dec 12, 2002, at 07:49:35PM +0100, MagerValp wrote:
> >
> > Maybe, define both
> > CH_STOP and CH_ESC to 0x03 on the C64/VIC-20, and 0x03/0x1b on the
> > other platforms?
>
> Better: Define CH_ESC on machines that have an escape key and CH_STOP on keys
> with a stop-key (which are all CBM machines, I think). So the existance of the
> symbol means that the machine has this key, similar to the function-keys. This
> will allow tests like:
>
>         switch (cgetc ()) {
>
> #ifdef CH_ESC
>             CH_ESC:
>                 /* Handle the escape key */
>                 break;
> #endif
>
>         }

MagerValp's way is more transparent.  A programmer should not need to wonder if
a key exists or not -- he simply should use it!  Each implementation "secretly"
should take care of those "niggling" little details about "Is it there?", "Where
is it?", "How does it look?", "Should there be a substitute?", and "What should
be that substitute?".

That example should be simply:

        switch (cgetc()) {
            ...
            case CH_ESC:
                /* Do the escape-procedure. */
                ...
                break;
            ...
        }

"Behind the scenes," the implementation's header-file would have chosen the
appropriate character for that -- portable -- test.

The same thing goes for the function-key names!  Do the Apple and Atari
keyboards have actual function-keys, or did someone decide that pressing two
keys simultaneously will have the same effect as a true function-key?  That's
"appropriate substitution."  Do it for all targets -- every one of them should
have ten function-keys -- real or simulated.  (If a keyboard physically doesn't
have enough available codes, then perhaps, some codes could be "borrowed" from
other key-combinations.  Would that really break any [well-written] programs?)

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-12-14 03:23:40 CET