mirror of
https://github.com/httpie/cli.git
synced 2024-12-23 23:09:17 +01:00
Merge pull request #10 from marblar/osx
Support for terminals not using 256 color
This commit is contained in:
commit
ed3a491c81
@ -1,8 +1,10 @@
|
||||
import json
|
||||
from functools import partial
|
||||
import pygments
|
||||
import os
|
||||
from pygments.lexers import get_lexer_for_mimetype
|
||||
from pygments.formatters.terminal256 import Terminal256Formatter
|
||||
from pygments.formatters.terminal import TerminalFormatter
|
||||
from pygments.lexer import RegexLexer, bygroups
|
||||
from pygments import token
|
||||
from . import solarized
|
||||
@ -23,9 +25,14 @@ class HTTPLexer(RegexLexer):
|
||||
(r'(.*?:)(.+)', bygroups(token.Name, token.String))
|
||||
]}
|
||||
|
||||
if os.environ['TERM'] == 'xterm-256color':
|
||||
formatter = Terminal256Formatter
|
||||
else:
|
||||
formatter = TerminalFormatter
|
||||
|
||||
|
||||
highlight = partial(pygments.highlight,
|
||||
formatter=Terminal256Formatter(
|
||||
formatter=formatter(
|
||||
style=solarized.SolarizedStyle))
|
||||
highlight_http = partial(highlight, lexer=HTTPLexer())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user