Khimenko Victor wrote:
The gpc works now on my Linux Mandrake, it is GREAT, it has many more functionality than Borland Pascal 7
In the crtdemo the ESC key doesn't work to quit, is it a problem of my config ?
More like problem with *nix design (not even *nix exacly bu more like old unix terminals design - it's stupid, ugly and unneeded but it's used by SUCH big number of systems all around the world now that it's really not worth trying to fix).
One could probably fix it (under Linux at least) by changing the keymap (or the kernel) and the termcap and terminfo entries. However, this would break:
- programs run remotely unless you install the new termcap/terminfo on the host as well,
- programs that hard-code escapes sequences (but such programs are broken by design, anyway).
ESC key is used as prefix for other keys (like arrows and functional keys - it was even used this way in Turbo Pascal 2.x and 3.x if you recall). And there are NO reliable way to distinguish sequence of keys ESC,[,U from Left arrow, for example (I'm not remember well what exactly sequence is for left arrow but it's not relevant). Plus not all keyboards on teminals have F1-F10 keys, for example and then sequences ESC,1 ... ESC,9 ESC,0 are used instead. Thus for ESC to work you must be patient: just wait few seconds and it'll close program.
Perhaps we should go MC way and use double-ESC as "true" ESC so you can use ESC,ESC when needed and still can use ESC,1 ESC,A and so on without worry ?
Unfortunately (but consequently) double-ESC is the sequence for Alt- (or Meta-)ESC. So, a program could recognize Alt-ESC (kbAltEsc in the CRT unit) as equivalent to ESC. I'm doing it in CRTDemo now, but each program has to do it for itself -- and this could be many places. Alternatively, I could add a flag to CRT which, if set, will cause CRT to transparently translate Alt-ESC to ESC (if the flag is not set, Alt-ESC can be distinguished from ESC for programs that want this). Should I do so?
But even worse, there are sequences that start with double-ESC, e.g. Alt-function key, so the code has to wait further after reading double-ESC. So, if you press ESC three times, you get an Alt-ESC and (after some delay) a plain ESC. So, if Alt-ESC terminates the program (like CRTDemo with my next changes), that works, since Alt-ESC terminates the program and it won't get to the delay...
But generally, on a local console, I have no problems with a small ESCDELAY -- if you set it larger than ~30, repeated ESC keys (i.e. holding down the key) will get converted to Alt-ESC, but 10 is fine for me.
I'm adding a comment about it in the CRT unit.
Frank
13-Jul-00 22:18 you wrote:
Khimenko Victor wrote:
The gpc works now on my Linux Mandrake, it is GREAT, it has many more functionality than Borland Pascal 7
In the crtdemo the ESC key doesn't work to quit, is it a problem of my config ?
More like problem with *nix design (not even *nix exacly bu more like old unix terminals design - it's stupid, ugly and unneeded but it's used by SUCH big number of systems all around the world now that it's really not worth trying to fix).
One could probably fix it (under Linux at least) by changing the keymap (or the kernel) and the termcap and terminfo entries.
What about xterm, kterm and bunch of VT100 emulators ?
However, this would break:
- programs run remotely unless you install the new termcap/terminfo on the host as well,
- programs that hard-code escapes sequences (but such programs are broken by design, anyway).
Yes. What's more important is that you can not RELY on ESC to be easily distinguishable - otherwise you'll pretty much lock your users to console and it's BAD THIING(tm). When working with console you can easily fix problem without remapping: just try to read from console in big chunks. If ESC is pressed you'll get just ESC, if F10 (or something like this) is pressed you'll get more then just ESC in buffer. And you can find out if you are dealing with console or not: just try to call console-specific ioctl (num lock led, for example). But then it's pretty natural for linux novadays to not use console at all but use just [x,k,e]term (and perhaps ssh). It's be REAL BAD to make program working only on console :-/
ESC key is used as prefix for other keys (like arrows and functional keys - it was even used this way in Turbo Pascal 2.x and 3.x if you recall). And there are NO reliable way to distinguish sequence of keys ESC,[,U from Left arrow, for example (I'm not remember well what exactly sequence is for left arrow but it's not relevant). Plus not all keyboards on teminals have F1-F10 keys, for example and then sequences ESC,1 ... ESC,9 ESC,0 are used instead. Thus for ESC to work you must be patient: just wait few seconds and it'll close program.
Perhaps we should go MC way and use double-ESC as "true" ESC so you can use ESC,ESC when needed and still can use ESC,1 ESC,A and so on without worry ?
Unfortunately (but consequently) double-ESC is the sequence for Alt- (or Meta-)ESC. So, a program could recognize Alt-ESC (kbAltEsc in the CRT unit) as equivalent to ESC. I'm doing it in CRTDemo now, but each program has to do it for itself -- and this could be many places. Alternatively, I could add a flag to CRT which, if set, will cause CRT to transparently translate Alt-ESC to ESC (if the flag is not set, Alt-ESC can be distinguished from ESC for programs that want this). Should I do so?
God knows. I've looked on few programs where ESC works "just fine" like ViM and/or minicom. Minicom is using "console approarch" explained above (and works without delays only for console) while ViM is goeing even further: if it gets ESC it will wait for VERY short time and then will react just as ESC should do (will go out of insert mode, for example) BUT will remember that ESC was just pressed AND if later it'll find valid code for arrows and such it will undo ESC work and do what whould be done for left-arrow or right-arrow. Both solutions hardly look partable to me :-/
But even worse, there are sequences that start with double-ESC, e.g. Alt-function key, so the code has to wait further after reading double-ESC. So, if you press ESC three times, you get an Alt-ESC and (after some delay) a plain ESC. So, if Alt-ESC terminates the program (like CRTDemo with my next changes), that works, since Alt-ESC terminates the program and it won't get to the delay...
But generally, on a local console, I have no problems with a small ESCDELAY -- if you set it larger than ~30, repeated ESC keys (i.e. holding down the key) will get converted to Alt-ESC, but 10 is fine for me.
I'm adding a comment about it in the CRT unit.
Looks like it's all what can be done: give CRT user all the information about ESC problems and let him decide what to do with it. Looks like there no universal solution anyway.
P.S. A lot of programs (like Emacs or bash) just use ESC as prefix and do not assign ANY meaning by itself: ESC,1,2,3 is the same as Meta-1,2,3 and is "repeat next command 123 times", Esc,* is the same as Meta-* (put names of files with common prefix in command line) and so on. It's REAL handy when you are using dumb terminal (like Microsoft's built-in telnet :-) without Meta- support and (on other hand) it's most reliable way to handle ESC. It looks like most natural thing to do if you'll think about it...