import curses
import time

def main(stdscr):
    # Turn off cursor
    curses.curs_set(0)                     # non-blocking input
    stdscr.nodelay(True)                  
    stdscr.timeout(50)                     # refresh every 50 ms
    # Initialize colors
    curses.start_color()
    curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_RED)  # White text on blue background

    text = " HW in making DemoScene "
    width = curses.COLS
    pos = width//2

    while True:
        stdscr.clear()


        # Draw scrolling text
        if 0 <= pos < width:
            stdscr.attron(curses.color_pair(1))
            stdscr.addstr(curses.LINES // 2, pos, text)
            stdscr.attroff(curses.color_pair(1))
        # Update position
        pos -= 1
        if pos < -len(text):
            pos = width

        stdscr.refresh()
        time.sleep(0.05)

        # Exit if user presses 'q'
        key = stdscr.getch()
        if key == ord('q'):
            break

curses.wrapper(main)
