tartley / colorama

Simple cross-platform colored terminal text in Python
BSD 3-Clause "New" or "Revised" License
3.56k stars 254 forks source link

a way to disable scrolling with the current text buffer #33

Open tartley opened 9 years ago

tartley commented 9 years ago

(Feature request(s) submitted in an email, details below.)

Hello. I am writing a data analysis app for a local university and jazzed it up a bit with your fine module. Thanks! I thought I'd send a list, and outline a feature suggestion or two.

http://youtu.be/oKabJY-IAJI

two feature requests: 1) way to disable scrolling with the current text buffer. I'm pretty sure there's functions for this in the windows api but I couldnt' get it sorted out and eventually gave up. But if you had an easy way to implement that in your module, I'd use it.

Similar to 1 - Way to resize the textbuffer so it's the same size as the window and (maybe?) remove the scroll bar from python console apps.

2 isn't really a request but here's the deal, I wanted to make that bottom bar blue, and what i found was any write to the bottom right most character cell resulted in scrolling. So instead I blank the screen (with the ansi clear command) with the background set to the color I want the bottom bar to be, then I set the real page bg color and draw everywhere else, leaving only blue bar at bottom. It works but it feels clunky, so I thought if I explained the process to you maybe you had a better suggestion or you could factor that into your development somehow.

Have you thought about rolling mouse support in there too? Feels like a totally different module but it's another one I'd use a lot. I have hacked together some basic 'get the current font metrics, current window position, mouse screen position, and window client position of the mouse screen position, scaled by the font metric' sorted out... So it outputs 'mx,my = [0-80],[0-maxy]'. If this would help you let me know and I'll throw it on codepad, I'm sure you could rewrite it a lot better than my quick and dirty hack job.

btw I wrote http://store.raspberrypi.org/projects/scamp - It's an all-ascii UI to the RPI media player (using python/curses). I've had a lot of requests to port it to windows/other linux, which I don't understand since VLC is so nice but whatever, I'm thinking about doing it and if I do I'm going to use colorama for the windows side.

Thanks again for all your hard work, have a nice day and if you ever need another beta tester or just someone to hash out some 'ansi issues' with, email me any time

Matt Kimball greyworld at host gmail with tld com.

wiggin15 commented 9 years ago

Regarding the first feature request, I don't think colorama should implement this. There is no ANSI escape sequence to do either of the requests (disable scrolling or adjust the buffer size to the window size). It's also something that is specific to the terminal being used, so I can't see how we can create a cross-platform implementation of this.

Regarding the second issue - it is indeed a problem. This code:

print colorama.ansi.Cursor.POS(1,25) + colorama.ansi.Back.BLUE + ' ' * 80  +colorama.ansi.Cursor.POS(1,1)

(assuming the terminal window's size is 25x80) will cause a line scroll that is not wanted.

tartley commented 9 years ago

1st issue: Seems reasonable. I think there is genuine utility in a module to assist with scrolling / buffer window sizes, but I don't think Colorama (converting UNIXy ANSI codes into something that works on Windows) is the right place for it.