from PyQt5.QtGui import qRgb
from idacyber import ColorFilter

class Ascii(ColorFilter):
    name = 'Ascii'
    highlight_cursor = True
    help = ''

    def render_img(self, buf, addr, mouse_offs):
        colors = []
        last_offs = None
        cur_len = 0
        offsets = {}
        min_len = 5
        for i in xrange(len(buf)):           
            c = ord(buf[i])
            r = 0
            printable = c >= 0x20 and c <= 0x7E
            if printable:
                if last_offs is not None:
                    cur_len += 1
                else:
                    last_offs = i
                    cur_len = 1
            else:
                if last_offs is not None and cur_len >= min_len:
                    offsets[last_offs] = cur_len
                last_offs = None
                cur_len = 0
            colors.append(qRgb(0x10, 0x10, 0x10))

        for k, v in offsets.iteritems():
            for i in xrange(v):
                    c = ord(buf[k+i])
                    b = c + (0xFF - 0x7E)
                    if c >= 0x41 and c <= 0x5A or \
                    c >= 0x61 and c <= 0x7A or \
                    c >= 0x30 and c <= 0x39:
                        colors[k+i] = qRgb(b, b, 0)
                    else:
                        colors[k+i] = qRgb(b, 0, 0)

        return colors
    
def FILTER_ENTRY():
    return Ascii()

@@ -31,123 +31,599 @@
 rom 
-idacyber import ColorFilter%0A%0Aclass Ascii(ColorFilter):%0A    name = 'Ascii'%0A    highlight_cursor = True%0A    help = ''
+PyQt5.QtCore import Qt%0Afrom idacyber import ColorFilter%0Afrom ida_kernwin import ask_long%0A%0Aclass Ascii(ColorFilter):%0A    name = 'Ascii'%0A    highlight_cursor = True%0A    help = 'Highlight ascii strings.%5Cn%5CnSet threshold using right mouse button.'%0A%0A    def __init__(self):%0A        self.threshold = 4%0A%0A    def _set_threshold(self):%0A        res = ask_long(self.threshold, %22Please specify minimum string length%22)%0A        if res is not None:%0A            self.threshold = res%0A%0A    def on_mb_click(self, button, addr, mouse_offs):%0A        if button == Qt.RightButton:%0A            self._set_threshold()
 %0A%0A  
@@ -759,28 +759,8 @@
  %7B%7D%0A
-        min_len = 5%0A
     
@@ -1162,15 +1162,22 @@
  %3E= 
-min_len
+self.threshold
 :%0A  
@@ -1276,32 +1276,55 @@
     cur_len = 0%0A
+            # bg color%0A
             colo

Update ascii.py