This is a small python program using curses:
import curses
import locale
def init_curses():
stdscr = curses.initscr()
curses.start_color()
curses.use_default_colors()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
curses.curs_set(0)
stdscr.encoding = 'utf-8'
locale.setlocale(locale.LC_ALL, '')
return stdscr
# Clean up and close the curses environment
def close_curses(stdscr):
stdscr.keypad(False)
curses.echo()
curses.nocbreak()
curses.endwin()
def main(stdscr):
stdscr.clear()
stdscr.addstr(1, 0, "Hello World!")
stdscr.addstr(2, 0, "あ")
stdscr.addstr(3, 0, "ああ")
stdscr.addstr(4, 0, "あああ")
stdscr.addstr(5, 0, "ああああ")
stdscr.addstr(6, 0, "あああああ")
stdscr.addstr(7, 0, "ああああああ")
stdscr.addstr(8, 0, "あああああああ")
stdscr.addstr(9, 0, "ああああああああ")
stdscr.addstr(10, 0, "あああああああああ")
stdscr.refresh()
stdscr.getkey()
if __name__ == "__main__":
stdscr = init_curses()
try:
curses.wrapper(main)
finally:
close_curses(stdscr)
The expected output should be this:
Hello World!
あ
ああ
あああ
ああああ
あああああ
ああああああ
あああああああ
ああああああああ
あああああああああ
Instead I get this:
It's driving me insane. I'd like to know how to get the expected output. I've also run into issues where the displaced lines have characters missing on their left side sometimes, leaving me with half eaten displaced sentences.
I'm using python 3.10.2, and the windows-curses library on the windows terminal with powershell 7, if that is of any value.