From b381966b79e98a36566b289ce211bdad02614dd9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Apr 2014 14:55:11 +0530 Subject: [PATCH] Easier debugging of syntax highlighters --- src/calibre/gui2/tweak_book/editor/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/editor/__init__.py b/src/calibre/gui2/tweak_book/editor/__init__.py index 270f45f2dc..a16cc7fae6 100644 --- a/src/calibre/gui2/tweak_book/editor/__init__.py +++ b/src/calibre/gui2/tweak_book/editor/__init__.py @@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import, __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' -from PyQt4.Qt import QTextCharFormat +from PyQt4.Qt import QTextCharFormat, QFont from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES from calibre.ebooks.oeb.polish.container import guess_type @@ -41,3 +41,9 @@ class SyntaxTextCharFormat(QTextCharFormat): QTextCharFormat.__init__(self, *args) self.setProperty(SYNTAX_PROPERTY, True) + def __repr__(self): + return 'SyntaxFormat(id=%s, color=%s, italic=%s, bold=%s)' % ( + id(self), self.foreground().color().name(), self.fontItalic(), self.fontWeight() >= QFont.DemiBold) + __str__ = __repr__ + +