tapio / rlutil

C and C++ utilities for cross-platform console roguelike game creation.
http://tapio.github.com/rlutil/
229 stars 42 forks source link

Mac OS X clear screen #10

Closed Zorgatone closed 8 years ago

Zorgatone commented 8 years ago

In OS X I'm able to see all the example's screens (which should have been cleared) when I scroll my terminal upwards.

Can we portably reset the screen without keeping the old buffer?

Zorgatone commented 8 years ago

I haven't tasted on Linux, but my guess is that unix/POSIX terminal with that escape code will do the same effect

Zorgatone commented 8 years ago

About this I saw another project (based on NodeJS) which seems to clear the screen correctly. It works in tty raw mode, and actually resets the screen completely on OS X at least.

https://github.com/substack/node-charm/blob/master/index.js#L110

Maybe we could use the same excape

nabijaczleweli commented 8 years ago

resets the screen on iTerm, which appears to lack support for the reset character.

Is there a different terminal (emulator(?)) on OSX you could test this on, @Zorgatone?

Zorgatone commented 8 years ago

I have to get on my office machine. But yes I tested and I could see the previous screens.

I use both the Terminal.app default terminal and iTerm2. I'm not sure on which of them I saw this issue. Maybe it was the latter. I saw in the NodeJS project they are using one more escape character for iTerm only

https://www.iterm2.com/

Zorgatone commented 8 years ago

Also on Windows, I have issues if I try to clear the screen outside the standard CMD (ie. Git Bash and Cygwin, etc...). :/

(I've tried without winpty and it doesn't reset. With winpty it resets only the part after the last prompt)

nabijaczleweli commented 8 years ago

For non-cmd usage on Windows you need to define RLUTIL_USE_ANSI during compilation.

Zorgatone commented 8 years ago

@nabijaczleweli: oh thanks about that.

Anyway I think we could just print that extra ANSI escape character for iTerm support. It shouldn't be complicated at all...

nabijaczleweli commented 8 years ago

Yeah

Zorgatone commented 8 years ago

Isn't there any way to detect ANSI support on runtime and choose the correct function?

nabijaczleweli commented 8 years ago

I wouldn't think so, it's thoroughly transparent, AFAICT, and even if it wasn't, there would need to be a list of ANSI-characteristics for a fixed amount of pseudoterminals, which is, let's just say, inconvenient

Zorgatone commented 8 years ago

Uhm, ok

Zorgatone commented 8 years ago

I can confirm the terminal screen buffer doesn't reset either on iTerm or Terminal.app on OS X El Capitan.

If you scroll up you see all the previous states

Zorgatone commented 8 years ago

It does an equivalent of clear which is not the same of Windows' cls

nabijaczleweli commented 8 years ago

@Zorgatone Can you test https://github.com/nabijaczleweli/rlutil/commit/b3e4cd4dce289ad983769a8d5de28253c3432cb2?

Zorgatone commented 8 years ago

@nabijaczleweli Nothing works.. The example says press any key to start, prints the first map and exits... Leaving the screen a total mess :scream:

Zorgatone commented 8 years ago

On iTerm:

TR: ~/repos/rlutil tommaso$ ./example-c
Welcome! Use WASD to move.
Hit any key to start.
   #######
  ..o..o...
 ...........
#............
#..o..#....#..
#...o......#..#
#..#..........#
#.....@                                                                                   TR: ~/repos/rlutil tommaso$

On Terminal.app:

TR:rlutil tommaso$ ./example-c
Welcome! Use WASD to move.
Hit any key to start.
   #######     
  ..o..o...    
 ...........   
#............  
#..o..#....#.. 
#...o......#..#
#..#..........#
#.....@TR:rlutil tommaso$ wsdsadasd
#.o.#.o..#....#
#...<#......o.#
#..oo.#.o..#.. 
#........#oo#  
 .#.........   
  o.o..#..#    
   #######     
Coins: 0
Torch: 30
Moves: 0
Level: 1
nabijaczleweli commented 8 years ago

Does it work on current master (both work for me on WIndooze, Ubuntu 14 no X, Ubuntu 14 over SSH)?

nabijaczleweli commented 8 years ago

I'd just v0v at it, because ~Mac~, but...

Zorgatone commented 8 years ago

I'll be on a Mac again tomorrow morning

Zorgatone commented 8 years ago

Solved by #21 (at least on OS X).

Need to check on Linux