Skip to content
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

Merged
merged 4 commits into from
Sep 11, 2017
Merged

Implement softwrapping at user specified margin line #313

merged 4 commits into from
Sep 11, 2017

Conversation

oguzhanogreden
Copy link
Contributor

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.

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'),
Copy link
Member

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'))
Copy link
Member

@mitya57 mitya57 Sep 8, 2017

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)
Copy link
Member

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:
Copy link
Member

@mitya57 mitya57 Sep 9, 2017

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.

@mitya57 mitya57 merged commit 062eca5 into retext-project:master Sep 11, 2017
@mitya57
Copy link
Member

mitya57 commented Sep 11, 2017

Thank you! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants