mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More stupid PyQt enums
This commit is contained in:
parent
98d34f057a
commit
3cba0dcec8
@ -3,7 +3,7 @@
|
||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from PyQt5.Qt import QTextCursor
|
||||
from PyQt5.Qt import QTextCursor, QTextDocument
|
||||
|
||||
opening_map = {
|
||||
'css':'/*',
|
||||
@ -24,10 +24,10 @@ def apply_smart_comment(editor, opening='/*', closing='*/', line_comment=None):
|
||||
doc = editor.document()
|
||||
c = QTextCursor(editor.textCursor())
|
||||
c.clearSelection()
|
||||
before_opening = doc.find(opening, c, doc.FindBackward | doc.FindCaseSensitively)
|
||||
before_closing = doc.find(closing, c, doc.FindBackward | doc.FindCaseSensitively)
|
||||
after_opening = doc.find(opening, c, doc.FindCaseSensitively)
|
||||
after_closing = doc.find(closing, c, doc.FindCaseSensitively)
|
||||
before_opening = doc.find(opening, c, QTextDocument.FindFlag.FindBackward | QTextDocument.FindFlag.FindCaseSensitively)
|
||||
before_closing = doc.find(closing, c, QTextDocument.FindFlag.FindBackward | QTextDocument.FindFlag.FindCaseSensitively)
|
||||
after_opening = doc.find(opening, c, QTextDocument.FindFlag.FindCaseSensitively)
|
||||
after_closing = doc.find(closing, c, QTextDocument.FindFlag.FindCaseSensitively)
|
||||
in_block_comment = (not before_opening.isNull() and (before_closing.isNull() or before_opening.position() >= before_closing.position())) and \
|
||||
(not after_closing.isNull() and (after_opening.isNull() or after_closing.position() <= after_opening.position()))
|
||||
if in_block_comment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user