mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-01 10:39:34 +12:00
Fixes bugs in focus mode (#259)
This commit is contained in:
parent
826d53933f
commit
46384b68eb
|
@ -105,7 +105,7 @@ class MarkdownHighlighter(BasicHighlighter):
|
||||||
line = block.layout().lineAt(i)
|
line = block.layout().lineAt(i)
|
||||||
start = line.textStart()
|
start = line.textStart()
|
||||||
end = line.textStart() + line.textLength()
|
end = line.textStart() + line.textLength()
|
||||||
if start <= pos < end:
|
if start <= pos <= end:
|
||||||
return (start, end)
|
return (start, end)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from PyQt5.QtCore import QRegExp, Qt
|
from PyQt5.QtCore import QRegExp, Qt, QTimer
|
||||||
from PyQt5.QtGui import QTextCursor
|
from PyQt5.QtGui import QTextCursor
|
||||||
# from PyQt5.QtWidgets import
|
# from PyQt5.QtWidgets import
|
||||||
|
|
||||||
|
@ -173,6 +173,9 @@ class MDEditView(textEditView):
|
||||||
|
|
||||||
def cursorPositionHasChanged(self):
|
def cursorPositionHasChanged(self):
|
||||||
self.centerCursor()
|
self.centerCursor()
|
||||||
|
# Focus mode
|
||||||
|
if self.highlighter:
|
||||||
|
QTimer.singleShot(50, self.highlighter.rehighlight)
|
||||||
|
|
||||||
def centerCursor(self, force=False):
|
def centerCursor(self, force=False):
|
||||||
cursor = self.cursorRect()
|
cursor = self.cursorRect()
|
||||||
|
|
|
@ -67,9 +67,6 @@ class textEditView(QTextEdit):
|
||||||
|
|
||||||
# self.document().contentsChanged.connect(lambda: print(self.objectName(), "Contents changed"))
|
# self.document().contentsChanged.connect(lambda: print(self.objectName(), "Contents changed"))
|
||||||
|
|
||||||
# Focus mode
|
|
||||||
self.cursorPositionChanged.connect(self.cursorHasMoved)
|
|
||||||
|
|
||||||
self.setEnabled(False)
|
self.setEnabled(False)
|
||||||
|
|
||||||
if index:
|
if index:
|
||||||
|
@ -94,10 +91,6 @@ class textEditView(QTextEdit):
|
||||||
self.highlighter = self._highlighterClass(self)
|
self.highlighter = self._highlighterClass(self)
|
||||||
self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat)
|
self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat)
|
||||||
|
|
||||||
def cursorHasMoved(self):
|
|
||||||
if self.highlighter:
|
|
||||||
self.highlighter.rehighlight()
|
|
||||||
|
|
||||||
def getDefaultLocale(self):
|
def getDefaultLocale(self):
|
||||||
default_locale = enchant.get_default_language()
|
default_locale = enchant.get_default_language()
|
||||||
if default_locale is None:
|
if default_locale is None:
|
||||||
|
|
Loading…
Reference in a new issue