Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS X clear screen #10

Closed
Zorgatone opened this issue Nov 12, 2015 · 20 comments
Closed

Mac OS X clear screen #10

Zorgatone opened this issue Nov 12, 2015 · 20 comments

Comments

@Zorgatone
Copy link
Contributor

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
Copy link
Contributor Author

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

@Zorgatone
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@Zorgatone
Copy link
Contributor Author

@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
Copy link
Contributor

Yeah

@Zorgatone
Copy link
Contributor Author

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

@nabijaczleweli
Copy link
Contributor

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
Copy link
Contributor Author

Uhm, ok

@Zorgatone
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@nabijaczleweli
Copy link
Contributor

@Zorgatone
Copy link
Contributor Author

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

@Zorgatone
Copy link
Contributor Author

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
Copy link
Contributor

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

@nabijaczleweli
Copy link
Contributor

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

@Zorgatone
Copy link
Contributor Author

I'll be on a Mac again tomorrow morning

@Zorgatone
Copy link
Contributor Author

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

Need to check on Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants