Preferences/PreferencesLexer.py

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

eric ide

mercurial