Here's a puzzle in the from of a program. Regards to all! Tom
program inout (input,output); (* version = 1.01 of inout.p 2010 Aug 12 2010 Aug 12, 1.01: testing on Sun 2010 Aug 12, 1.00: origin on mac
Thomas D. Schneider, Ph.D. National Institutes of Health Gene Regulation and Chromosome Biology Laboratory schneidt@mail.nih.gov http://alum.mit.edu/www/toms (permanent)
Test input string in GPC.
The program reads one character from the user at a time. If the user types the wrong character and wishes to correct it, then they should be able to type control-H (^H) or delete and correct the input. This works with GPC on a Sun computer, but on a Mac OSX (10.6.2) one instead sees '^H' and no backspace occurs.
What can be done at compile time to make backspace work on the Mac?
******************************************************************************** On a Sun computer:
% inout h the character was h u the character was u b the character was b z the character was z a the character was a b the character was b q the character was q
Backspace (control-H) and delete work as expected.
On a Mac:
% inout a the character was a abcd the character was a abcd^H^H^H^H^H^H^H^H control H or delete gives same^H^H^H the character was a q the character was q
Backspace (control-H) and delete do not work.
*)
var n: char; (* a character from the user *) begin n := ' '; while (n <> 'q') do begin readln(input, n); writeln(output, 'the character was ',n); end; end.
It turns out that backspace isn't always CTRL-H. I don't know what it is on MacOS, but on many UNIX platforms, the default backspace character is CTRL-? (changeable with a terminal setting). This is probably not something you want to specify directly on the UNIX side (I assume that MacOS X behaves like other UNIX variants in this regard); rather, you would want your program to look up the terminal setting for backspace and use that (no, I don't know how to do that in GPC, sorry to say).
--------------------------| John L. Ries | Salford Systems | Phone: (619)543-8880 x107 | or (435)867-8885 | --------------------------|
On Thu, 12 Aug 2010, Tom Schneider wrote:
Here's a puzzle in the from of a program. Regards to all! Tom
program inout (input,output); (* version = 1.01 of inout.p 2010 Aug 12 2010 Aug 12, 1.01: testing on Sun 2010 Aug 12, 1.00: origin on mac
Thomas D. Schneider, Ph.D. National Institutes of Health Gene Regulation and Chromosome Biology Laboratory schneidt@mail.nih.gov http://alum.mit.edu/www/toms (permanent)
Test input string in GPC.
The program reads one character from the user at a time. If the user types the wrong character and wishes to correct it, then they should be able to type control-H (^H) or delete and correct the input. This works with GPC on a Sun computer, but on a Mac OSX (10.6.2) one instead sees '^H' and no backspace occurs.
What can be done at compile time to make backspace work on the Mac?
On a Sun computer:
% inout h the character was h u the character was u b the character was b z the character was z a the character was a b the character was b q the character was q
Backspace (control-H) and delete work as expected.
On a Mac:
% inout a the character was a abcd the character was a abcd^H^H^H^H^H^H^H^H control H or delete gives same^H^H^H the character was a q the character was q
Backspace (control-H) and delete do not work.
*)
var n: char; (* a character from the user *) begin n := ' '; while (n <> 'q') do begin readln(input, n); writeln(output, 'the character was ',n); end; end.
John:
It turns out that backspace isn't always CTRL-H. I don't know what it is on MacOS, but on many UNIX platforms, the default backspace character is CTRL-? (changeable with a terminal setting). This is probably not something you want to specify directly on the UNIX side (I assume that MacOS X behaves like other UNIX variants in this regard); rather, you would want your program to look up the terminal setting for backspace and use that (no, I don't know how to do that in GPC, sorry to say).
On my command line on Mac OS X, control-H and the delete key work just fine. They stop working when the GPC compiled program runs. Also, I want to avoid having to modify my programs or they would break on other systems.
Control-? does not work inside the inout program or on the Mac OS X command line.
I found the solution! On the Mac in the ~/.cshrc (or a sourced file from there) include:
stty erase ^h
That does the job and control-h and delete now work inside the GPC compiled program.
Tom
Thomas D. Schneider, Ph.D. National Institutes of Health Gene Regulation and Chromosome Biology Laboratory schneidt@mail.nih.gov toms@alum.mit.edu (permanent) http://alum.mit.edu/www/toms (permanent)
On Fri, 13 Aug 2010, Tom Schneider wrote:
John:
It turns out that backspace isn't always CTRL-H. I don't know what it is on MacOS, but on many UNIX platforms, the default backspace character is CTRL-? (changeable with a terminal setting). This is probably not something you want to specify directly on the UNIX side (I assume that MacOS X behaves like other UNIX variants in this regard); rather, you would want your program to look up the terminal setting for backspace and use that (no, I don't know how to do that in GPC, sorry to say).
On my command line on Mac OS X, control-H and the delete key work just fine. They stop working when the GPC compiled program runs. Also, I want to avoid having to modify my programs or they would break on other systems.
Control-? does not work inside the inout program or on the Mac OS X command line.
I found the solution! On the Mac in the ~/.cshrc (or a sourced file from there) include:
stty erase ^h
That does the job and control-h and delete now work inside the GPC compiled program.
Tom
Yep, it's a terminal setting (that's what stty does).
--------------------------| John L. Ries | Salford Systems | Phone: (619)543-8880 x107 | or (435)867-8885 | --------------------------|