mike820324 / microProxy

A http/https interceptor written in pure python.
MIT License
17 stars 3 forks source link

[TUIViewer]: Upgrade GViewer to v3.0.0 #169

Closed chhsiao90 closed 8 years ago

chhsiao90 commented 8 years ago

I planned release GViewer v3.0.0 recently. That could support functionality for: #155 , #116

Do you have any other idea or suggestion that could be implement in gviewer that microproxy need?

mike820324 commented 8 years ago

The following list some wish list that I would love to have in tui-viewer.

...
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatter import Terminal256Formatter

class JsonFormatter(object):
...
def colorize(self, raw_text):
   lexer = get_lexer_by_name("json", stripall=True)
   formatter = Terminal256Formatter()
   return highligh(raw_text, lexer, formatter)

def format_body(self, body):
   parsed_body = json.loads(...)
   json_string = json_dumps(...)
   return self.colorize(json_string)
...

The output would look something like this.

 ?[38;5;28;01m"data"?[39;00m: {                                                            
        ?[38;5;28;01m"total"?[39;00m: ?[38;5;241m3?[39m,                                      
        ?[38;5;28;01m"hosts"?[39;00m: [                                                       
            {                                                                                 
                ?[38;5;28;01m"index"?[39;00m: [                                               
                    ?[38;5;124m"index.html"?[39m,                                             
                    ?[38;5;124m"index.htm"?[39m,                                              
                    ?[38;5;124m"index.cgi"?[39m,                                              
                    ?[38;5;124m"index.php"?[39m,                                              
                    ?[38;5;124m"index.php5"?[39m                                              
                ], 
mike820324 commented 8 years ago

There is a thread talking about the pygments styles working with urwid.

http://lists.excess.org/pipermail/urwid/2011-August/001092.html

chhsiao90 commented 8 years ago

The list you provide that all make sense. I will add them into next release. Thanks!

mike820324 commented 8 years ago

Thank you for your help, thanks