139 if self.__insertInlineDoc and self.__beginNlRX.exactMatch(txt): |
139 if self.__insertInlineDoc and self.__beginNlRX.exactMatch(txt): |
140 self.editor.insert('=end') |
140 self.editor.insert('=end') |
141 elif self.__insertHereDoc and self.__hereRX.exactMatch(txt): |
141 elif self.__insertHereDoc and self.__hereRX.exactMatch(txt): |
142 self.editor.insert(self.__hereRX.cap(1)) |
142 self.editor.insert(self.__hereRX.cap(1)) |
143 elif self.__indentBrace and re.search(":\r?\n", txt) is None: |
143 elif self.__indentBrace and re.search(":\r?\n", txt) is None: |
144 openCount = len(re.findall("[({[]", txt)) |
144 stxt = txt.strip() |
145 closeCount = len(re.findall(r"[)}\]]", txt)) |
145 if stxt and stxt[-1] in ("(", "[", "{"): |
146 if openCount > closeCount: |
146 # indent one more level |
147 openCount = 0 |
147 self.editor.indent(line) |
148 closeCount = 0 |
148 self.editor.editorCommand(QsciScintilla.SCI_VCHOME) |
149 openList = list(re.finditer("[({[]", txt)) |
149 else: |
150 index = len(openList) - 1 |
150 # indent to the level of the opening brace |
151 while index > -1 and openCount == closeCount: |
151 openCount = len(re.findall("[({[]", txt)) |
152 lastOpenIndex = openList[index].start() |
152 closeCount = len(re.findall(r"[)}\]]", txt)) |
153 txt2 = txt[lastOpenIndex:] |
153 if openCount > closeCount: |
154 openCount = len(re.findall("[({[]", txt2)) |
154 openCount = 0 |
155 closeCount = len(re.findall(r"[)}\]]", txt2)) |
155 closeCount = 0 |
156 index -= 1 |
156 openList = list(re.finditer("[({[]", txt)) |
157 if openCount > closeCount and lastOpenIndex > col: |
157 index = len(openList) - 1 |
158 self.editor.insert(' ' * (lastOpenIndex - col + 1)) |
158 while index > -1 and openCount == closeCount: |
159 self.editor.setCursorPosition(line, lastOpenIndex + 1) |
159 lastOpenIndex = openList[index].start() |
|
160 txt2 = txt[lastOpenIndex:] |
|
161 openCount = len(re.findall("[({[]", txt2)) |
|
162 closeCount = len(re.findall(r"[)}\]]", txt2)) |
|
163 index -= 1 |
|
164 if openCount > closeCount and lastOpenIndex > col: |
|
165 self.editor.insert(' ' * (lastOpenIndex - col + 1)) |
|
166 self.editor.setCursorPosition(line, |
|
167 lastOpenIndex + 1) |
160 |
168 |
161 def __inComment(self, line, col): |
169 def __inComment(self, line, col): |
162 """ |
170 """ |
163 Private method to check, if the cursor is inside a comment. |
171 Private method to check, if the cursor is inside a comment. |
164 |
172 |