3934 |
3934 |
3935 commentStr = self.lexer_.commentStr() |
3935 commentStr = self.lexer_.commentStr() |
3936 |
3936 |
3937 # get the selection boundaries |
3937 # get the selection boundaries |
3938 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
3938 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
3939 if indexTo == 0: |
3939 endLine = lineTo if indexTo else lineTo - 1 |
3940 endLine = lineTo - 1 |
|
3941 else: |
|
3942 endLine = lineTo |
|
3943 |
3940 |
3944 self.beginUndoAction() |
3941 self.beginUndoAction() |
3945 # iterate over the lines |
3942 # iterate over the lines |
3946 for line in range(lineFrom, endLine + 1): |
3943 for line in range(lineFrom, endLine + 1): |
3947 if Preferences.getEditor("CommentColumn0"): |
3944 if Preferences.getEditor("CommentColumn0"): |
3965 |
3962 |
3966 commentStr = self.lexer_.commentStr() |
3963 commentStr = self.lexer_.commentStr() |
3967 |
3964 |
3968 # get the selection boundaries |
3965 # get the selection boundaries |
3969 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
3966 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
3970 if indexTo == 0: |
3967 endLine = lineTo if indexTo else lineTo - 1 |
3971 endLine = lineTo - 1 |
|
3972 else: |
|
3973 endLine = lineTo |
|
3974 |
3968 |
3975 self.beginUndoAction() |
3969 self.beginUndoAction() |
3976 # iterate over the lines |
3970 # iterate over the lines |
3977 for line in range(lineFrom, endLine + 1): |
3971 for line in range(lineFrom, endLine + 1): |
3978 # check if line starts with our comment string (i.e. was commented |
3972 # check if line starts with our comment string (i.e. was commented |
4111 |
4105 |
4112 commentStr = self.lexer_.boxCommentStr() |
4106 commentStr = self.lexer_.boxCommentStr() |
4113 |
4107 |
4114 # get the selection boundaries |
4108 # get the selection boundaries |
4115 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
4109 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
4116 if indexTo == 0: |
4110 endLine = lineTo if indexTo else lineTo - 1 |
4117 endLine = lineTo - 1 |
|
4118 else: |
|
4119 endLine = lineTo |
|
4120 |
4111 |
4121 self.beginUndoAction() |
4112 self.beginUndoAction() |
4122 # iterate over the lines |
4113 # iterate over the lines |
4123 for line in range(lineFrom, endLine + 1): |
4114 for line in range(lineFrom, endLine + 1): |
4124 self.insertAt(commentStr['middle'], line, 0) |
4115 self.insertAt(commentStr['middle'], line, 0) |
4178 if not self.hasSelectedText(): |
4169 if not self.hasSelectedText(): |
4179 return |
4170 return |
4180 |
4171 |
4181 # get the selection |
4172 # get the selection |
4182 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
4173 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
4183 |
4174 endLine = lineTo if indexTo else lineTo - 1 |
4184 if indexTo == 0: |
|
4185 endLine = lineTo - 1 |
|
4186 else: |
|
4187 endLine = lineTo |
|
4188 |
4175 |
4189 self.beginUndoAction() |
4176 self.beginUndoAction() |
4190 # iterate over the lines |
4177 # iterate over the lines |
4191 for line in range(lineFrom, endLine + 1): |
4178 for line in range(lineFrom, endLine + 1): |
4192 if indent: |
4179 if indent: |
7041 @param encString string to use to enclose the selection |
7028 @param encString string to use to enclose the selection |
7042 (one or two characters) |
7029 (one or two characters) |
7043 @type str |
7030 @type str |
7044 """ |
7031 """ |
7045 startChar = encString[0] |
7032 startChar = encString[0] |
7046 if len(encString) == 2: |
7033 endChar = encString[1] if len(encString) == 2 else startChar |
7047 endChar = encString[1] |
|
7048 else: |
|
7049 endChar = startChar |
|
7050 |
7034 |
7051 sline, sindex, eline, eindex = self.getSelection() |
7035 sline, sindex, eline, eindex = self.getSelection() |
7052 replaceText = startChar + self.selectedText() + endChar |
7036 replaceText = startChar + self.selectedText() + endChar |
7053 self.beginUndoAction() |
7037 self.beginUndoAction() |
7054 self.replaceSelectedText(replaceText) |
7038 self.replaceSelectedText(replaceText) |
8339 wordStart, wordEnd = self.getCurrentWordBoundaries() |
8323 wordStart, wordEnd = self.getCurrentWordBoundaries() |
8340 wordStartPos = self.positionFromLineIndex(line, wordStart) |
8324 wordStartPos = self.positionFromLineIndex(line, wordStart) |
8341 wordEndPos = self.positionFromLineIndex(line, wordEnd) |
8325 wordEndPos = self.positionFromLineIndex(line, wordEnd) |
8342 |
8326 |
8343 regExp = re.compile(r"\b{0}\b".format(word)) |
8327 regExp = re.compile(r"\b{0}\b".format(word)) |
8344 if forward: |
8328 startPos = wordEndPos if forward else wordStartPos |
8345 startPos = wordEndPos |
|
8346 else: |
|
8347 startPos = wordStartPos |
|
8348 |
8329 |
8349 matches = [m for m in regExp.finditer(self.text())] |
8330 matches = [m for m in regExp.finditer(self.text())] |
8350 if matches: |
8331 if matches: |
8351 if forward: |
8332 if forward: |
8352 matchesAfter = [m for m in matches if m.start() >= startPos] |
8333 matchesAfter = [m for m in matches if m.start() >= startPos] |