-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement softwrapping at user specified margin line #313
Conversation
Conditional went wrong...
ReText/config.py
Outdated
@@ -83,6 +84,7 @@ def initConfigOptions(self): | |||
(self.tr('Tab key inserts spaces'), 'tabInsertsSpaces'), | |||
(self.tr('Tabulation width'), 'tabWidth'), | |||
(self.tr('Draw vertical line at column'), 'rightMargin'), | |||
(self.tr('Enable soft wrap'), 'rightMarginWrap'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation :)
ReText/config.py
Outdated
def handleRightMarginSet(self, value): | ||
if value > 0: | ||
self.configurators['rightMarginWrap'].setEnabled(True) | ||
self.configurators['rightMarginWrap'].setChecked(getattr(globalSettings, 'rightMarginWrap')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, just use globalSettings.rightMarginWrap
.
ReText/editor.py
Outdated
self.document().blockCountChanged.connect(self.updateLineNumberAreaWidth) | ||
self.cursorPositionChanged.connect(self.highlightCurrentLine) | ||
self.document().contentsChange.connect(self.contentsChange) | ||
if globalSettings.useFakeVim: | ||
self.installFakeVimHandler() | ||
|
||
def setWrapModeAndWidth(self): | ||
if globalSettings.rightMarginWrap and (self.rect().topRight().x() > self.marginx): | ||
self.setLineWrapMode(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use magic numbers 1 or 2. Use QTextEdit.WidgetWidth
and QTextEdit.FixedPixelWidth
instead.
ReText/config.py
Outdated
@@ -122,6 +124,8 @@ def initWidgets(self): | |||
if isinstance(value, bool): | |||
self.configurators[name] = QCheckBox(self) | |||
self.configurators[name].setChecked(value) | |||
if name == 'rightMarginWrap' and getattr(globalSettings, 'rightMargin') == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use globalSettings.rightMargin
, no need for getattr.
Thank you! Merged. |
As I started using ReText more often, I noticed that I missed the softwrap option of Atom.
This pull request implements a simple softwrap feature and creates the necessary preferences entry. Moreover, it can take into account whether the width of ReTextEdit(QTextEdit) is smaller than user specified margin.