Preferences/PreferencesLexer.py

changeset 2503
3f1fa98e8e03
parent 2408
dc3a7c9d8f6e
child 2525
8b507a9a2d40
child 2964
84b65fb9e780
equal deleted inserted replaced
2502:f31954903e39 2503:3f1fa98e8e03
9 9
10 from PyQt4.QtGui import QColor, QFont, QApplication 10 from PyQt4.QtGui import QColor, QFont, QApplication
11 from PyQt4.Qsci import QsciLexer 11 from PyQt4.Qsci import QsciLexer
12 12
13 import Preferences 13 import Preferences
14 import Globals
14 15
15 16
16 class PreferencesLexerError(Exception): 17 class PreferencesLexerError(Exception):
17 """ 18 """
18 Class defining a special error for the PreferencesLexer class. 19 Class defining a special error for the PreferencesLexer class.
66 67
67 @param language The lexer language. (string) 68 @param language The lexer language. (string)
68 @param parent The parent widget of this lexer. (QextScintilla) 69 @param parent The parent widget of this lexer. (QextScintilla)
69 """ 70 """
70 super().__init__(parent) 71 super().__init__(parent)
72
73 # These default font families are taken from QScintilla
74 if Globals.isWindowsPlatform():
75 self.__defaultFontFamily = "Courier New"
76 elif Globals.isMacPlatform():
77 self.__defaultFontFamily = "Courier"
78 else:
79 self.__defaultFontFamily = "Bitstream Vera Sans Mono"
71 80
72 # instantiate a lexer object for the given language 81 # instantiate a lexer object for the given language
73 import QScintilla.Lexers 82 import QScintilla.Lexers
74 lex = QScintilla.Lexers.getLexer(language) 83 lex = QScintilla.Lexers.getLexer(language)
75 if lex is None: 84 if lex is None:
101 110
102 self.colours[i] = lex.defaultColor(i) 111 self.colours[i] = lex.defaultColor(i)
103 self.papers[i] = lex.defaultPaper(i) 112 self.papers[i] = lex.defaultPaper(i)
104 self.eolFills[i] = lex.defaultEolFill(i) 113 self.eolFills[i] = lex.defaultEolFill(i)
105 self.fonts[i] = lex.defaultFont(i) 114 self.fonts[i] = lex.defaultFont(i)
115 # Override QScintilla's default font family to
116 # always use a monospaced font
117 self.fonts[i].setFamily(self.__defaultFontFamily)
106 118
107 self.defaultColours[i] = lex.defaultColor(i) 119 self.defaultColours[i] = lex.defaultColor(i)
108 self.defaultPapers[i] = lex.defaultPaper(i) 120 self.defaultPapers[i] = lex.defaultPaper(i)
109 self.defaultEolFills[i] = lex.defaultEolFill(i) 121 self.defaultEolFills[i] = lex.defaultEolFill(i)
110 self.defaultFonts[i] = lex.defaultFont(i) 122 self.defaultFonts[i] = lex.defaultFont(i)
123 self.defaultFonts[i].setFamily(self.__defaultFontFamily)
111 124
112 self.ind2style[index] = i 125 self.ind2style[index] = i
113 index += 1 126 index += 1
114 127
115 self.colorChanged.connect(self.setColor) 128 self.colorChanged.connect(self.setColor)

eric ide

mercurial