Search code examples
pythoncursespython-curses

How to merge two different borders in curses


Using curses for python, how can I seamlessly merge two borders? For example:

import curses

screen = curses.initscr()
curses.curs_set(0)
screen.border()
screen.refresh()

awindow =  curses.newwin(3, curses.COLS, 0, 0)
awindow.border()
awindow.refresh()

while True:
    curses.noecho()
    c = screen.getch(1, 1)
    if c == ord('q') or c == ord('Q'):
        break

curses.endwin()

this creates two windows, but in the two points where the borders meet there's a discontinuity. How can I remove that?

enter image description here


Solution

  • You can do this by overwriting those gaps with ACS_LTEE and ACS_RTEE characters. The python curses reference section For more information points you to the ncurses manual pages, saying

    If you’re in doubt about the detailed behavior of the curses functions, consult the manual pages for your curses implementation, whether it’s ncurses or a proprietary Unix vendor’s. The manual pages will document any quirks, and provide complete lists of all the functions, attributes, and ACS_* characters available to you.

    In this case, the information is in the addch manual page.