diff --git a/ReText/__init__.py b/ReText/__init__.py index b9dd0407..5af3e0fd 100644 --- a/ReText/__init__.py +++ b/ReText/__init__.py @@ -76,7 +76,7 @@ def getBundledIcon(iconName): 'font': QFont(), 'handleWebLinks': False, 'hideToolBar': False, - 'highlightCurrentLine': False, + 'highlightCurrentLine': 'disabled', 'iconTheme': '', 'lastTabIndex': 0, 'lineNumbersEnabled': False, diff --git a/ReText/config.py b/ReText/config.py index 61c93b10..056da48a 100644 --- a/ReText/config.py +++ b/ReText/config.py @@ -171,6 +171,13 @@ def getPageWidget(self, options): self.configurators[name].addItem(self.tr('Normal preview'), 'normal-preview') comboBoxIndex = self.configurators[name].findData(value) self.configurators[name].setCurrentIndex(comboBoxIndex) + elif name == 'highlightCurrentLine': + self.configurators[name] = QComboBox(self) + self.configurators[name].addItem(self.tr('Disabled'), 'disabled') + self.configurators[name].addItem(self.tr('Cursor Line'), 'cursor-line') + self.configurators[name].addItem(self.tr('Wrapped Line'), 'wrapped-line') + comboBoxIndex = self.configurators[name].findData(value) + self.configurators[name].setCurrentIndex(comboBoxIndex) elif isinstance(value, bool): self.configurators[name] = QCheckBox(self) self.configurators[name].setChecked(value) diff --git a/ReText/editor.py b/ReText/editor.py index 903f0371..affc0b9a 100644 --- a/ReText/editor.py +++ b/ReText/editor.py @@ -370,14 +370,23 @@ def resizeEvent(self, event): def highlightCurrentLine(self): if globalSettings.relativeLineNumbers: self.lineNumberArea.update() - if not globalSettings.highlightCurrentLine: + if globalSettings.highlightCurrentLine == 'disabled': return self.setExtraSelections([]) - selection = QTextEdit.ExtraSelection(); + selection = QTextEdit.ExtraSelection() selection.format.setBackground(colorValues['currentLineHighlight']) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = self.textCursor() selection.cursor.clearSelection() - self.setExtraSelections([selection]) + selections = [selection] + if globalSettings.highlightCurrentLine == 'wrapped-line': + selections.append(QTextEdit.ExtraSelection()) + selections[0].cursor.movePosition(QTextCursor.StartOfBlock) + selections[0].cursor.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor) + selections[1].format.setBackground(colorValues['currentLineHighlight']) + selections[1].format.setProperty(QTextFormat.FullWidthSelection, True) + selections[1].cursor = self.textCursor() + selections[1].cursor.movePosition(QTextCursor.EndOfBlock) + self.setExtraSelections(selections) def enableTableMode(self, enable): self.tableModeEnabled = enable