Example #1
0
    def load(self, *args):
        """Setup curses."""
        # Log the terminal type
        termname = curses.termname().decode("utf-8")
        self.logger.debug("Loading UI for terminal: {0}".format(termname))

        self.screen = curses.initscr()
        self.setup_colors()

        # curses.cbreak()
        # TODO: Raw mode seems to work ok. Should probably
        # switch to it from cbreak to get Ctrl+Z to work etc.
        curses.raw()

        curses.noecho()
        try:
            # Might fail on vt100 terminal emulators
            curses.curs_set(0)
        except:
            self.logger.warning("curses.curs_set(0) failed!")

        self.screen.keypad(1)

        self.current_yx = self.screen.getmaxyx()  # For checking resize
        self.setup_mouse()
        self.setup_windows()
Example #2
0
    def __enter__(self):
        curses.initscr()

        if not curses.termname().startswith(b'xterm'):
            raise Exception(f"This backend only supports xterm as terminal emulator. Got: '{curses.termname()}'.")

        curses.cbreak()
Example #3
0
    def load(self, *args):
        """Setup curses."""
        # Log the terminal type
        termname = curses.termname().decode("utf-8")
        self.logger.debug("Loading UI for terminal: {0}".format(termname))

        self.screen = curses.initscr()
        self.setup_colors()

        # curses.cbreak()
        # TODO: Raw mode seems to work ok. Should probably
        # switch to it from cbreak to get Ctrl+Z to work etc.
        curses.raw()

        curses.noecho()
        try:
            # Might fail on vt100 terminal emulators
            curses.curs_set(0)
        except:
            self.logger.warning("curses.curs_set(0) failed!")

        self.screen.keypad(1)

        self.current_yx = self.screen.getmaxyx()  # For checking resize
        self.setup_mouse()
        self.setup_windows()
Example #4
0
    def load(self, *args):
        """Setup curses."""
        # Log the terminal type
        termname = curses.termname().decode("utf-8")
        self.logger.debug("Loading UI for terminal: {0}".format(termname))

        self.screen = curses.initscr()
        self.setup_colors()

        curses.raw()
        curses.noecho()

        try:
            # Hide the default cursor
            # Might fail on vt100 terminal emulators
            curses.curs_set(0)
        except:
            self.logger.warning("curses.curs_set(0) failed!")

        if "get_wch" not in dir(self.screen):
            self.logger.warning(
                "Using old curses! Some keys and special characters might not work."
            )

        self.screen.keypad(1)

        self.current_yx = self.screen.getmaxyx()  # For checking resize
        self.setup_mouse()
        self.setup_windows()
Example #5
0
def main(scrn):
    box = scrn.subwin(3,5, 0,0)
    box.box()
    box.addstr(1,1, "box")
    
    border = scrn.subwin(3,8, 0,6)
    border.border()
    border.addstr(1,1, "border")
    
    background = scrn.subwin(3,14, 0,15)
    curses.init_pair(7, curses.COLOR_RED, curses.COLOR_GREEN)
    curses.init_pair(8, curses.COLOR_BLUE, curses.COLOR_WHITE)
    background.bkgd("#", curses.color_pair(7))
    background.addstr(1,2, "background", curses.color_pair(8))
    background.refresh
    
    background2 = scrn.subwin(4,14, 0,30)
    background2.bkgdset("#")
    background2.addstr("              ")
    background2.addstr("  background  ")
    background2.addstr("              ")
    
    
    lines = scrn.subwin(3,11, 0,45)
    lines.hline(1,0, curses.ACS_HLINE, 11)
    lines.vline(0,2, curses.ACS_VLINE, 3)
    lines.vline(0,8, curses.ACS_VLINE, 3)
    lines.addstr(0,3, "lines")
    lines.addch(1,2, curses.ACS_SSSS)
    lines.addch(1,8, curses.ACS_SSSS)
    
    text = scrn.subwin(10,9, 4,0)
    text.addstr(0,0, "dim", curses.A_DIM)
    text.addstr(1,0, "normal", curses.A_NORMAL)
    text.addstr(2,0, "underline", curses.A_UNDERLINE)
    text.addstr(3,0, "bold", curses.A_BOLD)
    text.addstr(4,0, "standout", curses.A_STANDOUT)
    text.addstr(5,0, "reverse", curses.A_REVERSE)
    text.addstr(6,0, "blink", curses.A_BLINK)
    text.addstr(7,0, "invisible", curses.A_INVIS)
    
    curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
    text.move(8,0)
    text.addch("c", curses.color_pair(1) | curses.A_BOLD)
    text.addch("o", curses.color_pair(2) | curses.A_BOLD)
    text.addch("l", curses.color_pair(3) | curses.A_BOLD)
    text.addch("o", curses.color_pair(2) | curses.A_BOLD)
    text.addch("r", curses.color_pair(1) | curses.A_BOLD)
    
    scrn.addstr(15,0, curses.termname())
    scrn.addstr(": " + curses.longname())
    
    scrn.getch()
    curses.flash()
    scrn.getch()
Example #6
0
 def __init__(self):
     self.window = curses.initscr()
     self.name = curses.termname()
     curses.noecho()
     self.window.keypad(True)
     self.window.scrollok(True)
     self.last_cursor_pos = (0, 0)
     self.write_win_file = True
     self.windowlog = 'windowlog'
     (self.height, self.width) = self.window.getmaxyx()
     self.resize = False
Example #7
0
def colortest(stdscr):
    # http://stackoverflow.com/questions/18551558/how-to-use-terminal-color-palette-with-curses
    curses.start_color()
    curses.use_default_colors()
    stdscr.addstr(
        0, 0,
        "%s colors on %s.\n" % (str(curses.COLORS), str(curses.termname())))
    for i in range(0, curses.COLORS):
        curses.init_pair(i + 1, i, -1)
    for i in range(curses.COLORS):
        try:
            stdscr.addstr(str(i) + "\t", curses.color_pair(i))
        except:
            pass
    stdscr.getch()
Example #8
0
    def __init__(self, scr):
        self.scr = scr
        if config.passphrase:
            words = config.passphrase.split()
        else:
            words = id_generator.randomwords()

        self.ttyId = id_generator.id_hash(words)
        self.url = feed_url(self.ttyId)

        self.info = m.Info()
        self.info.passphrase = ' '.join(words)
        self.info.termname = str(curses.termname(), 'utf-8')
        self.info.baudrate = curses.baudrate()
        self.info.lines, self.info.cols = scr.getmaxyx()
Example #9
0
    def load(self):
        """Load an setup curses."""
        # Log the terminal type
        self.app.log("Loading UI for terminal: " + curses.termname().decode("utf-8"), LOG_INFO)

        self.screen = curses.initscr()
        self.setup_colors()

        curses.cbreak()
        curses.noecho()
        curses.curs_set(0)

        self.screen.keypad(1)

        self.current_yx = self.screen.getmaxyx() # For checking resize
        self.setup_mouse()
        self.setup_windows()
Example #10
0
    def load(self):
        """Load an setup curses."""
        # Log the terminal type
        self.app.log(
            "Loading UI for terminal: " + curses.termname().decode("utf-8"),
            LOG_INFO)

        self.screen = curses.initscr()
        self.setup_colors()

        curses.cbreak()
        curses.noecho()
        curses.curs_set(0)

        self.screen.keypad(1)

        self.current_yx = self.screen.getmaxyx()  # For checking resize
        self.setup_mouse()
        self.setup_windows()
Example #11
0
File: ui.py Project: Jimx-/suplemon
    def load(self, *args):
        """Setup curses."""
        # Log the terminal type
        self.app.log("Loading UI for terminal: " + curses.termname().decode("utf-8"), LOG_INFO)

        self.screen = curses.initscr()
        self.setup_colors()

        curses.cbreak()
        curses.noecho()
        try:
            # Might fail on vt100 terminal emulators
            curses.curs_set(0)
        except:
            self.app.log("curses.curs_set(0) failed!", LOG_WARNING)

        self.screen.keypad(1)

        self.current_yx = self.screen.getmaxyx()  # For checking resize
        self.setup_mouse()
        self.setup_windows()
Example #12
0
    def load(self, *args):
        """Setup curses."""
        # Log the terminal type
        termname = curses.termname().decode("utf-8")
        self.logger.debug("Loading UI for terminal: {0}".format(termname))

        self.screen = curses.initscr()
        self.setup_colors()

        curses.raw()
        curses.noecho()

        try:
            # Hide the default cursor
            # Might fail on vt100 terminal emulators
            curses.curs_set(0)
        except:
            self.logger.warning("curses.curs_set(0) failed!")

        self.screen.keypad(1)

        self.current_yx = self.screen.getmaxyx()  # For checking resize
        self.setup_mouse()
        self.setup_windows()
from config import console
import time

import curses

screen = curses.initscr()
console.init()

print(curses.termname())

left = curses.newwin(10, 10, 0, 0)
right = curses.newwin(10, 10, 0, 10)
left.border()
right.box()

#left.addstr(' '*99, curses.A_REVERSE)
#right.addstr('.'*99, curses.COLOR_RED)

left.refresh()
right.refresh()

console.screen.refresh()

time.sleep(1)

console.close()
'''
console.init()

print(console.get_size())
for i in range(5):
Example #14
0
 def stop(self):
     curses.echo()
     curses.nocbreak()
     self.stdscr.keypad(0)
     curses.endwin()
     curses.termname()
Example #15
0
                self.n()

        self.render()

if __name__ == '__main__':
    logger.debug('V2EX terminal startup.')
    logger.debug("set terminal title: `%s'" % settings['title'])
    sys.stdout.write('\x1b]0;%s\x07' % settings['title'])
    sys.stdout.flush()
    logger.debug(settings)
    try:
        sc = curses.initscr()
        curses.noecho()
        curses.cbreak()
        sc.keypad(1)
        logger.info("terminal: `%s'", curses.termname())

        # init colors
        if 'xterm-256color' in curses.termname():
            black = 16
            logger.debug('xterm-256color background.')
        else:
            black = curses.COLOR_BLACK
        curses.start_color()
        curses.init_pair(1, curses.COLOR_RED, black)
        curses.init_pair(2, curses.COLOR_GREEN, black)
        curses.init_pair(3, curses.COLOR_YELLOW, black)
        curses.init_pair(4, curses.COLOR_BLUE, black)
        curses.init_pair(5, curses.COLOR_MAGENTA, black)
        curses.init_pair(6, curses.COLOR_CYAN, black)
        curses.init_pair(7, curses.COLOR_WHITE, black)
Example #16
0
import curses,sys,termios,tty

stdscr = curses.initscr()
curses.start_color()
begin_x = 20
begin_y = 7
height = 3
width = 40
win = curses.newwin(height, width, begin_y, begin_x)
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
stdscr.box(0,0)
if curses.has_colors():
	termname = curses.termname()
	stdscr.addstr('%s Color available\n'%termname)
while 1:
	c = stdscr.getch()
	if c == ord('p'):
		try:
			stdscr.addstr(23,1,'Current mode: Typing mode',curses.color_pair(1))
		except:
			sys.stderr.write('error occured\n')
			break
	elif c == ord('c'):
		stdscr.clear()
	elif c == ord('q'):
		break  # Exit the while()
	elif c == curses.KEY_HOME: x = y = 0