def curses_status( ca, args ): ca.stdscr.addstr( "Baudrate : %s\n" % curses.baudrate() ) ca.stdscr.addstr( "Has color : %s\n" % curses.has_colors() ) ca.stdscr.addstr( "Change color : %s\n" % curses.can_change_color() ) ca.stdscr.addstr( "Insert char : %s\n" % curses.has_ic() ) ca.stdscr.addstr( "Insert line : %s\n" % curses.has_il() ) ca.stdscr.addstr( "Color numbers : 0-%s\n" % curses.COLORS ) ca.stdscr.addstr( "COLOR_WHITE : %s\n" % (curses.color_content(curses.COLOR_WHITE),) ) ca.stdscr.addstr( "COLOR_BLACK : %s\n" % (curses.color_content(curses.COLOR_BLACK),) ) ca.stdscr.addstr( "COLOR_RED : %s\n" % (curses.color_content(curses.COLOR_RED),) ) ca.stdscr.addstr( "COLOR_GREEN : %s\n" % (curses.color_content(curses.COLOR_GREEN),) ) ca.stdscr.addstr( "COLOR_BLUE : %s\n" % (curses.color_content(curses.COLOR_BLUE),) ) ca.stdscr.addstr( "COLOR_YELLOW : %s\n" % (curses.color_content(curses.COLOR_YELLOW),) ) ca.stdscr.addstr( "COLOR_MAGENTA : %s\n" % (curses.color_content(curses.COLOR_MAGENTA),)) ca.stdscr.addstr( "COLOR_CYAN : %s\n" % (curses.color_content(curses.COLOR_CYAN),) ) ca.stdscr.addstr( "Erase char : %s\n" % (curses.erasechar(),) ) ls = list( filter( lambda x: curses.has_key(x), range(255) )) ca.stdscr.addstr( "Unknown keys : %s\n" % ls )
def debugDraw(self, win): """Draw real-time debug information to the screen.""" if not self.debugWindow: return textBuffer = win.textBuffer y, x = win.top, win.left maxRow, maxCol = win.rows, win.cols self.debugWindow.writeLineRow = 0 intent = "noIntent" try: intent = win.userIntent except: pass color = app.color.get('debug_window') self.debugWindow.writeLine( " cRow %3d cCol %2d goalCol %2d %s" % (win.textBuffer.penRow, win.textBuffer.penCol, win.textBuffer.goalCol, intent), color) self.debugWindow.writeLine( " pRow %3d pCol %2d chRow %4d" % (textBuffer.penRow, textBuffer.penCol, textBuffer.debugUpperChangedRow), color) self.debugWindow.writeLine( " mkrRow %3d mkrCol %2d sm %d" % (textBuffer.markerRow, textBuffer.markerCol, textBuffer.selectionMode), color) self.debugWindow.writeLine( "scrlRow %3d scrlCol %2d lines %3d" % (win.scrollRow, win.scrollCol, len(textBuffer.lines)), color) self.debugWindow.writeLine( "y %2d x %2d maxRow %d maxCol %d baud %d color %d" % (y, x, maxRow, maxCol, curses.baudrate(), curses.can_change_color()), color) screenRows, screenCols = self.cursesScreen.getmaxyx() self.debugWindow.writeLine( "scr rows %d cols %d mlt %f/%f pt %f" % (screenRows, screenCols, self.mainLoopTime, self.mainLoopTimePeak, textBuffer.parserTime), color) self.debugWindow.writeLine( "ch %3s %s" % (self.ch, app.curses_util.cursesKeyName(self.ch) or 'UNKNOWN'), color) self.debugWindow.writeLine("win %r" % (win, ), color) self.debugWindow.writeLine("win %r" % (self.focusedWindow, ), color) self.debugWindow.writeLine("tb %r" % (textBuffer, ), color) (id, mouseCol, mouseRow, mouseZ, bState) = self.debugMouseEvent self.debugWindow.writeLine( "mouse id %d, mouseCol %d, mouseRow %d, mouseZ %d" % (id, mouseCol, mouseRow, mouseZ), color) self.debugWindow.writeLine( "bState %s %d" % (app.curses_util.mouseButtonName(bState), bState), color) self.debugWindow.writeLine( "startAndEnd %r" % (textBuffer.startAndEnd(), ), color)
def debug_draw(self, program, win): """Draw real-time debug information to the screen.""" textBuffer = win.textBuffer self.writeLineRow = 0 intent = u"noIntent" if hasattr(win, u"userIntent"): intent = win.userIntent color = program.color.get(u'debug_window') self.write_line( u" cRow %3d cCol %2d goalCol %2d %s" % (win.textBuffer.penRow, win.textBuffer.penCol, win.textBuffer.goalCol, intent), color) self.write_line( u" pRow %3d pCol %2d chRow %4d" % (textBuffer.penRow, textBuffer.penCol, textBuffer.debugUpperChangedRow), color) self.write_line( u" mkrRow %3d mkrCol %2d sm %d" % (textBuffer.markerRow, textBuffer.markerCol, textBuffer.selectionMode), color) self.write_line( u"scrlRow %3d scrlCol %2d lines %3d" % (win.scrollRow, win.scrollCol, textBuffer.parser.row_count()), color) y, x = win.top, win.left maxRow, maxCol = win.rows, win.cols self.write_line( u"y %2d x %2d maxRow %d maxCol %d baud %d color %d" % (y, x, maxRow, maxCol, curses.baudrate(), curses.can_change_color()), color) screenRows, screenCols = program.cursesScreen.getmaxyx() self.write_line( u"scr rows %d cols %d mlt %f/%f pt %f" % (screenRows, screenCols, program.mainLoopTime, program.mainLoopTimePeak, textBuffer.parserTime), color) self.write_line( u"ch %3s %s" % (program.ch, app.curses_util.curses_key_name(program.ch) or u'UNKNOWN'), color) self.write_line(u"win %r" % (win, ), color) self.write_line(u"foc %r" % (program.programWindow.focusedWindow, ), color) self.write_line(u"tb %r" % (textBuffer, ), color) (id, mouseCol, mouseRow, mouseZ, bState) = program.debugMouseEvent self.write_line( u"mouse id %d, mouseCol %d, mouseRow %d, mouseZ %d" % (id, mouseCol, mouseRow, mouseZ), color) self.write_line( u"bState %s %d" % (app.curses_util.mouse_button_name(bState), bState), color) self.write_line(u"start_and_end %r" % (textBuffer.start_and_end(), ), color)
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()
def __init__(self): # Curses initialization self.stdscr = initscr() #self.stdscr.notimeout(0) # Colors curses.resize_term(HEIGHT, WIDTH) curses.start_color() self.br = str(curses.baudrate()) noecho() cbreak() self.stdscr.keypad(0) # Changed to 0 self.stdscr.nodelay(1) curs_set(0) self.stdscr.clear() self.stdscr.border(0) # stdscr functions made accessible through the Screen object self.addstr = self.stdscr.addstr self.getch = self.stdscr.getch self.flushinp = curses.flushinp self.refresh = self.stdscr.refresh # Colours self.init_pair = curses.init_pair self.color_pair = curses.color_pair self.COLOR_GREEN = curses.COLOR_GREEN self.COLOR_BLACK = curses.COLOR_BLACK # Effects self.A_BLINK = curses.A_BLINK self.A_UNDERLINE = curses.A_UNDERLINE # List of all words to be drawn # words: [[word, x, y, speed], ...] self.words = [] # Buffer of current pressed keys self.keys = [] # Score self.score = 0 # Life self.life = 3 # Game Over self.game_over = False
def debugDraw(self, win): """Draw real-time debug information to the screen.""" if not self.debugWindow: return textBuffer = win.textBuffer y, x = win.top, win.left maxRow, maxCol = win.rows, win.cols self.debugWindow.writeLineRow = 0 intent = "noIntent" try: intent = win.userIntent except: pass color = app.color.get('debug_window') self.debugWindow.writeLine( " cRow %3d cCol %2d goalCol %2d %s" % (win.textBuffer.penRow, win.textBuffer.penCol, win.textBuffer.goalCol, intent), color) self.debugWindow.writeLine( " pRow %3d pCol %2d chRow %4d" % (textBuffer.penRow, textBuffer.penCol, textBuffer.sentUpperChangedRow), color) self.debugWindow.writeLine( " mkrRow %3d mkrCol %2d sm %d" % (textBuffer.markerRow, textBuffer.markerCol, textBuffer.selectionMode), color) self.debugWindow.writeLine( "scrlRow %3d scrlCol %2d lines %3d" % (win.scrollRow, win.scrollCol, len(textBuffer.lines)), color) self.debugWindow.writeLine( "y %2d x %2d maxRow %d maxCol %d baud %d color %d" % (y, x, maxRow, maxCol, curses.baudrate(), curses.can_change_color()), color) screenRows, screenCols = self.cursesScreen.getmaxyx() self.debugWindow.writeLine( "scr rows %d cols %d mlt %f/%f pt %f" % (screenRows, screenCols, self.mainLoopTime, self.mainLoopTimePeak, textBuffer.parserTime), color) self.debugWindow.writeLine( "ch %3s %s" % (self.ch, app.curses_util.cursesKeyName(self.ch) or 'UNKNOWN'), color) self.debugWindow.writeLine("win %r" % (win, ), color) self.debugWindow.writeLine("win %r" % (self.focusedWindow, ), color) self.debugWindow.writeLine("tb %r" % (textBuffer, ), color) (id, mouseCol, mouseRow, mouseZ, bState) = self.debugMouseEvent self.debugWindow.writeLine( "mouse id %d, mouseCol %d, mouseRow %d, mouseZ %d" % (id, mouseCol, mouseRow, mouseZ), color) self.debugWindow.writeLine( "bState %s %d" % (app.curses_util.mouseButtonName(bState), bState), color) # Display some of the redo chain. redoColorA = app.color.get(100) self.debugWindow.writeLine( "redoIndex %3d savedAt %3d depth %3d" % (textBuffer.redoIndex, textBuffer.savedAtRedoIndex, len(textBuffer.redoChain)), redoColorA) lenChain = textBuffer.redoIndex redoColorB = app.color.get(101) for i in range(textBuffer.redoIndex - 5, textBuffer.redoIndex): text = i >= 0 and textBuffer.redoChain[i] or '' self.debugWindow.writeLine(text, redoColorB) redoColorC = app.color.get(1) for i in range(textBuffer.redoIndex, textBuffer.redoIndex + 4): text = (i < len(textBuffer.redoChain) and textBuffer.redoChain[i] or '') self.debugWindow.writeLine(text, redoColorC)
-if we want to use speech, can use pyttsx -only update individual lines when required instead of updating all lines -add in a line manager to manage bookmarked lines (use threading) -show time to leave in addition to minutes until you need to leave -calculate arrival time at a specific destination -link to bart arrival times ''' ######## IMPORTS ####### from BeautifulSoup import BeautifulStoneSoup import urllib, time, curses from config import * ##### SETUP WINDOW ##### stdscr = curses.initscr() baudrate = curses.baudrate() begin_x = 0 ; begin_y = 0 height = 3 ; width = COLUMNS headscr = curses.newwin(height, width, begin_y, begin_x) begin_x = 0 ; begin_y = 3 height = ROWS - 5 ; width = COLUMNS mainscr = curses.newwin(height, width, begin_y, begin_x) begin_x = 0 ; begin_y = ROWS - 1 height = 2 ; width = COLUMNS footscr = curses.newwin(height, width, begin_y, begin_x) curses.start_color() curses.init_pair(1, LINE_TITLE_TEXT_COLOR, LINE_TITLE_HIGHLIGHT_COLOR)
import curses print "Imported" w1 = curses.initscr() print "initscr" print "Type:", type(w1) print curses.longname() print "Baudrate:", curses.baudrate() print "Has colors:", curses.has_colors() curses.curs_set(1) w2 = curses.newwin(0, 0) print "New window (fullscreen)" w2.addch(ord('A')) w2.addch('B') w2.addstr("some text") print "some text" w2.addstr(" more text") print "more text" w2.addstr(" even more text") print "even more text"
# https://docs.python.org/3.6/library/curses.html import curses stdscr = curses.initscr() # Clear and refresh the screen for a blank canvas stdscr.clear() stdscr.refresh() curses.flash() curses.delay_output(250) curses.flash() curses.delay_output(250) print('curses.baudrates() =', curses.baudrate()) print('curses.can_change_color() ?', curses.can_change_color()) print('curses.has_color() ?', curses.has_colors()) if curses.can_change_color() and curses.has_colors(): curses.start_color() curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE) # print('2 Flashes happened') stdscr.attron(curses.color_pair(1)) stdscr.addstr(10, 20, '2 Flashes happened') stdscr.attroff(curses.color_pair(1)) # Refresh the screen stdscr.refresh() print() print() print('curses.color_content(1) =', curses.color_content(1))
import curses, sys try: try: curses.initscr() print 1 print curses.version curses.longname() print curses.baudrate() print curses.can_change_color() curses.start_color() print curses.color_pair(curses.A_BLINK) finally: curses.endwin() except: print sys.exc_info()[1]
import curses print "Imported" w1 = curses.initscr() print "initscr" print "Type:", type(w1) print curses.longname() print "Baudrate:", curses.baudrate() print "Has colors:", curses.has_colors() curses.curs_set(1) w2=curses.newwin(0,0) print "New window (fullscreen)" w2.addch(ord('A')) w2.addch('B') w2.addstr("some text") print "some text" w2.addstr(" more text") print "more text" w2.addstr(" even more text") print "even more text" w2.addstr(" even more text")