Commit 4536e275 authored by Seblu's avatar Seblu
Browse files

fix bad color length calculation by readline

fix command history traceback
parent f50f96d1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ from sjrpc.client import SimpleRpcClient
from sjrpc.utils import RpcHandler, ConnectionProxy, pure
from sjrpc.core.exceptions import *



class Cli(object):
    def __init__(self, settings):
        self.settings = settings
+2 −2
Original line number Diff line number Diff line
@@ -161,9 +161,9 @@ class Command(object):

    def cmd_history(self, argv):
        '''Show history of commands'''
        if not self.cli.history:
        if not self.printer.history:
            raise cmdError("History is not available")
        for l in self.cli.history:
        for l in self.printer.history:
            self.printer.out(l)
    cmd_history.usage = "history"
    cmd_history.desc = "Show commands history"
+22 −22
Original line number Diff line number Diff line
@@ -13,30 +13,30 @@ import cccli

color = {
    # regular
    "red": "\033[0;31m",
    "green": "\033[0;32m",
    "yellow": "\033[0;33m",
    "blue": "\033[0;34m",
    "purple": "\033[0;35m",
    "cyan": "\033[0;36m",
    "white": "\033[0;37m",
    "red": "\001\033[0;31m\002",
    "green": "\001\033[0;32m\002",
    "yellow": "\001\033[0;33m\002",
    "blue": "\001\033[0;34m\002",
    "purple": "\001\033[0;35m\002",
    "cyan": "\001\033[0;36m\002",
    "white": "\001\033[0;37m\002",
    # lighted
    "lred": "\033[1;31m",
    "lgreen": "\033[1;32m",
    "lyellow": "\033[1;33m",
    "lblue": "\033[1;34m",
    "lpurple": "\033[1;35m",
    "lcyan": "\033[1;36m",
    "lwhite": "\033[1;37m",
    "lred": "\001\033[1;31m",
    "lgreen": "\001\033[1;32m\002",
    "lyellow": "\001\033[1;33m\002",
    "lblue": "\001\033[1;34m\002",
    "lpurple": "\001\033[1;35m\002",
    "lcyan": "\001\033[1;36m\002",
    "lwhite": "\001\033[1;37m\002",
    # underline
    "ured": "\033[4;31m",
    "ugreen": "\033[4;32m",
    "uyellow": "\033[4;33m",
    "ublue": "\033[4;34m",
    "upurple": "\033[4;35m",
    "ucyan": "\033[4;36m",
    "ured": "\001\033[4;31m\002",
    "ugreen": "\001\033[4;32m\002",
    "uyellow": "\001\033[4;33m\002",
    "ublue": "\001\033[4;34m\002",
    "upurple": "\001\033[4;35m\002",
    "ucyan": "\001\033[4;36m\002",
    # others
    "reset": "\033[m",
    "reset": "\001\033[m\002",
    }


@@ -152,7 +152,7 @@ class History(object):

    def removelast(self):
        '''Remove last history line'''
        self.readline.remove_history_item(self.readline.get_current_history_length())
        self.readline.remove_history_item(self.readline.get_current_history_length() - 1)

    def clear(self):
        '''Clear history'''