Dear all,
My question is :how can I disable or delay the automatic CRTInit?
What I need to do is write a program that (according to situations) writes binary data to output or open an interface (requiring CRT)
The problem is that my binary data gets "filtered" somehow, and some bytes are replaced. I imagine this is because of ncurses, and reading the docs I found out that:
If you terminate the program before calling CRTInit or any routine that causes automatic initialization, curses will never be initialized, so e.g., the screen won't be cleared.
But in effects, even without using any CRT routine, just including the crt in the uses clause will initialize ncurses.
I have minimized this problem to a small program that uses the ANSI "reverse video" escape sequence Esc-[7m (I use an ansi sequence just because it's easily visible, the problem is the same with any other non-printable character).
unit beforecrt; interface
implementation
begin write(chr(27),'[7m','BEFORE'); readln; end.
program chr; uses beforecrt, crt;
begin write(chr(27),'[7m','AFTER'); end.
This is what happens: 1) without any clear screen, I see BEFORE in reverse 2) I press Enter 3) The screen is cleared, and "<[7m AFTER" is printed (in normal mode)
The unit beforecrt is initialized before crt, so it's output is correct. The output from the main program (that gets executed after the initialization of crt) is filtered.
Somehow, CRTInit is happening even if I do not use any routine of crt. How can I avoid this? Alternatively, how can I disable the ncurses at all? I have tried to use CRTSetTerminal('dumb', input, output); without any result.
thanks Francesco (using gps 20040516)
Francesco Bonomi wrote:
My question is :how can I disable or delay the automatic CRTInit?
What I need to do is write a program that (according to situations) writes binary data to output or open an interface (requiring CRT)
The problem is that my binary data gets "filtered" somehow, and some bytes are replaced. I imagine this is because of ncurses, and reading the docs I found out that:
If you terminate the program before calling CRTInit or any routine that causes automatic initialization, curses will never be initialized, so e.g., the screen won't be cleared.
But in effects, even without using any CRT routine, just including the crt in the uses clause will initialize ncurses.
Not exactly. But CRT redirects Input and Output to its I/O:
AssignCRT (Input); Reset (Input); AssignCRT (Output); Rewrite (Output)
So any attempt to read/write via Input/Output (including a plain `Write[Ln]' will cause CRT to initialize).
You can redirect them back if you want (e.g., conditionally):
Close (Input); Reset (Input, '-'); Close (Output); Rewrite (Output, '-');
(cf. the bottom of crt.pas.)
I have minimized this problem to a small program that uses the ANSI "reverse video" escape sequence Esc-[7m (I use an ansi sequence just because it's easily visible, the problem is the same with any other non-printable character).
Just to avoid a misunderstanding (if this is not just for testing): You're not supposed to pass ANSI sequences to CRT output. Instead, CRT will generated the sequences itself when you use its routines (cursor positioning, color, etc.) -- not only ANSI, but the correct ones depending on the current TERM setting, thanks to ncurses.
Sending escape sequences directly will cause the characters to be displayed as they are (with some graphic character standing for ESC, cf. crt.inc: const chArrowL = #27;).
Frank