mirror of
https://github.com/httpie/cli.git
synced 2024-11-24 08:22:22 +02: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
|
import json
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import pygments
|
import pygments
|
||||||
|
import os
|
||||||
from pygments.lexers import get_lexer_for_mimetype
|
from pygments.lexers import get_lexer_for_mimetype
|
||||||
from pygments.formatters.terminal256 import Terminal256Formatter
|
from pygments.formatters.terminal256 import Terminal256Formatter
|
||||||
|
from pygments.formatters.terminal import TerminalFormatter
|
||||||
from pygments.lexer import RegexLexer, bygroups
|
from pygments.lexer import RegexLexer, bygroups
|
||||||
from pygments import token
|
from pygments import token
|
||||||
from . import solarized
|
from . import solarized
|
||||||
@ -23,9 +25,14 @@ class HTTPLexer(RegexLexer):
|
|||||||
(r'(.*?:)(.+)', bygroups(token.Name, token.String))
|
(r'(.*?:)(.+)', bygroups(token.Name, token.String))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
if os.environ['TERM'] == 'xterm-256color':
|
||||||
|
formatter = Terminal256Formatter
|
||||||
|
else:
|
||||||
|
formatter = TerminalFormatter
|
||||||
|
|
||||||
|
|
||||||
highlight = partial(pygments.highlight,
|
highlight = partial(pygments.highlight,
|
||||||
formatter=Terminal256Formatter(
|
formatter=formatter(
|
||||||
style=solarized.SolarizedStyle))
|
style=solarized.SolarizedStyle))
|
||||||
highlight_http = partial(highlight, lexer=HTTPLexer())
|
highlight_http = partial(highlight, lexer=HTTPLexer())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user