Hello All,
I'm having trouble after return from NCurses program in c to BBS.
After that the newlines in some cases are not correct. It just simply doesn't scroll by a page when there is multi-page document but writes
all the lines to the last line and overwrite what was there.
I tried to put some ANSI codes into the C to the end of it like RSI
Reset Initial State or Set New Line. But nothing helps. Could anyone please guide me what to use? (ESC Sequence)
I also terminate the program with endwin at the end of it.
I'm having trouble after return from NCurses program in c to BBS.
I have expereienced the same thing when calling curses-based apps as
doors from Mystic. I believe it is a terminal issue. I'm not sure there's a fix for it.
I added this line to my program:
int c=27;
printf ("%c[1;25r",esc); /* reset and refresh the screen
*/
Not to critique your code, but you've got a mismatch of your variables - 'c' and 'esc' - you'll need to use one or the other.
Also, you're using '%c' as your format string - this is a character. You should define 'c' as an unsigned char instead of an int.
But really, to help your compiler from writing inefficient code, you should just embed the escape character in your string, like this:
printf("\x1b[1;25r");
The '\x1b' is the escape character (1B hex is 27 decimal).
int c=27;
printf ("%c[1;25r",esc); /* reset and refresh the scre
Not to critique your code, but you've got a mismatch of your variables - 'c' and 'esc' - you'll need to use one or the other.
printf("\x1b[1;25r");
Well yes; he's using '%c' because he wants to print 'c' as a character, not as an integer.
The '\x1b' is the escape character (1B hex is 27 decimal).This is good advice.
Is there really any difference between writing the printf and variable
and using the \x1b notation. Except of course in prior You define one variable more. When I tried that I failed to comprehend the code when I read it again. But that's more or less just my inability to use proper code. I went with like 10 tries and I got lost in the Hexadecimal world.
I guess my problem is I come from an embedded programmer background - I tend to work towards the most efficient code, not necessarily the
easiest to read. That's why I suggested a char instead of an int - saves at least one byte of data. Also, creating a variable and asking printf
to parse your string and replace the %c with your variable will take
time to process at runtime, and will produce more bytes of code in your compiled binary. But there's nothing wrong with writing the code as I suggested, then putting in a comment explaining what it's doing :)
Is there really any difference between writing the printf and variable
and using the \x1b notation. Except of course in prior You define one variable more. When I tried that I failed to comprehend the code when I read it again. But that's more or less just my inability to use proper code. I went with like 10 tries and I got lost in the Hexadecimal world.
I guess my problem is I come from an embedded programmer background - I tend to work towards the most efficient code, not necessarily the
easiest to read. That's why I suggested a char instead of an int - saves at least one byte of data. Also, creating a variable and asking printf
to parse your string and replace the %c with your variable will take
time to process at runtime, and will produce more bytes of code in your compiled binary. But there's nothing wrong with writing the code as I suggested, then putting in a comment explaining what it's doing :)
and using the \x1b notation. Except of course in prior You define oneI suppose the answer is, "it depends on what you mean by 'difference'." antiquated octal syntax: "\033[...").
.. Correct me if I'm wrong but the \x1b syntax doesn't work on Windows.
Is that right? Well... I mean in the Windows console none of the above works. Is it like so?
It could be that the default Windows command terminal doesn't understand ANSI terminal escape sequences, but I'm afraid I just don't know: I don't use Windows. But something like SyncTERM should do ok for you.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (3 / 13) |
Uptime: | 50:14:10 |
Calls: | 6,649 |
Calls today: | 1 |
Files: | 12,200 |
Messages: | 5,330,205 |