Tue, 10 Aug 2010 10:42:11 +0200
Added an editor action to join the current line with the next one.
QScintilla/Editor.py | file | annotate | diff | comparison | revisions | |
ViewManager/ViewManager.py | file | annotate | diff | comparison | revisions | |
changelog | file | annotate | diff | comparison | revisions |
--- a/QScintilla/Editor.py Mon Aug 09 19:58:48 2010 +0200 +++ b/QScintilla/Editor.py Tue Aug 10 10:42:11 2010 +0200 @@ -4009,6 +4009,37 @@ """ self.selectAll(False) + def joinLines(self): + """ + Public slot to join the current line with the next one. + """ + curLine = self.getCursorPosition()[0] + if curLine == self.lines() - 1: + return + + line0Text = self.text(curLine) + line1Text = self.text(curLine + 1) + if line1Text in ["", "\r", "\n", "\r\n"]: + return + + # determine start index + startIndex = len(line0Text) + while startIndex > 0 and line0Text[startIndex - 1] in "\r\n\\ \t": + startIndex -= 1 + if startIndex == 0: + return + + # determine end index + endIndex = 0 + while line1Text[endIndex] in " \t": + endIndex += 1 + + self.setSelection(curLine, startIndex, curLine + 1, endIndex) + self.beginUndoAction() + self.removeSelectedText() + self.insertAt(" ", curLine, startIndex) + self.endUndoAction() + def shortenEmptyLines(self): """ Public slot to compress lines consisting solely of whitespace characters.
--- a/ViewManager/ViewManager.py Mon Aug 09 19:58:48 2010 +0200 +++ b/ViewManager/ViewManager.py Tue Aug 10 10:42:11 2010 +0200 @@ -846,6 +846,21 @@ self.deleteAct.triggered[()].connect(self.__editDelete) self.editActions.append(self.deleteAct) + self.joinAct = E5Action(QApplication.translate('ViewManager', 'Join Lines'), + QApplication.translate('ViewManager', 'Join Lines'), + QKeySequence(QApplication.translate('ViewManager', + "Ctrl+J", "Edit|Join Lines")), + 0, + self.copyActGrp, 'vm_edit_join_lines') + self.joinAct.setStatusTip(QApplication.translate('ViewManager', + 'Join Lines')) + self.joinAct.setWhatsThis(QApplication.translate('ViewManager', + """<b>Join Lines</b>""" + """<p>Join the current and the next lines.</p>""" + )) + self.joinAct.triggered[()].connect(self.__editJoin) + self.editActions.append(self.joinAct) + self.indentAct = E5Action(QApplication.translate('ViewManager', 'Indent'), UI.PixmapCache.getIcon("editIndent.png"), QApplication.translate('ViewManager', '&Indent'), @@ -3804,6 +3819,12 @@ else: self.activeWindow().clear() + def __editJoin(self): + """ + Private method to handle the join action. + """ + self.activeWindow().joinLines() + def __editIndent(self): """ Private method to handle the indent action.
--- a/changelog Mon Aug 09 19:58:48 2010 +0200 +++ b/changelog Tue Aug 10 10:42:11 2010 +0200 @@ -5,6 +5,7 @@ - added action to copy the editor path to the clipboard to the tab context menu - added code to adjust the cursor flash time of the editor to the global settings - added code to show hidden files in the various browsers +- added an editor action to join the current line with the next one Version 5.1-snapshot-20100718: - bug fixes