Created
May 14, 2015 06:55
-
-
Save secondwtq/189c415b09c2fa3ef757 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import pygments | |
import pygments.lexers | |
import pygments.formatters | |
import curses | |
formatter_default = pygments.formatters.TerminalFormatter() | |
def highlight(code): | |
lexer = pygments.lexers.get_lexer_by_name('python') | |
return pygments.highlight(code, lexer, formatter_default) | |
STR = ''' | |
def start(self): | |
key = 0 | |
page_size = len(context) | |
current_page = -1 | |
''' | |
if __name__ == '__main__': | |
stdscr = curses.initscr() | |
curses.start_color() | |
curses.noecho() | |
curses.cbreak() | |
stdscr.keypad(True) | |
stdscr.addstr(3, 0, highlight(STR)) | |
stdscr.refresh() | |
stdscr.getkey() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment