3891 line, index = self.getCursorPosition() |
3891 line, index = self.getCursorPosition() |
3892 self.beginUndoAction() |
3892 self.beginUndoAction() |
3893 if Preferences.getEditor("CommentColumn0"): |
3893 if Preferences.getEditor("CommentColumn0"): |
3894 self.insertAt(self.lexer_.commentStr(), line, 0) |
3894 self.insertAt(self.lexer_.commentStr(), line, 0) |
3895 else: |
3895 else: |
3896 self.insertAt(self.lexer_.commentStr(), line, |
3896 lineText = self.text(line) |
3897 self.indentation(line)) |
3897 pos = len(lineText.replace(lineText.lstrip(" \t"), "")) |
|
3898 self.insertAt(self.lexer_.commentStr(), line, pos) |
3898 self.endUndoAction() |
3899 self.endUndoAction() |
3899 |
3900 |
3900 def uncommentLine(self): |
3901 def uncommentLine(self): |
3901 """ |
3902 """ |
3902 Public slot to uncomment the current line. |
3903 Public slot to uncomment the current line. |
3915 # now remove the comment string |
3916 # now remove the comment string |
3916 self.beginUndoAction() |
3917 self.beginUndoAction() |
3917 if Preferences.getEditor("CommentColumn0"): |
3918 if Preferences.getEditor("CommentColumn0"): |
3918 self.setSelection(line, 0, line, len(commentStr)) |
3919 self.setSelection(line, 0, line, len(commentStr)) |
3919 else: |
3920 else: |
3920 self.setSelection(line, self.indentation(line), |
3921 lineText = self.text(line) |
3921 line, self.indentation(line) + len(commentStr)) |
3922 pos = len(lineText.replace(lineText.lstrip(" \t"), "")) |
|
3923 self.setSelection(line, pos, line, pos + len(commentStr)) |
3922 self.removeSelectedText() |
3924 self.removeSelectedText() |
3923 self.endUndoAction() |
3925 self.endUndoAction() |
3924 |
3926 |
3925 def commentSelection(self): |
3927 def commentSelection(self): |
3926 """ |
3928 """ |
3942 # iterate over the lines |
3944 # iterate over the lines |
3943 for line in range(lineFrom, endLine + 1): |
3945 for line in range(lineFrom, endLine + 1): |
3944 if Preferences.getEditor("CommentColumn0"): |
3946 if Preferences.getEditor("CommentColumn0"): |
3945 self.insertAt(commentStr, line, 0) |
3947 self.insertAt(commentStr, line, 0) |
3946 else: |
3948 else: |
3947 self.insertAt(commentStr, line, self.indentation(line)) |
3949 lineText = self.text(line) |
|
3950 pos = len(lineText.replace(lineText.lstrip(" \t"), "")) |
|
3951 self.insertAt(commentStr, line, pos) |
3948 |
3952 |
3949 # change the selection accordingly |
3953 # change the selection accordingly |
3950 self.setSelection(lineFrom, 0, endLine + 1, 0) |
3954 self.setSelection(lineFrom, 0, endLine + 1, 0) |
3951 self.endUndoAction() |
3955 self.endUndoAction() |
3952 |
3956 |
3975 continue |
3979 continue |
3976 |
3980 |
3977 if Preferences.getEditor("CommentColumn0"): |
3981 if Preferences.getEditor("CommentColumn0"): |
3978 self.setSelection(line, 0, line, len(commentStr)) |
3982 self.setSelection(line, 0, line, len(commentStr)) |
3979 else: |
3983 else: |
3980 self.setSelection(line, |
3984 lineText = self.text(line) |
3981 self.indentation(line), |
3985 pos = len(lineText.replace(lineText.lstrip(" \t"), "")) |
3982 line, |
3986 self.setSelection(line, pos, line, pos + len(commentStr)) |
3983 self.indentation(line) + len(commentStr)) |
|
3984 self.removeSelectedText() |
3987 self.removeSelectedText() |
3985 |
3988 |
3986 # adjust selection start |
3989 # adjust selection start |
3987 if line == lineFrom: |
3990 if line == lineFrom: |
3988 indexFrom -= len(commentStr) |
3991 indexFrom -= len(commentStr) |