https://github.com/spyoungtech/pywinconsolebuffer
ctypes wrapper for a console buffer for multi-line text writing and re-writing.
https://github.com/spyoungtech/pywinconsolebuffer
Last synced: 12 months ago
JSON representation
ctypes wrapper for a console buffer for multi-line text writing and re-writing.
- Host: GitHub
- URL: https://github.com/spyoungtech/pywinconsolebuffer
- Owner: spyoungtech
- Created: 2020-04-11T07:57:29.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-11T08:15:57.000Z (about 6 years ago)
- Last Synced: 2025-03-04T00:44:42.975Z (over 1 year ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PyWinConsoleBuffer
ctypes wrapper for a console buffer for multi-line text writing and re-writing.
# Usage
The main usage is for moving the write cursor along the buffer to write and update text.
Example updating 3 lines of text:
```python
from console_buffer import ConsoleBuffer, get_console_handle
import random
import time
buffer = ConsoleBuffer(100, 3) # 3 line buffer with width of 100
handle = get_console_handle()
while True:
line_one = f'One: {random.random()}'
line_two = f'Two: {random.random()}'
line_three = f'Three: {random.random()}'
for index, line in enumerate([line_one, line_two, line_three]):
buffer.set_position(0, index)
buffer.write(line)
buffer.show(handle)
time.sleep(0.1)
```
## TODO
- [ ] Implement a writeline that takes care of trailing whitespace (ensuring previous text does not dangle at the tail)
- [ ] Get the properties of the console to determine the width/height of the console as potential default
- [ ] Allow the buffer to start somewhere other than origin (0, 0)
- [ ] Factor the console handle as a default in show method