4007 """ |
4007 """ |
4008 Private slot handling the deselect all context menu action. |
4008 Private slot handling the deselect all context menu action. |
4009 """ |
4009 """ |
4010 self.selectAll(False) |
4010 self.selectAll(False) |
4011 |
4011 |
|
4012 def joinLines(self): |
|
4013 """ |
|
4014 Public slot to join the current line with the next one. |
|
4015 """ |
|
4016 curLine = self.getCursorPosition()[0] |
|
4017 if curLine == self.lines() - 1: |
|
4018 return |
|
4019 |
|
4020 line0Text = self.text(curLine) |
|
4021 line1Text = self.text(curLine + 1) |
|
4022 if line1Text in ["", "\r", "\n", "\r\n"]: |
|
4023 return |
|
4024 |
|
4025 # determine start index |
|
4026 startIndex = len(line0Text) |
|
4027 while startIndex > 0 and line0Text[startIndex - 1] in "\r\n\\ \t": |
|
4028 startIndex -= 1 |
|
4029 if startIndex == 0: |
|
4030 return |
|
4031 |
|
4032 # determine end index |
|
4033 endIndex = 0 |
|
4034 while line1Text[endIndex] in " \t": |
|
4035 endIndex += 1 |
|
4036 |
|
4037 self.setSelection(curLine, startIndex, curLine + 1, endIndex) |
|
4038 self.beginUndoAction() |
|
4039 self.removeSelectedText() |
|
4040 self.insertAt(" ", curLine, startIndex) |
|
4041 self.endUndoAction() |
|
4042 |
4012 def shortenEmptyLines(self): |
4043 def shortenEmptyLines(self): |
4013 """ |
4044 """ |
4014 Public slot to compress lines consisting solely of whitespace characters. |
4045 Public slot to compress lines consisting solely of whitespace characters. |
4015 """ |
4046 """ |
4016 searchRE = r"^[ \t]+$" |
4047 searchRE = r"^[ \t]+$" |