Show More
@@ -100,10 +100,22 b' class ConsoleWidget(QtGui.QPlainTextEdit):' | |||||
100 | handling ANSI escape sequences. |
|
100 | handling ANSI escape sequences. | |
101 | """ |
|
101 | """ | |
102 |
|
102 | |||
103 |
# |
|
103 | # Whether to process ANSI escape codes. | |
|
104 | ansi_codes = True | |||
|
105 | ||||
|
106 | # The maximum number of lines of text before truncation. | |||
|
107 | buffer_size = 500 | |||
|
108 | ||||
|
109 | # Whether to use a CompletionWidget or plain text output for tab completion. | |||
|
110 | gui_completion = True | |||
|
111 | ||||
|
112 | # Whether to override ShortcutEvents for the keybindings defined by this | |||
|
113 | # widget (Ctrl+n, Ctrl+a, etc). Enable this if you want this widget to take | |||
|
114 | # priority (when it has focus) over, e.g., window-level menu shortcuts. | |||
|
115 | override_shortcuts = False | |||
|
116 | ||||
|
117 | # Protected class variables. | |||
104 | _ansi_pattern = re.compile('\x01?\x1b\[(.*?)m\x02?') |
|
118 | _ansi_pattern = re.compile('\x01?\x1b\[(.*?)m\x02?') | |
105 |
|
||||
106 | # When ctrl is pressed, map certain keys to other keys (without the ctrl): |
|
|||
107 | _ctrl_down_remap = { QtCore.Qt.Key_B : QtCore.Qt.Key_Left, |
|
119 | _ctrl_down_remap = { QtCore.Qt.Key_B : QtCore.Qt.Key_Left, | |
108 | QtCore.Qt.Key_F : QtCore.Qt.Key_Right, |
|
120 | QtCore.Qt.Key_F : QtCore.Qt.Key_Right, | |
109 | QtCore.Qt.Key_A : QtCore.Qt.Key_Home, |
|
121 | QtCore.Qt.Key_A : QtCore.Qt.Key_Home, | |
@@ -119,10 +131,7 b' class ConsoleWidget(QtGui.QPlainTextEdit):' | |||||
119 | def __init__(self, parent=None): |
|
131 | def __init__(self, parent=None): | |
120 | QtGui.QPlainTextEdit.__init__(self, parent) |
|
132 | QtGui.QPlainTextEdit.__init__(self, parent) | |
121 |
|
133 | |||
122 |
# Initialize p |
|
134 | # Initialize protected variables. | |
123 | self.ansi_codes = True |
|
|||
124 | self.buffer_size = 500 |
|
|||
125 | self.gui_completion = True |
|
|||
126 | self._ansi_processor = QtAnsiCodeProcessor() |
|
135 | self._ansi_processor = QtAnsiCodeProcessor() | |
127 | self._completion_widget = CompletionWidget(self) |
|
136 | self._completion_widget = CompletionWidget(self) | |
128 | self._continuation_prompt = '> ' |
|
137 | self._continuation_prompt = '> ' | |
@@ -160,6 +169,18 b' class ConsoleWidget(QtGui.QPlainTextEdit):' | |||||
160 |
|
169 | |||
161 | self._context_menu.exec_(event.globalPos()) |
|
170 | self._context_menu.exec_(event.globalPos()) | |
162 |
|
171 | |||
|
172 | def event(self, event): | |||
|
173 | """ Reimplemented to override shortcuts, if necessary. | |||
|
174 | """ | |||
|
175 | if self.override_shortcuts and \ | |||
|
176 | event.type() == QtCore.QEvent.ShortcutOverride and \ | |||
|
177 | event.modifiers() & QtCore.Qt.ControlModifier and \ | |||
|
178 | event.key() in self._ctrl_down_remap: | |||
|
179 | event.accept() | |||
|
180 | return True | |||
|
181 | else: | |||
|
182 | return QtGui.QPlainTextEdit.event(self, event) | |||
|
183 | ||||
163 | def keyPressEvent(self, event): |
|
184 | def keyPressEvent(self, event): | |
164 | """ Reimplemented to create a console-like interface. |
|
185 | """ Reimplemented to create a console-like interface. | |
165 | """ |
|
186 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now