119 # insert quote |
122 # insert quote |
120 elif char == "'" and self.__insertQuote: |
123 elif char == "'" and self.__insertQuote: |
121 self.editor.insert("'") |
124 self.editor.insert("'") |
122 |
125 |
123 # new line |
126 # new line |
124 # indent after line ending with ':' |
|
125 elif char == "\n" and self.__autoIndentation: |
127 elif char == "\n" and self.__autoIndentation: |
126 txt = self.editor.text(line - 1) |
128 txt = self.editor.text(line - 1) |
127 match = re.search( |
129 if self.__autoIndentation and self.__autoIndentationRe.search(txt): |
128 r"(?:\||\|-|\|\+|>|>-|>\+|-|:)(\s*)\r?\n", |
130 # indent after line ending with auto indentation character |
129 # __IGNORE_WARNING_W605__ |
131 match = self.__autoIndentationRe.search(txt) |
130 txt, |
132 if match is not None: |
131 ) |
133 startBlanks = match.start(1) |
132 if match is not None: |
134 endBlanks = match.end(1) |
133 startBlanks = match.start(1) |
135 if startBlanks != -1 and startBlanks != endBlanks: |
134 endBlanks = match.end(1) |
136 # previous line ends with whitespace, e.g. caused by |
135 if startBlanks != -1 and startBlanks != endBlanks: |
137 # blank insertion above |
136 # previous line ends with whitespace, e.g. caused by |
138 self.editor.setSelection( |
137 # blank insertion above |
139 line - 1, startBlanks, line - 1, endBlanks |
138 self.editor.setSelection(line - 1, startBlanks, line - 1, endBlanks) |
140 ) |
139 self.editor.removeSelectedText() |
141 self.editor.removeSelectedText() |
140 |
142 |
141 self.editor.indent(line) |
143 self.editor.indent(line) |
142 self.editor.setCursorPosition(line, 0) |
144 self.editor.setCursorPosition(line, 0) |
143 self.editor.editorCommand(QsciScintilla.SCI_VCHOME) |
145 self.editor.editorCommand(QsciScintilla.SCI_VCHOME) |
|
146 |
|
147 elif ( |
|
148 self.__insertBlankColon |
|
149 or self.__insertBlankComma |
|
150 or self.__insertBlankDash |
|
151 or self.__insertBlankQuestion |
|
152 ) and self.__trailingBlankRe.search(txt): |
|
153 # remove blank at end of line inserted by blank insertion above |
|
154 match = self.__trailingBlankRe.search(txt) |
|
155 if match is not None: |
|
156 startBlanks = match.start(1) |
|
157 endBlanks = match.end(1) |
|
158 if startBlanks != -1 and startBlanks != endBlanks: |
|
159 self.editor.setSelection( |
|
160 line - 1, startBlanks, line - 1, endBlanks |
|
161 ) |
|
162 self.editor.removeSelectedText() |
|
163 |
|
164 self.editor.setCursorPosition(line, 0) |
|
165 self.editor.editorCommand(QsciScintilla.SCI_VCHOME) |
144 |
166 |
145 def __inComment(self, line, col): |
167 def __inComment(self, line, col): |
146 """ |
168 """ |
147 Private method to check, if the cursor is inside a comment. |
169 Private method to check, if the cursor is inside a comment. |
148 |
170 |