In article <
2017May2...@mips.complang.tuwien.ac.at>,
Anton Ertl <
an...@mips.complang.tuwien.ac.at> wrote:
>Alex <
al...@rivadpm.com> writes:
>>
>><quote>
>>6.1.0695 ACCEPT
>>
>>Because external system hardware and software may perform the ACCEPT
>>function, when a line terminator is received the action of the cursor,
>>and therefore the display, is implementation-defined. It is recommended
>>that *the cursor remain immediately following the entered text* after a
>>line terminator is received.
>></quote>
>>
>>Which is very elegant, but unfortunately with a standard Windows console
>>an absolute swine to implement. Using file reads through stdin, Windows
>>treats the enter key as a CR LF, and moves the cursor appropriately.
>
>Under Unix you have to switch the terminal to raw mode to get decent
>behaviour. Googling for "Windows console raw mode" brought up this:
>
>
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683462%28v=vs.85%29.aspx
>
>This tells you to disable Line input mode, Processed input mode, Echo
>input mode and Processed output mode to get the console into raw mode.
I don't think that having line input behave like the standard with ACCEPT
describes has advantages except for CP/M compatibility.
I prefer a compatibility with Python, Guile etc.
Not playing tricks with standard i/o and accepting what the system gives
you, buys you behaviour compatible with other programs under windows,
which means that you can get commands back by arrow up and edit
them by arrow left, without any programming in the Forth.
Under linux you can run your program under rlwrap like so
rlwrap lina
and then you get the same editing functions plus history accross
sessions just like gforth has.
>Once you have a properly working KEY (which requires raw mode), you
>can build an ACCEPT on top of that.
>
>The alternative indicated in the text above is if you cannot get a
>raw-mode terminal. Then KEY and KEY? won't work properly, and ACCEPT
>will just process the complete line provided by the cooked-mode
>terminal.
An ACCEPT that is just a READ-FILE from standard input, allows
me to test all exceptions in ciforth using input redirection.
>
>- anton
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&
c.xs4all.nl &=n
http://home.hccnet.nl/a.w.m.van.der.horst