def __swapLine(self, up: bool): helper = TextHelper(self) text = helper.current_line_text() line_nbr = helper.current_line_nbr() if up: swap_line_nbr = line_nbr - 1 else: swap_line_nbr = line_nbr + 1 swap_text = helper.line_text(swap_line_nbr) if (swap_line_nbr < helper.line_count() and line_nbr < helper.line_count()): helper.set_line_text(line_nbr, swap_text) helper.set_line_text(swap_line_nbr, text)
def __swapLine(self, up: bool): helper = TextHelper(self) text = helper.current_line_text() line_nbr = helper.current_line_nbr() if up: swap_line_nbr = line_nbr - 1 else: swap_line_nbr = line_nbr + 1 swap_text = helper.line_text(swap_line_nbr) if (swap_line_nbr < helper.line_count() and line_nbr < helper.line_count()): helper.set_line_text(line_nbr, swap_text) helper.set_line_text(swap_line_nbr, text)
def cut(self): tc = self.textCursor() helper = TextHelper(self) tc.beginEditBlock() no_selection = False if not helper.current_line_text().strip(): tc.deleteChar() else: if not self.textCursor().hasSelection(): no_selection = True TextHelper(self).select_whole_line() super(CodeEdit, self).cut() if no_selection: tc.deleteChar() tc.endEditBlock() self.setTextCursor(tc)
def cut(self): """ Cuts the selected text or the whole line if no text was selected. """ tc = self.textCursor() helper = TextHelper(self) tc.beginEditBlock() no_selection = False sText = tc.selection().toPlainText() if not helper.current_line_text() and sText.count("\n") > 1: tc.deleteChar() else: if not self.textCursor().hasSelection(): no_selection = True TextHelper(self).select_whole_line() super(CodeEdit, self).cut() if no_selection: tc.deleteChar() tc.endEditBlock() self.setTextCursor(tc)
def cut(self): """ Cuts the selected text or the whole line if no text was selected. """ tc = self.textCursor() helper = TextHelper(self) tc.beginEditBlock() no_selection = False sText = tc.selection().toPlainText() if not helper.current_line_text() and sText.count("\n") > 1: tc.deleteChar() else: if not self.textCursor().hasSelection(): no_selection = True TextHelper(self).select_whole_line() super(CodeEdit, self).cut() if no_selection: tc.deleteChar() tc.endEditBlock() self.setTextCursor(tc)
def cut(self): """ Cuts the selected text or the whole line if no text was selected. """ tc = self.textCursor() helper = TextHelper(self) tc.beginEditBlock() no_selection = False sText = tc.selection().toPlainText() # If only whitespace is selected, simply delete it if not helper.current_line_text() and not sText.strip(): tc.deleteChar() else: if not self.textCursor().hasSelection(): no_selection = True TextHelper(self).select_whole_line() super(CodeEdit, self).cut() if no_selection: tc.deleteChar() tc.endEditBlock() self.setTextCursor(tc)