Show More
@@ -29,13 +29,16 b" ScrollAction = namedtuple('ScrollAction', ['action', 'dir', 'unit', 'count'])" | |||
|
29 | 29 | # An action for the carriage return character |
|
30 | 30 | CarriageReturnAction = namedtuple('CarriageReturnAction', ['action']) |
|
31 | 31 | |
|
32 | # An action for the beep character | |
|
33 | BeepAction = namedtuple('BeepAction', ['action']) | |
|
34 | ||
|
32 | 35 | # Regular expressions. |
|
33 | 36 | CSI_COMMANDS = 'ABCDEFGHJKSTfmnsu' |
|
34 | 37 | CSI_SUBPATTERN = '\[(.*?)([%s])' % CSI_COMMANDS |
|
35 | 38 | OSC_SUBPATTERN = '\](.*?)[\x07\x1b]' |
|
36 | 39 | ANSI_PATTERN = ('\x01?\x1b(%s|%s)\x02?' % \ |
|
37 | 40 | (CSI_SUBPATTERN, OSC_SUBPATTERN)) |
|
38 |
ANSI_OR_ |
|
|
41 | ANSI_OR_SPECIAL_PATTERN = re.compile('(\b|\r)|(?:%s)' % ANSI_PATTERN) | |
|
39 | 42 | SPECIAL_PATTERN = re.compile('([\f])') |
|
40 | 43 | |
|
41 | 44 | #----------------------------------------------------------------------------- |
@@ -80,7 +83,7 b' class AnsiCodeProcessor(object):' | |||
|
80 | 83 | self.actions = [] |
|
81 | 84 | start = 0 |
|
82 | 85 | |
|
83 |
for match in ANSI_OR_ |
|
|
86 | for match in ANSI_OR_SPECIAL_PATTERN.finditer(string): | |
|
84 | 87 | raw = string[start:match.start()] |
|
85 | 88 | substring = SPECIAL_PATTERN.sub(self._replace_special, raw) |
|
86 | 89 | if substring or self.actions: |
@@ -92,6 +95,9 b' class AnsiCodeProcessor(object):' | |||
|
92 | 95 | if groups[0] == '\r': |
|
93 | 96 | self.actions.append(CarriageReturnAction('carriage-return')) |
|
94 | 97 | yield '' |
|
98 | elif groups[0] == '\b': | |
|
99 | self.actions.append(BeepAction('beep')) | |
|
100 | yield '' | |
|
95 | 101 | else: |
|
96 | 102 | params = [ param for param in groups[1].split(';') if param ] |
|
97 | 103 | if groups[0].startswith('['): |
@@ -1517,6 +1517,9 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
1517 | 1517 | cursor.movePosition( |
|
1518 | 1518 | cursor.StartOfLine, cursor.KeepAnchor) |
|
1519 | 1519 | |
|
1520 | elif act.action == 'beep': | |
|
1521 | QtGui.qApp.beep() | |
|
1522 | ||
|
1520 | 1523 | format = self._ansi_processor.get_format() |
|
1521 | 1524 | cursor.insertText(substring, format) |
|
1522 | 1525 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now