Ejemplo n.º 1
0
    def __init__(self, fileName):
        """
        """
        self.logger         = logging.getLogger('FrontEnd')
        self.cursor         = Cursor.Cursor(fileName)

        self.stdscr = curses.initscr()
        curses.def_shell_mode()
        self.fileName    = './tmp/'+fileName

        curses.noecho()

        screenHeight, screenWidth = self.stdscr.getmaxyx()

        self.statusWin  = curses.newwin( 1,screenWidth, screenHeight-1,0)
        self.leftBorder = curses.newwin( screenHeight-0,4, 0,0)
        self.contentWin = curses.newwin( screenHeight, screenWidth-3, 0,4)

        self.height, self.width = self.contentWin.getmaxyx()
        bY,bX                   = self.contentWin.getbegyx()
        self.cursorWindow       = CursorWindow.CursorWindow(0,0,self.width-1,self.height-1, 0)

        self.stdscr.clear()
        self.stdscr.keypad(True)

        if curses.can_change_color():
            # init_color(n, r, g, b)
            # n=0 is background
            curses.start_color()
            curses.init_color(0, 255, 255, 255)

        self.fh         = open(self.fileName, 'rb')
        self.RedrawBuffer()

        self.stdscr.move(0,4)
Ejemplo n.º 2
0
def mywrapper(func, *args, **kwds):
	"""This is a modified copy of the curses.wrapper() function
  Wrapper function that initializes curses and calls another function,
	restoring normal keyboard/screen behavior on error.
	The callable object 'func' is then passed the main window 'stdscr'
	as its first argument, followed by any other arguments passed to
	wrapper().
	"""

	res = None
	try:
		# Initialize curses
		stdscr=curses.initscr()
		curses.def_shell_mode()
		curses.noecho()
		curses.cbreak()
		stdscr.keypad(1)

		try:
			curses.start_color()
		except:
			pass

		return func(stdscr, *args, **kwds)
	finally:
		# Set everything back to normal
		stdscr.keypad(0)
		curses.echo()
		curses.nocbreak()
		# I added the def_shell_mode and restore:
		curses.reset_shell_mode()
		curses.endwin()
Ejemplo n.º 3
0
 def __init__(self):
     self._rows = OrderedDict()
     self._screen = curses.initscr()
     curses.def_shell_mode()
     curses.start_color()
     curses.use_default_colors()
     curses.init_pair(1, curses.COLOR_GREEN, -1)
     curses.init_pair(2, curses.COLOR_RED, -1)
     curses.cbreak()
     curses.noecho()
Ejemplo n.º 4
0
	def __init__(self):
		# start curses
		stdscr = curses.initscr()
		curses.def_shell_mode()
		# Keine Anzeige gedrückter Tasten
		curses.noecho()
		# Kein line-buffer
		curses.cbreak()
		# Escape-Sequenzen aktivieren
		stdscr.keypad(1)
		self.channelDict()
		self.playRadio(stdscr)
    def curses_init(self):         
        self.stdscr = curses.initscr()
        curses.def_shell_mode()
        curses.noecho()
        curses.cbreak()
        curses.curs_set(0)

        self.stdscr.keypad(1)
        self.world_pad = curses.newpad(self.world.height+1, self.world.width)
        self.stats_pad = curses.newpad(self.stats_height+1, self.stats_width)

        self.stdscr.refresh()    
Ejemplo n.º 6
0
 def __init__(self):
     # start curses
     stdscr = curses.initscr()
     curses.def_shell_mode()
     # Keine Anzeige gedrückter Tasten
     curses.noecho()
     # Kein line-buffer
     curses.cbreak()
     # Escape-Sequenzen aktivieren
     stdscr.keypad(1)
     self.channelDict()
     self.playRadio(stdscr)
Ejemplo n.º 7
0
def init():
    screen=curses.initscr()
    curses.start_color()
    curses.cbreak()
    curses.meta(1)
    curses.noecho()
    curses.nonl()
    curses.def_prog_mode()
    curses.endwin()
    curses.def_shell_mode()
    curses.reset_prog_mode()
    return Screen(screen)
Ejemplo n.º 8
0
def init():
    screen = curses.initscr()
    curses.start_color()
    curses.cbreak()
    curses.meta(1)
    curses.noecho()
    curses.nonl()
    curses.def_prog_mode()
    curses.endwin()
    curses.def_shell_mode()
    curses.reset_prog_mode()
    return Screen(screen)
Ejemplo n.º 9
0
def run_curses(window, buff):
	#curses.curs_set(2)#highly visible cursor
	curses.def_shell_mode()
	if curses.has_colors():
		curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_YELLOW)
		curses.init_pair(2, curses.COLOR_CYAN, 0)
		curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_MAGENTA)
		curses.init_pair(4, curses.COLOR_MAGENTA, 0)
		curses.init_pair(5, curses.COLOR_RED, 0)
		curses.init_pair(6, curses.COLOR_YELLOW, 0)
		curses.init_pair(7, curses.COLOR_WHITE, 0)
	w = MainWindow(window, buff) # returns a window object
	w.key_loop()
	return(0)
Ejemplo n.º 10
0
def setup_console():
    # Curses wipes scrollback on exit and that's lame. I'm probably already wiping scrollback on start...
    # but that's not entirely my fault
    tcattr = termios.tcgetattr(sys.stdout.fileno())

    stdscr = curses.initscr()
    curses.def_shell_mode()  # Can I do this before init? (LOL NO CURSES MAD)

    curses.start_color()  # Turning on color mode SETS the text color to some weird grey. Why? WHO KNOWS.
    curses.use_default_colors()
    if curses.COLORS != 256:
        raise RuntimeError('256-color mode not detected')

    # WHY DO I HAVE TO MAKE THE COLORS
    for i in range(curses.COLORS):
        curses.init_pair(i + 1, i, -1)

    # Color pair for color number x is 256*x
    # They can be redefined.
    # Do i just need to init all of them
    curses.init_pair(100, 100, 0)

    curses.noecho()
    curses.curs_set(0)

    curses.cbreak()  # TBH idk if this is helpful. I WON'T receive ^C
    stdscr.keypad(True)

    curses.def_prog_mode()  # I MEAN I GUESS

    # Moved to game logic because UGH, maybe I'll just use the wrapper
    # Wrapper sucks because endwin() resets terminal content
    # Atexit is after stacktrace printing
    # Making my OWN wrapper >:C
    # atexit.register(teardown_console, stdscr)

    return stdscr, tcattr
Ejemplo n.º 11
0
def emailLister(MainSession, msgNOs, stdscr):
    curses.def_shell_mode(); curses.reset_prog_mode()    # Back to curses
    curses.curs_set(0); stdscr.clear(); stdscr.refresh() # Init curses
    maxY, maxX = stdscr.getmaxyx(); stdscr.clear(); stdscr.box()
    stdscr.addstr(0, max(0, (maxX - len(JIMMY_MAIL)) / 2), JIMMY_MAIL)
    stdscr.addstr(min(2,maxY-1),max(0,(maxX-len(PLEASE_WAIT))/2),PLEASE_WAIT)
    stdscr.refresh()
    emlData = fetchList(MainSession, msgNOs, stdscr)    # Retrieve Messages
    (maxDigit,flag,event,currentTop,currentSelect)=(digitNo(len(msgNOs)),
            True, None, 0, 0)
    while flag:
        maxY, maxX = stdscr.getmaxyx(); stdscr.clear(); stdscr.box()
        stdscr.addstr(0, max(0, (maxX - len(JIMMY_MAIL)) / 2), JIMMY_MAIL)
        # Draw the Email list by calling drawList().
        drawList(MainSession, stdscr, emlData, currentTop, currentSelect)
        # Draw the footnotes by calling drawInstruction().
        drawInstruction(MainSession, stdscr)
        event = stdscr.getch();
        # Respond to key stroke events.
        (flag, event, currentSelect, currentTop, maxY, msgNOs, emlData) =\
            emailListResponder(event, MainSession, emlData, currentSelect,
                    currentTop, maxY, msgNOs, flag, stdscr)
    stdscr.clear(); stdscr.refresh()
    curses.reset_shell_mode(); curses.curs_set(1)   # Restore to shell mode.
Ejemplo n.º 12
0
        self.scr.clear()

    def draw(self):
        self.updscr(draw_box=False)
        self.printsubs()
        attr = self.color

        t = ""
        for s in self.sb_text:
            t += str(s) + "\n"
        t.rstrip("\n")
        # self._addstr(0, 0, t, attr=curses.color_pair(1))
        self.scr.addstr(0, 0, t, curses.color_pair(1))


curses.def_shell_mode()
root = Root(curses.initscr())

# Add a status bar
content = ["something"]
status_bar = StatusBar(root.get_win(), content)
# status_bar.display("foo", "bar", "baz", "barfoo", "", "foobar")
status_bar.print_content("foo")

entries = menu.generatemenu("Menu")

for i, a in enumerate(entries):
    # root.list.append(str(i) + "  " + str(a))
    root.list.append(str(a))
    root.len += 1
Ejemplo n.º 13
0
                          
__     ___    ____  ___    _    ____  _     _____ ____  
\ \   / / \  |  _ \|_ _|  / \  | __ )| |   | ____/ ___| 
 \ \ / / _ \ | |_) || |  / _ \ |  _ \| |   |  _| \___ \ 
  \ V / ___ \|  _ < | | / ___ \| |_) | |___| |___ ___) |
   \_/_/   \_\_| \_\___/_/   \_\____/|_____|_____|____/ 

'''


buttonPressed = 0 #timer for button held down > 5 seconds, trigger shutdown
encoderEvent = time.time() -5  #encoder event paused subpatch menu
patchRunning = 0
pixel = 0
ORIGTTY = curses.savetty()
ORIGPROG = curses.def_shell_mode()
def invertline(a,t,d,s):
	menu.highlight(d[0])
	menu.update()
	menu.show()
def graphicsUpdate(a,t,d,s):
	#bash('setfont /usr/share/organelle/configs/pixel.psfu') #or you'll error out
	graphics.updateG() #push new pad to screen
	#graphics.show()
	
def dummyShow():
	dummy.erase()
	dummy.updateG()
	dummy.show()
def graphicsWave(a,t,d,s):
	global pixel