Skip to content

Instantly share code, notes, and snippets.

@secondwtq
Created May 14, 2015 06:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secondwtq/189c415b09c2fa3ef757 to your computer and use it in GitHub Desktop.
Save secondwtq/189c415b09c2fa3ef757 to your computer and use it in GitHub Desktop.
# -*- 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