src/eric7/QScintilla/MiniEditor.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9333
b0541ec21e51
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
13 import contextlib 13 import contextlib
14 14
15 import editorconfig 15 import editorconfig
16 16
17 from PyQt6.QtCore import ( 17 from PyQt6.QtCore import (
18 pyqtSignal, pyqtSlot, Qt, QSignalMapper, QPoint, QTimer, QSize, 18 pyqtSignal,
19 QCoreApplication 19 pyqtSlot,
20 Qt,
21 QSignalMapper,
22 QPoint,
23 QTimer,
24 QSize,
25 QCoreApplication,
20 ) 26 )
21 from PyQt6.QtGui import ( 27 from PyQt6.QtGui import QKeySequence, QPalette, QFont, QPixmap, QActionGroup, QAction
22 QKeySequence, QPalette, QFont, QPixmap, QActionGroup, QAction
23 )
24 from PyQt6.QtWidgets import ( 28 from PyQt6.QtWidgets import (
25 QWidget, QWhatsThis, QDialog, QInputDialog, QApplication, 29 QWidget,
26 QMenu, QVBoxLayout, QHBoxLayout, QLabel 30 QWhatsThis,
31 QDialog,
32 QInputDialog,
33 QApplication,
34 QMenu,
35 QVBoxLayout,
36 QHBoxLayout,
37 QLabel,
27 ) 38 )
28 from PyQt6.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog 39 from PyQt6.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog
29 from PyQt6.Qsci import QsciScintilla 40 from PyQt6.Qsci import QsciScintilla
30 41
31 from EricGui.EricAction import EricAction, createActionGroup 42 from EricGui.EricAction import EricAction, createActionGroup
49 class MiniScintilla(QsciScintillaCompat): 60 class MiniScintilla(QsciScintillaCompat):
50 """ 61 """
51 Class implementing a QsciScintillaCompat subclass for handling focus 62 Class implementing a QsciScintillaCompat subclass for handling focus
52 events. 63 events.
53 """ 64 """
65
54 EncloseChars = { 66 EncloseChars = {
55 '"': '"', 67 '"': '"',
56 "'": "'", 68 "'": "'",
57 "(": "()", 69 "(": "()",
58 ")": "()", 70 ")": "()",
59 "{": "{}", # __IGNORE_WARNING_M613__ 71 "{": "{}", # __IGNORE_WARNING_M613__
60 "}": "{}", # __IGNORE_WARNING_M613__ 72 "}": "{}", # __IGNORE_WARNING_M613__
61 "[": "[]", 73 "[": "[]",
62 "]": "[]", 74 "]": "[]",
63 "<": "<>", 75 "<": "<>",
64 ">": "<>", 76 ">": "<>",
65 } 77 }
66 78
67 def __init__(self, parent=None): 79 def __init__(self, parent=None):
68 """ 80 """
69 Constructor 81 Constructor
70 82
71 @param parent parent widget 83 @param parent parent widget
72 @type QWidget 84 @type QWidget
73 """ 85 """
74 super().__init__(parent) 86 super().__init__(parent)
75 87
76 self.enableMultiCursorSupport() 88 self.enableMultiCursorSupport()
77 89
78 self.mw = parent 90 self.mw = parent
79 91
80 def getFileName(self): 92 def getFileName(self):
81 """ 93 """
82 Public method to return the name of the file being displayed. 94 Public method to return the name of the file being displayed.
83 95
84 @return filename of the displayed file 96 @return filename of the displayed file
85 @rtype str 97 @rtype str
86 """ 98 """
87 return self.mw.getFileName() 99 return self.mw.getFileName()
88 100
89 def editorCommand(self, cmd): 101 def editorCommand(self, cmd):
90 """ 102 """
91 Public method to perform a simple editor command. 103 Public method to perform a simple editor command.
92 104
93 @param cmd the scintilla command to be performed (integer) 105 @param cmd the scintilla command to be performed (integer)
94 """ 106 """
95 if cmd == QsciScintilla.SCI_DELETEBACK: 107 if cmd == QsciScintilla.SCI_DELETEBACK:
96 line, index = self.getCursorPosition() 108 line, index = self.getCursorPosition()
97 text = self.text(line)[index - 1:index + 1] 109 text = self.text(line)[index - 1 : index + 1]
98 matchingPairs = ['()', '[]', '{}', '<>', "''", '""'] 110 matchingPairs = ["()", "[]", "{}", "<>", "''", '""']
99 # __IGNORE_WARNING_M613__ 111 # __IGNORE_WARNING_M613__
100 if text in matchingPairs: 112 if text in matchingPairs:
101 self.delete() 113 self.delete()
102 114
103 super().editorCommand(cmd) 115 super().editorCommand(cmd)
104 116
105 def keyPressEvent(self, ev): 117 def keyPressEvent(self, ev):
106 """ 118 """
107 Protected method to handle the user input a key at a time. 119 Protected method to handle the user input a key at a time.
108 120
109 @param ev key event 121 @param ev key event
110 @type QKeyEvent 122 @type QKeyEvent
111 """ 123 """
124
112 def encloseSelectedText(encString): 125 def encloseSelectedText(encString):
113 """ 126 """
114 Local function to enclose the current selection with some 127 Local function to enclose the current selection with some
115 characters. 128 characters.
116 129
117 @param encString string to use to enclose the selection 130 @param encString string to use to enclose the selection
118 (one or two characters) 131 (one or two characters)
119 @type str 132 @type str
120 """ 133 """
121 startChar = encString[0] 134 startChar = encString[0]
122 endChar = encString[1] if len(encString) == 2 else startChar 135 endChar = encString[1] if len(encString) == 2 else startChar
123 136
124 sline, sindex, eline, eindex = self.getSelection() 137 sline, sindex, eline, eindex = self.getSelection()
125 replaceText = startChar + self.selectedText() + endChar 138 replaceText = startChar + self.selectedText() + endChar
126 self.beginUndoAction() 139 self.beginUndoAction()
127 self.replaceSelectedText(replaceText) 140 self.replaceSelectedText(replaceText)
128 self.endUndoAction() 141 self.endUndoAction()
129 self.setSelection(sline, sindex + 1, eline, eindex + 1) 142 self.setSelection(sline, sindex + 1, eline, eindex + 1)
130 143
131 txt = ev.text() 144 txt = ev.text()
132 145
133 # See it is text to insert. 146 # See it is text to insert.
134 if len(txt) and txt >= " ": 147 if len(txt) and txt >= " ":
135 if ( 148 if self.hasSelectedText() and txt in MiniScintilla.EncloseChars:
136 self.hasSelectedText() and
137 txt in MiniScintilla.EncloseChars
138 ):
139 encloseSelectedText(MiniScintilla.EncloseChars[txt]) 149 encloseSelectedText(MiniScintilla.EncloseChars[txt])
140 ev.accept() 150 ev.accept()
141 return 151 return
142 152
143 super().keyPressEvent(ev) 153 super().keyPressEvent(ev)
144 else: 154 else:
145 ev.ignore() 155 ev.ignore()
146 156
147 def mousePressEvent(self, event): 157 def mousePressEvent(self, event):
148 """ 158 """
149 Protected method to handle the mouse press event. 159 Protected method to handle the mouse press event.
150 160
151 @param event the mouse press event 161 @param event the mouse press event
152 @type QMouseEvent 162 @type QMouseEvent
153 """ 163 """
154 if event.button() == Qt.MouseButton.XButton1: 164 if event.button() == Qt.MouseButton.XButton1:
155 self.undo() 165 self.undo()
156 event.accept() 166 event.accept()
157 elif event.button() == Qt.MouseButton.XButton2: 167 elif event.button() == Qt.MouseButton.XButton2:
158 self.redo() 168 self.redo()
159 event.accept() 169 event.accept()
160 elif ( 170 elif event.button() == Qt.MouseButton.LeftButton and bool(
161 event.button() == Qt.MouseButton.LeftButton and 171 event.modifiers()
162 bool(event.modifiers() & ( 172 & (Qt.KeyboardModifier.MetaModifier | Qt.KeyboardModifier.AltModifier)
163 Qt.KeyboardModifier.MetaModifier |
164 Qt.KeyboardModifier.AltModifier
165 ))
166 ): 173 ):
167 line, index = self.lineIndexFromPoint(event.position().toPoint()) 174 line, index = self.lineIndexFromPoint(event.position().toPoint())
168 self.addCursor(line, index) 175 self.addCursor(line, index)
169 event.accept() 176 event.accept()
170 else: 177 else:
171 super().mousePressEvent(event) 178 super().mousePressEvent(event)
172 179
173 def focusInEvent(self, event): 180 def focusInEvent(self, event):
174 """ 181 """
175 Protected method called when the editor receives focus. 182 Protected method called when the editor receives focus.
176 183
177 This method checks for modifications of the current file and 184 This method checks for modifications of the current file and
178 rereads it upon request. The cursor is placed at the current position 185 rereads it upon request. The cursor is placed at the current position
179 assuming, that it is in the vicinity of the old position after the 186 assuming, that it is in the vicinity of the old position after the
180 reread. 187 reread.
181 188
182 @param event the event object 189 @param event the event object
183 @type QFocusEvent 190 @type QFocusEvent
184 """ 191 """
185 self.mw.editorActGrp.setEnabled(True) 192 self.mw.editorActGrp.setEnabled(True)
186 with contextlib.suppress(AttributeError): 193 with contextlib.suppress(AttributeError):
187 self.setCaretWidth(self.mw.caretWidth) 194 self.setCaretWidth(self.mw.caretWidth)
188 195
189 self.setCursorFlashTime(QApplication.cursorFlashTime()) 196 self.setCursorFlashTime(QApplication.cursorFlashTime())
190 197
191 super().focusInEvent(event) 198 super().focusInEvent(event)
192 199
193 def focusOutEvent(self, event): 200 def focusOutEvent(self, event):
194 """ 201 """
195 Protected method called when the editor loses focus. 202 Protected method called when the editor loses focus.
196 203
197 @param event the event object 204 @param event the event object
198 @type QFocusEvent 205 @type QFocusEvent
199 """ 206 """
200 self.mw.editorActGrp.setEnabled(False) 207 self.mw.editorActGrp.setEnabled(False)
201 self.setCaretWidth(0) 208 self.setCaretWidth(0)
202 209
203 super().focusOutEvent(event) 210 super().focusOutEvent(event)
204 211
205 def removeTrailingWhitespace(self): 212 def removeTrailingWhitespace(self):
206 """ 213 """
207 Public method to remove trailing whitespace. 214 Public method to remove trailing whitespace.
208 """ 215 """
209 searchRE = r"[ \t]+$" # whitespace at the end of a line 216 searchRE = r"[ \t]+$" # whitespace at the end of a line
210 217
211 ok = self.findFirstTarget(searchRE, True, False, False, 0, 0) 218 ok = self.findFirstTarget(searchRE, True, False, False, 0, 0)
212 self.beginUndoAction() 219 self.beginUndoAction()
213 while ok: 220 while ok:
214 self.replaceTarget("") 221 self.replaceTarget("")
215 ok = self.findNextTarget() 222 ok = self.findNextTarget()
217 224
218 225
219 class MiniEditor(EricMainWindow): 226 class MiniEditor(EricMainWindow):
220 """ 227 """
221 Class implementing an editor for simple editing tasks. 228 Class implementing an editor for simple editing tasks.
222 229
223 @signal editorSaved() emitted after the file has been saved 230 @signal editorSaved() emitted after the file has been saved
224 @signal languageChanged(str) emitted when the editors language was set. The 231 @signal languageChanged(str) emitted when the editors language was set. The
225 language is passed as a parameter. 232 language is passed as a parameter.
226 @signal editorRenamed(str) emitted after the editor got a new name 233 @signal editorRenamed(str) emitted after the editor got a new name
227 (i.e. after a 'Save As') 234 (i.e. after a 'Save As')
228 @signal cursorLineChanged(int) emitted when the cursor line was changed 235 @signal cursorLineChanged(int) emitted when the cursor line was changed
229 236
230 @signal refreshed() dummy signal to emulate the Editor interface 237 @signal refreshed() dummy signal to emulate the Editor interface
231 """ 238 """
239
232 editorSaved = pyqtSignal() 240 editorSaved = pyqtSignal()
233 languageChanged = pyqtSignal(str) 241 languageChanged = pyqtSignal(str)
234 editorRenamed = pyqtSignal(str) 242 editorRenamed = pyqtSignal(str)
235 cursorLineChanged = pyqtSignal(int) 243 cursorLineChanged = pyqtSignal(int)
236 244
237 refreshed = pyqtSignal() 245 refreshed = pyqtSignal()
238 246
239 def __init__(self, filename="", filetype="", parent=None, name=None): 247 def __init__(self, filename="", filetype="", parent=None, name=None):
240 """ 248 """
241 Constructor 249 Constructor
242 250
243 @param filename name of the file to open (string) 251 @param filename name of the file to open (string)
244 @param filetype type of the source file (string) 252 @param filetype type of the source file (string)
245 @param parent reference to the parent widget (QWidget) 253 @param parent reference to the parent widget (QWidget)
246 @param name object name of the window (string) 254 @param name object name of the window (string)
247 """ 255 """
248 super().__init__(parent) 256 super().__init__(parent)
249 if name is not None: 257 if name is not None:
250 self.setObjectName(name) 258 self.setObjectName(name)
251 self.setWindowIcon(UI.PixmapCache.getIcon("editor")) 259 self.setWindowIcon(UI.PixmapCache.getIcon("editor"))
252 260
253 self.setStyle(Preferences.getUI("Style"), 261 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet"))
254 Preferences.getUI("StyleSheet")) 262
255
256 self.__textEdit = MiniScintilla(self) 263 self.__textEdit = MiniScintilla(self)
257 self.__textEdit.clearSearchIndicators = self.clearSearchIndicators 264 self.__textEdit.clearSearchIndicators = self.clearSearchIndicators
258 self.__textEdit.setSearchIndicator = self.setSearchIndicator 265 self.__textEdit.setSearchIndicator = self.setSearchIndicator
259 self.__textEdit.setUtf8(True) 266 self.__textEdit.setUtf8(True)
260 267
261 self.getCursorPosition = self.__textEdit.getCursorPosition 268 self.getCursorPosition = self.__textEdit.getCursorPosition
262 self.text = self.__textEdit.text 269 self.text = self.__textEdit.text
263 self.getZoom = self.__textEdit.getZoom 270 self.getZoom = self.__textEdit.getZoom
264 self.zoomTo = self.__textEdit.zoomTo 271 self.zoomTo = self.__textEdit.zoomTo
265 self.zoomIn = self.__textEdit.zoomIn 272 self.zoomIn = self.__textEdit.zoomIn
266 self.zoomOut = self.__textEdit.zoomOut 273 self.zoomOut = self.__textEdit.zoomOut
267 274
268 self.__curFile = filename 275 self.__curFile = filename
269 self.__lastLine = 0 276 self.__lastLine = 0
270 277
271 self.srHistory = { 278 self.srHistory = {"search": [], "replace": []}
272 "search": [],
273 "replace": []
274 }
275 from .SearchReplaceWidget import SearchReplaceWidget 279 from .SearchReplaceWidget import SearchReplaceWidget
280
276 self.__searchWidget = SearchReplaceWidget(False, self, self) 281 self.__searchWidget = SearchReplaceWidget(False, self, self)
277 self.__replaceWidget = SearchReplaceWidget(True, self, self) 282 self.__replaceWidget = SearchReplaceWidget(True, self, self)
278 283
279 from .EditorOutline import EditorOutlineView 284 from .EditorOutline import EditorOutlineView
285
280 self.__sourceOutline = EditorOutlineView(self, populate=False) 286 self.__sourceOutline = EditorOutlineView(self, populate=False)
281 self.__sourceOutline.setMaximumWidth( 287 self.__sourceOutline.setMaximumWidth(
282 Preferences.getEditor("SourceOutlineWidth")) 288 Preferences.getEditor("SourceOutlineWidth")
283 289 )
290
284 hlayout = QHBoxLayout() 291 hlayout = QHBoxLayout()
285 hlayout.setContentsMargins(0, 0, 0, 0) 292 hlayout.setContentsMargins(0, 0, 0, 0)
286 hlayout.setSpacing(1) 293 hlayout.setSpacing(1)
287 hlayout.addWidget(self.__textEdit) 294 hlayout.addWidget(self.__textEdit)
288 hlayout.addWidget(self.__sourceOutline) 295 hlayout.addWidget(self.__sourceOutline)
289 296
290 centralWidget = QWidget() 297 centralWidget = QWidget()
291 layout = QVBoxLayout() 298 layout = QVBoxLayout()
292 layout.setContentsMargins(1, 1, 1, 1) 299 layout.setContentsMargins(1, 1, 1, 1)
293 layout.addLayout(hlayout) 300 layout.addLayout(hlayout)
294 layout.addWidget(self.__searchWidget) 301 layout.addWidget(self.__searchWidget)
295 layout.addWidget(self.__replaceWidget) 302 layout.addWidget(self.__replaceWidget)
296 centralWidget.setLayout(layout) 303 centralWidget.setLayout(layout)
297 self.setCentralWidget(centralWidget) 304 self.setCentralWidget(centralWidget)
298 self.__searchWidget.hide() 305 self.__searchWidget.hide()
299 self.__replaceWidget.hide() 306 self.__replaceWidget.hide()
300 307
301 self.lexer_ = None 308 self.lexer_ = None
302 self.apiLanguage = "" 309 self.apiLanguage = ""
303 self.filetype = "" 310 self.filetype = ""
304 311
305 self.__loadEditorConfig(filename) 312 self.__loadEditorConfig(filename)
306 313
307 self.__createActions() 314 self.__createActions()
308 self.__createMenus() 315 self.__createMenus()
309 self.__createToolBars() 316 self.__createToolBars()
310 self.__createStatusBar() 317 self.__createStatusBar()
311 318
312 self.__loadConfiguration() 319 self.__loadConfiguration()
313 self.__readSettings() 320 self.__readSettings()
314 321
315 # clear QScintilla defined keyboard commands 322 # clear QScintilla defined keyboard commands
316 # we do our own handling through the view manager 323 # we do our own handling through the view manager
317 self.__textEdit.clearAlternateKeys() 324 self.__textEdit.clearAlternateKeys()
318 self.__textEdit.clearKeys() 325 self.__textEdit.clearKeys()
319 326
320 # initialise the mark occurrences timer 327 # initialise the mark occurrences timer
321 self.__markOccurrencesTimer = QTimer(self) 328 self.__markOccurrencesTimer = QTimer(self)
322 self.__markOccurrencesTimer.setSingleShot(True) 329 self.__markOccurrencesTimer.setSingleShot(True)
323 self.__markOccurrencesTimer.setInterval( 330 self.__markOccurrencesTimer.setInterval(
324 Preferences.getEditor("MarkOccurrencesTimeout")) 331 Preferences.getEditor("MarkOccurrencesTimeout")
332 )
325 self.__markOccurrencesTimer.timeout.connect(self.__markOccurrences) 333 self.__markOccurrencesTimer.timeout.connect(self.__markOccurrences)
326 self.__markedText = "" 334 self.__markedText = ""
327 335
328 self.__changeTimer = QTimer(self) 336 self.__changeTimer = QTimer(self)
329 self.__changeTimer.setSingleShot(True) 337 self.__changeTimer.setSingleShot(True)
330 self.__changeTimer.setInterval(5 * 1000) 338 self.__changeTimer.setInterval(5 * 1000)
331 self.__textEdit.textChanged.connect(self.__resetChangeTimer) 339 self.__textEdit.textChanged.connect(self.__resetChangeTimer)
332 340
333 self.__textEdit.textChanged.connect(self.__documentWasModified) 341 self.__textEdit.textChanged.connect(self.__documentWasModified)
334 self.__textEdit.modificationChanged.connect(self.__modificationChanged) 342 self.__textEdit.modificationChanged.connect(self.__modificationChanged)
335 self.__textEdit.cursorPositionChanged.connect( 343 self.__textEdit.cursorPositionChanged.connect(self.__cursorPositionChanged)
336 self.__cursorPositionChanged)
337 self.__textEdit.linesChanged.connect(self.__resizeLinenoMargin) 344 self.__textEdit.linesChanged.connect(self.__resizeLinenoMargin)
338 345
339 self.__textEdit.setContextMenuPolicy( 346 self.__textEdit.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
340 Qt.ContextMenuPolicy.CustomContextMenu) 347 self.__textEdit.customContextMenuRequested.connect(self.__contextMenuRequested)
341 self.__textEdit.customContextMenuRequested.connect( 348
342 self.__contextMenuRequested)
343
344 self.__textEdit.selectionChanged.connect( 349 self.__textEdit.selectionChanged.connect(
345 lambda: self.__searchWidget.selectionChanged(self.__textEdit)) 350 lambda: self.__searchWidget.selectionChanged(self.__textEdit)
351 )
346 self.__textEdit.selectionChanged.connect( 352 self.__textEdit.selectionChanged.connect(
347 lambda: self.__replaceWidget.selectionChanged(self.__textEdit)) 353 lambda: self.__replaceWidget.selectionChanged(self.__textEdit)
348 354 )
355
349 if filename: 356 if filename:
350 self.__loadFile(filename, filetype) 357 self.__loadFile(filename, filetype)
351 else: 358 else:
352 self.__setCurrentFile("") 359 self.__setCurrentFile("")
353 self.encoding = self.__getEditorConfig("DefaultEncoding") 360 self.encoding = self.__getEditorConfig("DefaultEncoding")
354 361
355 self.__checkActions() 362 self.__checkActions()
356 363
357 self.__sourceOutline.setActive(True) 364 self.__sourceOutline.setActive(True)
358 self.__sourceOutline.setVisible( 365 self.__sourceOutline.setVisible(
359 self.__sourceOutline.isSupportedLanguage( 366 self.__sourceOutline.isSupportedLanguage(self.getLanguage())
360 self.getLanguage()
361 )
362 ) 367 )
363 self.__changeTimer.timeout.connect(self.__sourceOutline.repopulate) 368 self.__changeTimer.timeout.connect(self.__sourceOutline.repopulate)
364 self.languageChanged.connect(self.__editorChanged) 369 self.languageChanged.connect(self.__editorChanged)
365 self.editorRenamed.connect(self.__editorChanged) 370 self.editorRenamed.connect(self.__editorChanged)
366 371
367 def closeEvent(self, event): 372 def closeEvent(self, event):
368 """ 373 """
369 Protected method to handle the close event. 374 Protected method to handle the close event.
370 375
371 @param event close event (QCloseEvent) 376 @param event close event (QCloseEvent)
372 """ 377 """
373 if self.__maybeSave(): 378 if self.__maybeSave():
374 self.__writeSettings() 379 self.__writeSettings()
375 event.accept() 380 event.accept()
376 else: 381 else:
377 event.ignore() 382 event.ignore()
378 383
379 def __newFile(self): 384 def __newFile(self):
380 """ 385 """
381 Private slot to create a new file. 386 Private slot to create a new file.
382 """ 387 """
383 if self.__maybeSave(): 388 if self.__maybeSave():
384 self.__textEdit.clear() 389 self.__textEdit.clear()
385 self.__setCurrentFile("") 390 self.__setCurrentFile("")
386 391
387 self.__checkActions() 392 self.__checkActions()
388 393
389 def __open(self): 394 def __open(self):
390 """ 395 """
391 Private slot to open a file. 396 Private slot to open a file.
392 """ 397 """
393 if self.__maybeSave(): 398 if self.__maybeSave():
394 fileName = EricFileDialog.getOpenFileName(self) 399 fileName = EricFileDialog.getOpenFileName(self)
395 if fileName: 400 if fileName:
396 self.__loadFile(fileName) 401 self.__loadFile(fileName)
397 self.__checkActions() 402 self.__checkActions()
398 403
399 def __save(self): 404 def __save(self):
400 """ 405 """
401 Private slot to save a file. 406 Private slot to save a file.
402 407
403 @return flag indicating success (boolean) 408 @return flag indicating success (boolean)
404 """ 409 """
405 if not self.__curFile: 410 if not self.__curFile:
406 return self.__saveAs() 411 return self.__saveAs()
407 else: 412 else:
408 return self.__saveFile(self.__curFile) 413 return self.__saveFile(self.__curFile)
409 414
410 def __saveAs(self): 415 def __saveAs(self):
411 """ 416 """
412 Private slot to save a file with a new name. 417 Private slot to save a file with a new name.
413 418
414 @return flag indicating success (boolean) 419 @return flag indicating success (boolean)
415 """ 420 """
416 fileName = EricFileDialog.getSaveFileName(self) 421 fileName = EricFileDialog.getSaveFileName(self)
417 if not fileName: 422 if not fileName:
418 return False 423 return False
419 424
420 result = self.__saveFile(fileName) 425 result = self.__saveFile(fileName)
421 426
422 self.editorRenamed.emit(fileName) 427 self.editorRenamed.emit(fileName)
423 428
424 return result 429 return result
425 430
426 def __saveCopy(self): 431 def __saveCopy(self):
427 """ 432 """
428 Private slot to save a copy of the file with a new name. 433 Private slot to save a copy of the file with a new name.
429 """ 434 """
430 fileName = EricFileDialog.getSaveFileName(self) 435 fileName = EricFileDialog.getSaveFileName(self)
431 if not fileName: 436 if not fileName:
432 return 437 return
433 438
434 self.__writeFile(fileName) 439 self.__writeFile(fileName)
435 440
436 def __about(self): 441 def __about(self):
437 """ 442 """
438 Private slot to show a little About message. 443 Private slot to show a little About message.
439 """ 444 """
440 EricMessageBox.about( 445 EricMessageBox.about(
442 self.tr("About eric Mini Editor"), 447 self.tr("About eric Mini Editor"),
443 self.tr( 448 self.tr(
444 "The eric Mini Editor is an editor component" 449 "The eric Mini Editor is an editor component"
445 " based on QScintilla. It may be used for simple" 450 " based on QScintilla. It may be used for simple"
446 " editing tasks, that don't need the power of" 451 " editing tasks, that don't need the power of"
447 " a full blown editor.")) 452 " a full blown editor."
448 453 ),
454 )
455
449 def __aboutQt(self): 456 def __aboutQt(self):
450 """ 457 """
451 Private slot to handle the About Qt dialog. 458 Private slot to handle the About Qt dialog.
452 """ 459 """
453 EricMessageBox.aboutQt(self, "eric Mini Editor") 460 EricMessageBox.aboutQt(self, "eric Mini Editor")
454 461
455 def __whatsThis(self): 462 def __whatsThis(self):
456 """ 463 """
457 Private slot called in to enter Whats This mode. 464 Private slot called in to enter Whats This mode.
458 """ 465 """
459 QWhatsThis.enterWhatsThisMode() 466 QWhatsThis.enterWhatsThisMode()
460 467
461 def __documentWasModified(self): 468 def __documentWasModified(self):
462 """ 469 """
463 Private slot to handle a change in the documents modification status. 470 Private slot to handle a change in the documents modification status.
464 """ 471 """
465 self.setWindowModified(self.__textEdit.isModified()) 472 self.setWindowModified(self.__textEdit.isModified())
466 473
467 def __checkActions(self, setSb=True): 474 def __checkActions(self, setSb=True):
468 """ 475 """
469 Private slot to check some actions for their enable/disable status 476 Private slot to check some actions for their enable/disable status
470 and set the statusbar info. 477 and set the statusbar info.
471 478
472 @param setSb flag indicating an update of the status bar is wanted 479 @param setSb flag indicating an update of the status bar is wanted
473 (boolean) 480 (boolean)
474 """ 481 """
475 self.saveAct.setEnabled(self.__textEdit.isModified()) 482 self.saveAct.setEnabled(self.__textEdit.isModified())
476 483
477 self.undoAct.setEnabled(self.__textEdit.isUndoAvailable()) 484 self.undoAct.setEnabled(self.__textEdit.isUndoAvailable())
478 self.redoAct.setEnabled(self.__textEdit.isRedoAvailable()) 485 self.redoAct.setEnabled(self.__textEdit.isRedoAvailable())
479 486
480 if setSb: 487 if setSb:
481 line, pos = self.getCursorPosition() 488 line, pos = self.getCursorPosition()
482 lang = self.getLanguage() 489 lang = self.getLanguage()
483 self.__setSbFile(line + 1, pos, lang) 490 self.__setSbFile(line + 1, pos, lang)
484 491
485 def __setSbFile(self, line=None, pos=None, language=None, zoom=None): 492 def __setSbFile(self, line=None, pos=None, language=None, zoom=None):
486 """ 493 """
487 Private method to set the file info in the status bar. 494 Private method to set the file info in the status bar.
488 495
489 @param line line number to display 496 @param line line number to display
490 @type int 497 @type int
491 @param pos character position to display 498 @param pos character position to display
492 @type int 499 @type int
493 @param language language to display 500 @param language language to display
494 @type str 501 @type str
495 @param zoom zoom value 502 @param zoom zoom value
496 @type int 503 @type int
497 """ 504 """
498 if not self.__curFile: 505 if not self.__curFile:
499 writ = ' ' 506 writ = " "
500 else: 507 else:
501 if os.access(self.__curFile, os.W_OK): 508 if os.access(self.__curFile, os.W_OK):
502 writ = ' rw' 509 writ = " rw"
503 else: 510 else:
504 writ = ' ro' 511 writ = " ro"
505 512
506 self.sbWritable.setText(writ) 513 self.sbWritable.setText(writ)
507 514
508 if line is None: 515 if line is None:
509 line = '' 516 line = ""
510 self.sbLine.setText(self.tr('Line: {0:5}').format(line)) 517 self.sbLine.setText(self.tr("Line: {0:5}").format(line))
511 518
512 if pos is None: 519 if pos is None:
513 pos = '' 520 pos = ""
514 self.sbPos.setText(self.tr('Pos: {0:5}').format(pos)) 521 self.sbPos.setText(self.tr("Pos: {0:5}").format(pos))
515 522
516 if language is None: 523 if language is None:
517 pixmap = QPixmap() 524 pixmap = QPixmap()
518 elif language == "": 525 elif language == "":
519 pixmap = UI.PixmapCache.getPixmap("fileText") 526 pixmap = UI.PixmapCache.getPixmap("fileText")
520 else: 527 else:
521 import QScintilla.Lexers 528 import QScintilla.Lexers
529
522 pixmap = QScintilla.Lexers.getLanguageIcon(language, True) 530 pixmap = QScintilla.Lexers.getLanguageIcon(language, True)
523 self.sbLanguage.setPixmap(pixmap) 531 self.sbLanguage.setPixmap(pixmap)
524 if pixmap.isNull(): 532 if pixmap.isNull():
525 self.sbLanguage.setText(language) 533 self.sbLanguage.setText(language)
526 self.sbLanguage.setToolTip("") 534 self.sbLanguage.setToolTip("")
527 else: 535 else:
528 self.sbLanguage.setText("") 536 self.sbLanguage.setText("")
529 self.sbLanguage.setToolTip( 537 self.sbLanguage.setToolTip(self.tr("Language: {0}").format(language))
530 self.tr('Language: {0}').format(language)) 538
531
532 if zoom is None: 539 if zoom is None:
533 self.sbZoom.setValue(self.getZoom()) 540 self.sbZoom.setValue(self.getZoom())
534 else: 541 else:
535 self.sbZoom.setValue(zoom) 542 self.sbZoom.setValue(zoom)
536 543
537 def __readShortcut(self, act, category): 544 def __readShortcut(self, act, category):
538 """ 545 """
539 Private function to read a single keyboard shortcut from the settings. 546 Private function to read a single keyboard shortcut from the settings.
540 547
541 @param act reference to the action object (EricAction) 548 @param act reference to the action object (EricAction)
542 @param category category the action belongs to (string) 549 @param category category the action belongs to (string)
543 """ 550 """
544 if act.objectName(): 551 if act.objectName():
545 accel = Preferences.getSettings().value( 552 accel = Preferences.getSettings().value(
546 "Shortcuts/{0}/{1}/Accel".format(category, act.objectName())) 553 "Shortcuts/{0}/{1}/Accel".format(category, act.objectName())
554 )
547 if accel is not None: 555 if accel is not None:
548 act.setShortcut(QKeySequence(accel)) 556 act.setShortcut(QKeySequence(accel))
549 accel = Preferences.getSettings().value( 557 accel = Preferences.getSettings().value(
550 "Shortcuts/{0}/{1}/AltAccel".format( 558 "Shortcuts/{0}/{1}/AltAccel".format(category, act.objectName())
551 category, act.objectName())) 559 )
552 if accel is not None: 560 if accel is not None:
553 act.setAlternateShortcut(QKeySequence(accel), removeEmpty=True) 561 act.setAlternateShortcut(QKeySequence(accel), removeEmpty=True)
554 562
555 def __createActions(self): 563 def __createActions(self):
556 """ 564 """
557 Private method to create the actions. 565 Private method to create the actions.
558 """ 566 """
559 self.fileActions = [] 567 self.fileActions = []
560 self.editActions = [] 568 self.editActions = []
561 self.helpActions = [] 569 self.helpActions = []
562 self.searchActions = [] 570 self.searchActions = []
563 self.viewActions = [] 571 self.viewActions = []
564 self.configActions = [] 572 self.configActions = []
565 573
566 self.__createFileActions() 574 self.__createFileActions()
567 self.__createEditActions() 575 self.__createEditActions()
568 self.__createHelpActions() 576 self.__createHelpActions()
569 self.__createSearchActions() 577 self.__createSearchActions()
570 self.__createViewActions() 578 self.__createViewActions()
571 self.__createConfigActions() 579 self.__createConfigActions()
572 580
573 # read the keyboard shortcuts and make them identical to the main 581 # read the keyboard shortcuts and make them identical to the main
574 # eric shortcuts 582 # eric shortcuts
575 for act in self.helpActions + self.configActions: 583 for act in self.helpActions + self.configActions:
576 self.__readShortcut(act, "General") 584 self.__readShortcut(act, "General")
577 for act in self.editActions: 585 for act in self.editActions:
580 self.__readShortcut(act, "File") 588 self.__readShortcut(act, "File")
581 for act in self.searchActions: 589 for act in self.searchActions:
582 self.__readShortcut(act, "Search") 590 self.__readShortcut(act, "Search")
583 for act in self.viewActions: 591 for act in self.viewActions:
584 self.__readShortcut(act, "View") 592 self.__readShortcut(act, "View")
585 593
586 def __createFileActions(self): 594 def __createFileActions(self):
587 """ 595 """
588 Private method to create the File actions. 596 Private method to create the File actions.
589 """ 597 """
590 self.newAct = EricAction( 598 self.newAct = EricAction(
591 self.tr('New'), 599 self.tr("New"),
592 UI.PixmapCache.getIcon("new"), 600 UI.PixmapCache.getIcon("new"),
593 self.tr('&New'), 601 self.tr("&New"),
594 QKeySequence(self.tr("Ctrl+N", "File|New")), 602 QKeySequence(self.tr("Ctrl+N", "File|New")),
595 0, self, 'vm_file_new') 603 0,
596 self.newAct.setStatusTip(self.tr('Open an empty editor window')) 604 self,
597 self.newAct.setWhatsThis(self.tr( 605 "vm_file_new",
598 """<b>New</b>""" 606 )
599 """<p>An empty editor window will be created.</p>""" 607 self.newAct.setStatusTip(self.tr("Open an empty editor window"))
600 )) 608 self.newAct.setWhatsThis(
609 self.tr(
610 """<b>New</b>""" """<p>An empty editor window will be created.</p>"""
611 )
612 )
601 self.newAct.triggered.connect(self.__newFile) 613 self.newAct.triggered.connect(self.__newFile)
602 self.fileActions.append(self.newAct) 614 self.fileActions.append(self.newAct)
603 615
604 self.openAct = EricAction( 616 self.openAct = EricAction(
605 self.tr('Open'), 617 self.tr("Open"),
606 UI.PixmapCache.getIcon("open"), 618 UI.PixmapCache.getIcon("open"),
607 self.tr('&Open...'), 619 self.tr("&Open..."),
608 QKeySequence(self.tr("Ctrl+O", "File|Open")), 620 QKeySequence(self.tr("Ctrl+O", "File|Open")),
609 0, self, 'vm_file_open') 621 0,
610 self.openAct.setStatusTip(self.tr('Open a file')) 622 self,
611 self.openAct.setWhatsThis(self.tr( 623 "vm_file_open",
612 """<b>Open a file</b>""" 624 )
613 """<p>You will be asked for the name of a file to be opened.</p>""" 625 self.openAct.setStatusTip(self.tr("Open a file"))
614 )) 626 self.openAct.setWhatsThis(
627 self.tr(
628 """<b>Open a file</b>"""
629 """<p>You will be asked for the name of a file to be opened.</p>"""
630 )
631 )
615 self.openAct.triggered.connect(self.__open) 632 self.openAct.triggered.connect(self.__open)
616 self.fileActions.append(self.openAct) 633 self.fileActions.append(self.openAct)
617 634
618 self.saveAct = EricAction( 635 self.saveAct = EricAction(
619 self.tr('Save'), 636 self.tr("Save"),
620 UI.PixmapCache.getIcon("fileSave"), 637 UI.PixmapCache.getIcon("fileSave"),
621 self.tr('&Save'), 638 self.tr("&Save"),
622 QKeySequence(self.tr("Ctrl+S", "File|Save")), 639 QKeySequence(self.tr("Ctrl+S", "File|Save")),
623 0, self, 'vm_file_save') 640 0,
624 self.saveAct.setStatusTip(self.tr('Save the current file')) 641 self,
625 self.saveAct.setWhatsThis(self.tr( 642 "vm_file_save",
626 """<b>Save File</b>""" 643 )
627 """<p>Save the contents of current editor window.</p>""" 644 self.saveAct.setStatusTip(self.tr("Save the current file"))
628 )) 645 self.saveAct.setWhatsThis(
646 self.tr(
647 """<b>Save File</b>"""
648 """<p>Save the contents of current editor window.</p>"""
649 )
650 )
629 self.saveAct.triggered.connect(self.__save) 651 self.saveAct.triggered.connect(self.__save)
630 self.fileActions.append(self.saveAct) 652 self.fileActions.append(self.saveAct)
631 653
632 self.saveAsAct = EricAction( 654 self.saveAsAct = EricAction(
633 self.tr('Save as'), 655 self.tr("Save as"),
634 UI.PixmapCache.getIcon("fileSaveAs"), 656 UI.PixmapCache.getIcon("fileSaveAs"),
635 self.tr('Save &as...'), 657 self.tr("Save &as..."),
636 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")), 658 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")),
637 0, self, 'vm_file_save_as') 659 0,
638 self.saveAsAct.setStatusTip(self.tr( 660 self,
639 'Save the current file to a new one')) 661 "vm_file_save_as",
640 self.saveAsAct.setWhatsThis(self.tr( 662 )
641 """<b>Save File as</b>""" 663 self.saveAsAct.setStatusTip(self.tr("Save the current file to a new one"))
642 """<p>Save the contents of current editor window to a new file.""" 664 self.saveAsAct.setWhatsThis(
643 """ The file can be entered in a file selection dialog.</p>""" 665 self.tr(
644 )) 666 """<b>Save File as</b>"""
667 """<p>Save the contents of current editor window to a new file."""
668 """ The file can be entered in a file selection dialog.</p>"""
669 )
670 )
645 self.saveAsAct.triggered.connect(self.__saveAs) 671 self.saveAsAct.triggered.connect(self.__saveAs)
646 self.fileActions.append(self.saveAsAct) 672 self.fileActions.append(self.saveAsAct)
647 673
648 self.saveCopyAct = EricAction( 674 self.saveCopyAct = EricAction(
649 self.tr('Save Copy'), 675 self.tr("Save Copy"),
650 UI.PixmapCache.getIcon("fileSaveCopy"), 676 UI.PixmapCache.getIcon("fileSaveCopy"),
651 self.tr('Save &Copy...'), 677 self.tr("Save &Copy..."),
652 0, 0, self, 'vm_file_save_copy') 678 0,
653 self.saveCopyAct.setStatusTip(self.tr( 679 0,
654 'Save a copy of the current file')) 680 self,
655 self.saveCopyAct.setWhatsThis(self.tr( 681 "vm_file_save_copy",
656 """<b>Save Copy</b>""" 682 )
657 """<p>Save a copy of the contents of current editor window.""" 683 self.saveCopyAct.setStatusTip(self.tr("Save a copy of the current file"))
658 """ The file can be entered in a file selection dialog.</p>""" 684 self.saveCopyAct.setWhatsThis(
659 )) 685 self.tr(
686 """<b>Save Copy</b>"""
687 """<p>Save a copy of the contents of current editor window."""
688 """ The file can be entered in a file selection dialog.</p>"""
689 )
690 )
660 self.saveCopyAct.triggered.connect(self.__saveCopy) 691 self.saveCopyAct.triggered.connect(self.__saveCopy)
661 self.fileActions.append(self.saveCopyAct) 692 self.fileActions.append(self.saveCopyAct)
662 693
663 self.closeAct = EricAction( 694 self.closeAct = EricAction(
664 self.tr('Close'), 695 self.tr("Close"),
665 UI.PixmapCache.getIcon("close"), 696 UI.PixmapCache.getIcon("close"),
666 self.tr('&Close'), 697 self.tr("&Close"),
667 QKeySequence(self.tr("Ctrl+W", "File|Close")), 698 QKeySequence(self.tr("Ctrl+W", "File|Close")),
668 0, self, 'vm_file_close') 699 0,
669 self.closeAct.setStatusTip(self.tr('Close the editor window')) 700 self,
670 self.closeAct.setWhatsThis(self.tr( 701 "vm_file_close",
671 """<b>Close Window</b>""" 702 )
672 """<p>Close the current window.</p>""" 703 self.closeAct.setStatusTip(self.tr("Close the editor window"))
673 )) 704 self.closeAct.setWhatsThis(
705 self.tr("""<b>Close Window</b>""" """<p>Close the current window.</p>""")
706 )
674 self.closeAct.triggered.connect(self.close) 707 self.closeAct.triggered.connect(self.close)
675 self.fileActions.append(self.closeAct) 708 self.fileActions.append(self.closeAct)
676 709
677 self.printAct = EricAction( 710 self.printAct = EricAction(
678 self.tr('Print'), 711 self.tr("Print"),
679 UI.PixmapCache.getIcon("print"), 712 UI.PixmapCache.getIcon("print"),
680 self.tr('&Print'), 713 self.tr("&Print"),
681 QKeySequence(self.tr("Ctrl+P", "File|Print")), 714 QKeySequence(self.tr("Ctrl+P", "File|Print")),
682 0, self, 'vm_file_print') 715 0,
683 self.printAct.setStatusTip(self.tr('Print the current file')) 716 self,
684 self.printAct.setWhatsThis(self.tr( 717 "vm_file_print",
685 """<b>Print File</b>""" 718 )
686 """<p>Print the contents of the current file.</p>""" 719 self.printAct.setStatusTip(self.tr("Print the current file"))
687 )) 720 self.printAct.setWhatsThis(
721 self.tr(
722 """<b>Print File</b>"""
723 """<p>Print the contents of the current file.</p>"""
724 )
725 )
688 self.printAct.triggered.connect(self.__printFile) 726 self.printAct.triggered.connect(self.__printFile)
689 self.fileActions.append(self.printAct) 727 self.fileActions.append(self.printAct)
690 728
691 self.printPreviewAct = EricAction( 729 self.printPreviewAct = EricAction(
692 self.tr('Print Preview'), 730 self.tr("Print Preview"),
693 UI.PixmapCache.getIcon("printPreview"), 731 UI.PixmapCache.getIcon("printPreview"),
694 QCoreApplication.translate('ViewManager', 'Print Preview'), 732 QCoreApplication.translate("ViewManager", "Print Preview"),
695 0, 0, self, 'vm_file_print_preview') 733 0,
696 self.printPreviewAct.setStatusTip(self.tr( 734 0,
697 'Print preview of the current file')) 735 self,
698 self.printPreviewAct.setWhatsThis(self.tr( 736 "vm_file_print_preview",
699 """<b>Print Preview</b>""" 737 )
700 """<p>Print preview of the current file.</p>""" 738 self.printPreviewAct.setStatusTip(self.tr("Print preview of the current file"))
701 )) 739 self.printPreviewAct.setWhatsThis(
740 self.tr(
741 """<b>Print Preview</b>"""
742 """<p>Print preview of the current file.</p>"""
743 )
744 )
702 self.printPreviewAct.triggered.connect(self.__printPreviewFile) 745 self.printPreviewAct.triggered.connect(self.__printPreviewFile)
703 self.fileActions.append(self.printPreviewAct) 746 self.fileActions.append(self.printPreviewAct)
704 747
705 def __createEditActions(self): 748 def __createEditActions(self):
706 """ 749 """
707 Private method to create the Edit actions. 750 Private method to create the Edit actions.
708 """ 751 """
709 self.undoAct = EricAction( 752 self.undoAct = EricAction(
710 self.tr('Undo'), 753 self.tr("Undo"),
711 UI.PixmapCache.getIcon("editUndo"), 754 UI.PixmapCache.getIcon("editUndo"),
712 self.tr('&Undo'), 755 self.tr("&Undo"),
713 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")), 756 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")),
714 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")), 757 QKeySequence(self.tr("Alt+Backspace", "Edit|Undo")),
715 self, 'vm_edit_undo') 758 self,
716 self.undoAct.setStatusTip(self.tr('Undo the last change')) 759 "vm_edit_undo",
717 self.undoAct.setWhatsThis(self.tr( 760 )
718 """<b>Undo</b>""" 761 self.undoAct.setStatusTip(self.tr("Undo the last change"))
719 """<p>Undo the last change done in the current editor.</p>""" 762 self.undoAct.setWhatsThis(
720 )) 763 self.tr(
764 """<b>Undo</b>"""
765 """<p>Undo the last change done in the current editor.</p>"""
766 )
767 )
721 self.undoAct.triggered.connect(self.__undo) 768 self.undoAct.triggered.connect(self.__undo)
722 self.editActions.append(self.undoAct) 769 self.editActions.append(self.undoAct)
723 770
724 self.redoAct = EricAction( 771 self.redoAct = EricAction(
725 self.tr('Redo'), 772 self.tr("Redo"),
726 UI.PixmapCache.getIcon("editRedo"), 773 UI.PixmapCache.getIcon("editRedo"),
727 self.tr('&Redo'), 774 self.tr("&Redo"),
728 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")), 775 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")),
729 0, self, 'vm_edit_redo') 776 0,
730 self.redoAct.setStatusTip(self.tr('Redo the last change')) 777 self,
731 self.redoAct.setWhatsThis(self.tr( 778 "vm_edit_redo",
732 """<b>Redo</b>""" 779 )
733 """<p>Redo the last change done in the current editor.</p>""" 780 self.redoAct.setStatusTip(self.tr("Redo the last change"))
734 )) 781 self.redoAct.setWhatsThis(
782 self.tr(
783 """<b>Redo</b>"""
784 """<p>Redo the last change done in the current editor.</p>"""
785 )
786 )
735 self.redoAct.triggered.connect(self.__redo) 787 self.redoAct.triggered.connect(self.__redo)
736 self.editActions.append(self.redoAct) 788 self.editActions.append(self.redoAct)
737 789
738 self.cutAct = EricAction( 790 self.cutAct = EricAction(
739 self.tr('Cut'), 791 self.tr("Cut"),
740 UI.PixmapCache.getIcon("editCut"), 792 UI.PixmapCache.getIcon("editCut"),
741 self.tr('Cu&t'), 793 self.tr("Cu&t"),
742 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")), 794 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")),
743 QKeySequence(self.tr("Shift+Del", "Edit|Cut")), 795 QKeySequence(self.tr("Shift+Del", "Edit|Cut")),
744 self, 'vm_edit_cut') 796 self,
745 self.cutAct.setStatusTip(self.tr('Cut the selection')) 797 "vm_edit_cut",
746 self.cutAct.setWhatsThis(self.tr( 798 )
747 """<b>Cut</b>""" 799 self.cutAct.setStatusTip(self.tr("Cut the selection"))
748 """<p>Cut the selected text of the current editor to the""" 800 self.cutAct.setWhatsThis(
749 """ clipboard.</p>""" 801 self.tr(
750 )) 802 """<b>Cut</b>"""
803 """<p>Cut the selected text of the current editor to the"""
804 """ clipboard.</p>"""
805 )
806 )
751 self.cutAct.triggered.connect(self.__textEdit.cut) 807 self.cutAct.triggered.connect(self.__textEdit.cut)
752 self.editActions.append(self.cutAct) 808 self.editActions.append(self.cutAct)
753 809
754 self.copyAct = EricAction( 810 self.copyAct = EricAction(
755 self.tr('Copy'), 811 self.tr("Copy"),
756 UI.PixmapCache.getIcon("editCopy"), 812 UI.PixmapCache.getIcon("editCopy"),
757 self.tr('&Copy'), 813 self.tr("&Copy"),
758 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")), 814 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")),
759 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")), 815 QKeySequence(self.tr("Ctrl+Ins", "Edit|Copy")),
760 self, 'vm_edit_copy') 816 self,
761 self.copyAct.setStatusTip(self.tr('Copy the selection')) 817 "vm_edit_copy",
762 self.copyAct.setWhatsThis(self.tr( 818 )
763 """<b>Copy</b>""" 819 self.copyAct.setStatusTip(self.tr("Copy the selection"))
764 """<p>Copy the selected text of the current editor to the""" 820 self.copyAct.setWhatsThis(
765 """ clipboard.</p>""" 821 self.tr(
766 )) 822 """<b>Copy</b>"""
823 """<p>Copy the selected text of the current editor to the"""
824 """ clipboard.</p>"""
825 )
826 )
767 self.copyAct.triggered.connect(self.__textEdit.copy) 827 self.copyAct.triggered.connect(self.__textEdit.copy)
768 self.editActions.append(self.copyAct) 828 self.editActions.append(self.copyAct)
769 829
770 self.pasteAct = EricAction( 830 self.pasteAct = EricAction(
771 self.tr('Paste'), 831 self.tr("Paste"),
772 UI.PixmapCache.getIcon("editPaste"), 832 UI.PixmapCache.getIcon("editPaste"),
773 self.tr('&Paste'), 833 self.tr("&Paste"),
774 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")), 834 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")),
775 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")), 835 QKeySequence(self.tr("Shift+Ins", "Edit|Paste")),
776 self, 'vm_edit_paste') 836 self,
777 self.pasteAct.setStatusTip(self.tr( 837 "vm_edit_paste",
778 'Paste the last cut/copied text')) 838 )
779 self.pasteAct.setWhatsThis(self.tr( 839 self.pasteAct.setStatusTip(self.tr("Paste the last cut/copied text"))
780 """<b>Paste</b>""" 840 self.pasteAct.setWhatsThis(
781 """<p>Paste the last cut/copied text from the clipboard to""" 841 self.tr(
782 """ the current editor.</p>""" 842 """<b>Paste</b>"""
783 )) 843 """<p>Paste the last cut/copied text from the clipboard to"""
844 """ the current editor.</p>"""
845 )
846 )
784 self.pasteAct.triggered.connect(self.__textEdit.paste) 847 self.pasteAct.triggered.connect(self.__textEdit.paste)
785 self.editActions.append(self.pasteAct) 848 self.editActions.append(self.pasteAct)
786 849
787 self.deleteAct = EricAction( 850 self.deleteAct = EricAction(
788 self.tr('Clear'), 851 self.tr("Clear"),
789 UI.PixmapCache.getIcon("editDelete"), 852 UI.PixmapCache.getIcon("editDelete"),
790 self.tr('Cl&ear'), 853 self.tr("Cl&ear"),
791 QKeySequence(self.tr("Alt+Shift+C", "Edit|Clear")), 854 QKeySequence(self.tr("Alt+Shift+C", "Edit|Clear")),
792 0, 855 0,
793 self, 'vm_edit_clear') 856 self,
794 self.deleteAct.setStatusTip(self.tr('Clear all text')) 857 "vm_edit_clear",
795 self.deleteAct.setWhatsThis(self.tr( 858 )
796 """<b>Clear</b>""" 859 self.deleteAct.setStatusTip(self.tr("Clear all text"))
797 """<p>Delete all text of the current editor.</p>""" 860 self.deleteAct.setWhatsThis(
798 )) 861 self.tr(
862 """<b>Clear</b>""" """<p>Delete all text of the current editor.</p>"""
863 )
864 )
799 self.deleteAct.triggered.connect(self.__textEdit.clear) 865 self.deleteAct.triggered.connect(self.__textEdit.clear)
800 self.editActions.append(self.deleteAct) 866 self.editActions.append(self.deleteAct)
801 867
802 self.cutAct.setEnabled(False) 868 self.cutAct.setEnabled(False)
803 self.copyAct.setEnabled(False) 869 self.copyAct.setEnabled(False)
804 self.__textEdit.copyAvailable.connect(self.cutAct.setEnabled) 870 self.__textEdit.copyAvailable.connect(self.cutAct.setEnabled)
805 self.__textEdit.copyAvailable.connect(self.copyAct.setEnabled) 871 self.__textEdit.copyAvailable.connect(self.copyAct.setEnabled)
806 872
807 #################################################################### 873 ####################################################################
808 ## Below follow the actions for QScintilla standard commands. 874 ## Below follow the actions for QScintilla standard commands.
809 #################################################################### 875 ####################################################################
810 876
811 self.esm = QSignalMapper(self) 877 self.esm = QSignalMapper(self)
812 try: 878 try:
813 self.esm.mappedInt.connect(self.__textEdit.editorCommand) 879 self.esm.mappedInt.connect(self.__textEdit.editorCommand)
814 except AttributeError: 880 except AttributeError:
815 # pre Qt 5.15 881 # pre Qt 5.15
816 self.esm.mapped[int].connect(self.__textEdit.editorCommand) 882 self.esm.mapped[int].connect(self.__textEdit.editorCommand)
817 883
818 self.editorActGrp = createActionGroup(self) 884 self.editorActGrp = createActionGroup(self)
819 885
820 act = EricAction( 886 act = EricAction(
821 QCoreApplication.translate('ViewManager', 887 QCoreApplication.translate("ViewManager", "Move left one character"),
822 'Move left one character'), 888 QCoreApplication.translate("ViewManager", "Move left one character"),
823 QCoreApplication.translate('ViewManager', 889 QKeySequence(QCoreApplication.translate("ViewManager", "Left")),
824 'Move left one character'), 890 0,
825 QKeySequence(QCoreApplication.translate('ViewManager', 'Left')), 0, 891 self.editorActGrp,
826 self.editorActGrp, 'vm_edit_move_left_char') 892 "vm_edit_move_left_char",
893 )
827 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT) 894 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT)
828 if isMacPlatform(): 895 if isMacPlatform():
829 act.setAlternateShortcut(QKeySequence( 896 act.setAlternateShortcut(
830 QCoreApplication.translate('ViewManager', 'Meta+B'))) 897 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+B"))
831 act.triggered.connect(self.esm.map) 898 )
832 self.editActions.append(act) 899 act.triggered.connect(self.esm.map)
833 900 self.editActions.append(act)
834 act = EricAction( 901
835 QCoreApplication.translate('ViewManager', 902 act = EricAction(
836 'Move right one character'), 903 QCoreApplication.translate("ViewManager", "Move right one character"),
837 QCoreApplication.translate('ViewManager', 904 QCoreApplication.translate("ViewManager", "Move right one character"),
838 'Move right one character'), 905 QKeySequence(QCoreApplication.translate("ViewManager", "Right")),
839 QKeySequence(QCoreApplication.translate('ViewManager', 'Right')), 906 0,
840 0, self.editorActGrp, 'vm_edit_move_right_char') 907 self.editorActGrp,
908 "vm_edit_move_right_char",
909 )
841 if isMacPlatform(): 910 if isMacPlatform():
842 act.setAlternateShortcut(QKeySequence( 911 act.setAlternateShortcut(
843 QCoreApplication.translate('ViewManager', 'Meta+F'))) 912 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+F"))
913 )
844 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT) 914 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT)
845 act.triggered.connect(self.esm.map) 915 act.triggered.connect(self.esm.map)
846 self.editActions.append(act) 916 self.editActions.append(act)
847 917
848 act = EricAction( 918 act = EricAction(
849 QCoreApplication.translate('ViewManager', 'Move up one line'), 919 QCoreApplication.translate("ViewManager", "Move up one line"),
850 QCoreApplication.translate('ViewManager', 'Move up one line'), 920 QCoreApplication.translate("ViewManager", "Move up one line"),
851 QKeySequence(QCoreApplication.translate('ViewManager', 'Up')), 0, 921 QKeySequence(QCoreApplication.translate("ViewManager", "Up")),
852 self.editorActGrp, 'vm_edit_move_up_line') 922 0,
923 self.editorActGrp,
924 "vm_edit_move_up_line",
925 )
853 if isMacPlatform(): 926 if isMacPlatform():
854 act.setAlternateShortcut(QKeySequence( 927 act.setAlternateShortcut(
855 QCoreApplication.translate('ViewManager', 'Meta+P'))) 928 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+P"))
929 )
856 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP) 930 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP)
857 act.triggered.connect(self.esm.map) 931 act.triggered.connect(self.esm.map)
858 self.editActions.append(act) 932 self.editActions.append(act)
859 933
860 act = EricAction( 934 act = EricAction(
861 QCoreApplication.translate('ViewManager', 'Move down one line'), 935 QCoreApplication.translate("ViewManager", "Move down one line"),
862 QCoreApplication.translate('ViewManager', 'Move down one line'), 936 QCoreApplication.translate("ViewManager", "Move down one line"),
863 QKeySequence(QCoreApplication.translate('ViewManager', 'Down')), 0, 937 QKeySequence(QCoreApplication.translate("ViewManager", "Down")),
864 self.editorActGrp, 'vm_edit_move_down_line') 938 0,
939 self.editorActGrp,
940 "vm_edit_move_down_line",
941 )
865 if isMacPlatform(): 942 if isMacPlatform():
866 act.setAlternateShortcut(QKeySequence( 943 act.setAlternateShortcut(
867 QCoreApplication.translate('ViewManager', 'Meta+N'))) 944 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+N"))
945 )
868 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN) 946 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN)
869 act.triggered.connect(self.esm.map) 947 act.triggered.connect(self.esm.map)
870 self.editActions.append(act) 948 self.editActions.append(act)
871 949
872 act = EricAction( 950 act = EricAction(
873 QCoreApplication.translate('ViewManager', 951 QCoreApplication.translate("ViewManager", "Move left one word part"),
874 'Move left one word part'), 952 QCoreApplication.translate("ViewManager", "Move left one word part"),
875 QCoreApplication.translate('ViewManager', 953 0,
876 'Move left one word part'), 954 0,
877 0, 0, 955 self.editorActGrp,
878 self.editorActGrp, 'vm_edit_move_left_word_part') 956 "vm_edit_move_left_word_part",
957 )
879 if not isMacPlatform(): 958 if not isMacPlatform():
880 act.setShortcut(QKeySequence( 959 act.setShortcut(
881 QCoreApplication.translate('ViewManager', 'Alt+Left'))) 960 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Left"))
961 )
882 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFT) 962 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFT)
883 act.triggered.connect(self.esm.map) 963 act.triggered.connect(self.esm.map)
884 self.editActions.append(act) 964 self.editActions.append(act)
885 965
886 act = EricAction( 966 act = EricAction(
887 QCoreApplication.translate('ViewManager', 967 QCoreApplication.translate("ViewManager", "Move right one word part"),
888 'Move right one word part'), 968 QCoreApplication.translate("ViewManager", "Move right one word part"),
889 QCoreApplication.translate('ViewManager', 969 0,
890 'Move right one word part'), 970 0,
891 0, 0, 971 self.editorActGrp,
892 self.editorActGrp, 'vm_edit_move_right_word_part') 972 "vm_edit_move_right_word_part",
973 )
893 if not isMacPlatform(): 974 if not isMacPlatform():
894 act.setShortcut(QKeySequence( 975 act.setShortcut(
895 QCoreApplication.translate('ViewManager', 'Alt+Right'))) 976 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Right"))
977 )
896 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHT) 978 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHT)
897 act.triggered.connect(self.esm.map) 979 act.triggered.connect(self.esm.map)
898 self.editActions.append(act) 980 self.editActions.append(act)
899 981
900 act = EricAction( 982 act = EricAction(
901 QCoreApplication.translate('ViewManager', 'Move left one word'), 983 QCoreApplication.translate("ViewManager", "Move left one word"),
902 QCoreApplication.translate('ViewManager', 'Move left one word'), 984 QCoreApplication.translate("ViewManager", "Move left one word"),
903 0, 0, 985 0,
904 self.editorActGrp, 'vm_edit_move_left_word') 986 0,
987 self.editorActGrp,
988 "vm_edit_move_left_word",
989 )
905 if isMacPlatform(): 990 if isMacPlatform():
906 act.setShortcut(QKeySequence( 991 act.setShortcut(
907 QCoreApplication.translate('ViewManager', 'Alt+Left'))) 992 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Left"))
993 )
908 else: 994 else:
909 act.setShortcut(QKeySequence( 995 act.setShortcut(
910 QCoreApplication.translate('ViewManager', 'Ctrl+Left'))) 996 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Left"))
997 )
911 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFT) 998 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFT)
912 act.triggered.connect(self.esm.map) 999 act.triggered.connect(self.esm.map)
913 self.editActions.append(act) 1000 self.editActions.append(act)
914 1001
915 act = EricAction( 1002 act = EricAction(
916 QCoreApplication.translate('ViewManager', 'Move right one word'), 1003 QCoreApplication.translate("ViewManager", "Move right one word"),
917 QCoreApplication.translate('ViewManager', 'Move right one word'), 1004 QCoreApplication.translate("ViewManager", "Move right one word"),
918 0, 0, 1005 0,
919 self.editorActGrp, 'vm_edit_move_right_word') 1006 0,
1007 self.editorActGrp,
1008 "vm_edit_move_right_word",
1009 )
920 if isMacPlatform(): 1010 if isMacPlatform():
921 act.setShortcut(QKeySequence( 1011 act.setShortcut(
922 QCoreApplication.translate('ViewManager', 'Alt+Right'))) 1012 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Right"))
1013 )
923 else: 1014 else:
924 act.setShortcut(QKeySequence( 1015 act.setShortcut(
925 QCoreApplication.translate('ViewManager', 'Ctrl+Right'))) 1016 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Right"))
1017 )
926 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT) 1018 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT)
927 act.triggered.connect(self.esm.map) 1019 act.triggered.connect(self.esm.map)
928 self.editActions.append(act) 1020 self.editActions.append(act)
929 1021
930 act = EricAction( 1022 act = EricAction(
931 QCoreApplication.translate( 1023 QCoreApplication.translate(
932 'ViewManager', 1024 "ViewManager", "Move to first visible character in document line"
933 'Move to first visible character in document line'), 1025 ),
934 QCoreApplication.translate( 1026 QCoreApplication.translate(
935 'ViewManager', 1027 "ViewManager", "Move to first visible character in document line"
936 'Move to first visible character in document line'), 1028 ),
937 0, 0, 1029 0,
938 self.editorActGrp, 'vm_edit_move_first_visible_char') 1030 0,
1031 self.editorActGrp,
1032 "vm_edit_move_first_visible_char",
1033 )
939 if not isMacPlatform(): 1034 if not isMacPlatform():
940 act.setShortcut(QKeySequence( 1035 act.setShortcut(
941 QCoreApplication.translate('ViewManager', 'Home'))) 1036 QKeySequence(QCoreApplication.translate("ViewManager", "Home"))
1037 )
942 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME) 1038 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME)
943 act.triggered.connect(self.esm.map) 1039 act.triggered.connect(self.esm.map)
944 self.editActions.append(act) 1040 self.editActions.append(act)
945 1041
946 act = EricAction( 1042 act = EricAction(
947 QCoreApplication.translate( 1043 QCoreApplication.translate("ViewManager", "Move to start of display line"),
948 'ViewManager', 1044 QCoreApplication.translate("ViewManager", "Move to start of display line"),
949 'Move to start of display line'), 1045 0,
950 QCoreApplication.translate( 1046 0,
951 'ViewManager', 1047 self.editorActGrp,
952 'Move to start of display line'), 1048 "vm_edit_move_start_line",
953 0, 0, 1049 )
954 self.editorActGrp, 'vm_edit_move_start_line')
955 if isMacPlatform(): 1050 if isMacPlatform():
956 act.setShortcut(QKeySequence( 1051 act.setShortcut(
957 QCoreApplication.translate('ViewManager', 'Ctrl+Left'))) 1052 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Left"))
1053 )
958 else: 1054 else:
959 act.setShortcut(QKeySequence( 1055 act.setShortcut(
960 QCoreApplication.translate('ViewManager', 'Alt+Home'))) 1056 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Home"))
1057 )
961 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAY) 1058 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAY)
962 act.triggered.connect(self.esm.map) 1059 act.triggered.connect(self.esm.map)
963 self.editActions.append(act) 1060 self.editActions.append(act)
964 1061
965 act = EricAction( 1062 act = EricAction(
966 QCoreApplication.translate( 1063 QCoreApplication.translate("ViewManager", "Move to end of document line"),
967 'ViewManager', 1064 QCoreApplication.translate("ViewManager", "Move to end of document line"),
968 'Move to end of document line'), 1065 0,
969 QCoreApplication.translate( 1066 0,
970 'ViewManager', 1067 self.editorActGrp,
971 'Move to end of document line'), 1068 "vm_edit_move_end_line",
972 0, 0, 1069 )
973 self.editorActGrp, 'vm_edit_move_end_line')
974 if isMacPlatform(): 1070 if isMacPlatform():
975 act.setShortcut(QKeySequence( 1071 act.setShortcut(
976 QCoreApplication.translate('ViewManager', 'Meta+E'))) 1072 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+E"))
1073 )
977 else: 1074 else:
978 act.setShortcut(QKeySequence( 1075 act.setShortcut(
979 QCoreApplication.translate('ViewManager', 'End'))) 1076 QKeySequence(QCoreApplication.translate("ViewManager", "End"))
1077 )
980 self.esm.setMapping(act, QsciScintilla.SCI_LINEEND) 1078 self.esm.setMapping(act, QsciScintilla.SCI_LINEEND)
981 act.triggered.connect(self.esm.map) 1079 act.triggered.connect(self.esm.map)
982 self.editActions.append(act) 1080 self.editActions.append(act)
983 1081
984 act = EricAction( 1082 act = EricAction(
985 QCoreApplication.translate('ViewManager', 1083 QCoreApplication.translate("ViewManager", "Scroll view down one line"),
986 'Scroll view down one line'), 1084 QCoreApplication.translate("ViewManager", "Scroll view down one line"),
987 QCoreApplication.translate('ViewManager', 1085 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Down")),
988 'Scroll view down one line'), 1086 0,
989 QKeySequence(QCoreApplication.translate('ViewManager', 1087 self.editorActGrp,
990 'Ctrl+Down')), 1088 "vm_edit_scroll_down_line",
991 0, self.editorActGrp, 'vm_edit_scroll_down_line') 1089 )
992 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLDOWN) 1090 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLDOWN)
993 act.triggered.connect(self.esm.map) 1091 act.triggered.connect(self.esm.map)
994 self.editActions.append(act) 1092 self.editActions.append(act)
995 1093
996 act = EricAction( 1094 act = EricAction(
997 QCoreApplication.translate('ViewManager', 1095 QCoreApplication.translate("ViewManager", "Scroll view up one line"),
998 'Scroll view up one line'), 1096 QCoreApplication.translate("ViewManager", "Scroll view up one line"),
999 QCoreApplication.translate('ViewManager', 1097 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Up")),
1000 'Scroll view up one line'), 1098 0,
1001 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+Up')), 1099 self.editorActGrp,
1002 0, self.editorActGrp, 'vm_edit_scroll_up_line') 1100 "vm_edit_scroll_up_line",
1101 )
1003 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLUP) 1102 self.esm.setMapping(act, QsciScintilla.SCI_LINESCROLLUP)
1004 act.triggered.connect(self.esm.map) 1103 act.triggered.connect(self.esm.map)
1005 self.editActions.append(act) 1104 self.editActions.append(act)
1006 1105
1007 act = EricAction( 1106 act = EricAction(
1008 QCoreApplication.translate('ViewManager', 'Move up one paragraph'), 1107 QCoreApplication.translate("ViewManager", "Move up one paragraph"),
1009 QCoreApplication.translate('ViewManager', 'Move up one paragraph'), 1108 QCoreApplication.translate("ViewManager", "Move up one paragraph"),
1010 QKeySequence(QCoreApplication.translate('ViewManager', 'Alt+Up')), 1109 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Up")),
1011 0, self.editorActGrp, 'vm_edit_move_up_para') 1110 0,
1111 self.editorActGrp,
1112 "vm_edit_move_up_para",
1113 )
1012 self.esm.setMapping(act, QsciScintilla.SCI_PARAUP) 1114 self.esm.setMapping(act, QsciScintilla.SCI_PARAUP)
1013 act.triggered.connect(self.esm.map) 1115 act.triggered.connect(self.esm.map)
1014 self.editActions.append(act) 1116 self.editActions.append(act)
1015 1117
1016 act = EricAction( 1118 act = EricAction(
1017 QCoreApplication.translate('ViewManager', 1119 QCoreApplication.translate("ViewManager", "Move down one paragraph"),
1018 'Move down one paragraph'), 1120 QCoreApplication.translate("ViewManager", "Move down one paragraph"),
1019 QCoreApplication.translate('ViewManager', 1121 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Down")),
1020 'Move down one paragraph'), 1122 0,
1021 QKeySequence(QCoreApplication.translate('ViewManager', 1123 self.editorActGrp,
1022 'Alt+Down')), 1124 "vm_edit_move_down_para",
1023 0, self.editorActGrp, 'vm_edit_move_down_para') 1125 )
1024 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWN) 1126 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWN)
1025 act.triggered.connect(self.esm.map) 1127 act.triggered.connect(self.esm.map)
1026 self.editActions.append(act) 1128 self.editActions.append(act)
1027 1129
1028 act = EricAction( 1130 act = EricAction(
1029 QCoreApplication.translate('ViewManager', 'Move up one page'), 1131 QCoreApplication.translate("ViewManager", "Move up one page"),
1030 QCoreApplication.translate('ViewManager', 'Move up one page'), 1132 QCoreApplication.translate("ViewManager", "Move up one page"),
1031 QKeySequence(QCoreApplication.translate('ViewManager', 'PgUp')), 0, 1133 QKeySequence(QCoreApplication.translate("ViewManager", "PgUp")),
1032 self.editorActGrp, 'vm_edit_move_up_page') 1134 0,
1135 self.editorActGrp,
1136 "vm_edit_move_up_page",
1137 )
1033 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUP) 1138 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUP)
1034 act.triggered.connect(self.esm.map) 1139 act.triggered.connect(self.esm.map)
1035 self.editActions.append(act) 1140 self.editActions.append(act)
1036 1141
1037 act = EricAction( 1142 act = EricAction(
1038 QCoreApplication.translate('ViewManager', 'Move down one page'), 1143 QCoreApplication.translate("ViewManager", "Move down one page"),
1039 QCoreApplication.translate('ViewManager', 'Move down one page'), 1144 QCoreApplication.translate("ViewManager", "Move down one page"),
1040 QKeySequence(QCoreApplication.translate('ViewManager', 'PgDown')), 1145 QKeySequence(QCoreApplication.translate("ViewManager", "PgDown")),
1041 0, self.editorActGrp, 'vm_edit_move_down_page') 1146 0,
1147 self.editorActGrp,
1148 "vm_edit_move_down_page",
1149 )
1042 if isMacPlatform(): 1150 if isMacPlatform():
1043 act.setAlternateShortcut(QKeySequence( 1151 act.setAlternateShortcut(
1044 QCoreApplication.translate('ViewManager', 'Meta+V'))) 1152 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+V"))
1153 )
1045 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN) 1154 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN)
1046 act.triggered.connect(self.esm.map) 1155 act.triggered.connect(self.esm.map)
1047 self.editActions.append(act) 1156 self.editActions.append(act)
1048 1157
1049 act = EricAction( 1158 act = EricAction(
1050 QCoreApplication.translate('ViewManager', 1159 QCoreApplication.translate("ViewManager", "Move to start of document"),
1051 'Move to start of document'), 1160 QCoreApplication.translate("ViewManager", "Move to start of document"),
1052 QCoreApplication.translate('ViewManager', 1161 0,
1053 'Move to start of document'), 1162 0,
1054 0, 0, 1163 self.editorActGrp,
1055 self.editorActGrp, 'vm_edit_move_start_text') 1164 "vm_edit_move_start_text",
1165 )
1056 if isMacPlatform(): 1166 if isMacPlatform():
1057 act.setShortcut(QKeySequence( 1167 act.setShortcut(
1058 QCoreApplication.translate('ViewManager', 'Ctrl+Up'))) 1168 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Up"))
1169 )
1059 else: 1170 else:
1060 act.setShortcut(QKeySequence( 1171 act.setShortcut(
1061 QCoreApplication.translate('ViewManager', 'Ctrl+Home'))) 1172 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Home"))
1173 )
1062 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTART) 1174 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTART)
1063 act.triggered.connect(self.esm.map) 1175 act.triggered.connect(self.esm.map)
1064 self.editActions.append(act) 1176 self.editActions.append(act)
1065 1177
1066 act = EricAction( 1178 act = EricAction(
1067 QCoreApplication.translate('ViewManager', 1179 QCoreApplication.translate("ViewManager", "Move to end of document"),
1068 'Move to end of document'), 1180 QCoreApplication.translate("ViewManager", "Move to end of document"),
1069 QCoreApplication.translate('ViewManager', 1181 0,
1070 'Move to end of document'), 1182 0,
1071 0, 0, 1183 self.editorActGrp,
1072 self.editorActGrp, 'vm_edit_move_end_text') 1184 "vm_edit_move_end_text",
1185 )
1073 if isMacPlatform(): 1186 if isMacPlatform():
1074 act.setShortcut(QKeySequence( 1187 act.setShortcut(
1075 QCoreApplication.translate('ViewManager', 'Ctrl+Down'))) 1188 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Down"))
1189 )
1076 else: 1190 else:
1077 act.setShortcut(QKeySequence( 1191 act.setShortcut(
1078 QCoreApplication.translate('ViewManager', 'Ctrl+End'))) 1192 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+End"))
1193 )
1079 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTEND) 1194 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTEND)
1080 act.triggered.connect(self.esm.map) 1195 act.triggered.connect(self.esm.map)
1081 self.editActions.append(act) 1196 self.editActions.append(act)
1082 1197
1083 act = EricAction( 1198 act = EricAction(
1084 QCoreApplication.translate('ViewManager', 'Indent one level'), 1199 QCoreApplication.translate("ViewManager", "Indent one level"),
1085 QCoreApplication.translate('ViewManager', 'Indent one level'), 1200 QCoreApplication.translate("ViewManager", "Indent one level"),
1086 QKeySequence(QCoreApplication.translate('ViewManager', 'Tab')), 0, 1201 QKeySequence(QCoreApplication.translate("ViewManager", "Tab")),
1087 self.editorActGrp, 'vm_edit_indent_one_level') 1202 0,
1203 self.editorActGrp,
1204 "vm_edit_indent_one_level",
1205 )
1088 self.esm.setMapping(act, QsciScintilla.SCI_TAB) 1206 self.esm.setMapping(act, QsciScintilla.SCI_TAB)
1089 act.triggered.connect(self.esm.map) 1207 act.triggered.connect(self.esm.map)
1090 self.editActions.append(act) 1208 self.editActions.append(act)
1091 1209
1092 act = EricAction( 1210 act = EricAction(
1093 QCoreApplication.translate('ViewManager', 'Unindent one level'), 1211 QCoreApplication.translate("ViewManager", "Unindent one level"),
1094 QCoreApplication.translate('ViewManager', 'Unindent one level'), 1212 QCoreApplication.translate("ViewManager", "Unindent one level"),
1095 QKeySequence(QCoreApplication.translate('ViewManager', 1213 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Tab")),
1096 'Shift+Tab')), 1214 0,
1097 0, self.editorActGrp, 'vm_edit_unindent_one_level') 1215 self.editorActGrp,
1216 "vm_edit_unindent_one_level",
1217 )
1098 self.esm.setMapping(act, QsciScintilla.SCI_BACKTAB) 1218 self.esm.setMapping(act, QsciScintilla.SCI_BACKTAB)
1099 act.triggered.connect(self.esm.map) 1219 act.triggered.connect(self.esm.map)
1100 self.editActions.append(act) 1220 self.editActions.append(act)
1101 1221
1102 act = EricAction( 1222 act = EricAction(
1103 QCoreApplication.translate( 1223 QCoreApplication.translate(
1104 'ViewManager', 'Extend selection left one character'), 1224 "ViewManager", "Extend selection left one character"
1105 QCoreApplication.translate( 1225 ),
1106 'ViewManager', 1226 QCoreApplication.translate(
1107 'Extend selection left one character'), 1227 "ViewManager", "Extend selection left one character"
1108 QKeySequence(QCoreApplication.translate('ViewManager', 1228 ),
1109 'Shift+Left')), 1229 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Left")),
1110 0, self.editorActGrp, 'vm_edit_extend_selection_left_char') 1230 0,
1231 self.editorActGrp,
1232 "vm_edit_extend_selection_left_char",
1233 )
1111 if isMacPlatform(): 1234 if isMacPlatform():
1112 act.setAlternateShortcut(QKeySequence( 1235 act.setAlternateShortcut(
1113 QCoreApplication.translate('ViewManager', 'Meta+Shift+B'))) 1236 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+B"))
1237 )
1114 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND) 1238 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND)
1115 act.triggered.connect(self.esm.map) 1239 act.triggered.connect(self.esm.map)
1116 self.editActions.append(act) 1240 self.editActions.append(act)
1117 1241
1118 act = EricAction( 1242 act = EricAction(
1119 QCoreApplication.translate( 1243 QCoreApplication.translate(
1120 'ViewManager', 1244 "ViewManager", "Extend selection right one character"
1121 'Extend selection right one character'), 1245 ),
1122 QCoreApplication.translate( 1246 QCoreApplication.translate(
1123 'ViewManager', 1247 "ViewManager", "Extend selection right one character"
1124 'Extend selection right one character'), 1248 ),
1125 QKeySequence(QCoreApplication.translate('ViewManager', 1249 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Right")),
1126 'Shift+Right')), 1250 0,
1127 0, self.editorActGrp, 'vm_edit_extend_selection_right_char') 1251 self.editorActGrp,
1252 "vm_edit_extend_selection_right_char",
1253 )
1128 if isMacPlatform(): 1254 if isMacPlatform():
1129 act.setAlternateShortcut(QKeySequence( 1255 act.setAlternateShortcut(
1130 QCoreApplication.translate('ViewManager', 'Meta+Shift+F'))) 1256 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+F"))
1257 )
1131 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND) 1258 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND)
1132 act.triggered.connect(self.esm.map) 1259 act.triggered.connect(self.esm.map)
1133 self.editActions.append(act) 1260 self.editActions.append(act)
1134 1261
1135 act = EricAction( 1262 act = EricAction(
1136 QCoreApplication.translate( 1263 QCoreApplication.translate("ViewManager", "Extend selection up one line"),
1137 'ViewManager', 1264 QCoreApplication.translate("ViewManager", "Extend selection up one line"),
1138 'Extend selection up one line'), 1265 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Up")),
1139 QCoreApplication.translate( 1266 0,
1140 'ViewManager', 1267 self.editorActGrp,
1141 'Extend selection up one line'), 1268 "vm_edit_extend_selection_up_line",
1142 QKeySequence(QCoreApplication.translate('ViewManager', 1269 )
1143 'Shift+Up')),
1144 0, self.editorActGrp, 'vm_edit_extend_selection_up_line')
1145 if isMacPlatform(): 1270 if isMacPlatform():
1146 act.setAlternateShortcut(QKeySequence( 1271 act.setAlternateShortcut(
1147 QCoreApplication.translate('ViewManager', 'Meta+Shift+P'))) 1272 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+P"))
1273 )
1148 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPEXTEND) 1274 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPEXTEND)
1149 act.triggered.connect(self.esm.map) 1275 act.triggered.connect(self.esm.map)
1150 self.editActions.append(act) 1276 self.editActions.append(act)
1151 1277
1152 act = EricAction( 1278 act = EricAction(
1153 QCoreApplication.translate( 1279 QCoreApplication.translate("ViewManager", "Extend selection down one line"),
1154 'ViewManager', 1280 QCoreApplication.translate("ViewManager", "Extend selection down one line"),
1155 'Extend selection down one line'), 1281 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Down")),
1156 QCoreApplication.translate( 1282 0,
1157 'ViewManager', 1283 self.editorActGrp,
1158 'Extend selection down one line'), 1284 "vm_edit_extend_selection_down_line",
1159 QKeySequence(QCoreApplication.translate('ViewManager', 1285 )
1160 'Shift+Down')),
1161 0, self.editorActGrp, 'vm_edit_extend_selection_down_line')
1162 if isMacPlatform(): 1286 if isMacPlatform():
1163 act.setAlternateShortcut(QKeySequence( 1287 act.setAlternateShortcut(
1164 QCoreApplication.translate('ViewManager', 'Meta+Shift+N'))) 1288 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+N"))
1289 )
1165 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNEXTEND) 1290 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNEXTEND)
1166 act.triggered.connect(self.esm.map) 1291 act.triggered.connect(self.esm.map)
1167 self.editActions.append(act) 1292 self.editActions.append(act)
1168 1293
1169 act = EricAction( 1294 act = EricAction(
1170 QCoreApplication.translate( 1295 QCoreApplication.translate(
1171 'ViewManager', 1296 "ViewManager", "Extend selection left one word part"
1172 'Extend selection left one word part'), 1297 ),
1173 QCoreApplication.translate( 1298 QCoreApplication.translate(
1174 'ViewManager', 1299 "ViewManager", "Extend selection left one word part"
1175 'Extend selection left one word part'), 1300 ),
1176 0, 0, 1301 0,
1177 self.editorActGrp, 'vm_edit_extend_selection_left_word_part') 1302 0,
1303 self.editorActGrp,
1304 "vm_edit_extend_selection_left_word_part",
1305 )
1178 if not isMacPlatform(): 1306 if not isMacPlatform():
1179 act.setShortcut(QKeySequence( 1307 act.setShortcut(
1180 QCoreApplication.translate('ViewManager', 'Alt+Shift+Left'))) 1308 QKeySequence(
1309 QCoreApplication.translate("ViewManager", "Alt+Shift+Left")
1310 )
1311 )
1181 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFTEXTEND) 1312 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFTEXTEND)
1182 act.triggered.connect(self.esm.map) 1313 act.triggered.connect(self.esm.map)
1183 self.editActions.append(act) 1314 self.editActions.append(act)
1184 1315
1185 act = EricAction( 1316 act = EricAction(
1186 QCoreApplication.translate( 1317 QCoreApplication.translate(
1187 'ViewManager', 1318 "ViewManager", "Extend selection right one word part"
1188 'Extend selection right one word part'), 1319 ),
1189 QCoreApplication.translate( 1320 QCoreApplication.translate(
1190 'ViewManager', 1321 "ViewManager", "Extend selection right one word part"
1191 'Extend selection right one word part'), 1322 ),
1192 0, 0, 1323 0,
1193 self.editorActGrp, 'vm_edit_extend_selection_right_word_part') 1324 0,
1325 self.editorActGrp,
1326 "vm_edit_extend_selection_right_word_part",
1327 )
1194 if not isMacPlatform(): 1328 if not isMacPlatform():
1195 act.setShortcut(QKeySequence( 1329 act.setShortcut(
1196 QCoreApplication.translate('ViewManager', 'Alt+Shift+Right'))) 1330 QKeySequence(
1331 QCoreApplication.translate("ViewManager", "Alt+Shift+Right")
1332 )
1333 )
1197 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHTEXTEND) 1334 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHTEXTEND)
1198 act.triggered.connect(self.esm.map) 1335 act.triggered.connect(self.esm.map)
1199 self.editActions.append(act) 1336 self.editActions.append(act)
1200 1337
1201 act = EricAction( 1338 act = EricAction(
1202 QCoreApplication.translate( 1339 QCoreApplication.translate("ViewManager", "Extend selection left one word"),
1203 'ViewManager', 'Extend selection left one word'), 1340 QCoreApplication.translate("ViewManager", "Extend selection left one word"),
1204 QCoreApplication.translate( 1341 0,
1205 'ViewManager', 'Extend selection left one word'), 1342 0,
1206 0, 0, 1343 self.editorActGrp,
1207 self.editorActGrp, 'vm_edit_extend_selection_left_word') 1344 "vm_edit_extend_selection_left_word",
1345 )
1208 if isMacPlatform(): 1346 if isMacPlatform():
1209 act.setShortcut(QKeySequence( 1347 act.setShortcut(
1210 QCoreApplication.translate('ViewManager', 'Alt+Shift+Left'))) 1348 QKeySequence(
1349 QCoreApplication.translate("ViewManager", "Alt+Shift+Left")
1350 )
1351 )
1211 else: 1352 else:
1212 act.setShortcut(QKeySequence( 1353 act.setShortcut(
1213 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Left'))) 1354 QKeySequence(
1355 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Left")
1356 )
1357 )
1214 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEXTEND) 1358 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEXTEND)
1215 act.triggered.connect(self.esm.map) 1359 act.triggered.connect(self.esm.map)
1216 self.editActions.append(act) 1360 self.editActions.append(act)
1217 1361
1218 act = EricAction( 1362 act = EricAction(
1219 QCoreApplication.translate( 1363 QCoreApplication.translate(
1220 'ViewManager', 'Extend selection right one word'), 1364 "ViewManager", "Extend selection right one word"
1221 QCoreApplication.translate( 1365 ),
1222 'ViewManager', 'Extend selection right one word'), 1366 QCoreApplication.translate(
1223 0, 0, 1367 "ViewManager", "Extend selection right one word"
1224 self.editorActGrp, 'vm_edit_extend_selection_right_word') 1368 ),
1369 0,
1370 0,
1371 self.editorActGrp,
1372 "vm_edit_extend_selection_right_word",
1373 )
1225 if isMacPlatform(): 1374 if isMacPlatform():
1226 act.setShortcut(QKeySequence( 1375 act.setShortcut(
1227 QCoreApplication.translate('ViewManager', 'Alt+Shift+Right'))) 1376 QKeySequence(
1377 QCoreApplication.translate("ViewManager", "Alt+Shift+Right")
1378 )
1379 )
1228 else: 1380 else:
1229 act.setShortcut(QKeySequence( 1381 act.setShortcut(
1230 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Right'))) 1382 QKeySequence(
1383 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Right")
1384 )
1385 )
1231 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEXTEND) 1386 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEXTEND)
1232 act.triggered.connect(self.esm.map) 1387 act.triggered.connect(self.esm.map)
1233 self.editActions.append(act) 1388 self.editActions.append(act)
1234 1389
1235 act = EricAction( 1390 act = EricAction(
1236 QCoreApplication.translate( 1391 QCoreApplication.translate(
1237 'ViewManager', 1392 "ViewManager",
1238 'Extend selection to first visible character in document' 1393 "Extend selection to first visible character in document" " line",
1239 ' line'), 1394 ),
1240 QCoreApplication.translate( 1395 QCoreApplication.translate(
1241 'ViewManager', 1396 "ViewManager",
1242 'Extend selection to first visible character in document' 1397 "Extend selection to first visible character in document" " line",
1243 ' line'), 1398 ),
1244 0, 0, 1399 0,
1245 self.editorActGrp, 'vm_edit_extend_selection_first_visible_char') 1400 0,
1401 self.editorActGrp,
1402 "vm_edit_extend_selection_first_visible_char",
1403 )
1246 if not isMacPlatform(): 1404 if not isMacPlatform():
1247 act.setShortcut(QKeySequence( 1405 act.setShortcut(
1248 QCoreApplication.translate('ViewManager', 'Shift+Home'))) 1406 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Home"))
1407 )
1249 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND) 1408 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND)
1250 act.triggered.connect(self.esm.map) 1409 act.triggered.connect(self.esm.map)
1251 self.editActions.append(act) 1410 self.editActions.append(act)
1252 1411
1253 act = EricAction( 1412 act = EricAction(
1254 QCoreApplication.translate( 1413 QCoreApplication.translate(
1255 'ViewManager', 'Extend selection to end of document line'), 1414 "ViewManager", "Extend selection to end of document line"
1256 QCoreApplication.translate( 1415 ),
1257 'ViewManager', 'Extend selection to end of document line'), 1416 QCoreApplication.translate(
1258 0, 0, 1417 "ViewManager", "Extend selection to end of document line"
1259 self.editorActGrp, 'vm_edit_extend_selection_end_line') 1418 ),
1419 0,
1420 0,
1421 self.editorActGrp,
1422 "vm_edit_extend_selection_end_line",
1423 )
1260 if isMacPlatform(): 1424 if isMacPlatform():
1261 act.setShortcut(QKeySequence( 1425 act.setShortcut(
1262 QCoreApplication.translate('ViewManager', 'Meta+Shift+E'))) 1426 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+E"))
1427 )
1263 else: 1428 else:
1264 act.setShortcut(QKeySequence( 1429 act.setShortcut(
1265 QCoreApplication.translate('ViewManager', 'Shift+End'))) 1430 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+End"))
1431 )
1266 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDEXTEND) 1432 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDEXTEND)
1267 act.triggered.connect(self.esm.map) 1433 act.triggered.connect(self.esm.map)
1268 self.editActions.append(act) 1434 self.editActions.append(act)
1269 1435
1270 act = EricAction( 1436 act = EricAction(
1271 QCoreApplication.translate( 1437 QCoreApplication.translate(
1272 'ViewManager', 1438 "ViewManager", "Extend selection up one paragraph"
1273 'Extend selection up one paragraph'), 1439 ),
1274 QCoreApplication.translate( 1440 QCoreApplication.translate(
1275 'ViewManager', 1441 "ViewManager", "Extend selection up one paragraph"
1276 'Extend selection up one paragraph'), 1442 ),
1277 QKeySequence(QCoreApplication.translate('ViewManager', 1443 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+Up")),
1278 'Alt+Shift+Up')), 1444 0,
1279 0, self.editorActGrp, 'vm_edit_extend_selection_up_para') 1445 self.editorActGrp,
1446 "vm_edit_extend_selection_up_para",
1447 )
1280 self.esm.setMapping(act, QsciScintilla.SCI_PARAUPEXTEND) 1448 self.esm.setMapping(act, QsciScintilla.SCI_PARAUPEXTEND)
1281 act.triggered.connect(self.esm.map) 1449 act.triggered.connect(self.esm.map)
1282 self.editActions.append(act) 1450 self.editActions.append(act)
1283 1451
1284 act = EricAction( 1452 act = EricAction(
1285 QCoreApplication.translate( 1453 QCoreApplication.translate(
1286 'ViewManager', 'Extend selection down one paragraph'), 1454 "ViewManager", "Extend selection down one paragraph"
1287 QCoreApplication.translate( 1455 ),
1288 'ViewManager', 'Extend selection down one paragraph'), 1456 QCoreApplication.translate(
1289 QKeySequence(QCoreApplication.translate('ViewManager', 1457 "ViewManager", "Extend selection down one paragraph"
1290 'Alt+Shift+Down')), 1458 ),
1291 0, 1459 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+Down")),
1292 self.editorActGrp, 'vm_edit_extend_selection_down_para') 1460 0,
1461 self.editorActGrp,
1462 "vm_edit_extend_selection_down_para",
1463 )
1293 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWNEXTEND) 1464 self.esm.setMapping(act, QsciScintilla.SCI_PARADOWNEXTEND)
1294 act.triggered.connect(self.esm.map) 1465 act.triggered.connect(self.esm.map)
1295 self.editActions.append(act) 1466 self.editActions.append(act)
1296 1467
1297 act = EricAction( 1468 act = EricAction(
1298 QCoreApplication.translate( 1469 QCoreApplication.translate("ViewManager", "Extend selection up one page"),
1299 'ViewManager', 1470 QCoreApplication.translate("ViewManager", "Extend selection up one page"),
1300 'Extend selection up one page'), 1471 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+PgUp")),
1301 QCoreApplication.translate( 1472 0,
1302 'ViewManager', 1473 self.editorActGrp,
1303 'Extend selection up one page'), 1474 "vm_edit_extend_selection_up_page",
1304 QKeySequence(QCoreApplication.translate('ViewManager', 1475 )
1305 'Shift+PgUp')),
1306 0, self.editorActGrp, 'vm_edit_extend_selection_up_page')
1307 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPEXTEND) 1476 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPEXTEND)
1308 act.triggered.connect(self.esm.map) 1477 act.triggered.connect(self.esm.map)
1309 self.editActions.append(act) 1478 self.editActions.append(act)
1310 1479
1311 act = EricAction( 1480 act = EricAction(
1312 QCoreApplication.translate( 1481 QCoreApplication.translate("ViewManager", "Extend selection down one page"),
1313 'ViewManager', 1482 QCoreApplication.translate("ViewManager", "Extend selection down one page"),
1314 'Extend selection down one page'), 1483 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+PgDown")),
1315 QCoreApplication.translate( 1484 0,
1316 'ViewManager', 1485 self.editorActGrp,
1317 'Extend selection down one page'), 1486 "vm_edit_extend_selection_down_page",
1318 QKeySequence(QCoreApplication.translate('ViewManager', 1487 )
1319 'Shift+PgDown')),
1320 0, self.editorActGrp, 'vm_edit_extend_selection_down_page')
1321 if isMacPlatform(): 1488 if isMacPlatform():
1322 act.setAlternateShortcut(QKeySequence( 1489 act.setAlternateShortcut(
1323 QCoreApplication.translate('ViewManager', 'Meta+Shift+V'))) 1490 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+V"))
1491 )
1324 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNEXTEND) 1492 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNEXTEND)
1325 act.triggered.connect(self.esm.map) 1493 act.triggered.connect(self.esm.map)
1326 self.editActions.append(act) 1494 self.editActions.append(act)
1327 1495
1328 act = EricAction( 1496 act = EricAction(
1329 QCoreApplication.translate( 1497 QCoreApplication.translate(
1330 'ViewManager', 'Extend selection to start of document'), 1498 "ViewManager", "Extend selection to start of document"
1331 QCoreApplication.translate( 1499 ),
1332 'ViewManager', 'Extend selection to start of document'), 1500 QCoreApplication.translate(
1333 0, 0, 1501 "ViewManager", "Extend selection to start of document"
1334 self.editorActGrp, 'vm_edit_extend_selection_start_text') 1502 ),
1503 0,
1504 0,
1505 self.editorActGrp,
1506 "vm_edit_extend_selection_start_text",
1507 )
1335 if isMacPlatform(): 1508 if isMacPlatform():
1336 act.setShortcut(QKeySequence( 1509 act.setShortcut(
1337 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Up'))) 1510 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Shift+Up"))
1511 )
1338 else: 1512 else:
1339 act.setShortcut(QKeySequence( 1513 act.setShortcut(
1340 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Home'))) 1514 QKeySequence(
1515 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Home")
1516 )
1517 )
1341 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTARTEXTEND) 1518 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTSTARTEXTEND)
1342 act.triggered.connect(self.esm.map) 1519 act.triggered.connect(self.esm.map)
1343 self.editActions.append(act) 1520 self.editActions.append(act)
1344 1521
1345 act = EricAction( 1522 act = EricAction(
1346 QCoreApplication.translate( 1523 QCoreApplication.translate(
1347 'ViewManager', 'Extend selection to end of document'), 1524 "ViewManager", "Extend selection to end of document"
1348 QCoreApplication.translate( 1525 ),
1349 'ViewManager', 'Extend selection to end of document'), 1526 QCoreApplication.translate(
1350 0, 0, 1527 "ViewManager", "Extend selection to end of document"
1351 self.editorActGrp, 'vm_edit_extend_selection_end_text') 1528 ),
1529 0,
1530 0,
1531 self.editorActGrp,
1532 "vm_edit_extend_selection_end_text",
1533 )
1352 if isMacPlatform(): 1534 if isMacPlatform():
1353 act.setShortcut(QKeySequence( 1535 act.setShortcut(
1354 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Down'))) 1536 QKeySequence(
1537 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Down")
1538 )
1539 )
1355 else: 1540 else:
1356 act.setShortcut(QKeySequence( 1541 act.setShortcut(
1357 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+End'))) 1542 QKeySequence(
1543 QCoreApplication.translate("ViewManager", "Ctrl+Shift+End")
1544 )
1545 )
1358 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTENDEXTEND) 1546 self.esm.setMapping(act, QsciScintilla.SCI_DOCUMENTENDEXTEND)
1359 act.triggered.connect(self.esm.map) 1547 act.triggered.connect(self.esm.map)
1360 self.editActions.append(act) 1548 self.editActions.append(act)
1361 1549
1362 act = EricAction( 1550 act = EricAction(
1363 QCoreApplication.translate('ViewManager', 1551 QCoreApplication.translate("ViewManager", "Delete previous character"),
1364 'Delete previous character'), 1552 QCoreApplication.translate("ViewManager", "Delete previous character"),
1365 QCoreApplication.translate('ViewManager', 1553 QKeySequence(QCoreApplication.translate("ViewManager", "Backspace")),
1366 'Delete previous character'), 1554 0,
1367 QKeySequence(QCoreApplication.translate('ViewManager', 1555 self.editorActGrp,
1368 'Backspace')), 1556 "vm_edit_delete_previous_char",
1369 0, self.editorActGrp, 'vm_edit_delete_previous_char') 1557 )
1370 if isMacPlatform(): 1558 if isMacPlatform():
1371 act.setAlternateShortcut(QKeySequence( 1559 act.setAlternateShortcut(
1372 QCoreApplication.translate('ViewManager', 'Meta+H'))) 1560 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+H"))
1561 )
1373 else: 1562 else:
1374 act.setAlternateShortcut(QKeySequence( 1563 act.setAlternateShortcut(
1375 QCoreApplication.translate('ViewManager', 'Shift+Backspace'))) 1564 QKeySequence(
1565 QCoreApplication.translate("ViewManager", "Shift+Backspace")
1566 )
1567 )
1376 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACK) 1568 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACK)
1377 act.triggered.connect(self.esm.map) 1569 act.triggered.connect(self.esm.map)
1378 self.editActions.append(act) 1570 self.editActions.append(act)
1379 1571
1380 act = EricAction( 1572 act = EricAction(
1381 QCoreApplication.translate( 1573 QCoreApplication.translate(
1382 'ViewManager', 1574 "ViewManager", "Delete previous character if not at start of line"
1383 'Delete previous character if not at start of line'), 1575 ),
1384 QCoreApplication.translate( 1576 QCoreApplication.translate(
1385 'ViewManager', 1577 "ViewManager", "Delete previous character if not at start of line"
1386 'Delete previous character if not at start of line'), 1578 ),
1387 0, 0, 1579 0,
1388 self.editorActGrp, 'vm_edit_delet_previous_char_not_line_start') 1580 0,
1581 self.editorActGrp,
1582 "vm_edit_delet_previous_char_not_line_start",
1583 )
1389 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACKNOTLINE) 1584 self.esm.setMapping(act, QsciScintilla.SCI_DELETEBACKNOTLINE)
1390 act.triggered.connect(self.esm.map) 1585 act.triggered.connect(self.esm.map)
1391 self.editActions.append(act) 1586 self.editActions.append(act)
1392 1587
1393 act = EricAction( 1588 act = EricAction(
1394 QCoreApplication.translate('ViewManager', 1589 QCoreApplication.translate("ViewManager", "Delete current character"),
1395 'Delete current character'), 1590 QCoreApplication.translate("ViewManager", "Delete current character"),
1396 QCoreApplication.translate('ViewManager', 1591 QKeySequence(QCoreApplication.translate("ViewManager", "Del")),
1397 'Delete current character'), 1592 0,
1398 QKeySequence(QCoreApplication.translate('ViewManager', 'Del')), 0, 1593 self.editorActGrp,
1399 self.editorActGrp, 'vm_edit_delete_current_char') 1594 "vm_edit_delete_current_char",
1595 )
1400 if isMacPlatform(): 1596 if isMacPlatform():
1401 act.setAlternateShortcut(QKeySequence( 1597 act.setAlternateShortcut(
1402 QCoreApplication.translate('ViewManager', 'Meta+D'))) 1598 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+D"))
1599 )
1403 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR) 1600 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR)
1404 act.triggered.connect(self.esm.map) 1601 act.triggered.connect(self.esm.map)
1405 self.editActions.append(act) 1602 self.editActions.append(act)
1406 1603
1407 act = EricAction( 1604 act = EricAction(
1408 QCoreApplication.translate('ViewManager', 'Delete word to left'), 1605 QCoreApplication.translate("ViewManager", "Delete word to left"),
1409 QCoreApplication.translate('ViewManager', 'Delete word to left'), 1606 QCoreApplication.translate("ViewManager", "Delete word to left"),
1410 QKeySequence(QCoreApplication.translate('ViewManager', 1607 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Backspace")),
1411 'Ctrl+Backspace')), 1608 0,
1412 0, self.editorActGrp, 'vm_edit_delete_word_left') 1609 self.editorActGrp,
1610 "vm_edit_delete_word_left",
1611 )
1413 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDLEFT) 1612 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDLEFT)
1414 act.triggered.connect(self.esm.map) 1613 act.triggered.connect(self.esm.map)
1415 self.editActions.append(act) 1614 self.editActions.append(act)
1416 1615
1417 act = EricAction( 1616 act = EricAction(
1418 QCoreApplication.translate('ViewManager', 'Delete word to right'), 1617 QCoreApplication.translate("ViewManager", "Delete word to right"),
1419 QCoreApplication.translate('ViewManager', 'Delete word to right'), 1618 QCoreApplication.translate("ViewManager", "Delete word to right"),
1420 QKeySequence(QCoreApplication.translate('ViewManager', 1619 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Del")),
1421 'Ctrl+Del')), 1620 0,
1422 0, self.editorActGrp, 'vm_edit_delete_word_right') 1621 self.editorActGrp,
1622 "vm_edit_delete_word_right",
1623 )
1423 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHT) 1624 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHT)
1424 act.triggered.connect(self.esm.map) 1625 act.triggered.connect(self.esm.map)
1425 self.editActions.append(act) 1626 self.editActions.append(act)
1426 1627
1427 act = EricAction( 1628 act = EricAction(
1428 QCoreApplication.translate('ViewManager', 'Delete line to left'), 1629 QCoreApplication.translate("ViewManager", "Delete line to left"),
1429 QCoreApplication.translate('ViewManager', 'Delete line to left'), 1630 QCoreApplication.translate("ViewManager", "Delete line to left"),
1430 QKeySequence(QCoreApplication.translate('ViewManager', 1631 QKeySequence(
1431 'Ctrl+Shift+Backspace')), 1632 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Backspace")
1432 0, self.editorActGrp, 'vm_edit_delete_line_left') 1633 ),
1634 0,
1635 self.editorActGrp,
1636 "vm_edit_delete_line_left",
1637 )
1433 self.esm.setMapping(act, QsciScintilla.SCI_DELLINELEFT) 1638 self.esm.setMapping(act, QsciScintilla.SCI_DELLINELEFT)
1434 act.triggered.connect(self.esm.map) 1639 act.triggered.connect(self.esm.map)
1435 self.editActions.append(act) 1640 self.editActions.append(act)
1436 1641
1437 act = EricAction( 1642 act = EricAction(
1438 QCoreApplication.translate('ViewManager', 'Delete line to right'), 1643 QCoreApplication.translate("ViewManager", "Delete line to right"),
1439 QCoreApplication.translate('ViewManager', 'Delete line to right'), 1644 QCoreApplication.translate("ViewManager", "Delete line to right"),
1440 0, 0, 1645 0,
1441 self.editorActGrp, 'vm_edit_delete_line_right') 1646 0,
1647 self.editorActGrp,
1648 "vm_edit_delete_line_right",
1649 )
1442 if isMacPlatform(): 1650 if isMacPlatform():
1443 act.setShortcut(QKeySequence( 1651 act.setShortcut(
1444 QCoreApplication.translate('ViewManager', 'Meta+K'))) 1652 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+K"))
1653 )
1445 else: 1654 else:
1446 act.setShortcut(QKeySequence( 1655 act.setShortcut(
1447 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Del'))) 1656 QKeySequence(
1657 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Del")
1658 )
1659 )
1448 self.esm.setMapping(act, QsciScintilla.SCI_DELLINERIGHT) 1660 self.esm.setMapping(act, QsciScintilla.SCI_DELLINERIGHT)
1449 act.triggered.connect(self.esm.map) 1661 act.triggered.connect(self.esm.map)
1450 self.editActions.append(act) 1662 self.editActions.append(act)
1451 1663
1452 act = EricAction( 1664 act = EricAction(
1453 QCoreApplication.translate('ViewManager', 'Insert new line'), 1665 QCoreApplication.translate("ViewManager", "Insert new line"),
1454 QCoreApplication.translate('ViewManager', 'Insert new line'), 1666 QCoreApplication.translate("ViewManager", "Insert new line"),
1455 QKeySequence(QCoreApplication.translate('ViewManager', 'Return')), 1667 QKeySequence(QCoreApplication.translate("ViewManager", "Return")),
1456 QKeySequence(QCoreApplication.translate('ViewManager', 'Enter')), 1668 QKeySequence(QCoreApplication.translate("ViewManager", "Enter")),
1457 self.editorActGrp, 'vm_edit_insert_line') 1669 self.editorActGrp,
1670 "vm_edit_insert_line",
1671 )
1458 self.esm.setMapping(act, QsciScintilla.SCI_NEWLINE) 1672 self.esm.setMapping(act, QsciScintilla.SCI_NEWLINE)
1459 act.triggered.connect(self.esm.map) 1673 act.triggered.connect(self.esm.map)
1460 self.editActions.append(act) 1674 self.editActions.append(act)
1461 1675
1462 act = EricAction( 1676 act = EricAction(
1463 QCoreApplication.translate('ViewManager', 'Delete current line'), 1677 QCoreApplication.translate("ViewManager", "Delete current line"),
1464 QCoreApplication.translate('ViewManager', 'Delete current line'), 1678 QCoreApplication.translate("ViewManager", "Delete current line"),
1465 QKeySequence(QCoreApplication.translate('ViewManager', 1679 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Shift+L")),
1466 'Ctrl+Shift+L')), 1680 0,
1467 0, self.editorActGrp, 'vm_edit_delete_current_line') 1681 self.editorActGrp,
1682 "vm_edit_delete_current_line",
1683 )
1468 self.esm.setMapping(act, QsciScintilla.SCI_LINEDELETE) 1684 self.esm.setMapping(act, QsciScintilla.SCI_LINEDELETE)
1469 act.triggered.connect(self.esm.map) 1685 act.triggered.connect(self.esm.map)
1470 self.editActions.append(act) 1686 self.editActions.append(act)
1471 1687
1472 act = EricAction( 1688 act = EricAction(
1473 QCoreApplication.translate('ViewManager', 1689 QCoreApplication.translate("ViewManager", "Duplicate current line"),
1474 'Duplicate current line'), 1690 QCoreApplication.translate("ViewManager", "Duplicate current line"),
1475 QCoreApplication.translate('ViewManager', 1691 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+D")),
1476 'Duplicate current line'), 1692 0,
1477 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+D')), 1693 self.editorActGrp,
1478 0, self.editorActGrp, 'vm_edit_duplicate_current_line') 1694 "vm_edit_duplicate_current_line",
1695 )
1479 self.esm.setMapping(act, QsciScintilla.SCI_LINEDUPLICATE) 1696 self.esm.setMapping(act, QsciScintilla.SCI_LINEDUPLICATE)
1480 act.triggered.connect(self.esm.map) 1697 act.triggered.connect(self.esm.map)
1481 self.editActions.append(act) 1698 self.editActions.append(act)
1482 1699
1483 act = EricAction( 1700 act = EricAction(
1484 QCoreApplication.translate( 1701 QCoreApplication.translate(
1485 'ViewManager', 1702 "ViewManager", "Swap current and previous lines"
1486 'Swap current and previous lines'), 1703 ),
1487 QCoreApplication.translate( 1704 QCoreApplication.translate(
1488 'ViewManager', 1705 "ViewManager", "Swap current and previous lines"
1489 'Swap current and previous lines'), 1706 ),
1490 QKeySequence(QCoreApplication.translate('ViewManager', 'Ctrl+T')), 1707 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+T")),
1491 0, self.editorActGrp, 'vm_edit_swap_current_previous_line') 1708 0,
1709 self.editorActGrp,
1710 "vm_edit_swap_current_previous_line",
1711 )
1492 self.esm.setMapping(act, QsciScintilla.SCI_LINETRANSPOSE) 1712 self.esm.setMapping(act, QsciScintilla.SCI_LINETRANSPOSE)
1493 act.triggered.connect(self.esm.map) 1713 act.triggered.connect(self.esm.map)
1494 self.editActions.append(act) 1714 self.editActions.append(act)
1495 1715
1496 act = EricAction( 1716 act = EricAction(
1497 QCoreApplication.translate('ViewManager', 1717 QCoreApplication.translate("ViewManager", "Reverse selected lines"),
1498 'Reverse selected lines'), 1718 QCoreApplication.translate("ViewManager", "Reverse selected lines"),
1499 QCoreApplication.translate('ViewManager', 1719 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Alt+R")),
1500 'Reverse selected lines'), 1720 0,
1501 QKeySequence(QCoreApplication.translate('ViewManager', 1721 self.editorActGrp,
1502 'Meta+Alt+R')), 1722 "vm_edit_reverse selected_lines",
1503 0, self.editorActGrp, 'vm_edit_reverse selected_lines') 1723 )
1504 self.esm.setMapping(act, QsciScintilla.SCI_LINEREVERSE) 1724 self.esm.setMapping(act, QsciScintilla.SCI_LINEREVERSE)
1505 act.triggered.connect(self.esm.map) 1725 act.triggered.connect(self.esm.map)
1506 self.editActions.append(act) 1726 self.editActions.append(act)
1507 1727
1508 act = EricAction( 1728 act = EricAction(
1509 QCoreApplication.translate('ViewManager', 'Cut current line'), 1729 QCoreApplication.translate("ViewManager", "Cut current line"),
1510 QCoreApplication.translate('ViewManager', 'Cut current line'), 1730 QCoreApplication.translate("ViewManager", "Cut current line"),
1511 QKeySequence(QCoreApplication.translate('ViewManager', 1731 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+L")),
1512 'Alt+Shift+L')), 1732 0,
1513 0, self.editorActGrp, 'vm_edit_cut_current_line') 1733 self.editorActGrp,
1734 "vm_edit_cut_current_line",
1735 )
1514 self.esm.setMapping(act, QsciScintilla.SCI_LINECUT) 1736 self.esm.setMapping(act, QsciScintilla.SCI_LINECUT)
1515 act.triggered.connect(self.esm.map) 1737 act.triggered.connect(self.esm.map)
1516 self.editActions.append(act) 1738 self.editActions.append(act)
1517 1739
1518 act = EricAction( 1740 act = EricAction(
1519 QCoreApplication.translate('ViewManager', 'Copy current line'), 1741 QCoreApplication.translate("ViewManager", "Copy current line"),
1520 QCoreApplication.translate('ViewManager', 'Copy current line'), 1742 QCoreApplication.translate("ViewManager", "Copy current line"),
1521 QKeySequence(QCoreApplication.translate('ViewManager', 1743 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Shift+T")),
1522 'Ctrl+Shift+T')), 1744 0,
1523 0, self.editorActGrp, 'vm_edit_copy_current_line') 1745 self.editorActGrp,
1746 "vm_edit_copy_current_line",
1747 )
1524 self.esm.setMapping(act, QsciScintilla.SCI_LINECOPY) 1748 self.esm.setMapping(act, QsciScintilla.SCI_LINECOPY)
1525 act.triggered.connect(self.esm.map) 1749 act.triggered.connect(self.esm.map)
1526 self.editActions.append(act) 1750 self.editActions.append(act)
1527 1751
1528 act = EricAction( 1752 act = EricAction(
1529 QCoreApplication.translate('ViewManager', 1753 QCoreApplication.translate("ViewManager", "Toggle insert/overtype"),
1530 'Toggle insert/overtype'), 1754 QCoreApplication.translate("ViewManager", "Toggle insert/overtype"),
1531 QCoreApplication.translate('ViewManager', 1755 QKeySequence(QCoreApplication.translate("ViewManager", "Ins")),
1532 'Toggle insert/overtype'), 1756 0,
1533 QKeySequence(QCoreApplication.translate('ViewManager', 'Ins')), 0, 1757 self.editorActGrp,
1534 self.editorActGrp, 'vm_edit_toggle_insert_overtype') 1758 "vm_edit_toggle_insert_overtype",
1759 )
1535 self.esm.setMapping(act, QsciScintilla.SCI_EDITTOGGLEOVERTYPE) 1760 self.esm.setMapping(act, QsciScintilla.SCI_EDITTOGGLEOVERTYPE)
1536 act.triggered.connect(self.esm.map) 1761 act.triggered.connect(self.esm.map)
1537 self.editActions.append(act) 1762 self.editActions.append(act)
1538 1763
1539 act = EricAction( 1764 act = EricAction(
1540 QCoreApplication.translate( 1765 QCoreApplication.translate(
1541 'ViewManager', 1766 "ViewManager", "Convert selection to lower case"
1542 'Convert selection to lower case'), 1767 ),
1543 QCoreApplication.translate( 1768 QCoreApplication.translate(
1544 'ViewManager', 1769 "ViewManager", "Convert selection to lower case"
1545 'Convert selection to lower case'), 1770 ),
1546 QKeySequence(QCoreApplication.translate('ViewManager', 1771 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+U")),
1547 'Alt+Shift+U')), 1772 0,
1548 0, self.editorActGrp, 'vm_edit_convert_selection_lower') 1773 self.editorActGrp,
1774 "vm_edit_convert_selection_lower",
1775 )
1549 self.esm.setMapping(act, QsciScintilla.SCI_LOWERCASE) 1776 self.esm.setMapping(act, QsciScintilla.SCI_LOWERCASE)
1550 act.triggered.connect(self.esm.map) 1777 act.triggered.connect(self.esm.map)
1551 self.editActions.append(act) 1778 self.editActions.append(act)
1552 1779
1553 act = EricAction( 1780 act = EricAction(
1554 QCoreApplication.translate( 1781 QCoreApplication.translate(
1555 'ViewManager', 1782 "ViewManager", "Convert selection to upper case"
1556 'Convert selection to upper case'), 1783 ),
1557 QCoreApplication.translate( 1784 QCoreApplication.translate(
1558 'ViewManager', 1785 "ViewManager", "Convert selection to upper case"
1559 'Convert selection to upper case'), 1786 ),
1560 QKeySequence(QCoreApplication.translate('ViewManager', 1787 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Shift+U")),
1561 'Ctrl+Shift+U')), 1788 0,
1562 0, self.editorActGrp, 'vm_edit_convert_selection_upper') 1789 self.editorActGrp,
1790 "vm_edit_convert_selection_upper",
1791 )
1563 self.esm.setMapping(act, QsciScintilla.SCI_UPPERCASE) 1792 self.esm.setMapping(act, QsciScintilla.SCI_UPPERCASE)
1564 act.triggered.connect(self.esm.map) 1793 act.triggered.connect(self.esm.map)
1565 self.editActions.append(act) 1794 self.editActions.append(act)
1566 1795
1567 act = EricAction( 1796 act = EricAction(
1568 QCoreApplication.translate( 1797 QCoreApplication.translate("ViewManager", "Move to end of display line"),
1569 'ViewManager', 'Move to end of display line'), 1798 QCoreApplication.translate("ViewManager", "Move to end of display line"),
1570 QCoreApplication.translate( 1799 0,
1571 'ViewManager', 'Move to end of display line'), 1800 0,
1572 0, 0, 1801 self.editorActGrp,
1573 self.editorActGrp, 'vm_edit_move_end_displayed_line') 1802 "vm_edit_move_end_displayed_line",
1803 )
1574 if isMacPlatform(): 1804 if isMacPlatform():
1575 act.setShortcut(QKeySequence( 1805 act.setShortcut(
1576 QCoreApplication.translate('ViewManager', 'Ctrl+Right'))) 1806 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Right"))
1807 )
1577 else: 1808 else:
1578 act.setShortcut(QKeySequence( 1809 act.setShortcut(
1579 QCoreApplication.translate('ViewManager', 'Alt+End'))) 1810 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+End"))
1811 )
1580 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAY) 1812 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAY)
1581 act.triggered.connect(self.esm.map) 1813 act.triggered.connect(self.esm.map)
1582 self.editActions.append(act) 1814 self.editActions.append(act)
1583 1815
1584 act = EricAction( 1816 act = EricAction(
1585 QCoreApplication.translate( 1817 QCoreApplication.translate(
1586 'ViewManager', 1818 "ViewManager", "Extend selection to end of display line"
1587 'Extend selection to end of display line'), 1819 ),
1588 QCoreApplication.translate( 1820 QCoreApplication.translate(
1589 'ViewManager', 1821 "ViewManager", "Extend selection to end of display line"
1590 'Extend selection to end of display line'), 1822 ),
1591 0, 0, 1823 0,
1592 self.editorActGrp, 'vm_edit_extend_selection_end_displayed_line') 1824 0,
1825 self.editorActGrp,
1826 "vm_edit_extend_selection_end_displayed_line",
1827 )
1593 if isMacPlatform(): 1828 if isMacPlatform():
1594 act.setShortcut(QKeySequence( 1829 act.setShortcut(
1595 QCoreApplication.translate('ViewManager', 'Ctrl+Shift+Right'))) 1830 QKeySequence(
1831 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Right")
1832 )
1833 )
1596 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAYEXTEND) 1834 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDDISPLAYEXTEND)
1597 act.triggered.connect(self.esm.map) 1835 act.triggered.connect(self.esm.map)
1598 self.editActions.append(act) 1836 self.editActions.append(act)
1599 1837
1600 act = EricAction( 1838 act = EricAction(
1601 QCoreApplication.translate('ViewManager', 'Formfeed'), 1839 QCoreApplication.translate("ViewManager", "Formfeed"),
1602 QCoreApplication.translate('ViewManager', 'Formfeed'), 1840 QCoreApplication.translate("ViewManager", "Formfeed"),
1603 0, 0, 1841 0,
1604 self.editorActGrp, 'vm_edit_formfeed') 1842 0,
1843 self.editorActGrp,
1844 "vm_edit_formfeed",
1845 )
1605 self.esm.setMapping(act, QsciScintilla.SCI_FORMFEED) 1846 self.esm.setMapping(act, QsciScintilla.SCI_FORMFEED)
1606 act.triggered.connect(self.esm.map) 1847 act.triggered.connect(self.esm.map)
1607 self.editActions.append(act) 1848 self.editActions.append(act)
1608 1849
1609 act = EricAction( 1850 act = EricAction(
1610 QCoreApplication.translate('ViewManager', 'Escape'), 1851 QCoreApplication.translate("ViewManager", "Escape"),
1611 QCoreApplication.translate('ViewManager', 'Escape'), 1852 QCoreApplication.translate("ViewManager", "Escape"),
1612 QKeySequence(QCoreApplication.translate('ViewManager', 'Esc')), 0, 1853 QKeySequence(QCoreApplication.translate("ViewManager", "Esc")),
1613 self.editorActGrp, 'vm_edit_escape') 1854 0,
1855 self.editorActGrp,
1856 "vm_edit_escape",
1857 )
1614 self.esm.setMapping(act, QsciScintilla.SCI_CANCEL) 1858 self.esm.setMapping(act, QsciScintilla.SCI_CANCEL)
1615 act.triggered.connect(self.esm.map) 1859 act.triggered.connect(self.esm.map)
1616 self.editActions.append(act) 1860 self.editActions.append(act)
1617 1861
1618 act = EricAction( 1862 act = EricAction(
1619 QCoreApplication.translate( 1863 QCoreApplication.translate(
1620 'ViewManager', 1864 "ViewManager", "Extend rectangular selection down one line"
1621 'Extend rectangular selection down one line'), 1865 ),
1622 QCoreApplication.translate( 1866 QCoreApplication.translate(
1623 'ViewManager', 1867 "ViewManager", "Extend rectangular selection down one line"
1624 'Extend rectangular selection down one line'), 1868 ),
1625 QKeySequence(QCoreApplication.translate('ViewManager', 1869 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Down")),
1626 'Alt+Ctrl+Down')), 1870 0,
1627 0, self.editorActGrp, 'vm_edit_extend_rect_selection_down_line') 1871 self.editorActGrp,
1872 "vm_edit_extend_rect_selection_down_line",
1873 )
1628 if isMacPlatform(): 1874 if isMacPlatform():
1629 act.setAlternateShortcut(QKeySequence( 1875 act.setAlternateShortcut(
1630 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+N'))) 1876 QKeySequence(
1877 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+N")
1878 )
1879 )
1631 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNRECTEXTEND) 1880 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNRECTEXTEND)
1632 act.triggered.connect(self.esm.map) 1881 act.triggered.connect(self.esm.map)
1633 self.editActions.append(act) 1882 self.editActions.append(act)
1634 1883
1635 act = EricAction( 1884 act = EricAction(
1636 QCoreApplication.translate( 1885 QCoreApplication.translate(
1637 'ViewManager', 1886 "ViewManager", "Extend rectangular selection up one line"
1638 'Extend rectangular selection up one line'), 1887 ),
1639 QCoreApplication.translate( 1888 QCoreApplication.translate(
1640 'ViewManager', 1889 "ViewManager", "Extend rectangular selection up one line"
1641 'Extend rectangular selection up one line'), 1890 ),
1642 QKeySequence(QCoreApplication.translate('ViewManager', 1891 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Up")),
1643 'Alt+Ctrl+Up')), 1892 0,
1644 0, self.editorActGrp, 'vm_edit_extend_rect_selection_up_line') 1893 self.editorActGrp,
1894 "vm_edit_extend_rect_selection_up_line",
1895 )
1645 if isMacPlatform(): 1896 if isMacPlatform():
1646 act.setAlternateShortcut(QKeySequence( 1897 act.setAlternateShortcut(
1647 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+P'))) 1898 QKeySequence(
1899 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+P")
1900 )
1901 )
1648 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPRECTEXTEND) 1902 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPRECTEXTEND)
1649 act.triggered.connect(self.esm.map) 1903 act.triggered.connect(self.esm.map)
1650 self.editActions.append(act) 1904 self.editActions.append(act)
1651 1905
1652 act = EricAction( 1906 act = EricAction(
1653 QCoreApplication.translate( 1907 QCoreApplication.translate(
1654 'ViewManager', 1908 "ViewManager", "Extend rectangular selection left one character"
1655 'Extend rectangular selection left one character'), 1909 ),
1656 QCoreApplication.translate( 1910 QCoreApplication.translate(
1657 'ViewManager', 1911 "ViewManager", "Extend rectangular selection left one character"
1658 'Extend rectangular selection left one character'), 1912 ),
1659 QKeySequence(QCoreApplication.translate('ViewManager', 1913 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Left")),
1660 'Alt+Ctrl+Left')), 1914 0,
1661 0, self.editorActGrp, 'vm_edit_extend_rect_selection_left_char') 1915 self.editorActGrp,
1916 "vm_edit_extend_rect_selection_left_char",
1917 )
1662 if isMacPlatform(): 1918 if isMacPlatform():
1663 act.setAlternateShortcut(QKeySequence( 1919 act.setAlternateShortcut(
1664 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+B'))) 1920 QKeySequence(
1921 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+B")
1922 )
1923 )
1665 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTRECTEXTEND) 1924 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTRECTEXTEND)
1666 act.triggered.connect(self.esm.map) 1925 act.triggered.connect(self.esm.map)
1667 self.editActions.append(act) 1926 self.editActions.append(act)
1668 1927
1669 act = EricAction( 1928 act = EricAction(
1670 QCoreApplication.translate( 1929 QCoreApplication.translate(
1671 'ViewManager', 1930 "ViewManager", "Extend rectangular selection right one character"
1672 'Extend rectangular selection right one character'), 1931 ),
1673 QCoreApplication.translate( 1932 QCoreApplication.translate(
1674 'ViewManager', 1933 "ViewManager", "Extend rectangular selection right one character"
1675 'Extend rectangular selection right one character'), 1934 ),
1676 QKeySequence(QCoreApplication.translate('ViewManager', 1935 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Right")),
1677 'Alt+Ctrl+Right')), 1936 0,
1678 0, self.editorActGrp, 'vm_edit_extend_rect_selection_right_char') 1937 self.editorActGrp,
1938 "vm_edit_extend_rect_selection_right_char",
1939 )
1679 if isMacPlatform(): 1940 if isMacPlatform():
1680 act.setAlternateShortcut(QKeySequence( 1941 act.setAlternateShortcut(
1681 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+F'))) 1942 QKeySequence(
1943 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+F")
1944 )
1945 )
1682 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTRECTEXTEND) 1946 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTRECTEXTEND)
1683 act.triggered.connect(self.esm.map) 1947 act.triggered.connect(self.esm.map)
1684 self.editActions.append(act) 1948 self.editActions.append(act)
1685 1949
1686 act = EricAction( 1950 act = EricAction(
1687 QCoreApplication.translate( 1951 QCoreApplication.translate(
1688 'ViewManager', 1952 "ViewManager",
1689 'Extend rectangular selection to first' 1953 "Extend rectangular selection to first"
1690 ' visible character in document line'), 1954 " visible character in document line",
1691 QCoreApplication.translate( 1955 ),
1692 'ViewManager', 1956 QCoreApplication.translate(
1693 'Extend rectangular selection to first' 1957 "ViewManager",
1694 ' visible character in document line'), 1958 "Extend rectangular selection to first"
1695 0, 0, 1959 " visible character in document line",
1696 self.editorActGrp, 1960 ),
1697 'vm_edit_extend_rect_selection_first_visible_char') 1961 0,
1962 0,
1963 self.editorActGrp,
1964 "vm_edit_extend_rect_selection_first_visible_char",
1965 )
1698 if not isMacPlatform(): 1966 if not isMacPlatform():
1699 act.setShortcut(QKeySequence( 1967 act.setShortcut(
1700 QCoreApplication.translate('ViewManager', 'Alt+Shift+Home'))) 1968 QKeySequence(
1969 QCoreApplication.translate("ViewManager", "Alt+Shift+Home")
1970 )
1971 )
1701 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMERECTEXTEND) 1972 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMERECTEXTEND)
1702 act.triggered.connect(self.esm.map) 1973 act.triggered.connect(self.esm.map)
1703 self.editActions.append(act) 1974 self.editActions.append(act)
1704 1975
1705 act = EricAction( 1976 act = EricAction(
1706 QCoreApplication.translate( 1977 QCoreApplication.translate(
1707 'ViewManager', 1978 "ViewManager", "Extend rectangular selection to end of document line"
1708 'Extend rectangular selection to end of document line'), 1979 ),
1709 QCoreApplication.translate( 1980 QCoreApplication.translate(
1710 'ViewManager', 1981 "ViewManager", "Extend rectangular selection to end of document line"
1711 'Extend rectangular selection to end of document line'), 1982 ),
1712 0, 0, 1983 0,
1713 self.editorActGrp, 'vm_edit_extend_rect_selection_end_line') 1984 0,
1985 self.editorActGrp,
1986 "vm_edit_extend_rect_selection_end_line",
1987 )
1714 if isMacPlatform(): 1988 if isMacPlatform():
1715 act.setShortcut(QKeySequence( 1989 act.setShortcut(
1716 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+E'))) 1990 QKeySequence(
1991 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+E")
1992 )
1993 )
1717 else: 1994 else:
1718 act.setShortcut(QKeySequence( 1995 act.setShortcut(
1719 QCoreApplication.translate('ViewManager', 'Alt+Shift+End'))) 1996 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+End"))
1997 )
1720 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDRECTEXTEND) 1998 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDRECTEXTEND)
1721 act.triggered.connect(self.esm.map) 1999 act.triggered.connect(self.esm.map)
1722 self.editActions.append(act) 2000 self.editActions.append(act)
1723 2001
1724 act = EricAction( 2002 act = EricAction(
1725 QCoreApplication.translate( 2003 QCoreApplication.translate(
1726 'ViewManager', 2004 "ViewManager", "Extend rectangular selection up one page"
1727 'Extend rectangular selection up one page'), 2005 ),
1728 QCoreApplication.translate( 2006 QCoreApplication.translate(
1729 'ViewManager', 2007 "ViewManager", "Extend rectangular selection up one page"
1730 'Extend rectangular selection up one page'), 2008 ),
1731 QKeySequence(QCoreApplication.translate('ViewManager', 2009 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+PgUp")),
1732 'Alt+Shift+PgUp')), 2010 0,
1733 0, self.editorActGrp, 'vm_edit_extend_rect_selection_up_page') 2011 self.editorActGrp,
2012 "vm_edit_extend_rect_selection_up_page",
2013 )
1734 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPRECTEXTEND) 2014 self.esm.setMapping(act, QsciScintilla.SCI_PAGEUPRECTEXTEND)
1735 act.triggered.connect(self.esm.map) 2015 act.triggered.connect(self.esm.map)
1736 self.editActions.append(act) 2016 self.editActions.append(act)
1737 2017
1738 act = EricAction( 2018 act = EricAction(
1739 QCoreApplication.translate( 2019 QCoreApplication.translate(
1740 'ViewManager', 2020 "ViewManager", "Extend rectangular selection down one page"
1741 'Extend rectangular selection down one page'), 2021 ),
1742 QCoreApplication.translate( 2022 QCoreApplication.translate(
1743 'ViewManager', 2023 "ViewManager", "Extend rectangular selection down one page"
1744 'Extend rectangular selection down one page'), 2024 ),
1745 QKeySequence(QCoreApplication.translate('ViewManager', 2025 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+PgDown")),
1746 'Alt+Shift+PgDown')), 2026 0,
1747 0, self.editorActGrp, 'vm_edit_extend_rect_selection_down_page') 2027 self.editorActGrp,
2028 "vm_edit_extend_rect_selection_down_page",
2029 )
1748 if isMacPlatform(): 2030 if isMacPlatform():
1749 act.setAlternateShortcut(QKeySequence( 2031 act.setAlternateShortcut(
1750 QCoreApplication.translate('ViewManager', 'Meta+Alt+Shift+V'))) 2032 QKeySequence(
2033 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+V")
2034 )
2035 )
1751 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNRECTEXTEND) 2036 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNRECTEXTEND)
1752 act.triggered.connect(self.esm.map) 2037 act.triggered.connect(self.esm.map)
1753 self.editActions.append(act) 2038 self.editActions.append(act)
1754 2039
1755 act = EricAction( 2040 act = EricAction(
1756 QCoreApplication.translate( 2041 QCoreApplication.translate("ViewManager", "Duplicate current selection"),
1757 'ViewManager', 2042 QCoreApplication.translate("ViewManager", "Duplicate current selection"),
1758 'Duplicate current selection'), 2043 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Shift+D")),
1759 QCoreApplication.translate( 2044 0,
1760 'ViewManager', 2045 self.editorActGrp,
1761 'Duplicate current selection'), 2046 "vm_edit_duplicate_current_selection",
1762 QKeySequence(QCoreApplication.translate('ViewManager', 2047 )
1763 'Ctrl+Shift+D')),
1764 0, self.editorActGrp, 'vm_edit_duplicate_current_selection')
1765 self.esm.setMapping(act, QsciScintilla.SCI_SELECTIONDUPLICATE) 2048 self.esm.setMapping(act, QsciScintilla.SCI_SELECTIONDUPLICATE)
1766 act.triggered.connect(self.esm.map) 2049 act.triggered.connect(self.esm.map)
1767 self.editActions.append(act) 2050 self.editActions.append(act)
1768 2051
1769 if hasattr(QsciScintilla, "SCI_SCROLLTOSTART"): 2052 if hasattr(QsciScintilla, "SCI_SCROLLTOSTART"):
1770 act = EricAction( 2053 act = EricAction(
1771 QCoreApplication.translate( 2054 QCoreApplication.translate(
1772 'ViewManager', 'Scroll to start of document'), 2055 "ViewManager", "Scroll to start of document"
1773 QCoreApplication.translate( 2056 ),
1774 'ViewManager', 'Scroll to start of document'), 2057 QCoreApplication.translate(
1775 0, 0, 2058 "ViewManager", "Scroll to start of document"
1776 self.editorActGrp, 'vm_edit_scroll_start_text') 2059 ),
2060 0,
2061 0,
2062 self.editorActGrp,
2063 "vm_edit_scroll_start_text",
2064 )
1777 if isMacPlatform(): 2065 if isMacPlatform():
1778 act.setShortcut(QKeySequence( 2066 act.setShortcut(
1779 QCoreApplication.translate('ViewManager', 'Home'))) 2067 QKeySequence(QCoreApplication.translate("ViewManager", "Home"))
2068 )
1780 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOSTART) 2069 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOSTART)
1781 act.triggered.connect(self.esm.map) 2070 act.triggered.connect(self.esm.map)
1782 self.editActions.append(act) 2071 self.editActions.append(act)
1783 2072
1784 if hasattr(QsciScintilla, "SCI_SCROLLTOEND"): 2073 if hasattr(QsciScintilla, "SCI_SCROLLTOEND"):
1785 act = EricAction( 2074 act = EricAction(
1786 QCoreApplication.translate( 2075 QCoreApplication.translate("ViewManager", "Scroll to end of document"),
1787 'ViewManager', 'Scroll to end of document'), 2076 QCoreApplication.translate("ViewManager", "Scroll to end of document"),
1788 QCoreApplication.translate( 2077 0,
1789 'ViewManager', 'Scroll to end of document'), 2078 0,
1790 0, 0, 2079 self.editorActGrp,
1791 self.editorActGrp, 'vm_edit_scroll_end_text') 2080 "vm_edit_scroll_end_text",
2081 )
1792 if isMacPlatform(): 2082 if isMacPlatform():
1793 act.setShortcut(QKeySequence( 2083 act.setShortcut(
1794 QCoreApplication.translate('ViewManager', 'End'))) 2084 QKeySequence(QCoreApplication.translate("ViewManager", "End"))
2085 )
1795 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOEND) 2086 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOEND)
1796 act.triggered.connect(self.esm.map) 2087 act.triggered.connect(self.esm.map)
1797 self.editActions.append(act) 2088 self.editActions.append(act)
1798 2089
1799 if hasattr(QsciScintilla, "SCI_VERTICALCENTRECARET"): 2090 if hasattr(QsciScintilla, "SCI_VERTICALCENTRECARET"):
1800 act = EricAction( 2091 act = EricAction(
1801 QCoreApplication.translate( 2092 QCoreApplication.translate(
1802 'ViewManager', 'Scroll vertically to center current line'), 2093 "ViewManager", "Scroll vertically to center current line"
1803 QCoreApplication.translate( 2094 ),
1804 'ViewManager', 'Scroll vertically to center current line'), 2095 QCoreApplication.translate(
1805 0, 0, 2096 "ViewManager", "Scroll vertically to center current line"
1806 self.editorActGrp, 'vm_edit_scroll_vertically_center') 2097 ),
2098 0,
2099 0,
2100 self.editorActGrp,
2101 "vm_edit_scroll_vertically_center",
2102 )
1807 if isMacPlatform(): 2103 if isMacPlatform():
1808 act.setShortcut(QKeySequence( 2104 act.setShortcut(
1809 QCoreApplication.translate('ViewManager', 'Meta+L'))) 2105 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+L"))
2106 )
1810 self.esm.setMapping(act, QsciScintilla.SCI_VERTICALCENTRECARET) 2107 self.esm.setMapping(act, QsciScintilla.SCI_VERTICALCENTRECARET)
1811 act.triggered.connect(self.esm.map) 2108 act.triggered.connect(self.esm.map)
1812 self.editActions.append(act) 2109 self.editActions.append(act)
1813 2110
1814 if hasattr(QsciScintilla, "SCI_WORDRIGHTEND"): 2111 if hasattr(QsciScintilla, "SCI_WORDRIGHTEND"):
1815 act = EricAction( 2112 act = EricAction(
1816 QCoreApplication.translate( 2113 QCoreApplication.translate("ViewManager", "Move to end of next word"),
1817 'ViewManager', 'Move to end of next word'), 2114 QCoreApplication.translate("ViewManager", "Move to end of next word"),
1818 QCoreApplication.translate( 2115 0,
1819 'ViewManager', 'Move to end of next word'), 2116 0,
1820 0, 0, 2117 self.editorActGrp,
1821 self.editorActGrp, 'vm_edit_move_end_next_word') 2118 "vm_edit_move_end_next_word",
2119 )
1822 if isMacPlatform(): 2120 if isMacPlatform():
1823 act.setShortcut(QKeySequence( 2121 act.setShortcut(
1824 QCoreApplication.translate('ViewManager', 'Alt+Right'))) 2122 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Right"))
2123 )
1825 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEND) 2124 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEND)
1826 act.triggered.connect(self.esm.map) 2125 act.triggered.connect(self.esm.map)
1827 self.editActions.append(act) 2126 self.editActions.append(act)
1828 2127
1829 if hasattr(QsciScintilla, "SCI_WORDRIGHTENDEXTEND"): 2128 if hasattr(QsciScintilla, "SCI_WORDRIGHTENDEXTEND"):
1830 act = EricAction( 2129 act = EricAction(
1831 QCoreApplication.translate( 2130 QCoreApplication.translate(
1832 'ViewManager', 'Extend selection to end of next word'), 2131 "ViewManager", "Extend selection to end of next word"
1833 QCoreApplication.translate( 2132 ),
1834 'ViewManager', 'Extend selection to end of next word'), 2133 QCoreApplication.translate(
1835 0, 0, 2134 "ViewManager", "Extend selection to end of next word"
1836 self.editorActGrp, 'vm_edit_select_end_next_word') 2135 ),
2136 0,
2137 0,
2138 self.editorActGrp,
2139 "vm_edit_select_end_next_word",
2140 )
1837 if isMacPlatform(): 2141 if isMacPlatform():
1838 act.setShortcut(QKeySequence( 2142 act.setShortcut(
1839 QCoreApplication.translate('ViewManager', 2143 QKeySequence(
1840 'Alt+Shift+Right'))) 2144 QCoreApplication.translate("ViewManager", "Alt+Shift+Right")
2145 )
2146 )
1841 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTENDEXTEND) 2147 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTENDEXTEND)
1842 act.triggered.connect(self.esm.map) 2148 act.triggered.connect(self.esm.map)
1843 self.editActions.append(act) 2149 self.editActions.append(act)
1844 2150
1845 if hasattr(QsciScintilla, "SCI_WORDLEFTEND"): 2151 if hasattr(QsciScintilla, "SCI_WORDLEFTEND"):
1846 act = EricAction( 2152 act = EricAction(
1847 QCoreApplication.translate( 2153 QCoreApplication.translate(
1848 'ViewManager', 'Move to end of previous word'), 2154 "ViewManager", "Move to end of previous word"
1849 QCoreApplication.translate( 2155 ),
1850 'ViewManager', 'Move to end of previous word'), 2156 QCoreApplication.translate(
1851 0, 0, 2157 "ViewManager", "Move to end of previous word"
1852 self.editorActGrp, 'vm_edit_move_end_previous_word') 2158 ),
2159 0,
2160 0,
2161 self.editorActGrp,
2162 "vm_edit_move_end_previous_word",
2163 )
1853 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEND) 2164 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTEND)
1854 act.triggered.connect(self.esm.map) 2165 act.triggered.connect(self.esm.map)
1855 self.editActions.append(act) 2166 self.editActions.append(act)
1856 2167
1857 if hasattr(QsciScintilla, "SCI_WORDLEFTENDEXTEND"): 2168 if hasattr(QsciScintilla, "SCI_WORDLEFTENDEXTEND"):
1858 act = EricAction( 2169 act = EricAction(
1859 QCoreApplication.translate( 2170 QCoreApplication.translate(
1860 'ViewManager', 'Extend selection to end of previous word'), 2171 "ViewManager", "Extend selection to end of previous word"
1861 QCoreApplication.translate( 2172 ),
1862 'ViewManager', 'Extend selection to end of previous word'), 2173 QCoreApplication.translate(
1863 0, 0, 2174 "ViewManager", "Extend selection to end of previous word"
1864 self.editorActGrp, 'vm_edit_select_end_previous_word') 2175 ),
2176 0,
2177 0,
2178 self.editorActGrp,
2179 "vm_edit_select_end_previous_word",
2180 )
1865 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTENDEXTEND) 2181 self.esm.setMapping(act, QsciScintilla.SCI_WORDLEFTENDEXTEND)
1866 act.triggered.connect(self.esm.map) 2182 act.triggered.connect(self.esm.map)
1867 self.editActions.append(act) 2183 self.editActions.append(act)
1868 2184
1869 if hasattr(QsciScintilla, "SCI_HOME"): 2185 if hasattr(QsciScintilla, "SCI_HOME"):
1870 act = EricAction( 2186 act = EricAction(
1871 QCoreApplication.translate( 2187 QCoreApplication.translate(
1872 'ViewManager', 'Move to start of document line'), 2188 "ViewManager", "Move to start of document line"
1873 QCoreApplication.translate( 2189 ),
1874 'ViewManager', 'Move to start of document line'), 2190 QCoreApplication.translate(
1875 0, 0, 2191 "ViewManager", "Move to start of document line"
1876 self.editorActGrp, 'vm_edit_move_start_document_line') 2192 ),
2193 0,
2194 0,
2195 self.editorActGrp,
2196 "vm_edit_move_start_document_line",
2197 )
1877 if isMacPlatform(): 2198 if isMacPlatform():
1878 act.setShortcut(QKeySequence( 2199 act.setShortcut(
1879 QCoreApplication.translate('ViewManager', 'Meta+A'))) 2200 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+A"))
2201 )
1880 self.esm.setMapping(act, QsciScintilla.SCI_HOME) 2202 self.esm.setMapping(act, QsciScintilla.SCI_HOME)
1881 act.triggered.connect(self.esm.map) 2203 act.triggered.connect(self.esm.map)
1882 self.editActions.append(act) 2204 self.editActions.append(act)
1883 2205
1884 if hasattr(QsciScintilla, "SCI_HOMEEXTEND"): 2206 if hasattr(QsciScintilla, "SCI_HOMEEXTEND"):
1885 act = EricAction( 2207 act = EricAction(
1886 QCoreApplication.translate( 2208 QCoreApplication.translate(
1887 'ViewManager', 2209 "ViewManager", "Extend selection to start of document line"
1888 'Extend selection to start of document line'), 2210 ),
1889 QCoreApplication.translate( 2211 QCoreApplication.translate(
1890 'ViewManager', 2212 "ViewManager", "Extend selection to start of document line"
1891 'Extend selection to start of document line'), 2213 ),
1892 0, 0, 2214 0,
2215 0,
1893 self.editorActGrp, 2216 self.editorActGrp,
1894 'vm_edit_extend_selection_start_document_line') 2217 "vm_edit_extend_selection_start_document_line",
2218 )
1895 if isMacPlatform(): 2219 if isMacPlatform():
1896 act.setShortcut(QKeySequence( 2220 act.setShortcut(
1897 QCoreApplication.translate('ViewManager', 'Meta+Shift+A'))) 2221 QKeySequence(
2222 QCoreApplication.translate("ViewManager", "Meta+Shift+A")
2223 )
2224 )
1898 self.esm.setMapping(act, QsciScintilla.SCI_HOME) 2225 self.esm.setMapping(act, QsciScintilla.SCI_HOME)
1899 act.triggered.connect(self.esm.map) 2226 act.triggered.connect(self.esm.map)
1900 self.editActions.append(act) 2227 self.editActions.append(act)
1901 2228
1902 if hasattr(QsciScintilla, "SCI_HOMERECTEXTEND"): 2229 if hasattr(QsciScintilla, "SCI_HOMERECTEXTEND"):
1903 act = EricAction( 2230 act = EricAction(
1904 QCoreApplication.translate( 2231 QCoreApplication.translate(
1905 'ViewManager', 2232 "ViewManager",
1906 'Extend rectangular selection to start of document line'), 2233 "Extend rectangular selection to start of document line",
1907 QCoreApplication.translate( 2234 ),
1908 'ViewManager', 2235 QCoreApplication.translate(
1909 'Extend rectangular selection to start of document line'), 2236 "ViewManager",
1910 0, 0, 2237 "Extend rectangular selection to start of document line",
1911 self.editorActGrp, 'vm_edit_select_rect_start_line') 2238 ),
2239 0,
2240 0,
2241 self.editorActGrp,
2242 "vm_edit_select_rect_start_line",
2243 )
1912 if isMacPlatform(): 2244 if isMacPlatform():
1913 act.setShortcut(QKeySequence( 2245 act.setShortcut(
1914 QCoreApplication.translate('ViewManager', 2246 QKeySequence(
1915 'Meta+Alt+Shift+A'))) 2247 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+A")
2248 )
2249 )
1916 self.esm.setMapping(act, QsciScintilla.SCI_HOMERECTEXTEND) 2250 self.esm.setMapping(act, QsciScintilla.SCI_HOMERECTEXTEND)
1917 act.triggered.connect(self.esm.map) 2251 act.triggered.connect(self.esm.map)
1918 self.editActions.append(act) 2252 self.editActions.append(act)
1919 2253
1920 if hasattr(QsciScintilla, "SCI_HOMEDISPLAYEXTEND"): 2254 if hasattr(QsciScintilla, "SCI_HOMEDISPLAYEXTEND"):
1921 act = EricAction( 2255 act = EricAction(
1922 QCoreApplication.translate( 2256 QCoreApplication.translate(
1923 'ViewManager', 2257 "ViewManager", "Extend selection to start of display line"
1924 'Extend selection to start of display line'), 2258 ),
1925 QCoreApplication.translate( 2259 QCoreApplication.translate(
1926 'ViewManager', 2260 "ViewManager", "Extend selection to start of display line"
1927 'Extend selection to start of display line'), 2261 ),
1928 0, 0, 2262 0,
2263 0,
1929 self.editorActGrp, 2264 self.editorActGrp,
1930 'vm_edit_extend_selection_start_display_line') 2265 "vm_edit_extend_selection_start_display_line",
2266 )
1931 if isMacPlatform(): 2267 if isMacPlatform():
1932 act.setShortcut(QKeySequence( 2268 act.setShortcut(
1933 QCoreApplication.translate('ViewManager', 2269 QKeySequence(
1934 'Ctrl+Shift+Left'))) 2270 QCoreApplication.translate("ViewManager", "Ctrl+Shift+Left")
2271 )
2272 )
1935 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAYEXTEND) 2273 self.esm.setMapping(act, QsciScintilla.SCI_HOMEDISPLAYEXTEND)
1936 act.triggered.connect(self.esm.map) 2274 act.triggered.connect(self.esm.map)
1937 self.editActions.append(act) 2275 self.editActions.append(act)
1938 2276
1939 if hasattr(QsciScintilla, "SCI_HOMEWRAP"): 2277 if hasattr(QsciScintilla, "SCI_HOMEWRAP"):
1940 act = EricAction( 2278 act = EricAction(
1941 QCoreApplication.translate( 2279 QCoreApplication.translate(
1942 'ViewManager', 2280 "ViewManager", "Move to start of display or document line"
1943 'Move to start of display or document line'), 2281 ),
1944 QCoreApplication.translate( 2282 QCoreApplication.translate(
1945 'ViewManager', 2283 "ViewManager", "Move to start of display or document line"
1946 'Move to start of display or document line'), 2284 ),
1947 0, 0, 2285 0,
1948 self.editorActGrp, 'vm_edit_move_start_display_document_line') 2286 0,
2287 self.editorActGrp,
2288 "vm_edit_move_start_display_document_line",
2289 )
1949 self.esm.setMapping(act, QsciScintilla.SCI_HOMEWRAP) 2290 self.esm.setMapping(act, QsciScintilla.SCI_HOMEWRAP)
1950 act.triggered.connect(self.esm.map) 2291 act.triggered.connect(self.esm.map)
1951 self.editActions.append(act) 2292 self.editActions.append(act)
1952 2293
1953 if hasattr(QsciScintilla, "SCI_HOMEWRAPEXTEND"): 2294 if hasattr(QsciScintilla, "SCI_HOMEWRAPEXTEND"):
1954 act = EricAction( 2295 act = EricAction(
1955 QCoreApplication.translate( 2296 QCoreApplication.translate(
1956 'ViewManager', 2297 "ViewManager",
1957 'Extend selection to start of display or document line'), 2298 "Extend selection to start of display or document line",
1958 QCoreApplication.translate( 2299 ),
1959 'ViewManager', 2300 QCoreApplication.translate(
1960 'Extend selection to start of display or document line'), 2301 "ViewManager",
1961 0, 0, 2302 "Extend selection to start of display or document line",
2303 ),
2304 0,
2305 0,
1962 self.editorActGrp, 2306 self.editorActGrp,
1963 'vm_edit_extend_selection_start_display_document_line') 2307 "vm_edit_extend_selection_start_display_document_line",
2308 )
1964 self.esm.setMapping(act, QsciScintilla.SCI_HOMEWRAPEXTEND) 2309 self.esm.setMapping(act, QsciScintilla.SCI_HOMEWRAPEXTEND)
1965 act.triggered.connect(self.esm.map) 2310 act.triggered.connect(self.esm.map)
1966 self.editActions.append(act) 2311 self.editActions.append(act)
1967 2312
1968 if hasattr(QsciScintilla, "SCI_VCHOMEWRAP"): 2313 if hasattr(QsciScintilla, "SCI_VCHOMEWRAP"):
1969 act = EricAction( 2314 act = EricAction(
1970 QCoreApplication.translate( 2315 QCoreApplication.translate(
1971 'ViewManager', 2316 "ViewManager",
1972 'Move to first visible character in display' 2317 "Move to first visible character in display" " or document line",
1973 ' or document line'), 2318 ),
1974 QCoreApplication.translate( 2319 QCoreApplication.translate(
1975 'ViewManager', 2320 "ViewManager",
1976 'Move to first visible character in display' 2321 "Move to first visible character in display" " or document line",
1977 ' or document line'), 2322 ),
1978 0, 0, 2323 0,
2324 0,
1979 self.editorActGrp, 2325 self.editorActGrp,
1980 'vm_edit_move_first_visible_char_document_line') 2326 "vm_edit_move_first_visible_char_document_line",
2327 )
1981 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEWRAP) 2328 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEWRAP)
1982 act.triggered.connect(self.esm.map) 2329 act.triggered.connect(self.esm.map)
1983 self.editActions.append(act) 2330 self.editActions.append(act)
1984 2331
1985 if hasattr(QsciScintilla, "SCI_VCHOMEWRAPEXTEND"): 2332 if hasattr(QsciScintilla, "SCI_VCHOMEWRAPEXTEND"):
1986 act = EricAction( 2333 act = EricAction(
1987 QCoreApplication.translate( 2334 QCoreApplication.translate(
1988 'ViewManager', 2335 "ViewManager",
1989 'Extend selection to first visible character in' 2336 "Extend selection to first visible character in"
1990 ' display or document line'), 2337 " display or document line",
1991 QCoreApplication.translate( 2338 ),
1992 'ViewManager', 2339 QCoreApplication.translate(
1993 'Extend selection to first visible character in' 2340 "ViewManager",
1994 ' display or document line'), 2341 "Extend selection to first visible character in"
1995 0, 0, 2342 " display or document line",
2343 ),
2344 0,
2345 0,
1996 self.editorActGrp, 2346 self.editorActGrp,
1997 'vm_edit_extend_selection_first_visible_char_document_line') 2347 "vm_edit_extend_selection_first_visible_char_document_line",
2348 )
1998 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEWRAPEXTEND) 2349 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEWRAPEXTEND)
1999 act.triggered.connect(self.esm.map) 2350 act.triggered.connect(self.esm.map)
2000 self.editActions.append(act) 2351 self.editActions.append(act)
2001 2352
2002 if hasattr(QsciScintilla, "SCI_LINEENDWRAP"): 2353 if hasattr(QsciScintilla, "SCI_LINEENDWRAP"):
2003 act = EricAction( 2354 act = EricAction(
2004 QCoreApplication.translate( 2355 QCoreApplication.translate(
2005 'ViewManager', 2356 "ViewManager", "Move to end of display or document line"
2006 'Move to end of display or document line'), 2357 ),
2007 QCoreApplication.translate( 2358 QCoreApplication.translate(
2008 'ViewManager', 2359 "ViewManager", "Move to end of display or document line"
2009 'Move to end of display or document line'), 2360 ),
2010 0, 0, 2361 0,
2011 self.editorActGrp, 'vm_edit_end_start_display_document_line') 2362 0,
2363 self.editorActGrp,
2364 "vm_edit_end_start_display_document_line",
2365 )
2012 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDWRAP) 2366 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDWRAP)
2013 act.triggered.connect(self.esm.map) 2367 act.triggered.connect(self.esm.map)
2014 self.editActions.append(act) 2368 self.editActions.append(act)
2015 2369
2016 if hasattr(QsciScintilla, "SCI_LINEENDWRAPEXTEND"): 2370 if hasattr(QsciScintilla, "SCI_LINEENDWRAPEXTEND"):
2017 act = EricAction( 2371 act = EricAction(
2018 QCoreApplication.translate( 2372 QCoreApplication.translate(
2019 'ViewManager', 2373 "ViewManager", "Extend selection to end of display or document line"
2020 'Extend selection to end of display or document line'), 2374 ),
2021 QCoreApplication.translate( 2375 QCoreApplication.translate(
2022 'ViewManager', 2376 "ViewManager", "Extend selection to end of display or document line"
2023 'Extend selection to end of display or document line'), 2377 ),
2024 0, 0, 2378 0,
2379 0,
2025 self.editorActGrp, 2380 self.editorActGrp,
2026 'vm_edit_extend_selection_end_display_document_line') 2381 "vm_edit_extend_selection_end_display_document_line",
2382 )
2027 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDWRAPEXTEND) 2383 self.esm.setMapping(act, QsciScintilla.SCI_LINEENDWRAPEXTEND)
2028 act.triggered.connect(self.esm.map) 2384 act.triggered.connect(self.esm.map)
2029 self.editActions.append(act) 2385 self.editActions.append(act)
2030 2386
2031 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEUP"): 2387 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEUP"):
2032 act = EricAction( 2388 act = EricAction(
2033 QCoreApplication.translate( 2389 QCoreApplication.translate("ViewManager", "Stuttered move up one page"),
2034 'ViewManager', 'Stuttered move up one page'), 2390 QCoreApplication.translate("ViewManager", "Stuttered move up one page"),
2035 QCoreApplication.translate( 2391 0,
2036 'ViewManager', 'Stuttered move up one page'), 2392 0,
2037 0, 0, 2393 self.editorActGrp,
2038 self.editorActGrp, 'vm_edit_stuttered_move_up_page') 2394 "vm_edit_stuttered_move_up_page",
2395 )
2039 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEUP) 2396 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEUP)
2040 act.triggered.connect(self.esm.map) 2397 act.triggered.connect(self.esm.map)
2041 self.editActions.append(act) 2398 self.editActions.append(act)
2042 2399
2043 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEUPEXTEND"): 2400 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEUPEXTEND"):
2044 act = EricAction( 2401 act = EricAction(
2045 QCoreApplication.translate( 2402 QCoreApplication.translate(
2046 'ViewManager', 2403 "ViewManager", "Stuttered extend selection up one page"
2047 'Stuttered extend selection up one page'), 2404 ),
2048 QCoreApplication.translate( 2405 QCoreApplication.translate(
2049 'ViewManager', 2406 "ViewManager", "Stuttered extend selection up one page"
2050 'Stuttered extend selection up one page'), 2407 ),
2051 0, 0, 2408 0,
2409 0,
2052 self.editorActGrp, 2410 self.editorActGrp,
2053 'vm_edit_stuttered_extend_selection_up_page') 2411 "vm_edit_stuttered_extend_selection_up_page",
2412 )
2054 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEUPEXTEND) 2413 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEUPEXTEND)
2055 act.triggered.connect(self.esm.map) 2414 act.triggered.connect(self.esm.map)
2056 self.editActions.append(act) 2415 self.editActions.append(act)
2057 2416
2058 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEDOWN"): 2417 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEDOWN"):
2059 act = EricAction( 2418 act = EricAction(
2060 QCoreApplication.translate( 2419 QCoreApplication.translate(
2061 'ViewManager', 'Stuttered move down one page'), 2420 "ViewManager", "Stuttered move down one page"
2062 QCoreApplication.translate( 2421 ),
2063 'ViewManager', 'Stuttered move down one page'), 2422 QCoreApplication.translate(
2064 0, 0, 2423 "ViewManager", "Stuttered move down one page"
2065 self.editorActGrp, 'vm_edit_stuttered_move_down_page') 2424 ),
2425 0,
2426 0,
2427 self.editorActGrp,
2428 "vm_edit_stuttered_move_down_page",
2429 )
2066 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEDOWN) 2430 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEDOWN)
2067 act.triggered.connect(self.esm.map) 2431 act.triggered.connect(self.esm.map)
2068 self.editActions.append(act) 2432 self.editActions.append(act)
2069 2433
2070 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEDOWNEXTEND"): 2434 if hasattr(QsciScintilla, "SCI_STUTTEREDPAGEDOWNEXTEND"):
2071 act = EricAction( 2435 act = EricAction(
2072 QCoreApplication.translate( 2436 QCoreApplication.translate(
2073 'ViewManager', 2437 "ViewManager", "Stuttered extend selection down one page"
2074 'Stuttered extend selection down one page'), 2438 ),
2075 QCoreApplication.translate( 2439 QCoreApplication.translate(
2076 'ViewManager', 2440 "ViewManager", "Stuttered extend selection down one page"
2077 'Stuttered extend selection down one page'), 2441 ),
2078 0, 0, 2442 0,
2443 0,
2079 self.editorActGrp, 2444 self.editorActGrp,
2080 'vm_edit_stuttered_extend_selection_down_page') 2445 "vm_edit_stuttered_extend_selection_down_page",
2446 )
2081 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEDOWNEXTEND) 2447 self.esm.setMapping(act, QsciScintilla.SCI_STUTTEREDPAGEDOWNEXTEND)
2082 act.triggered.connect(self.esm.map) 2448 act.triggered.connect(self.esm.map)
2083 self.editActions.append(act) 2449 self.editActions.append(act)
2084 2450
2085 if hasattr(QsciScintilla, "SCI_DELWORDRIGHTEND"): 2451 if hasattr(QsciScintilla, "SCI_DELWORDRIGHTEND"):
2086 act = EricAction( 2452 act = EricAction(
2087 QCoreApplication.translate( 2453 QCoreApplication.translate(
2088 'ViewManager', 2454 "ViewManager", "Delete right to end of next word"
2089 'Delete right to end of next word'), 2455 ),
2090 QCoreApplication.translate( 2456 QCoreApplication.translate(
2091 'ViewManager', 2457 "ViewManager", "Delete right to end of next word"
2092 'Delete right to end of next word'), 2458 ),
2093 0, 0, 2459 0,
2094 self.editorActGrp, 'vm_edit_delete_right_end_next_word') 2460 0,
2461 self.editorActGrp,
2462 "vm_edit_delete_right_end_next_word",
2463 )
2095 if isMacPlatform(): 2464 if isMacPlatform():
2096 act.setShortcut(QKeySequence( 2465 act.setShortcut(
2097 QCoreApplication.translate('ViewManager', 'Alt+Del'))) 2466 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Del"))
2467 )
2098 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHTEND) 2468 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHTEND)
2099 act.triggered.connect(self.esm.map) 2469 act.triggered.connect(self.esm.map)
2100 self.editActions.append(act) 2470 self.editActions.append(act)
2101 2471
2102 if hasattr(QsciScintilla, "SCI_MOVESELECTEDLINESUP"): 2472 if hasattr(QsciScintilla, "SCI_MOVESELECTEDLINESUP"):
2103 act = EricAction( 2473 act = EricAction(
2104 QCoreApplication.translate( 2474 QCoreApplication.translate(
2105 'ViewManager', 2475 "ViewManager", "Move selected lines up one line"
2106 'Move selected lines up one line'), 2476 ),
2107 QCoreApplication.translate( 2477 QCoreApplication.translate(
2108 'ViewManager', 2478 "ViewManager", "Move selected lines up one line"
2109 'Move selected lines up one line'), 2479 ),
2110 0, 0, 2480 0,
2111 self.editorActGrp, 'vm_edit_move_selection_up_one_line') 2481 0,
2482 self.editorActGrp,
2483 "vm_edit_move_selection_up_one_line",
2484 )
2112 self.esm.setMapping(act, QsciScintilla.SCI_MOVESELECTEDLINESUP) 2485 self.esm.setMapping(act, QsciScintilla.SCI_MOVESELECTEDLINESUP)
2113 act.triggered.connect(self.esm.map) 2486 act.triggered.connect(self.esm.map)
2114 self.editActions.append(act) 2487 self.editActions.append(act)
2115 2488
2116 if hasattr(QsciScintilla, "SCI_MOVESELECTEDLINESDOWN"): 2489 if hasattr(QsciScintilla, "SCI_MOVESELECTEDLINESDOWN"):
2117 act = EricAction( 2490 act = EricAction(
2118 QCoreApplication.translate( 2491 QCoreApplication.translate(
2119 'ViewManager', 2492 "ViewManager", "Move selected lines down one line"
2120 'Move selected lines down one line'), 2493 ),
2121 QCoreApplication.translate( 2494 QCoreApplication.translate(
2122 'ViewManager', 2495 "ViewManager", "Move selected lines down one line"
2123 'Move selected lines down one line'), 2496 ),
2124 0, 0, 2497 0,
2125 self.editorActGrp, 'vm_edit_move_selection_down_one_line') 2498 0,
2499 self.editorActGrp,
2500 "vm_edit_move_selection_down_one_line",
2501 )
2126 self.esm.setMapping(act, QsciScintilla.SCI_MOVESELECTEDLINESDOWN) 2502 self.esm.setMapping(act, QsciScintilla.SCI_MOVESELECTEDLINESDOWN)
2127 act.triggered.connect(self.esm.map) 2503 act.triggered.connect(self.esm.map)
2128 self.editActions.append(act) 2504 self.editActions.append(act)
2129 2505
2130 act = EricAction( 2506 act = EricAction(
2131 QCoreApplication.translate( 2507 QCoreApplication.translate("ViewManager", "Duplicate current selection"),
2132 'ViewManager', 2508 QCoreApplication.translate("ViewManager", "Duplicate current selection"),
2133 'Duplicate current selection'), 2509 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Shift+D")),
2134 QCoreApplication.translate( 2510 0,
2135 'ViewManager', 2511 self.editorActGrp,
2136 'Duplicate current selection'), 2512 "vm_edit_duplicate_current_selection",
2137 QKeySequence(QCoreApplication.translate('ViewManager', 2513 )
2138 'Ctrl+Shift+D')),
2139 0, self.editorActGrp, 'vm_edit_duplicate_current_selection')
2140 self.esm.setMapping(act, QsciScintilla.SCI_SELECTIONDUPLICATE) 2514 self.esm.setMapping(act, QsciScintilla.SCI_SELECTIONDUPLICATE)
2141 act.triggered.connect(self.esm.map) 2515 act.triggered.connect(self.esm.map)
2142 self.editActions.append(act) 2516 self.editActions.append(act)
2143 2517
2144 self.__textEdit.addActions(self.editorActGrp.actions()) 2518 self.__textEdit.addActions(self.editorActGrp.actions())
2145 2519
2146 def __createSearchActions(self): 2520 def __createSearchActions(self):
2147 """ 2521 """
2148 Private method defining the user interface actions for the search 2522 Private method defining the user interface actions for the search
2149 commands. 2523 commands.
2150 """ 2524 """
2151 self.searchAct = EricAction( 2525 self.searchAct = EricAction(
2152 QCoreApplication.translate('ViewManager', 'Search'), 2526 QCoreApplication.translate("ViewManager", "Search"),
2153 UI.PixmapCache.getIcon("find"), 2527 UI.PixmapCache.getIcon("find"),
2154 QCoreApplication.translate('ViewManager', '&Search...'), 2528 QCoreApplication.translate("ViewManager", "&Search..."),
2155 QKeySequence(QCoreApplication.translate( 2529 QKeySequence(
2156 'ViewManager', "Ctrl+F", "Search|Search")), 2530 QCoreApplication.translate("ViewManager", "Ctrl+F", "Search|Search")
2157 0, 2531 ),
2158 self, 'vm_search') 2532 0,
2533 self,
2534 "vm_search",
2535 )
2159 self.searchAct.setStatusTip( 2536 self.searchAct.setStatusTip(
2160 QCoreApplication.translate('ViewManager', 'Search for a text')) 2537 QCoreApplication.translate("ViewManager", "Search for a text")
2161 self.searchAct.setWhatsThis(QCoreApplication.translate( 2538 )
2162 'ViewManager', 2539 self.searchAct.setWhatsThis(
2163 """<b>Search</b>""" 2540 QCoreApplication.translate(
2164 """<p>Search for some text in the current editor. A""" 2541 "ViewManager",
2165 """ dialog is shown to enter the searchtext and options""" 2542 """<b>Search</b>"""
2166 """ for the search.</p>""" 2543 """<p>Search for some text in the current editor. A"""
2167 )) 2544 """ dialog is shown to enter the searchtext and options"""
2545 """ for the search.</p>""",
2546 )
2547 )
2168 self.searchAct.triggered.connect(self.showSearchWidget) 2548 self.searchAct.triggered.connect(self.showSearchWidget)
2169 self.searchActions.append(self.searchAct) 2549 self.searchActions.append(self.searchAct)
2170 2550
2171 self.searchNextAct = EricAction( 2551 self.searchNextAct = EricAction(
2172 QCoreApplication.translate('ViewManager', 'Search next'), 2552 QCoreApplication.translate("ViewManager", "Search next"),
2173 UI.PixmapCache.getIcon("findNext"), 2553 UI.PixmapCache.getIcon("findNext"),
2174 QCoreApplication.translate('ViewManager', 'Search &next'), 2554 QCoreApplication.translate("ViewManager", "Search &next"),
2175 QKeySequence(QCoreApplication.translate( 2555 QKeySequence(
2176 'ViewManager', "F3", "Search|Search next")), 2556 QCoreApplication.translate("ViewManager", "F3", "Search|Search next")
2177 0, 2557 ),
2178 self, 'vm_search_next') 2558 0,
2179 self.searchNextAct.setStatusTip(QCoreApplication.translate( 2559 self,
2180 'ViewManager', 'Search next occurrence of text')) 2560 "vm_search_next",
2181 self.searchNextAct.setWhatsThis(QCoreApplication.translate( 2561 )
2182 'ViewManager', 2562 self.searchNextAct.setStatusTip(
2183 """<b>Search next</b>""" 2563 QCoreApplication.translate("ViewManager", "Search next occurrence of text")
2184 """<p>Search the next occurrence of some text in the current""" 2564 )
2185 """ editor. The previously entered searchtext and options are""" 2565 self.searchNextAct.setWhatsThis(
2186 """ reused.</p>""" 2566 QCoreApplication.translate(
2187 )) 2567 "ViewManager",
2568 """<b>Search next</b>"""
2569 """<p>Search the next occurrence of some text in the current"""
2570 """ editor. The previously entered searchtext and options are"""
2571 """ reused.</p>""",
2572 )
2573 )
2188 self.searchNextAct.triggered.connect(self.__searchNext) 2574 self.searchNextAct.triggered.connect(self.__searchNext)
2189 self.searchActions.append(self.searchNextAct) 2575 self.searchActions.append(self.searchNextAct)
2190 2576
2191 self.searchPrevAct = EricAction( 2577 self.searchPrevAct = EricAction(
2192 QCoreApplication.translate('ViewManager', 'Search previous'), 2578 QCoreApplication.translate("ViewManager", "Search previous"),
2193 UI.PixmapCache.getIcon("findPrev"), 2579 UI.PixmapCache.getIcon("findPrev"),
2194 QCoreApplication.translate('ViewManager', 'Search &previous'), 2580 QCoreApplication.translate("ViewManager", "Search &previous"),
2195 QKeySequence(QCoreApplication.translate( 2581 QKeySequence(
2196 'ViewManager', "Shift+F3", "Search|Search previous")), 2582 QCoreApplication.translate(
2197 0, 2583 "ViewManager", "Shift+F3", "Search|Search previous"
2198 self, 'vm_search_previous') 2584 )
2199 self.searchPrevAct.setStatusTip(QCoreApplication.translate( 2585 ),
2200 'ViewManager', 'Search previous occurrence of text')) 2586 0,
2201 self.searchPrevAct.setWhatsThis(QCoreApplication.translate( 2587 self,
2202 'ViewManager', 2588 "vm_search_previous",
2203 """<b>Search previous</b>""" 2589 )
2204 """<p>Search the previous occurrence of some text in the""" 2590 self.searchPrevAct.setStatusTip(
2205 """ current editor. The previously entered searchtext and""" 2591 QCoreApplication.translate(
2206 """ options are reused.</p>""" 2592 "ViewManager", "Search previous occurrence of text"
2207 )) 2593 )
2594 )
2595 self.searchPrevAct.setWhatsThis(
2596 QCoreApplication.translate(
2597 "ViewManager",
2598 """<b>Search previous</b>"""
2599 """<p>Search the previous occurrence of some text in the"""
2600 """ current editor. The previously entered searchtext and"""
2601 """ options are reused.</p>""",
2602 )
2603 )
2208 self.searchPrevAct.triggered.connect(self.__searchPrev) 2604 self.searchPrevAct.triggered.connect(self.__searchPrev)
2209 self.searchActions.append(self.searchPrevAct) 2605 self.searchActions.append(self.searchPrevAct)
2210 2606
2211 self.searchClearMarkersAct = EricAction( 2607 self.searchClearMarkersAct = EricAction(
2212 QCoreApplication.translate('ViewManager', 2608 QCoreApplication.translate("ViewManager", "Clear search markers"),
2213 'Clear search markers'),
2214 UI.PixmapCache.getIcon("findClear"), 2609 UI.PixmapCache.getIcon("findClear"),
2215 QCoreApplication.translate('ViewManager', 'Clear search markers'), 2610 QCoreApplication.translate("ViewManager", "Clear search markers"),
2216 QKeySequence(QCoreApplication.translate( 2611 QKeySequence(
2217 'ViewManager', "Ctrl+3", "Search|Clear search markers")), 2612 QCoreApplication.translate(
2218 0, 2613 "ViewManager", "Ctrl+3", "Search|Clear search markers"
2219 self, 'vm_clear_search_markers') 2614 )
2220 self.searchClearMarkersAct.setStatusTip(QCoreApplication.translate( 2615 ),
2221 'ViewManager', 'Clear all displayed search markers')) 2616 0,
2222 self.searchClearMarkersAct.setWhatsThis(QCoreApplication.translate( 2617 self,
2223 'ViewManager', 2618 "vm_clear_search_markers",
2224 """<b>Clear search markers</b>""" 2619 )
2225 """<p>Clear all displayed search markers.</p>""" 2620 self.searchClearMarkersAct.setStatusTip(
2226 )) 2621 QCoreApplication.translate(
2227 self.searchClearMarkersAct.triggered.connect( 2622 "ViewManager", "Clear all displayed search markers"
2228 self.__searchClearMarkers) 2623 )
2624 )
2625 self.searchClearMarkersAct.setWhatsThis(
2626 QCoreApplication.translate(
2627 "ViewManager",
2628 """<b>Clear search markers</b>"""
2629 """<p>Clear all displayed search markers.</p>""",
2630 )
2631 )
2632 self.searchClearMarkersAct.triggered.connect(self.__searchClearMarkers)
2229 self.searchActions.append(self.searchClearMarkersAct) 2633 self.searchActions.append(self.searchClearMarkersAct)
2230 2634
2231 self.replaceAct = EricAction( 2635 self.replaceAct = EricAction(
2232 QCoreApplication.translate('ViewManager', 'Replace'), 2636 QCoreApplication.translate("ViewManager", "Replace"),
2233 QCoreApplication.translate('ViewManager', '&Replace...'), 2637 QCoreApplication.translate("ViewManager", "&Replace..."),
2234 QKeySequence(QCoreApplication.translate( 2638 QKeySequence(
2235 'ViewManager', "Ctrl+R", "Search|Replace")), 2639 QCoreApplication.translate("ViewManager", "Ctrl+R", "Search|Replace")
2236 0, 2640 ),
2237 self, 'vm_search_replace') 2641 0,
2238 self.replaceAct.setStatusTip(QCoreApplication.translate( 2642 self,
2239 'ViewManager', 'Replace some text')) 2643 "vm_search_replace",
2240 self.replaceAct.setWhatsThis(QCoreApplication.translate( 2644 )
2241 'ViewManager', 2645 self.replaceAct.setStatusTip(
2242 """<b>Replace</b>""" 2646 QCoreApplication.translate("ViewManager", "Replace some text")
2243 """<p>Search for some text in the current editor and replace""" 2647 )
2244 """ it. A dialog is shown to enter the searchtext, the""" 2648 self.replaceAct.setWhatsThis(
2245 """ replacement text and options for the search and replace.</p>""" 2649 QCoreApplication.translate(
2246 )) 2650 "ViewManager",
2651 """<b>Replace</b>"""
2652 """<p>Search for some text in the current editor and replace"""
2653 """ it. A dialog is shown to enter the searchtext, the"""
2654 """ replacement text and options for the search and replace.</p>""",
2655 )
2656 )
2247 self.replaceAct.triggered.connect(self.showReplaceWidget) 2657 self.replaceAct.triggered.connect(self.showReplaceWidget)
2248 self.searchActions.append(self.replaceAct) 2658 self.searchActions.append(self.replaceAct)
2249 2659
2250 self.replaceAndSearchAct = EricAction( 2660 self.replaceAndSearchAct = EricAction(
2251 QCoreApplication.translate( 2661 QCoreApplication.translate("ViewManager", "Replace and Search"),
2252 'ViewManager', 'Replace and Search'),
2253 UI.PixmapCache.getIcon("editReplaceSearch"), 2662 UI.PixmapCache.getIcon("editReplaceSearch"),
2254 QCoreApplication.translate( 2663 QCoreApplication.translate("ViewManager", "Replace and Search"),
2255 'ViewManager', 'Replace and Search'), 2664 QKeySequence(
2256 QKeySequence(QCoreApplication.translate( 2665 QCoreApplication.translate(
2257 'ViewManager', "Meta+R", "Search|Replace and Search")), 2666 "ViewManager", "Meta+R", "Search|Replace and Search"
2258 0, 2667 )
2259 self, 'vm_replace_search') 2668 ),
2260 self.replaceAndSearchAct.setStatusTip(QCoreApplication.translate( 2669 0,
2261 'ViewManager', 2670 self,
2262 'Replace the found text and search the next occurrence')) 2671 "vm_replace_search",
2263 self.replaceAndSearchAct.setWhatsThis(QCoreApplication.translate( 2672 )
2264 'ViewManager', 2673 self.replaceAndSearchAct.setStatusTip(
2265 """<b>Replace and Search</b>""" 2674 QCoreApplication.translate(
2266 """<p>Replace the found occurrence of text in the current""" 2675 "ViewManager", "Replace the found text and search the next occurrence"
2267 """ editor and search for the next one. The previously entered""" 2676 )
2268 """ search text and options are reused.</p>""" 2677 )
2269 )) 2678 self.replaceAndSearchAct.setWhatsThis(
2270 self.replaceAndSearchAct.triggered.connect( 2679 QCoreApplication.translate(
2271 self.__replaceWidget.replaceSearch) 2680 "ViewManager",
2681 """<b>Replace and Search</b>"""
2682 """<p>Replace the found occurrence of text in the current"""
2683 """ editor and search for the next one. The previously entered"""
2684 """ search text and options are reused.</p>""",
2685 )
2686 )
2687 self.replaceAndSearchAct.triggered.connect(self.__replaceWidget.replaceSearch)
2272 self.searchActions.append(self.replaceAndSearchAct) 2688 self.searchActions.append(self.replaceAndSearchAct)
2273 2689
2274 self.replaceSelectionAct = EricAction( 2690 self.replaceSelectionAct = EricAction(
2275 QCoreApplication.translate( 2691 QCoreApplication.translate("ViewManager", "Replace Occurrence"),
2276 'ViewManager', 'Replace Occurrence'),
2277 UI.PixmapCache.getIcon("editReplace"), 2692 UI.PixmapCache.getIcon("editReplace"),
2278 QCoreApplication.translate( 2693 QCoreApplication.translate("ViewManager", "Replace Occurrence"),
2279 'ViewManager', 'Replace Occurrence'), 2694 QKeySequence(
2280 QKeySequence(QCoreApplication.translate( 2695 QCoreApplication.translate(
2281 'ViewManager', "Ctrl+Meta+R", "Search|Replace Occurrence")), 2696 "ViewManager", "Ctrl+Meta+R", "Search|Replace Occurrence"
2282 0, 2697 )
2283 self, 'vm_replace_occurrence') 2698 ),
2284 self.replaceSelectionAct.setStatusTip(QCoreApplication.translate( 2699 0,
2285 'ViewManager', 'Replace the found text')) 2700 self,
2286 self.replaceSelectionAct.setWhatsThis(QCoreApplication.translate( 2701 "vm_replace_occurrence",
2287 'ViewManager', 2702 )
2288 """<b>Replace Occurrence</b>""" 2703 self.replaceSelectionAct.setStatusTip(
2289 """<p>Replace the found occurrence of the search text in the""" 2704 QCoreApplication.translate("ViewManager", "Replace the found text")
2290 """ current editor.</p>""" 2705 )
2291 )) 2706 self.replaceSelectionAct.setWhatsThis(
2292 self.replaceSelectionAct.triggered.connect( 2707 QCoreApplication.translate(
2293 self.__replaceWidget.replace) 2708 "ViewManager",
2709 """<b>Replace Occurrence</b>"""
2710 """<p>Replace the found occurrence of the search text in the"""
2711 """ current editor.</p>""",
2712 )
2713 )
2714 self.replaceSelectionAct.triggered.connect(self.__replaceWidget.replace)
2294 self.searchActions.append(self.replaceSelectionAct) 2715 self.searchActions.append(self.replaceSelectionAct)
2295 2716
2296 self.replaceAllAct = EricAction( 2717 self.replaceAllAct = EricAction(
2297 QCoreApplication.translate( 2718 QCoreApplication.translate("ViewManager", "Replace All"),
2298 'ViewManager', 'Replace All'),
2299 UI.PixmapCache.getIcon("editReplaceAll"), 2719 UI.PixmapCache.getIcon("editReplaceAll"),
2300 QCoreApplication.translate( 2720 QCoreApplication.translate("ViewManager", "Replace All"),
2301 'ViewManager', 'Replace All'), 2721 QKeySequence(
2302 QKeySequence(QCoreApplication.translate( 2722 QCoreApplication.translate(
2303 'ViewManager', "Shift+Meta+R", "Search|Replace All")), 2723 "ViewManager", "Shift+Meta+R", "Search|Replace All"
2304 0, 2724 )
2305 self, 'vm_replace_all') 2725 ),
2306 self.replaceAllAct.setStatusTip(QCoreApplication.translate( 2726 0,
2307 'ViewManager', 'Replace search text occurrences')) 2727 self,
2308 self.replaceAllAct.setWhatsThis(QCoreApplication.translate( 2728 "vm_replace_all",
2309 'ViewManager', 2729 )
2310 """<b>Replace All</b>""" 2730 self.replaceAllAct.setStatusTip(
2311 """<p>Replace all occurrences of the search text in the current""" 2731 QCoreApplication.translate("ViewManager", "Replace search text occurrences")
2312 """ editor.</p>""" 2732 )
2313 )) 2733 self.replaceAllAct.setWhatsThis(
2314 self.replaceAllAct.triggered.connect( 2734 QCoreApplication.translate(
2315 self.__replaceWidget.replaceAll) 2735 "ViewManager",
2736 """<b>Replace All</b>"""
2737 """<p>Replace all occurrences of the search text in the current"""
2738 """ editor.</p>""",
2739 )
2740 )
2741 self.replaceAllAct.triggered.connect(self.__replaceWidget.replaceAll)
2316 self.searchActions.append(self.replaceAllAct) 2742 self.searchActions.append(self.replaceAllAct)
2317 2743
2318 def __createViewActions(self): 2744 def __createViewActions(self):
2319 """ 2745 """
2320 Private method to create the View actions. 2746 Private method to create the View actions.
2321 """ 2747 """
2322 self.zoomInAct = EricAction( 2748 self.zoomInAct = EricAction(
2323 QCoreApplication.translate('ViewManager', 'Zoom in'), 2749 QCoreApplication.translate("ViewManager", "Zoom in"),
2324 UI.PixmapCache.getIcon("zoomIn"), 2750 UI.PixmapCache.getIcon("zoomIn"),
2325 QCoreApplication.translate('ViewManager', 'Zoom &in'), 2751 QCoreApplication.translate("ViewManager", "Zoom &in"),
2326 QKeySequence(QCoreApplication.translate( 2752 QKeySequence(
2327 'ViewManager', "Ctrl++", "View|Zoom in")), 2753 QCoreApplication.translate("ViewManager", "Ctrl++", "View|Zoom in")
2328 QKeySequence(QCoreApplication.translate( 2754 ),
2329 'ViewManager', "Zoom In", "View|Zoom in")), 2755 QKeySequence(
2330 self, 'vm_view_zoom_in') 2756 QCoreApplication.translate("ViewManager", "Zoom In", "View|Zoom in")
2331 self.zoomInAct.setStatusTip(QCoreApplication.translate( 2757 ),
2332 'ViewManager', 'Zoom in on the text')) 2758 self,
2333 self.zoomInAct.setWhatsThis(QCoreApplication.translate( 2759 "vm_view_zoom_in",
2334 'ViewManager', 2760 )
2335 """<b>Zoom in</b>""" 2761 self.zoomInAct.setStatusTip(
2336 """<p>Zoom in on the text. This makes the text bigger.</p>""" 2762 QCoreApplication.translate("ViewManager", "Zoom in on the text")
2337 )) 2763 )
2764 self.zoomInAct.setWhatsThis(
2765 QCoreApplication.translate(
2766 "ViewManager",
2767 """<b>Zoom in</b>"""
2768 """<p>Zoom in on the text. This makes the text bigger.</p>""",
2769 )
2770 )
2338 self.zoomInAct.triggered.connect(self.__zoomIn) 2771 self.zoomInAct.triggered.connect(self.__zoomIn)
2339 self.viewActions.append(self.zoomInAct) 2772 self.viewActions.append(self.zoomInAct)
2340 2773
2341 self.zoomOutAct = EricAction( 2774 self.zoomOutAct = EricAction(
2342 QCoreApplication.translate('ViewManager', 'Zoom out'), 2775 QCoreApplication.translate("ViewManager", "Zoom out"),
2343 UI.PixmapCache.getIcon("zoomOut"), 2776 UI.PixmapCache.getIcon("zoomOut"),
2344 QCoreApplication.translate('ViewManager', 'Zoom &out'), 2777 QCoreApplication.translate("ViewManager", "Zoom &out"),
2345 QKeySequence(QCoreApplication.translate( 2778 QKeySequence(
2346 'ViewManager', "Ctrl+-", "View|Zoom out")), 2779 QCoreApplication.translate("ViewManager", "Ctrl+-", "View|Zoom out")
2347 QKeySequence(QCoreApplication.translate( 2780 ),
2348 'ViewManager', "Zoom Out", "View|Zoom out")), 2781 QKeySequence(
2349 self, 'vm_view_zoom_out') 2782 QCoreApplication.translate("ViewManager", "Zoom Out", "View|Zoom out")
2350 self.zoomOutAct.setStatusTip(QCoreApplication.translate( 2783 ),
2351 'ViewManager', 'Zoom out on the text')) 2784 self,
2352 self.zoomOutAct.setWhatsThis(QCoreApplication.translate( 2785 "vm_view_zoom_out",
2353 'ViewManager', 2786 )
2354 """<b>Zoom out</b>""" 2787 self.zoomOutAct.setStatusTip(
2355 """<p>Zoom out on the text. This makes the text smaller.</p>""" 2788 QCoreApplication.translate("ViewManager", "Zoom out on the text")
2356 )) 2789 )
2790 self.zoomOutAct.setWhatsThis(
2791 QCoreApplication.translate(
2792 "ViewManager",
2793 """<b>Zoom out</b>"""
2794 """<p>Zoom out on the text. This makes the text smaller.</p>""",
2795 )
2796 )
2357 self.zoomOutAct.triggered.connect(self.__zoomOut) 2797 self.zoomOutAct.triggered.connect(self.__zoomOut)
2358 self.viewActions.append(self.zoomOutAct) 2798 self.viewActions.append(self.zoomOutAct)
2359 2799
2360 self.zoomResetAct = EricAction( 2800 self.zoomResetAct = EricAction(
2361 QCoreApplication.translate('ViewManager', 'Zoom reset'), 2801 QCoreApplication.translate("ViewManager", "Zoom reset"),
2362 UI.PixmapCache.getIcon("zoomReset"), 2802 UI.PixmapCache.getIcon("zoomReset"),
2363 QCoreApplication.translate('ViewManager', 'Zoom &reset'), 2803 QCoreApplication.translate("ViewManager", "Zoom &reset"),
2364 QKeySequence(QCoreApplication.translate( 2804 QKeySequence(
2365 'ViewManager', "Ctrl+0", "View|Zoom reset")), 2805 QCoreApplication.translate("ViewManager", "Ctrl+0", "View|Zoom reset")
2366 0, 2806 ),
2367 self, 'vm_view_zoom_reset') 2807 0,
2368 self.zoomResetAct.setStatusTip(QCoreApplication.translate( 2808 self,
2369 'ViewManager', 'Reset the zoom of the text')) 2809 "vm_view_zoom_reset",
2370 self.zoomResetAct.setWhatsThis(QCoreApplication.translate( 2810 )
2371 'ViewManager', 2811 self.zoomResetAct.setStatusTip(
2372 """<b>Zoom reset</b>""" 2812 QCoreApplication.translate("ViewManager", "Reset the zoom of the text")
2373 """<p>Reset the zoom of the text. """ 2813 )
2374 """This sets the zoom factor to 100%.</p>""" 2814 self.zoomResetAct.setWhatsThis(
2375 )) 2815 QCoreApplication.translate(
2816 "ViewManager",
2817 """<b>Zoom reset</b>"""
2818 """<p>Reset the zoom of the text. """
2819 """This sets the zoom factor to 100%.</p>""",
2820 )
2821 )
2376 self.zoomResetAct.triggered.connect(self.__zoomReset) 2822 self.zoomResetAct.triggered.connect(self.__zoomReset)
2377 self.viewActions.append(self.zoomResetAct) 2823 self.viewActions.append(self.zoomResetAct)
2378 2824
2379 self.zoomToAct = EricAction( 2825 self.zoomToAct = EricAction(
2380 QCoreApplication.translate('ViewManager', 'Zoom'), 2826 QCoreApplication.translate("ViewManager", "Zoom"),
2381 UI.PixmapCache.getIcon("zoomTo"), 2827 UI.PixmapCache.getIcon("zoomTo"),
2382 QCoreApplication.translate('ViewManager', '&Zoom'), 2828 QCoreApplication.translate("ViewManager", "&Zoom"),
2383 0, 0, 2829 0,
2384 self, 'vm_view_zoom') 2830 0,
2385 self.zoomToAct.setStatusTip(QCoreApplication.translate( 2831 self,
2386 'ViewManager', 'Zoom the text')) 2832 "vm_view_zoom",
2387 self.zoomToAct.setWhatsThis(QCoreApplication.translate( 2833 )
2388 'ViewManager', 2834 self.zoomToAct.setStatusTip(
2389 """<b>Zoom</b>""" 2835 QCoreApplication.translate("ViewManager", "Zoom the text")
2390 """<p>Zoom the text. This opens a dialog where the""" 2836 )
2391 """ desired size can be entered.</p>""" 2837 self.zoomToAct.setWhatsThis(
2392 )) 2838 QCoreApplication.translate(
2839 "ViewManager",
2840 """<b>Zoom</b>"""
2841 """<p>Zoom the text. This opens a dialog where the"""
2842 """ desired size can be entered.</p>""",
2843 )
2844 )
2393 self.zoomToAct.triggered.connect(self.__zoom) 2845 self.zoomToAct.triggered.connect(self.__zoom)
2394 self.viewActions.append(self.zoomToAct) 2846 self.viewActions.append(self.zoomToAct)
2395 2847
2396 def __createHelpActions(self): 2848 def __createHelpActions(self):
2397 """ 2849 """
2398 Private method to create the Help actions. 2850 Private method to create the Help actions.
2399 """ 2851 """
2400 self.aboutAct = EricAction( 2852 self.aboutAct = EricAction(
2401 self.tr('About'), 2853 self.tr("About"), self.tr("&About"), 0, 0, self, "about_eric"
2402 self.tr('&About'), 2854 )
2403 0, 0, self, 'about_eric') 2855 self.aboutAct.setStatusTip(self.tr("Display information about this software"))
2404 self.aboutAct.setStatusTip(self.tr( 2856 self.aboutAct.setWhatsThis(
2405 'Display information about this software')) 2857 self.tr(
2406 self.aboutAct.setWhatsThis(self.tr( 2858 """<b>About</b>"""
2407 """<b>About</b>""" 2859 """<p>Display some information about this software.</p>"""
2408 """<p>Display some information about this software.</p>""")) 2860 )
2861 )
2409 self.aboutAct.triggered.connect(self.__about) 2862 self.aboutAct.triggered.connect(self.__about)
2410 self.helpActions.append(self.aboutAct) 2863 self.helpActions.append(self.aboutAct)
2411 2864
2412 self.aboutQtAct = EricAction( 2865 self.aboutQtAct = EricAction(
2413 self.tr('About Qt'), 2866 self.tr("About Qt"), self.tr("About &Qt"), 0, 0, self, "about_qt"
2414 self.tr('About &Qt'), 2867 )
2415 0, 0, self, 'about_qt')
2416 self.aboutQtAct.setStatusTip( 2868 self.aboutQtAct.setStatusTip(
2417 self.tr('Display information about the Qt toolkit')) 2869 self.tr("Display information about the Qt toolkit")
2418 self.aboutQtAct.setWhatsThis(self.tr( 2870 )
2419 """<b>About Qt</b>""" 2871 self.aboutQtAct.setWhatsThis(
2420 """<p>Display some information about the Qt toolkit.</p>""" 2872 self.tr(
2421 )) 2873 """<b>About Qt</b>"""
2874 """<p>Display some information about the Qt toolkit.</p>"""
2875 )
2876 )
2422 self.aboutQtAct.triggered.connect(self.__aboutQt) 2877 self.aboutQtAct.triggered.connect(self.__aboutQt)
2423 self.helpActions.append(self.aboutQtAct) 2878 self.helpActions.append(self.aboutQtAct)
2424 2879
2425 self.whatsThisAct = EricAction( 2880 self.whatsThisAct = EricAction(
2426 self.tr('What\'s This?'), 2881 self.tr("What's This?"),
2427 UI.PixmapCache.getIcon("whatsThis"), 2882 UI.PixmapCache.getIcon("whatsThis"),
2428 self.tr('&What\'s This?'), 2883 self.tr("&What's This?"),
2429 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")), 2884 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")),
2430 0, self, 'help_help_whats_this') 2885 0,
2431 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help')) 2886 self,
2432 self.whatsThisAct.setWhatsThis(self.tr( 2887 "help_help_whats_this",
2433 """<b>Display context sensitive help</b>""" 2888 )
2434 """<p>In What's This? mode, the mouse cursor shows an arrow""" 2889 self.whatsThisAct.setStatusTip(self.tr("Context sensitive help"))
2435 """ with a question mark, and you can click on the interface""" 2890 self.whatsThisAct.setWhatsThis(
2436 """ elements to get a short description of what they do and""" 2891 self.tr(
2437 """ how to use them. In dialogs, this feature can be""" 2892 """<b>Display context sensitive help</b>"""
2438 """ accessed using the context help button in the titlebar.""" 2893 """<p>In What's This? mode, the mouse cursor shows an arrow"""
2439 """</p>""" 2894 """ with a question mark, and you can click on the interface"""
2440 )) 2895 """ elements to get a short description of what they do and"""
2896 """ how to use them. In dialogs, this feature can be"""
2897 """ accessed using the context help button in the titlebar."""
2898 """</p>"""
2899 )
2900 )
2441 self.whatsThisAct.triggered.connect(self.__whatsThis) 2901 self.whatsThisAct.triggered.connect(self.__whatsThis)
2442 self.helpActions.append(self.whatsThisAct) 2902 self.helpActions.append(self.whatsThisAct)
2443 2903
2444 def __createConfigActions(self): 2904 def __createConfigActions(self):
2445 """ 2905 """
2446 Private method to create the Settings actions. 2906 Private method to create the Settings actions.
2447 """ 2907 """
2448 self.prefAct = EricAction( 2908 self.prefAct = EricAction(
2449 self.tr('Preferences'), 2909 self.tr("Preferences"),
2450 UI.PixmapCache.getIcon("configure"), 2910 UI.PixmapCache.getIcon("configure"),
2451 self.tr('&Preferences...'), 2911 self.tr("&Preferences..."),
2452 0, 0, self, 'hexEditor_settings_preferences') 2912 0,
2453 self.prefAct.setStatusTip(self.tr( 2913 0,
2454 'Set the prefered configuration')) 2914 self,
2455 self.prefAct.setWhatsThis(self.tr( 2915 "hexEditor_settings_preferences",
2456 """<b>Preferences</b>""" 2916 )
2457 """<p>Set the configuration items of the application""" 2917 self.prefAct.setStatusTip(self.tr("Set the prefered configuration"))
2458 """ with your prefered values.</p>""" 2918 self.prefAct.setWhatsThis(
2459 )) 2919 self.tr(
2920 """<b>Preferences</b>"""
2921 """<p>Set the configuration items of the application"""
2922 """ with your prefered values.</p>"""
2923 )
2924 )
2460 self.prefAct.triggered.connect(self.__showPreferences) 2925 self.prefAct.triggered.connect(self.__showPreferences)
2461 self.prefAct.setMenuRole(QAction.MenuRole.PreferencesRole) 2926 self.prefAct.setMenuRole(QAction.MenuRole.PreferencesRole)
2462 self.configActions.append(self.prefAct) 2927 self.configActions.append(self.prefAct)
2463 2928
2464 def __createMenus(self): 2929 def __createMenus(self):
2465 """ 2930 """
2466 Private method to create the menus of the menu bar. 2931 Private method to create the menus of the menu bar.
2467 """ 2932 """
2468 self.fileMenu = self.menuBar().addMenu(self.tr("&File")) 2933 self.fileMenu = self.menuBar().addMenu(self.tr("&File"))
2474 self.fileMenu.addSeparator() 2939 self.fileMenu.addSeparator()
2475 self.fileMenu.addAction(self.printPreviewAct) 2940 self.fileMenu.addAction(self.printPreviewAct)
2476 self.fileMenu.addAction(self.printAct) 2941 self.fileMenu.addAction(self.printAct)
2477 self.fileMenu.addSeparator() 2942 self.fileMenu.addSeparator()
2478 self.fileMenu.addAction(self.closeAct) 2943 self.fileMenu.addAction(self.closeAct)
2479 2944
2480 self.editMenu = self.menuBar().addMenu(self.tr("&Edit")) 2945 self.editMenu = self.menuBar().addMenu(self.tr("&Edit"))
2481 self.editMenu.addAction(self.undoAct) 2946 self.editMenu.addAction(self.undoAct)
2482 self.editMenu.addAction(self.redoAct) 2947 self.editMenu.addAction(self.redoAct)
2483 self.editMenu.addSeparator() 2948 self.editMenu.addSeparator()
2484 self.editMenu.addAction(self.cutAct) 2949 self.editMenu.addAction(self.cutAct)
2485 self.editMenu.addAction(self.copyAct) 2950 self.editMenu.addAction(self.copyAct)
2486 self.editMenu.addAction(self.pasteAct) 2951 self.editMenu.addAction(self.pasteAct)
2487 self.editMenu.addAction(self.deleteAct) 2952 self.editMenu.addAction(self.deleteAct)
2488 self.editMenu.addSeparator() 2953 self.editMenu.addSeparator()
2489 2954
2490 self.searchMenu = self.menuBar().addMenu(self.tr("&Search")) 2955 self.searchMenu = self.menuBar().addMenu(self.tr("&Search"))
2491 self.searchMenu.addAction(self.searchAct) 2956 self.searchMenu.addAction(self.searchAct)
2492 self.searchMenu.addAction(self.searchNextAct) 2957 self.searchMenu.addAction(self.searchNextAct)
2493 self.searchMenu.addAction(self.searchPrevAct) 2958 self.searchMenu.addAction(self.searchPrevAct)
2494 self.searchMenu.addAction(self.searchClearMarkersAct) 2959 self.searchMenu.addAction(self.searchClearMarkersAct)
2495 self.searchMenu.addAction(self.replaceAct) 2960 self.searchMenu.addAction(self.replaceAct)
2496 self.searchMenu.addAction(self.replaceAndSearchAct) 2961 self.searchMenu.addAction(self.replaceAndSearchAct)
2497 self.searchMenu.addAction(self.replaceSelectionAct) 2962 self.searchMenu.addAction(self.replaceSelectionAct)
2498 self.searchMenu.addAction(self.replaceAllAct) 2963 self.searchMenu.addAction(self.replaceAllAct)
2499 2964
2500 self.viewMenu = self.menuBar().addMenu(self.tr("&View")) 2965 self.viewMenu = self.menuBar().addMenu(self.tr("&View"))
2501 self.viewMenu.addAction(self.zoomInAct) 2966 self.viewMenu.addAction(self.zoomInAct)
2502 self.viewMenu.addAction(self.zoomOutAct) 2967 self.viewMenu.addAction(self.zoomOutAct)
2503 self.viewMenu.addAction(self.zoomResetAct) 2968 self.viewMenu.addAction(self.zoomResetAct)
2504 self.viewMenu.addAction(self.zoomToAct) 2969 self.viewMenu.addAction(self.zoomToAct)
2505 2970
2506 self.settingsMenu = self.menuBar().addMenu(self.tr("Se&ttings")) 2971 self.settingsMenu = self.menuBar().addMenu(self.tr("Se&ttings"))
2507 self.settingsMenu.addAction(self.prefAct) 2972 self.settingsMenu.addAction(self.prefAct)
2508 2973
2509 self.menuBar().addSeparator() 2974 self.menuBar().addSeparator()
2510 2975
2511 self.helpMenu = self.menuBar().addMenu(self.tr("&Help")) 2976 self.helpMenu = self.menuBar().addMenu(self.tr("&Help"))
2512 self.helpMenu.addAction(self.aboutAct) 2977 self.helpMenu.addAction(self.aboutAct)
2513 self.helpMenu.addAction(self.aboutQtAct) 2978 self.helpMenu.addAction(self.aboutQtAct)
2514 self.helpMenu.addSeparator() 2979 self.helpMenu.addSeparator()
2515 self.helpMenu.addAction(self.whatsThisAct) 2980 self.helpMenu.addAction(self.whatsThisAct)
2516 2981
2517 self.__initContextMenu() 2982 self.__initContextMenu()
2518 2983
2519 def __createToolBars(self): 2984 def __createToolBars(self):
2520 """ 2985 """
2521 Private method to create the various toolbars. 2986 Private method to create the various toolbars.
2522 """ 2987 """
2523 filetb = self.addToolBar(self.tr("File")) 2988 filetb = self.addToolBar(self.tr("File"))
2530 filetb.addSeparator() 2995 filetb.addSeparator()
2531 filetb.addAction(self.printPreviewAct) 2996 filetb.addAction(self.printPreviewAct)
2532 filetb.addAction(self.printAct) 2997 filetb.addAction(self.printAct)
2533 filetb.addSeparator() 2998 filetb.addSeparator()
2534 filetb.addAction(self.closeAct) 2999 filetb.addAction(self.closeAct)
2535 3000
2536 edittb = self.addToolBar(self.tr("Edit")) 3001 edittb = self.addToolBar(self.tr("Edit"))
2537 edittb.setIconSize(UI.Config.ToolBarIconSize) 3002 edittb.setIconSize(UI.Config.ToolBarIconSize)
2538 edittb.addAction(self.undoAct) 3003 edittb.addAction(self.undoAct)
2539 edittb.addAction(self.redoAct) 3004 edittb.addAction(self.redoAct)
2540 edittb.addSeparator() 3005 edittb.addSeparator()
2541 edittb.addAction(self.cutAct) 3006 edittb.addAction(self.cutAct)
2542 edittb.addAction(self.copyAct) 3007 edittb.addAction(self.copyAct)
2543 edittb.addAction(self.pasteAct) 3008 edittb.addAction(self.pasteAct)
2544 edittb.addAction(self.deleteAct) 3009 edittb.addAction(self.deleteAct)
2545 3010
2546 findtb = self.addToolBar(self.tr("Search")) 3011 findtb = self.addToolBar(self.tr("Search"))
2547 findtb.setIconSize(UI.Config.ToolBarIconSize) 3012 findtb.setIconSize(UI.Config.ToolBarIconSize)
2548 findtb.addAction(self.searchAct) 3013 findtb.addAction(self.searchAct)
2549 findtb.addAction(self.searchNextAct) 3014 findtb.addAction(self.searchNextAct)
2550 findtb.addAction(self.searchPrevAct) 3015 findtb.addAction(self.searchPrevAct)
2551 findtb.addAction(self.searchClearMarkersAct) 3016 findtb.addAction(self.searchClearMarkersAct)
2552 3017
2553 viewtb = self.addToolBar(self.tr("View")) 3018 viewtb = self.addToolBar(self.tr("View"))
2554 viewtb.setIconSize(UI.Config.ToolBarIconSize) 3019 viewtb.setIconSize(UI.Config.ToolBarIconSize)
2555 viewtb.addAction(self.zoomInAct) 3020 viewtb.addAction(self.zoomInAct)
2556 viewtb.addAction(self.zoomOutAct) 3021 viewtb.addAction(self.zoomOutAct)
2557 viewtb.addAction(self.zoomResetAct) 3022 viewtb.addAction(self.zoomResetAct)
2558 viewtb.addAction(self.zoomToAct) 3023 viewtb.addAction(self.zoomToAct)
2559 3024
2560 settingstb = self.addToolBar(self.tr("Settings")) 3025 settingstb = self.addToolBar(self.tr("Settings"))
2561 settingstb.setIconSize(UI.Config.ToolBarIconSize) 3026 settingstb.setIconSize(UI.Config.ToolBarIconSize)
2562 settingstb.addAction(self.prefAct) 3027 settingstb.addAction(self.prefAct)
2563 3028
2564 helptb = self.addToolBar(self.tr("Help")) 3029 helptb = self.addToolBar(self.tr("Help"))
2565 helptb.setIconSize(UI.Config.ToolBarIconSize) 3030 helptb.setIconSize(UI.Config.ToolBarIconSize)
2566 helptb.addAction(self.whatsThisAct) 3031 helptb.addAction(self.whatsThisAct)
2567 3032
2568 def __createStatusBar(self): 3033 def __createStatusBar(self):
2569 """ 3034 """
2570 Private method to initialize the status bar. 3035 Private method to initialize the status bar.
2571 """ 3036 """
2572 self.__statusBar = self.statusBar() 3037 self.__statusBar = self.statusBar()
2573 self.__statusBar.setSizeGripEnabled(True) 3038 self.__statusBar.setSizeGripEnabled(True)
2574 3039
2575 self.sbLanguage = EricClickableLabel(self.__statusBar) 3040 self.sbLanguage = EricClickableLabel(self.__statusBar)
2576 self.__statusBar.addPermanentWidget(self.sbLanguage) 3041 self.__statusBar.addPermanentWidget(self.sbLanguage)
2577 self.sbLanguage.setWhatsThis(self.tr( 3042 self.sbLanguage.setWhatsThis(
2578 """<p>This part of the status bar displays the""" 3043 self.tr(
2579 """ editor language.</p>""" 3044 """<p>This part of the status bar displays the"""
2580 )) 3045 """ editor language.</p>"""
3046 )
3047 )
2581 self.sbLanguage.clicked.connect(self.__showLanguagesMenu) 3048 self.sbLanguage.clicked.connect(self.__showLanguagesMenu)
2582 3049
2583 self.sbWritable = QLabel(self.__statusBar) 3050 self.sbWritable = QLabel(self.__statusBar)
2584 self.__statusBar.addPermanentWidget(self.sbWritable) 3051 self.__statusBar.addPermanentWidget(self.sbWritable)
2585 self.sbWritable.setWhatsThis(self.tr( 3052 self.sbWritable.setWhatsThis(
2586 """<p>This part of the status bar displays an indication of the""" 3053 self.tr(
2587 """ editors files writability.</p>""" 3054 """<p>This part of the status bar displays an indication of the"""
2588 )) 3055 """ editors files writability.</p>"""
3056 )
3057 )
2589 3058
2590 self.sbLine = QLabel(self.__statusBar) 3059 self.sbLine = QLabel(self.__statusBar)
2591 self.__statusBar.addPermanentWidget(self.sbLine) 3060 self.__statusBar.addPermanentWidget(self.sbLine)
2592 self.sbLine.setWhatsThis(self.tr( 3061 self.sbLine.setWhatsThis(
2593 """<p>This part of the status bar displays the line number of""" 3062 self.tr(
2594 """ the editor.</p>""" 3063 """<p>This part of the status bar displays the line number of"""
2595 )) 3064 """ the editor.</p>"""
3065 )
3066 )
2596 3067
2597 self.sbPos = QLabel(self.__statusBar) 3068 self.sbPos = QLabel(self.__statusBar)
2598 self.__statusBar.addPermanentWidget(self.sbPos) 3069 self.__statusBar.addPermanentWidget(self.sbPos)
2599 self.sbPos.setWhatsThis(self.tr( 3070 self.sbPos.setWhatsThis(
2600 """<p>This part of the status bar displays the cursor position""" 3071 self.tr(
2601 """ of the editor.</p>""" 3072 """<p>This part of the status bar displays the cursor position"""
2602 )) 3073 """ of the editor.</p>"""
2603 3074 )
3075 )
3076
2604 self.sbZoom = EricZoomWidget( 3077 self.sbZoom = EricZoomWidget(
2605 UI.PixmapCache.getPixmap("zoomOut"), 3078 UI.PixmapCache.getPixmap("zoomOut"),
2606 UI.PixmapCache.getPixmap("zoomIn"), 3079 UI.PixmapCache.getPixmap("zoomIn"),
2607 UI.PixmapCache.getPixmap("zoomReset"), 3080 UI.PixmapCache.getPixmap("zoomReset"),
2608 self.__statusBar) 3081 self.__statusBar,
3082 )
2609 self.__statusBar.addPermanentWidget(self.sbZoom) 3083 self.__statusBar.addPermanentWidget(self.sbZoom)
2610 self.sbZoom.setWhatsThis(self.tr( 3084 self.sbZoom.setWhatsThis(
2611 """<p>This part of the status bar allows zooming the editor.""" 3085 self.tr(
2612 """</p>""" 3086 """<p>This part of the status bar allows zooming the editor."""
2613 )) 3087 """</p>"""
3088 )
3089 )
2614 self.sbZoom.valueChanged.connect(self.__zoomTo) 3090 self.sbZoom.valueChanged.connect(self.__zoomTo)
2615 3091
2616 self.__statusBar.showMessage(self.tr("Ready")) 3092 self.__statusBar.showMessage(self.tr("Ready"))
2617 3093
2618 def __showPreferences(self): 3094 def __showPreferences(self):
2619 """ 3095 """
2620 Private slot to set the preferences. 3096 Private slot to set the preferences.
2621 """ 3097 """
2622 from Preferences.ConfigurationDialog import ( 3098 from Preferences.ConfigurationDialog import (
2623 ConfigurationDialog, ConfigurationMode 3099 ConfigurationDialog,
2624 ) 3100 ConfigurationMode,
3101 )
3102
2625 dlg = ConfigurationDialog( 3103 dlg = ConfigurationDialog(
2626 None, 'Configuration', True, fromEric=True, 3104 None,
2627 displayMode=ConfigurationMode.EDITORMODE) 3105 "Configuration",
3106 True,
3107 fromEric=True,
3108 displayMode=ConfigurationMode.EDITORMODE,
3109 )
2628 dlg.preferencesChanged.connect(self.__preferencesChanged) 3110 dlg.preferencesChanged.connect(self.__preferencesChanged)
2629 dlg.show() 3111 dlg.show()
2630 dlg.showConfigurationPageByName("interfacePage") 3112 dlg.showConfigurationPageByName("interfacePage")
2631 dlg.exec() 3113 dlg.exec()
2632 QCoreApplication.processEvents() 3114 QCoreApplication.processEvents()
2633 if dlg.result() == QDialog.DialogCode.Accepted: 3115 if dlg.result() == QDialog.DialogCode.Accepted:
2634 dlg.setPreferences() 3116 dlg.setPreferences()
2635 Preferences.syncPreferences() 3117 Preferences.syncPreferences()
2636 self.__preferencesChanged() 3118 self.__preferencesChanged()
2637 3119
2638 @pyqtSlot() 3120 @pyqtSlot()
2639 def __preferencesChanged(self): 3121 def __preferencesChanged(self):
2640 """ 3122 """
2641 Private slot to handle a configuration change. 3123 Private slot to handle a configuration change.
2642 """ 3124 """
2643 self.__loadConfiguration() 3125 self.__loadConfiguration()
2644 3126
2645 self.__markOccurrencesTimer.setInterval( 3127 self.__markOccurrencesTimer.setInterval(
2646 Preferences.getEditor("MarkOccurrencesTimeout")) 3128 Preferences.getEditor("MarkOccurrencesTimeout")
2647 3129 )
3130
2648 @pyqtSlot() 3131 @pyqtSlot()
2649 def __loadConfiguration(self): 3132 def __loadConfiguration(self):
2650 """ 3133 """
2651 Private slot to load the configuration. 3134 Private slot to load the configuration.
2652 """ 3135 """
2653 self.__setTextDisplay() 3136 self.__setTextDisplay()
2654 self.__setMargins() 3137 self.__setMargins()
2655 self.__setEolMode() 3138 self.__setEolMode()
2656 3139
2657 def __readSettings(self): 3140 def __readSettings(self):
2658 """ 3141 """
2659 Private method to read the settings remembered last time. 3142 Private method to read the settings remembered last time.
2660 """ 3143 """
2661 settings = Preferences.getSettings() 3144 settings = Preferences.getSettings()
2662 pos = settings.value("MiniEditor/Position", QPoint(0, 0)) 3145 pos = settings.value("MiniEditor/Position", QPoint(0, 0))
2663 size = settings.value("MiniEditor/Size", QSize(800, 600)) 3146 size = settings.value("MiniEditor/Size", QSize(800, 600))
2664 self.resize(size) 3147 self.resize(size)
2665 self.move(pos) 3148 self.move(pos)
2666 3149
2667 def __writeSettings(self): 3150 def __writeSettings(self):
2668 """ 3151 """
2669 Private method to write the settings for reuse. 3152 Private method to write the settings for reuse.
2670 """ 3153 """
2671 settings = Preferences.getSettings() 3154 settings = Preferences.getSettings()
2672 settings.setValue("MiniEditor/Position", self.pos()) 3155 settings.setValue("MiniEditor/Position", self.pos())
2673 settings.setValue("MiniEditor/Size", self.size()) 3156 settings.setValue("MiniEditor/Size", self.size())
2674 3157
2675 def __maybeSave(self): 3158 def __maybeSave(self):
2676 """ 3159 """
2677 Private method to ask the user to save the file, if it was modified. 3160 Private method to ask the user to save the file, if it was modified.
2678 3161
2679 @return flag indicating, if it is ok to continue (boolean) 3162 @return flag indicating, if it is ok to continue (boolean)
2680 """ 3163 """
2681 if self.__textEdit.isModified(): 3164 if self.__textEdit.isModified():
2682 ret = EricMessageBox.okToClearData( 3165 ret = EricMessageBox.okToClearData(
2683 self, 3166 self,
2684 self.tr("eric Mini Editor"), 3167 self.tr("eric Mini Editor"),
2685 self.tr("The document has unsaved changes."), 3168 self.tr("The document has unsaved changes."),
2686 self.__save) 3169 self.__save,
3170 )
2687 return ret 3171 return ret
2688 return True 3172 return True
2689 3173
2690 def __loadFile(self, fileName, filetype=None): 3174 def __loadFile(self, fileName, filetype=None):
2691 """ 3175 """
2692 Private method to load the given file. 3176 Private method to load the given file.
2693 3177
2694 @param fileName name of the file to load (string) 3178 @param fileName name of the file to load (string)
2695 @param filetype type of the source file (string) 3179 @param filetype type of the source file (string)
2696 """ 3180 """
2697 self.__loadEditorConfig(fileName=fileName) 3181 self.__loadEditorConfig(fileName=fileName)
2698 3182
2699 try: 3183 try:
2700 with EricOverrideCursor(): 3184 with EricOverrideCursor():
2701 encoding = self.__getEditorConfig("DefaultEncoding", 3185 encoding = self.__getEditorConfig("DefaultEncoding", nodefault=True)
2702 nodefault=True)
2703 if encoding: 3186 if encoding:
2704 txt, self.encoding = Utilities.readEncodedFileWithEncoding( 3187 txt, self.encoding = Utilities.readEncodedFileWithEncoding(
2705 fileName, encoding) 3188 fileName, encoding
3189 )
2706 else: 3190 else:
2707 txt, self.encoding = Utilities.readEncodedFile(fileName) 3191 txt, self.encoding = Utilities.readEncodedFile(fileName)
2708 except (UnicodeDecodeError, OSError) as why: 3192 except (UnicodeDecodeError, OSError) as why:
2709 EricMessageBox.critical( 3193 EricMessageBox.critical(
2710 self, self.tr('Open File'), 3194 self,
2711 self.tr('<p>The file <b>{0}</b> could not be opened.</p>' 3195 self.tr("Open File"),
2712 '<p>Reason: {1}</p>') 3196 self.tr(
2713 .format(fileName, str(why))) 3197 "<p>The file <b>{0}</b> could not be opened.</p>"
3198 "<p>Reason: {1}</p>"
3199 ).format(fileName, str(why)),
3200 )
2714 return 3201 return
2715 3202
2716 with EricOverrideCursor(): 3203 with EricOverrideCursor():
2717 self.__textEdit.setText(txt) 3204 self.__textEdit.setText(txt)
2718 3205
2719 if filetype is None: 3206 if filetype is None:
2720 self.filetype = "" 3207 self.filetype = ""
2721 else: 3208 else:
2722 self.filetype = filetype 3209 self.filetype = filetype
2723 self.__setCurrentFile(fileName) 3210 self.__setCurrentFile(fileName)
2724 3211
2725 self.__textEdit.setModified(False) 3212 self.__textEdit.setModified(False)
2726 self.setWindowModified(False) 3213 self.setWindowModified(False)
2727 3214
2728 self.__convertTabs() 3215 self.__convertTabs()
2729 3216
2730 eolMode = self.__getEditorConfig("EOLMode", nodefault=True) 3217 eolMode = self.__getEditorConfig("EOLMode", nodefault=True)
2731 if eolMode is None: 3218 if eolMode is None:
2732 fileEol = self.__textEdit.detectEolString(txt) 3219 fileEol = self.__textEdit.detectEolString(txt)
2733 self.__textEdit.setEolModeByEolString(fileEol) 3220 self.__textEdit.setEolModeByEolString(fileEol)
2734 else: 3221 else:
2735 self.__textEdit.convertEols(eolMode) 3222 self.__textEdit.convertEols(eolMode)
2736 3223
2737 self.__statusBar.showMessage(self.tr("File loaded"), 2000) 3224 self.__statusBar.showMessage(self.tr("File loaded"), 2000)
2738 3225
2739 def __convertTabs(self): 3226 def __convertTabs(self):
2740 """ 3227 """
2741 Private slot to convert tabulators to spaces. 3228 Private slot to convert tabulators to spaces.
2742 """ 3229 """
2743 if ( 3230 if (
2744 (not self.__getEditorConfig("TabForIndentation")) and 3231 (not self.__getEditorConfig("TabForIndentation"))
2745 Preferences.getEditor("ConvertTabsOnLoad") and 3232 and Preferences.getEditor("ConvertTabsOnLoad")
2746 not (self.lexer_ and 3233 and not (self.lexer_ and self.lexer_.alwaysKeepTabs())
2747 self.lexer_.alwaysKeepTabs())
2748 ): 3234 ):
2749 txt = self.__textEdit.text() 3235 txt = self.__textEdit.text()
2750 txtExpanded = txt.expandtabs(self.__getEditorConfig("TabWidth")) 3236 txtExpanded = txt.expandtabs(self.__getEditorConfig("TabWidth"))
2751 if txtExpanded != txt: 3237 if txtExpanded != txt:
2752 self.__textEdit.beginUndoAction() 3238 self.__textEdit.beginUndoAction()
2753 self.__textEdit.setText(txt) 3239 self.__textEdit.setText(txt)
2754 self.__textEdit.endUndoAction() 3240 self.__textEdit.endUndoAction()
2755 3241
2756 self.__textEdit.setModified(True) 3242 self.__textEdit.setModified(True)
2757 self.setWindowModified(True) 3243 self.setWindowModified(True)
2758 3244
2759 def __saveFile(self, fileName): 3245 def __saveFile(self, fileName):
2760 """ 3246 """
2761 Private method to save to the given file. 3247 Private method to save to the given file.
2762 3248
2763 @param fileName name of the file to save to 3249 @param fileName name of the file to save to
2764 @type str 3250 @type str
2765 @return flag indicating success 3251 @return flag indicating success
2766 @rtype bool 3252 @rtype bool
2767 """ 3253 """
2768 res = self.__writeFile(fileName) 3254 res = self.__writeFile(fileName)
2769 3255
2770 if res: 3256 if res:
2771 self.editorSaved.emit() 3257 self.editorSaved.emit()
2772 self.__setCurrentFile(fileName) 3258 self.__setCurrentFile(fileName)
2773 3259
2774 self.__checkActions() 3260 self.__checkActions()
2775 3261
2776 return res 3262 return res
2777 3263
2778 def __writeFile(self, fileName): 3264 def __writeFile(self, fileName):
2779 """ 3265 """
2780 Private method to write the current editor text to a file. 3266 Private method to write the current editor text to a file.
2781 3267
2782 @param fileName name of the file to be written to 3268 @param fileName name of the file to be written to
2783 @type str 3269 @type str
2784 @return flag indicating success 3270 @return flag indicating success
2785 @rtype bool 3271 @rtype bool
2786 """ 3272 """
2787 config = self.__loadEditorConfigObject(fileName) 3273 config = self.__loadEditorConfigObject(fileName)
2788 3274
2789 eol = self.__getEditorConfig("EOLMode", nodefault=True, config=config) 3275 eol = self.__getEditorConfig("EOLMode", nodefault=True, config=config)
2790 if eol is not None: 3276 if eol is not None:
2791 self.__textEdit.convertEols(eol) 3277 self.__textEdit.convertEols(eol)
2792 3278
2793 if self.__getEditorConfig("StripTrailingWhitespace", config=config): 3279 if self.__getEditorConfig("StripTrailingWhitespace", config=config):
2794 self.__textEdit.removeTrailingWhitespace() 3280 self.__textEdit.removeTrailingWhitespace()
2795 3281
2796 txt = self.__textEdit.text() 3282 txt = self.__textEdit.text()
2797 3283
2798 if self.__getEditorConfig("InsertFinalNewline", config=config): 3284 if self.__getEditorConfig("InsertFinalNewline", config=config):
2799 eol = self.__textEdit.getLineSeparator() 3285 eol = self.__textEdit.getLineSeparator()
2800 if eol: 3286 if eol:
2801 if len(txt) >= len(eol): 3287 if len(txt) >= len(eol):
2802 if txt[-len(eol):] != eol: 3288 if txt[-len(eol) :] != eol:
2803 txt += eol 3289 txt += eol
2804 else: 3290 else:
2805 txt += eol 3291 txt += eol
2806 3292
2807 # now write text to the file 3293 # now write text to the file
2808 try: 3294 try:
2809 with EricOverrideCursor(): 3295 with EricOverrideCursor():
2810 editorConfigEncoding = self.__getEditorConfig( 3296 editorConfigEncoding = self.__getEditorConfig(
2811 "DefaultEncoding", nodefault=True, config=config) 3297 "DefaultEncoding", nodefault=True, config=config
3298 )
2812 self.encoding = Utilities.writeEncodedFile( 3299 self.encoding = Utilities.writeEncodedFile(
2813 fileName, txt, self.encoding, 3300 fileName, txt, self.encoding, forcedEncoding=editorConfigEncoding
2814 forcedEncoding=editorConfigEncoding) 3301 )
2815 except (OSError, Utilities.CodingError, UnicodeError) as why: 3302 except (OSError, Utilities.CodingError, UnicodeError) as why:
2816 EricMessageBox.critical( 3303 EricMessageBox.critical(
2817 self, self.tr('Save File'), 3304 self,
2818 self.tr('<p>The file <b>{0}</b> could not be saved.<br/>' 3305 self.tr("Save File"),
2819 'Reason: {1}</p>') 3306 self.tr(
2820 .format(fileName, str(why))) 3307 "<p>The file <b>{0}</b> could not be saved.<br/>" "Reason: {1}</p>"
3308 ).format(fileName, str(why)),
3309 )
2821 return False 3310 return False
2822 3311
2823 self.__statusBar.showMessage(self.tr("File saved"), 2000) 3312 self.__statusBar.showMessage(self.tr("File saved"), 2000)
2824 3313
2825 return True 3314 return True
2826 3315
2827 def setWindowModified(self, modified): 3316 def setWindowModified(self, modified):
2828 """ 3317 """
2829 Public method to set the window modification status. 3318 Public method to set the window modification status.
2830 3319
2831 @param modified flag indicating the modification status 3320 @param modified flag indicating the modification status
2832 @type bool 3321 @type bool
2833 """ 3322 """
2834 if "[*]" not in self.windowTitle(): 3323 if "[*]" not in self.windowTitle():
2835 self.setWindowTitle(self.tr("[*] - {0}") 3324 self.setWindowTitle(self.tr("[*] - {0}").format(self.tr("Mini Editor")))
2836 .format(self.tr("Mini Editor")))
2837 super().setWindowModified(modified) 3325 super().setWindowModified(modified)
2838 3326
2839 def __setCurrentFile(self, fileName): 3327 def __setCurrentFile(self, fileName):
2840 """ 3328 """
2841 Private method to register the file name of the current file. 3329 Private method to register the file name of the current file.
2842 3330
2843 @param fileName name of the file to register (string) 3331 @param fileName name of the file to register (string)
2844 """ 3332 """
2845 self.__curFile = fileName 3333 self.__curFile = fileName
2846 3334
2847 shownName = ( 3335 shownName = (
2848 self.tr("Untitled") 3336 self.tr("Untitled")
2849 if not self.__curFile else 3337 if not self.__curFile
2850 self.__strippedName(self.__curFile) 3338 else self.__strippedName(self.__curFile)
2851 ) 3339 )
2852 3340
2853 self.setWindowTitle(self.tr("{0}[*] - {1}") 3341 self.setWindowTitle(
2854 .format(shownName, self.tr("Mini Editor"))) 3342 self.tr("{0}[*] - {1}").format(shownName, self.tr("Mini Editor"))
2855 3343 )
3344
2856 self.__textEdit.setModified(False) 3345 self.__textEdit.setModified(False)
2857 self.setWindowModified(False) 3346 self.setWindowModified(False)
2858 3347
2859 self.setLanguage(self.__bindName(self.__textEdit.text(0))) 3348 self.setLanguage(self.__bindName(self.__textEdit.text(0)))
2860 3349
2861 self.__loadEditorConfig() 3350 self.__loadEditorConfig()
2862 3351
2863 def getFileName(self): 3352 def getFileName(self):
2864 """ 3353 """
2865 Public method to return the name of the file being displayed. 3354 Public method to return the name of the file being displayed.
2866 3355
2867 @return filename of the displayed file (string) 3356 @return filename of the displayed file (string)
2868 """ 3357 """
2869 return self.__curFile 3358 return self.__curFile
2870 3359
2871 def __strippedName(self, fullFileName): 3360 def __strippedName(self, fullFileName):
2872 """ 3361 """
2873 Private method to return the filename part of the given path. 3362 Private method to return the filename part of the given path.
2874 3363
2875 @param fullFileName full pathname of the given file (string) 3364 @param fullFileName full pathname of the given file (string)
2876 @return filename part (string) 3365 @return filename part (string)
2877 """ 3366 """
2878 return pathlib.Path(fullFileName).name 3367 return pathlib.Path(fullFileName).name
2879 3368
2880 def __modificationChanged(self, m): 3369 def __modificationChanged(self, m):
2881 """ 3370 """
2882 Private slot to handle the modificationChanged signal. 3371 Private slot to handle the modificationChanged signal.
2883 3372
2884 @param m modification status 3373 @param m modification status
2885 """ 3374 """
2886 self.setWindowModified(m) 3375 self.setWindowModified(m)
2887 self.__checkActions() 3376 self.__checkActions()
2888 3377
2889 def __cursorPositionChanged(self, line, pos): 3378 def __cursorPositionChanged(self, line, pos):
2890 """ 3379 """
2891 Private slot to handle the cursorPositionChanged signal. 3380 Private slot to handle the cursorPositionChanged signal.
2892 3381
2893 @param line line number of the cursor 3382 @param line line number of the cursor
2894 @param pos position in line of the cursor 3383 @param pos position in line of the cursor
2895 """ 3384 """
2896 lang = self.getLanguage() 3385 lang = self.getLanguage()
2897 self.__setSbFile(line + 1, pos, lang) 3386 self.__setSbFile(line + 1, pos, lang)
2898 3387
2899 if Preferences.getEditor("MarkOccurrencesEnabled"): 3388 if Preferences.getEditor("MarkOccurrencesEnabled"):
2900 self.__markOccurrencesTimer.stop() 3389 self.__markOccurrencesTimer.stop()
2901 self.__markOccurrencesTimer.start() 3390 self.__markOccurrencesTimer.start()
2902 3391
2903 if self.__lastLine != line: 3392 if self.__lastLine != line:
2904 self.cursorLineChanged.emit(line) 3393 self.cursorLineChanged.emit(line)
2905 self.__lastLine = line 3394 self.__lastLine = line
2906 3395
2907 def __undo(self): 3396 def __undo(self):
2908 """ 3397 """
2909 Private method to undo the last recorded change. 3398 Private method to undo the last recorded change.
2910 """ 3399 """
2911 self.__textEdit.undo() 3400 self.__textEdit.undo()
2912 self.__checkActions() 3401 self.__checkActions()
2913 3402
2914 def __redo(self): 3403 def __redo(self):
2915 """ 3404 """
2916 Private method to redo the last recorded change. 3405 Private method to redo the last recorded change.
2917 """ 3406 """
2918 self.__textEdit.redo() 3407 self.__textEdit.redo()
2919 self.__checkActions() 3408 self.__checkActions()
2920 3409
2921 def __selectAll(self): 3410 def __selectAll(self):
2922 """ 3411 """
2923 Private slot handling the select all context menu action. 3412 Private slot handling the select all context menu action.
2924 """ 3413 """
2925 self.__textEdit.selectAll(True) 3414 self.__textEdit.selectAll(True)
2926 3415
2927 def __deselectAll(self): 3416 def __deselectAll(self):
2928 """ 3417 """
2929 Private slot handling the deselect all context menu action. 3418 Private slot handling the deselect all context menu action.
2930 """ 3419 """
2931 self.__textEdit.selectAll(False) 3420 self.__textEdit.selectAll(False)
2932 3421
2933 def __setMargins(self): 3422 def __setMargins(self):
2934 """ 3423 """
2935 Private method to configure the margins. 3424 Private method to configure the margins.
2936 """ 3425 """
2937 # set the settings for all margins 3426 # set the settings for all margins
2938 self.__textEdit.setMarginsFont( 3427 self.__textEdit.setMarginsFont(Preferences.getEditorOtherFonts("MarginsFont"))
2939 Preferences.getEditorOtherFonts("MarginsFont"))
2940 self.__textEdit.setMarginsForegroundColor( 3428 self.__textEdit.setMarginsForegroundColor(
2941 Preferences.getEditorColour("MarginsForeground")) 3429 Preferences.getEditorColour("MarginsForeground")
3430 )
2942 self.__textEdit.setMarginsBackgroundColor( 3431 self.__textEdit.setMarginsBackgroundColor(
2943 Preferences.getEditorColour("MarginsBackground")) 3432 Preferences.getEditorColour("MarginsBackground")
2944 3433 )
3434
2945 # set margin 0 settings 3435 # set margin 0 settings
2946 linenoMargin = Preferences.getEditor("LinenoMargin") 3436 linenoMargin = Preferences.getEditor("LinenoMargin")
2947 self.__textEdit.setMarginLineNumbers(0, linenoMargin) 3437 self.__textEdit.setMarginLineNumbers(0, linenoMargin)
2948 if linenoMargin: 3438 if linenoMargin:
2949 self.__resizeLinenoMargin() 3439 self.__resizeLinenoMargin()
2950 else: 3440 else:
2951 self.__textEdit.setMarginWidth(0, 16) 3441 self.__textEdit.setMarginWidth(0, 16)
2952 3442
2953 # set margin 1 settings 3443 # set margin 1 settings
2954 self.__textEdit.setMarginWidth(1, 0) 3444 self.__textEdit.setMarginWidth(1, 0)
2955 3445
2956 # set margin 2 settings 3446 # set margin 2 settings
2957 self.__textEdit.setMarginWidth(2, 16) 3447 self.__textEdit.setMarginWidth(2, 16)
2958 if Preferences.getEditor("FoldingMargin"): 3448 if Preferences.getEditor("FoldingMargin"):
2959 folding = Preferences.getEditor("FoldingStyle") 3449 folding = Preferences.getEditor("FoldingStyle")
2960 self.__textEdit.setFolding(folding) 3450 self.__textEdit.setFolding(folding)
2961 self.__textEdit.setFoldMarginColors( 3451 self.__textEdit.setFoldMarginColors(
2962 Preferences.getEditorColour("FoldmarginBackground"), 3452 Preferences.getEditorColour("FoldmarginBackground"),
2963 Preferences.getEditorColour("FoldmarginBackground")) 3453 Preferences.getEditorColour("FoldmarginBackground"),
3454 )
2964 self.__textEdit.setFoldMarkersColors( 3455 self.__textEdit.setFoldMarkersColors(
2965 Preferences.getEditorColour("FoldMarkersForeground"), 3456 Preferences.getEditorColour("FoldMarkersForeground"),
2966 Preferences.getEditorColour("FoldMarkersBackground")) 3457 Preferences.getEditorColour("FoldMarkersBackground"),
3458 )
2967 else: 3459 else:
2968 self.__textEdit.setFolding( 3460 self.__textEdit.setFolding(QsciScintilla.FoldStyle.NoFoldStyle.value)
2969 QsciScintilla.FoldStyle.NoFoldStyle.value) 3461
2970
2971 def __resizeLinenoMargin(self): 3462 def __resizeLinenoMargin(self):
2972 """ 3463 """
2973 Private slot to resize the line numbers margin. 3464 Private slot to resize the line numbers margin.
2974 """ 3465 """
2975 linenoMargin = Preferences.getEditor("LinenoMargin") 3466 linenoMargin = Preferences.getEditor("LinenoMargin")
2976 if linenoMargin: 3467 if linenoMargin:
2977 self.__textEdit.setMarginWidth( 3468 self.__textEdit.setMarginWidth(
2978 0, '8' * (len(str(self.__textEdit.lines())) + 1)) 3469 0, "8" * (len(str(self.__textEdit.lines())) + 1)
2979 3470 )
3471
2980 def __setTabAndIndent(self): 3472 def __setTabAndIndent(self):
2981 """ 3473 """
2982 Private method to set indentation size and style and tab width. 3474 Private method to set indentation size and style and tab width.
2983 """ 3475 """
2984 self.__textEdit.setTabWidth(self.__getEditorConfig("TabWidth")) 3476 self.__textEdit.setTabWidth(self.__getEditorConfig("TabWidth"))
2985 self.__textEdit.setIndentationWidth( 3477 self.__textEdit.setIndentationWidth(self.__getEditorConfig("IndentWidth"))
2986 self.__getEditorConfig("IndentWidth"))
2987 if self.lexer_ and self.lexer_.alwaysKeepTabs(): 3478 if self.lexer_ and self.lexer_.alwaysKeepTabs():
2988 self.__textEdit.setIndentationsUseTabs(True) 3479 self.__textEdit.setIndentationsUseTabs(True)
2989 else: 3480 else:
2990 self.__textEdit.setIndentationsUseTabs( 3481 self.__textEdit.setIndentationsUseTabs(
2991 self.__getEditorConfig("TabForIndentation")) 3482 self.__getEditorConfig("TabForIndentation")
2992 3483 )
3484
2993 def __setTextDisplay(self): 3485 def __setTextDisplay(self):
2994 """ 3486 """
2995 Private method to configure the text display. 3487 Private method to configure the text display.
2996 """ 3488 """
2997 self.__setTabAndIndent() 3489 self.__setTabAndIndent()
2998 3490
2999 self.__textEdit.setTabIndents(Preferences.getEditor("TabIndents")) 3491 self.__textEdit.setTabIndents(Preferences.getEditor("TabIndents"))
3000 self.__textEdit.setBackspaceUnindents( 3492 self.__textEdit.setBackspaceUnindents(Preferences.getEditor("TabIndents"))
3001 Preferences.getEditor("TabIndents")) 3493 self.__textEdit.setIndentationGuides(Preferences.getEditor("IndentationGuides"))
3002 self.__textEdit.setIndentationGuides(
3003 Preferences.getEditor("IndentationGuides"))
3004 self.__textEdit.setIndentationGuidesBackgroundColor( 3494 self.__textEdit.setIndentationGuidesBackgroundColor(
3005 Preferences.getEditorColour("IndentationGuidesBackground")) 3495 Preferences.getEditorColour("IndentationGuidesBackground")
3496 )
3006 self.__textEdit.setIndentationGuidesForegroundColor( 3497 self.__textEdit.setIndentationGuidesForegroundColor(
3007 Preferences.getEditorColour("IndentationGuidesForeground")) 3498 Preferences.getEditorColour("IndentationGuidesForeground")
3499 )
3008 if Preferences.getEditor("ShowWhitespace"): 3500 if Preferences.getEditor("ShowWhitespace"):
3009 self.__textEdit.setWhitespaceVisibility( 3501 self.__textEdit.setWhitespaceVisibility(
3010 QsciScintilla.WhitespaceVisibility.WsVisible) 3502 QsciScintilla.WhitespaceVisibility.WsVisible
3503 )
3011 self.__textEdit.setWhitespaceForegroundColor( 3504 self.__textEdit.setWhitespaceForegroundColor(
3012 Preferences.getEditorColour("WhitespaceForeground")) 3505 Preferences.getEditorColour("WhitespaceForeground")
3506 )
3013 self.__textEdit.setWhitespaceBackgroundColor( 3507 self.__textEdit.setWhitespaceBackgroundColor(
3014 Preferences.getEditorColour("WhitespaceBackground")) 3508 Preferences.getEditorColour("WhitespaceBackground")
3015 self.__textEdit.setWhitespaceSize( 3509 )
3016 Preferences.getEditor("WhitespaceSize")) 3510 self.__textEdit.setWhitespaceSize(Preferences.getEditor("WhitespaceSize"))
3017 else: 3511 else:
3018 self.__textEdit.setWhitespaceVisibility( 3512 self.__textEdit.setWhitespaceVisibility(
3019 QsciScintilla.WhitespaceVisibility.WsInvisible) 3513 QsciScintilla.WhitespaceVisibility.WsInvisible
3514 )
3020 self.__textEdit.setEolVisibility(Preferences.getEditor("ShowEOL")) 3515 self.__textEdit.setEolVisibility(Preferences.getEditor("ShowEOL"))
3021 self.__textEdit.setAutoIndent(Preferences.getEditor("AutoIndentation")) 3516 self.__textEdit.setAutoIndent(Preferences.getEditor("AutoIndentation"))
3022 if Preferences.getEditor("BraceHighlighting"): 3517 if Preferences.getEditor("BraceHighlighting"):
3023 self.__textEdit.setBraceMatching( 3518 self.__textEdit.setBraceMatching(QsciScintilla.BraceMatch.SloppyBraceMatch)
3024 QsciScintilla.BraceMatch.SloppyBraceMatch)
3025 else: 3519 else:
3026 self.__textEdit.setBraceMatching( 3520 self.__textEdit.setBraceMatching(QsciScintilla.BraceMatch.NoBraceMatch)
3027 QsciScintilla.BraceMatch.NoBraceMatch)
3028 self.__textEdit.setMatchedBraceForegroundColor( 3521 self.__textEdit.setMatchedBraceForegroundColor(
3029 Preferences.getEditorColour("MatchingBrace")) 3522 Preferences.getEditorColour("MatchingBrace")
3523 )
3030 self.__textEdit.setMatchedBraceBackgroundColor( 3524 self.__textEdit.setMatchedBraceBackgroundColor(
3031 Preferences.getEditorColour("MatchingBraceBack")) 3525 Preferences.getEditorColour("MatchingBraceBack")
3526 )
3032 self.__textEdit.setUnmatchedBraceForegroundColor( 3527 self.__textEdit.setUnmatchedBraceForegroundColor(
3033 Preferences.getEditorColour("NonmatchingBrace")) 3528 Preferences.getEditorColour("NonmatchingBrace")
3529 )
3034 self.__textEdit.setUnmatchedBraceBackgroundColor( 3530 self.__textEdit.setUnmatchedBraceBackgroundColor(
3035 Preferences.getEditorColour("NonmatchingBraceBack")) 3531 Preferences.getEditorColour("NonmatchingBraceBack")
3532 )
3036 if Preferences.getEditor("CustomSelectionColours"): 3533 if Preferences.getEditor("CustomSelectionColours"):
3037 self.__textEdit.setSelectionBackgroundColor( 3534 self.__textEdit.setSelectionBackgroundColor(
3038 Preferences.getEditorColour("SelectionBackground")) 3535 Preferences.getEditorColour("SelectionBackground")
3536 )
3039 else: 3537 else:
3040 self.__textEdit.setSelectionBackgroundColor( 3538 self.__textEdit.setSelectionBackgroundColor(
3041 QApplication.palette().color(QPalette.ColorRole.Highlight)) 3539 QApplication.palette().color(QPalette.ColorRole.Highlight)
3540 )
3042 if Preferences.getEditor("ColourizeSelText"): 3541 if Preferences.getEditor("ColourizeSelText"):
3043 self.__textEdit.resetSelectionForegroundColor() 3542 self.__textEdit.resetSelectionForegroundColor()
3044 elif Preferences.getEditor("CustomSelectionColours"): 3543 elif Preferences.getEditor("CustomSelectionColours"):
3045 self.__textEdit.setSelectionForegroundColor( 3544 self.__textEdit.setSelectionForegroundColor(
3046 Preferences.getEditorColour("SelectionForeground")) 3545 Preferences.getEditorColour("SelectionForeground")
3546 )
3047 else: 3547 else:
3048 self.__textEdit.setSelectionForegroundColor( 3548 self.__textEdit.setSelectionForegroundColor(
3049 QApplication.palette().color( 3549 QApplication.palette().color(QPalette.ColorRole.HighlightedText)
3050 QPalette.ColorRole.HighlightedText)) 3550 )
3051 self.__textEdit.setSelectionToEol( 3551 self.__textEdit.setSelectionToEol(Preferences.getEditor("ExtendSelectionToEol"))
3052 Preferences.getEditor("ExtendSelectionToEol"))
3053 self.__textEdit.setCaretForegroundColor( 3552 self.__textEdit.setCaretForegroundColor(
3054 Preferences.getEditorColour("CaretForeground")) 3553 Preferences.getEditorColour("CaretForeground")
3554 )
3055 self.__textEdit.setCaretLineBackgroundColor( 3555 self.__textEdit.setCaretLineBackgroundColor(
3056 Preferences.getEditorColour("CaretLineBackground")) 3556 Preferences.getEditorColour("CaretLineBackground")
3057 self.__textEdit.setCaretLineVisible( 3557 )
3058 Preferences.getEditor("CaretLineVisible")) 3558 self.__textEdit.setCaretLineVisible(Preferences.getEditor("CaretLineVisible"))
3059 self.__textEdit.setCaretLineAlwaysVisible( 3559 self.__textEdit.setCaretLineAlwaysVisible(
3060 Preferences.getEditor("CaretLineAlwaysVisible")) 3560 Preferences.getEditor("CaretLineAlwaysVisible")
3561 )
3061 self.caretWidth = Preferences.getEditor("CaretWidth") 3562 self.caretWidth = Preferences.getEditor("CaretWidth")
3062 self.__textEdit.setCaretWidth(self.caretWidth) 3563 self.__textEdit.setCaretWidth(self.caretWidth)
3063 self.caretLineFrameWidth = Preferences.getEditor("CaretLineFrameWidth") 3564 self.caretLineFrameWidth = Preferences.getEditor("CaretLineFrameWidth")
3064 self.__textEdit.setCaretLineFrameWidth(self.caretLineFrameWidth) 3565 self.__textEdit.setCaretLineFrameWidth(self.caretLineFrameWidth)
3065 self.useMonospaced = Preferences.getEditor("UseMonospacedFont") 3566 self.useMonospaced = Preferences.getEditor("UseMonospacedFont")
3068 edge = QsciScintilla.EdgeMode(edgeMode) 3569 edge = QsciScintilla.EdgeMode(edgeMode)
3069 self.__textEdit.setEdgeMode(edge) 3570 self.__textEdit.setEdgeMode(edge)
3070 if edgeMode: 3571 if edgeMode:
3071 self.__textEdit.setEdgeColumn(Preferences.getEditor("EdgeColumn")) 3572 self.__textEdit.setEdgeColumn(Preferences.getEditor("EdgeColumn"))
3072 self.__textEdit.setEdgeColor(Preferences.getEditorColour("Edge")) 3573 self.__textEdit.setEdgeColor(Preferences.getEditorColour("Edge"))
3073 3574
3074 wrapVisualFlag = Preferences.getEditor("WrapVisualFlag") 3575 wrapVisualFlag = Preferences.getEditor("WrapVisualFlag")
3075 self.__textEdit.setWrapMode(Preferences.getEditor("WrapLongLinesMode")) 3576 self.__textEdit.setWrapMode(Preferences.getEditor("WrapLongLinesMode"))
3076 self.__textEdit.setWrapVisualFlags(wrapVisualFlag, wrapVisualFlag) 3577 self.__textEdit.setWrapVisualFlags(wrapVisualFlag, wrapVisualFlag)
3077 self.__textEdit.setWrapIndentMode( 3578 self.__textEdit.setWrapIndentMode(Preferences.getEditor("WrapIndentMode"))
3078 Preferences.getEditor("WrapIndentMode")) 3579 self.__textEdit.setWrapStartIndent(Preferences.getEditor("WrapStartIndent"))
3079 self.__textEdit.setWrapStartIndent( 3580
3080 Preferences.getEditor("WrapStartIndent"))
3081
3082 self.searchIndicator = QsciScintilla.INDIC_CONTAINER 3581 self.searchIndicator = QsciScintilla.INDIC_CONTAINER
3083 self.__textEdit.indicatorDefine( 3582 self.__textEdit.indicatorDefine(
3084 self.searchIndicator, QsciScintilla.INDIC_BOX, 3583 self.searchIndicator,
3085 Preferences.getEditorColour("SearchMarkers")) 3584 QsciScintilla.INDIC_BOX,
3086 3585 Preferences.getEditorColour("SearchMarkers"),
3586 )
3587
3087 self.__textEdit.setCursorFlashTime(QApplication.cursorFlashTime()) 3588 self.__textEdit.setCursorFlashTime(QApplication.cursorFlashTime())
3088 3589
3089 if Preferences.getEditor("OverrideEditAreaColours"): 3590 if Preferences.getEditor("OverrideEditAreaColours"):
3090 self.__textEdit.setColor( 3591 self.__textEdit.setColor(Preferences.getEditorColour("EditAreaForeground"))
3091 Preferences.getEditorColour("EditAreaForeground")) 3592 self.__textEdit.setPaper(Preferences.getEditorColour("EditAreaBackground"))
3092 self.__textEdit.setPaper( 3593
3093 Preferences.getEditorColour("EditAreaBackground"))
3094
3095 self.__textEdit.setVirtualSpaceOptions( 3594 self.__textEdit.setVirtualSpaceOptions(
3096 Preferences.getEditor("VirtualSpaceOptions")) 3595 Preferences.getEditor("VirtualSpaceOptions")
3097 3596 )
3597
3098 # to avoid errors due to line endings by pasting 3598 # to avoid errors due to line endings by pasting
3099 self.__textEdit.SendScintilla( 3599 self.__textEdit.SendScintilla(QsciScintilla.SCI_SETPASTECONVERTENDINGS, True)
3100 QsciScintilla.SCI_SETPASTECONVERTENDINGS, True) 3600
3101
3102 def __setEolMode(self): 3601 def __setEolMode(self):
3103 """ 3602 """
3104 Private method to configure the eol mode of the editor. 3603 Private method to configure the eol mode of the editor.
3105 """ 3604 """
3106 eolMode = self.__getEditorConfig("EOLMode") 3605 eolMode = self.__getEditorConfig("EOLMode")
3107 self.__textEdit.setEolMode(eolMode) 3606 self.__textEdit.setEolMode(eolMode)
3108 3607
3109 def __setMonospaced(self, on): 3608 def __setMonospaced(self, on):
3110 """ 3609 """
3111 Private method to set/reset a monospaced font. 3610 Private method to set/reset a monospaced font.
3112 3611
3113 @param on flag to indicate usage of a monospace font (boolean) 3612 @param on flag to indicate usage of a monospace font (boolean)
3114 """ 3613 """
3115 if on: 3614 if on:
3116 if not self.lexer_: 3615 if not self.lexer_:
3117 f = Preferences.getEditorOtherFonts("MonospacedFont") 3616 f = Preferences.getEditorOtherFonts("MonospacedFont")
3118 self.__textEdit.monospacedStyles(f) 3617 self.__textEdit.monospacedStyles(f)
3119 else: 3618 else:
3120 if not self.lexer_: 3619 if not self.lexer_:
3121 self.__textEdit.clearStyles() 3620 self.__textEdit.clearStyles()
3122 self.__setMargins() 3621 self.__setMargins()
3123 self.__textEdit.setFont( 3622 self.__textEdit.setFont(Preferences.getEditorOtherFonts("DefaultFont"))
3124 Preferences.getEditorOtherFonts("DefaultFont")) 3623
3125
3126 self.useMonospaced = on 3624 self.useMonospaced = on
3127 3625
3128 def __printFile(self): 3626 def __printFile(self):
3129 """ 3627 """
3130 Private slot to print the text. 3628 Private slot to print the text.
3131 """ 3629 """
3132 from .Printer import Printer 3630 from .Printer import Printer
3631
3133 printer = Printer(mode=QPrinter.PrinterMode.HighResolution) 3632 printer = Printer(mode=QPrinter.PrinterMode.HighResolution)
3134 sb = self.statusBar() 3633 sb = self.statusBar()
3135 printDialog = QPrintDialog(printer, self) 3634 printDialog = QPrintDialog(printer, self)
3136 if self.__textEdit.hasSelectedText(): 3635 if self.__textEdit.hasSelectedText():
3137 printDialog.setOption( 3636 printDialog.setOption(
3138 QAbstractPrintDialog.PrintDialogOption.PrintSelection, 3637 QAbstractPrintDialog.PrintDialogOption.PrintSelection, True
3139 True) 3638 )
3140 if printDialog.exec() == QDialog.DialogCode.Accepted: 3639 if printDialog.exec() == QDialog.DialogCode.Accepted:
3141 sb.showMessage(self.tr('Printing...')) 3640 sb.showMessage(self.tr("Printing..."))
3142 QApplication.processEvents() 3641 QApplication.processEvents()
3143 if self.__curFile: 3642 if self.__curFile:
3144 printer.setDocName(pathlib.Path(self.__curFile).name) 3643 printer.setDocName(pathlib.Path(self.__curFile).name)
3145 else: 3644 else:
3146 printer.setDocName(self.tr("Untitled")) 3645 printer.setDocName(self.tr("Untitled"))
3147 if ( 3646 if printDialog.printRange() == QAbstractPrintDialog.PrintRange.Selection:
3148 printDialog.printRange() ==
3149 QAbstractPrintDialog.PrintRange.Selection
3150 ):
3151 # get the selection 3647 # get the selection
3152 fromLine, fromIndex, toLine, toIndex = ( 3648 fromLine, fromIndex, toLine, toIndex = self.__textEdit.getSelection()
3153 self.__textEdit.getSelection()
3154 )
3155 if toIndex == 0: 3649 if toIndex == 0:
3156 toLine -= 1 3650 toLine -= 1
3157 # QScintilla seems to print one line more than told 3651 # QScintilla seems to print one line more than told
3158 res = printer.printRange(self.__textEdit, fromLine, toLine - 1) 3652 res = printer.printRange(self.__textEdit, fromLine, toLine - 1)
3159 else: 3653 else:
3160 res = printer.printRange(self.__textEdit) 3654 res = printer.printRange(self.__textEdit)
3161 if res: 3655 if res:
3162 sb.showMessage(self.tr('Printing completed'), 2000) 3656 sb.showMessage(self.tr("Printing completed"), 2000)
3163 else: 3657 else:
3164 sb.showMessage(self.tr('Error while printing'), 2000) 3658 sb.showMessage(self.tr("Error while printing"), 2000)
3165 QApplication.processEvents() 3659 QApplication.processEvents()
3166 else: 3660 else:
3167 sb.showMessage(self.tr('Printing aborted'), 2000) 3661 sb.showMessage(self.tr("Printing aborted"), 2000)
3168 QApplication.processEvents() 3662 QApplication.processEvents()
3169 3663
3170 def __printPreviewFile(self): 3664 def __printPreviewFile(self):
3171 """ 3665 """
3172 Private slot to show a print preview of the text. 3666 Private slot to show a print preview of the text.
3173 """ 3667 """
3174 from PyQt6.QtPrintSupport import QPrintPreviewDialog 3668 from PyQt6.QtPrintSupport import QPrintPreviewDialog
3175 from .Printer import Printer 3669 from .Printer import Printer
3176 3670
3177 printer = Printer(mode=QPrinter.PrinterMode.HighResolution) 3671 printer = Printer(mode=QPrinter.PrinterMode.HighResolution)
3178 if self.__curFile: 3672 if self.__curFile:
3179 printer.setDocName(pathlib.Path(self.__curFile).name) 3673 printer.setDocName(pathlib.Path(self.__curFile).name)
3180 else: 3674 else:
3181 printer.setDocName(self.tr("Untitled")) 3675 printer.setDocName(self.tr("Untitled"))
3182 preview = QPrintPreviewDialog(printer, self) 3676 preview = QPrintPreviewDialog(printer, self)
3183 preview.paintRequested.connect(self.__printPreview) 3677 preview.paintRequested.connect(self.__printPreview)
3184 preview.exec() 3678 preview.exec()
3185 3679
3186 def __printPreview(self, printer): 3680 def __printPreview(self, printer):
3187 """ 3681 """
3188 Private slot to generate a print preview. 3682 Private slot to generate a print preview.
3189 3683
3190 @param printer reference to the printer object 3684 @param printer reference to the printer object
3191 (QScintilla.Printer.Printer) 3685 (QScintilla.Printer.Printer)
3192 """ 3686 """
3193 printer.printRange(self.__textEdit) 3687 printer.printRange(self.__textEdit)
3194 3688
3195 ######################################################### 3689 #########################################################
3196 ## Methods needed by the context menu 3690 ## Methods needed by the context menu
3197 ######################################################### 3691 #########################################################
3198 3692
3199 def __contextMenuRequested(self, coord): 3693 def __contextMenuRequested(self, coord):
3200 """ 3694 """
3201 Private slot to show the context menu. 3695 Private slot to show the context menu.
3202 3696
3203 @param coord the position of the mouse pointer (QPoint) 3697 @param coord the position of the mouse pointer (QPoint)
3204 """ 3698 """
3205 self.contextMenu.popup(self.mapToGlobal(coord)) 3699 self.contextMenu.popup(self.mapToGlobal(coord))
3206 3700
3207 def __initContextMenu(self): 3701 def __initContextMenu(self):
3208 """ 3702 """
3209 Private method used to setup the context menu. 3703 Private method used to setup the context menu.
3210 """ 3704 """
3211 self.contextMenu = QMenu() 3705 self.contextMenu = QMenu()
3212 3706
3213 self.languagesMenu = self.__initContextMenuLanguages() 3707 self.languagesMenu = self.__initContextMenuLanguages()
3214 3708
3215 self.contextMenu.addAction(self.undoAct) 3709 self.contextMenu.addAction(self.undoAct)
3216 self.contextMenu.addAction(self.redoAct) 3710 self.contextMenu.addAction(self.redoAct)
3217 self.contextMenu.addSeparator() 3711 self.contextMenu.addSeparator()
3218 self.contextMenu.addAction(self.cutAct) 3712 self.contextMenu.addAction(self.cutAct)
3219 self.contextMenu.addAction(self.copyAct) 3713 self.contextMenu.addAction(self.copyAct)
3220 self.contextMenu.addAction(self.pasteAct) 3714 self.contextMenu.addAction(self.pasteAct)
3221 self.contextMenu.addSeparator() 3715 self.contextMenu.addSeparator()
3222 self.contextMenu.addAction(self.tr('Select all'), self.__selectAll) 3716 self.contextMenu.addAction(self.tr("Select all"), self.__selectAll)
3223 self.contextMenu.addAction( 3717 self.contextMenu.addAction(self.tr("Deselect all"), self.__deselectAll)
3224 self.tr('Deselect all'), self.__deselectAll)
3225 self.contextMenu.addSeparator() 3718 self.contextMenu.addSeparator()
3226 self.languagesMenuAct = self.contextMenu.addMenu(self.languagesMenu) 3719 self.languagesMenuAct = self.contextMenu.addMenu(self.languagesMenu)
3227 self.contextMenu.addSeparator() 3720 self.contextMenu.addSeparator()
3228 self.contextMenu.addAction(self.printPreviewAct) 3721 self.contextMenu.addAction(self.printPreviewAct)
3229 self.contextMenu.addAction(self.printAct) 3722 self.contextMenu.addAction(self.printAct)
3230 3723
3231 def __initContextMenuLanguages(self): 3724 def __initContextMenuLanguages(self):
3232 """ 3725 """
3233 Private method used to setup the Languages context sub menu. 3726 Private method used to setup the Languages context sub menu.
3234 3727
3235 @return reference to the generated menu (QMenu) 3728 @return reference to the generated menu (QMenu)
3236 """ 3729 """
3237 menu = QMenu(self.tr("Languages")) 3730 menu = QMenu(self.tr("Languages"))
3238 3731
3239 self.languagesActGrp = QActionGroup(self) 3732 self.languagesActGrp = QActionGroup(self)
3240 self.noLanguageAct = menu.addAction(self.tr("No Language")) 3733 self.noLanguageAct = menu.addAction(self.tr("No Language"))
3241 self.noLanguageAct.setCheckable(True) 3734 self.noLanguageAct.setCheckable(True)
3242 self.noLanguageAct.setData("None") 3735 self.noLanguageAct.setData("None")
3243 self.languagesActGrp.addAction(self.noLanguageAct) 3736 self.languagesActGrp.addAction(self.noLanguageAct)
3244 menu.addSeparator() 3737 menu.addSeparator()
3245 3738
3246 from . import Lexers 3739 from . import Lexers
3740
3247 self.supportedLanguages = {} 3741 self.supportedLanguages = {}
3248 supportedLanguages = Lexers.getSupportedLanguages() 3742 supportedLanguages = Lexers.getSupportedLanguages()
3249 languages = sorted(supportedLanguages.keys()) 3743 languages = sorted(supportedLanguages.keys())
3250 for language in languages: 3744 for language in languages:
3251 if language != "Guessed": 3745 if language != "Guessed":
3252 self.supportedLanguages[language] = ( 3746 self.supportedLanguages[language] = supportedLanguages[language][:2]
3253 supportedLanguages[language][:2]
3254 )
3255 act = menu.addAction( 3747 act = menu.addAction(
3256 UI.PixmapCache.getIcon(supportedLanguages[language][2]), 3748 UI.PixmapCache.getIcon(supportedLanguages[language][2]),
3257 self.supportedLanguages[language][0]) 3749 self.supportedLanguages[language][0],
3750 )
3258 act.setCheckable(True) 3751 act.setCheckable(True)
3259 act.setData(language) 3752 act.setData(language)
3260 self.supportedLanguages[language].append(act) 3753 self.supportedLanguages[language].append(act)
3261 self.languagesActGrp.addAction(act) 3754 self.languagesActGrp.addAction(act)
3262 3755
3263 menu.addSeparator() 3756 menu.addSeparator()
3264 self.pygmentsAct = menu.addAction(self.tr("Guessed")) 3757 self.pygmentsAct = menu.addAction(self.tr("Guessed"))
3265 self.pygmentsAct.setCheckable(True) 3758 self.pygmentsAct.setCheckable(True)
3266 self.pygmentsAct.setData("Guessed") 3759 self.pygmentsAct.setData("Guessed")
3267 self.languagesActGrp.addAction(self.pygmentsAct) 3760 self.languagesActGrp.addAction(self.pygmentsAct)
3268 self.pygmentsSelAct = menu.addAction(self.tr("Alternatives")) 3761 self.pygmentsSelAct = menu.addAction(self.tr("Alternatives"))
3269 self.pygmentsSelAct.setData("Alternatives") 3762 self.pygmentsSelAct.setData("Alternatives")
3270 3763
3271 menu.triggered.connect(self.__languageMenuTriggered) 3764 menu.triggered.connect(self.__languageMenuTriggered)
3272 menu.aboutToShow.connect(self.__showContextMenuLanguages) 3765 menu.aboutToShow.connect(self.__showContextMenuLanguages)
3273 3766
3274 return menu 3767 return menu
3275 3768
3276 def __showContextMenuLanguages(self): 3769 def __showContextMenuLanguages(self):
3277 """ 3770 """
3278 Private slot handling the aboutToShow signal of the languages context 3771 Private slot handling the aboutToShow signal of the languages context
3279 menu. 3772 menu.
3280 """ 3773 """
3281 if self.apiLanguage.startswith("Pygments|"): 3774 if self.apiLanguage.startswith("Pygments|"):
3282 self.pygmentsSelAct.setText( 3775 self.pygmentsSelAct.setText(
3283 self.tr("Alternatives ({0})").format( 3776 self.tr("Alternatives ({0})").format(self.getLanguage(normalized=False))
3284 self.getLanguage(normalized=False))) 3777 )
3285 else: 3778 else:
3286 self.pygmentsSelAct.setText(self.tr("Alternatives")) 3779 self.pygmentsSelAct.setText(self.tr("Alternatives"))
3287 3780
3288 def __showLanguagesMenu(self, pos): 3781 def __showLanguagesMenu(self, pos):
3289 """ 3782 """
3290 Private slot to show the Languages menu of the status bar. 3783 Private slot to show the Languages menu of the status bar.
3291 3784
3292 @param pos position the menu should be shown at (QPoint) 3785 @param pos position the menu should be shown at (QPoint)
3293 """ 3786 """
3294 self.languagesMenu.exec(pos) 3787 self.languagesMenu.exec(pos)
3295 3788
3296 def __selectPygmentsLexer(self): 3789 def __selectPygmentsLexer(self):
3297 """ 3790 """
3298 Private method to select a specific pygments lexer. 3791 Private method to select a specific pygments lexer.
3299 3792
3300 @return name of the selected pygments lexer 3793 @return name of the selected pygments lexer
3301 @rtype str 3794 @rtype str
3302 """ 3795 """
3303 from pygments.lexers import get_all_lexers 3796 from pygments.lexers import get_all_lexers
3797
3304 lexerList = sorted(lex[0] for lex in get_all_lexers()) 3798 lexerList = sorted(lex[0] for lex in get_all_lexers())
3305 try: 3799 try:
3306 lexerSel = lexerList.index( 3800 lexerSel = lexerList.index(
3307 self.getLanguage(normalized=False, forPygments=True)) 3801 self.getLanguage(normalized=False, forPygments=True)
3802 )
3308 except ValueError: 3803 except ValueError:
3309 lexerSel = 0 3804 lexerSel = 0
3310 lexerName, ok = QInputDialog.getItem( 3805 lexerName, ok = QInputDialog.getItem(
3311 self, 3806 self,
3312 self.tr("Pygments Lexer"), 3807 self.tr("Pygments Lexer"),
3313 self.tr("Select the Pygments lexer to apply."), 3808 self.tr("Select the Pygments lexer to apply."),
3314 lexerList, 3809 lexerList,
3315 lexerSel, 3810 lexerSel,
3316 False) 3811 False,
3812 )
3317 if ok and lexerName: 3813 if ok and lexerName:
3318 return lexerName 3814 return lexerName
3319 else: 3815 else:
3320 return "" 3816 return ""
3321 3817
3322 def __languageMenuTriggered(self, act): 3818 def __languageMenuTriggered(self, act):
3323 """ 3819 """
3324 Private method to handle the selection of a lexer language. 3820 Private method to handle the selection of a lexer language.
3325 3821
3326 @param act reference to the action that was triggered (QAction) 3822 @param act reference to the action that was triggered (QAction)
3327 """ 3823 """
3328 if act == self.noLanguageAct: 3824 if act == self.noLanguageAct:
3329 self.__resetLanguage() 3825 self.__resetLanguage()
3330 elif act == self.pygmentsAct: 3826 elif act == self.pygmentsAct:
3335 self.setLanguage("dummy.pygments", pyname=language) 3831 self.setLanguage("dummy.pygments", pyname=language)
3336 else: 3832 else:
3337 language = act.data() 3833 language = act.data()
3338 if language: 3834 if language:
3339 self.setLanguage(self.supportedLanguages[language][1]) 3835 self.setLanguage(self.supportedLanguages[language][1])
3340 3836
3341 def __resetLanguage(self): 3837 def __resetLanguage(self):
3342 """ 3838 """
3343 Private method used to reset the language selection. 3839 Private method used to reset the language selection.
3344 """ 3840 """
3345 if ( 3841 if self.lexer_ is not None and (
3346 self.lexer_ is not None and 3842 self.lexer_.lexer() == "container" or self.lexer_.lexer() is None
3347 (self.lexer_.lexer() == "container" or
3348 self.lexer_.lexer() is None)
3349 ): 3843 ):
3350 self.__textEdit.SCN_STYLENEEDED.disconnect(self.__styleNeeded) 3844 self.__textEdit.SCN_STYLENEEDED.disconnect(self.__styleNeeded)
3351 3845
3352 self.apiLanguage = "" 3846 self.apiLanguage = ""
3353 self.lexer_ = None 3847 self.lexer_ = None
3354 self.__textEdit.setLexer() 3848 self.__textEdit.setLexer()
3355 self.__setMonospaced(self.useMonospaced) 3849 self.__setMonospaced(self.useMonospaced)
3356 3850
3357 if Preferences.getEditor("OverrideEditAreaColours"): 3851 if Preferences.getEditor("OverrideEditAreaColours"):
3358 self.__textEdit.setColor( 3852 self.__textEdit.setColor(Preferences.getEditorColour("EditAreaForeground"))
3359 Preferences.getEditorColour("EditAreaForeground")) 3853 self.__textEdit.setPaper(Preferences.getEditorColour("EditAreaBackground"))
3360 self.__textEdit.setPaper( 3854
3361 Preferences.getEditorColour("EditAreaBackground"))
3362
3363 self.languageChanged.emit(self.apiLanguage) 3855 self.languageChanged.emit(self.apiLanguage)
3364 3856
3365 def setLanguage(self, filename, initTextDisplay=True, pyname=""): 3857 def setLanguage(self, filename, initTextDisplay=True, pyname=""):
3366 """ 3858 """
3367 Public method to set a lexer language. 3859 Public method to set a lexer language.
3368 3860
3369 @param filename filename used to determine the associated lexer 3861 @param filename filename used to determine the associated lexer
3370 language (string) 3862 language (string)
3371 @param initTextDisplay flag indicating an initialization of the text 3863 @param initTextDisplay flag indicating an initialization of the text
3372 display is required as well (boolean) 3864 display is required as well (boolean)
3373 @param pyname name of the pygments lexer to use (string) 3865 @param pyname name of the pygments lexer to use (string)
3374 """ 3866 """
3375 self.__bindLexer(filename, pyname=pyname) 3867 self.__bindLexer(filename, pyname=pyname)
3376 self.__textEdit.recolor() 3868 self.__textEdit.recolor()
3377 self.__checkLanguage() 3869 self.__checkLanguage()
3378 3870
3379 # set the text display 3871 # set the text display
3380 if initTextDisplay: 3872 if initTextDisplay:
3381 self.__setTextDisplay() 3873 self.__setTextDisplay()
3382 self.__setMargins() 3874 self.__setMargins()
3383 3875
3384 self.languageChanged.emit(self.apiLanguage) 3876 self.languageChanged.emit(self.apiLanguage)
3385 3877
3386 def getLanguage(self, normalized=True, forPygments=False): 3878 def getLanguage(self, normalized=True, forPygments=False):
3387 """ 3879 """
3388 Public method to retrieve the language of the editor. 3880 Public method to retrieve the language of the editor.
3389 3881
3390 @param normalized flag indicating to normalize some Pygments 3882 @param normalized flag indicating to normalize some Pygments
3391 lexer names 3883 lexer names
3392 @type bool 3884 @type bool
3393 @param forPygments flag indicating to normalize some lexer 3885 @param forPygments flag indicating to normalize some lexer
3394 names for Pygments 3886 names for Pygments
3395 @type bool 3887 @type bool
3396 @return language of the editor 3888 @return language of the editor
3397 @rtype str 3889 @rtype str
3398 """ 3890 """
3399 if ( 3891 if self.apiLanguage == "Guessed" or self.apiLanguage.startswith("Pygments|"):
3400 self.apiLanguage == "Guessed" or
3401 self.apiLanguage.startswith("Pygments|")
3402 ):
3403 lang = self.lexer_.name() 3892 lang = self.lexer_.name()
3404 if normalized: 3893 if normalized:
3405 # adjust some Pygments lexer names 3894 # adjust some Pygments lexer names
3406 if lang in ("Python 2.x", "Python"): 3895 if lang in ("Python 2.x", "Python"):
3407 lang = "Python3" 3896 lang = "Python3"
3408 elif lang == "Protocol Buffer": 3897 elif lang == "Protocol Buffer":
3409 lang = "Protocol" 3898 lang = "Protocol"
3410 3899
3411 else: 3900 else:
3412 lang = self.apiLanguage 3901 lang = self.apiLanguage
3413 if forPygments: 3902 if forPygments:
3414 # adjust some names to Pygments lexer names 3903 # adjust some names to Pygments lexer names
3415 if lang == "Python3": 3904 if lang == "Python3":
3416 lang = "Python" 3905 lang = "Python"
3417 elif lang == "Protocol": 3906 elif lang == "Protocol":
3418 lang = "Protocol Buffer" 3907 lang = "Protocol Buffer"
3419 return lang 3908 return lang
3420 3909
3421 def __checkLanguage(self): 3910 def __checkLanguage(self):
3422 """ 3911 """
3423 Private method to check the selected language of the language submenu. 3912 Private method to check the selected language of the language submenu.
3424 """ 3913 """
3425 if self.apiLanguage == "": 3914 if self.apiLanguage == "":
3430 act = self.languagesActGrp.checkedAction() 3919 act = self.languagesActGrp.checkedAction()
3431 if act: 3920 if act:
3432 act.setChecked(False) 3921 act.setChecked(False)
3433 else: 3922 else:
3434 self.supportedLanguages[self.apiLanguage][2].setChecked(True) 3923 self.supportedLanguages[self.apiLanguage][2].setChecked(True)
3435 3924
3436 def __bindLexer(self, filename, pyname=""): 3925 def __bindLexer(self, filename, pyname=""):
3437 """ 3926 """
3438 Private slot to set the correct lexer depending on language. 3927 Private slot to set the correct lexer depending on language.
3439 3928
3440 @param filename filename used to determine the associated lexer 3929 @param filename filename used to determine the associated lexer
3441 language (string) 3930 language (string)
3442 @param pyname name of the pygments lexer to use (string) 3931 @param pyname name of the pygments lexer to use (string)
3443 """ 3932 """
3444 if ( 3933 if self.lexer_ is not None and (
3445 self.lexer_ is not None and 3934 self.lexer_.lexer() == "container" or self.lexer_.lexer() is None
3446 (self.lexer_.lexer() == "container" or
3447 self.lexer_.lexer() is None)
3448 ): 3935 ):
3449 self.__textEdit.SCN_STYLENEEDED.disconnect(self.__styleNeeded) 3936 self.__textEdit.SCN_STYLENEEDED.disconnect(self.__styleNeeded)
3450 3937
3451 filename = os.path.basename(filename) 3938 filename = os.path.basename(filename)
3452 language = Preferences.getEditorLexerAssoc(filename) 3939 language = Preferences.getEditorLexerAssoc(filename)
3453 if language == "Python": 3940 if language == "Python":
3454 language = "Python3" 3941 language = "Python3"
3455 if language.startswith("Pygments|"): 3942 if language.startswith("Pygments|"):
3456 pyname = language.split("|", 1)[1] 3943 pyname = language.split("|", 1)[1]
3457 language = "" 3944 language = ""
3458 3945
3459 if not self.filetype: 3946 if not self.filetype:
3460 if not language and pyname: 3947 if not language and pyname:
3461 self.filetype = pyname 3948 self.filetype = pyname
3462 else: 3949 else:
3463 self.filetype = language 3950 self.filetype = language
3464 3951
3465 from . import Lexers 3952 from . import Lexers
3953
3466 self.lexer_ = Lexers.getLexer(language, self.__textEdit, pyname=pyname) 3954 self.lexer_ = Lexers.getLexer(language, self.__textEdit, pyname=pyname)
3467 if self.lexer_ is None: 3955 if self.lexer_ is None:
3468 self.__textEdit.setLexer() 3956 self.__textEdit.setLexer()
3469 self.apiLanguage = "" 3957 self.apiLanguage = ""
3470 return 3958 return
3471 3959
3472 if pyname: 3960 if pyname:
3473 if pyname.startswith("Pygments|"): 3961 if pyname.startswith("Pygments|"):
3474 self.apiLanguage = pyname 3962 self.apiLanguage = pyname
3475 else: 3963 else:
3476 self.apiLanguage = "Pygments|{0}".format(pyname) 3964 self.apiLanguage = "Pygments|{0}".format(pyname)
3486 elif self.apiLanguage == "PO": 3974 elif self.apiLanguage == "PO":
3487 self.apiLanguage = "Gettext" 3975 self.apiLanguage = "Gettext"
3488 self.__textEdit.setLexer(self.lexer_) 3976 self.__textEdit.setLexer(self.lexer_)
3489 if self.lexer_.lexer() == "container" or self.lexer_.lexer() is None: 3977 if self.lexer_.lexer() == "container" or self.lexer_.lexer() is None:
3490 self.__textEdit.SCN_STYLENEEDED.connect(self.__styleNeeded) 3978 self.__textEdit.SCN_STYLENEEDED.connect(self.__styleNeeded)
3491 3979
3492 # get the font for style 0 and set it as the default font 3980 # get the font for style 0 and set it as the default font
3493 key = ( 3981 key = (
3494 'Scintilla/Guessed/style0/font' 3982 "Scintilla/Guessed/style0/font"
3495 if pyname and pyname.startswith("Pygments|") else 3983 if pyname and pyname.startswith("Pygments|")
3496 'Scintilla/{0}/style0/font'.format(self.lexer_.language()) 3984 else "Scintilla/{0}/style0/font".format(self.lexer_.language())
3497 ) 3985 )
3498 fdesc = Preferences.getSettings().value(key) 3986 fdesc = Preferences.getSettings().value(key)
3499 if fdesc is not None: 3987 if fdesc is not None:
3500 font = QFont([fdesc[0]], int(fdesc[1])) 3988 font = QFont([fdesc[0]], int(fdesc[1]))
3501 self.lexer_.setDefaultFont(font) 3989 self.lexer_.setDefaultFont(font)
3502 self.lexer_.readSettings(Preferences.getSettings(), "Scintilla") 3990 self.lexer_.readSettings(Preferences.getSettings(), "Scintilla")
3503 if self.lexer_.hasSubstyles(): 3991 if self.lexer_.hasSubstyles():
3504 self.lexer_.readSubstyles(self.__textEdit) 3992 self.lexer_.readSubstyles(self.__textEdit)
3505 3993
3506 # now set the lexer properties 3994 # now set the lexer properties
3507 self.lexer_.initProperties() 3995 self.lexer_.initProperties()
3508 3996
3509 self.lexer_.setDefaultColor(self.lexer_.color(0)) 3997 self.lexer_.setDefaultColor(self.lexer_.color(0))
3510 self.lexer_.setDefaultPaper(self.lexer_.paper(0)) 3998 self.lexer_.setDefaultPaper(self.lexer_.paper(0))
3511 3999
3512 def __styleNeeded(self, position): 4000 def __styleNeeded(self, position):
3513 """ 4001 """
3514 Private slot to handle the need for more styling. 4002 Private slot to handle the need for more styling.
3515 4003
3516 @param position end position, that needs styling (integer) 4004 @param position end position, that needs styling (integer)
3517 """ 4005 """
3518 self.lexer_.styleText(self.__textEdit.getEndStyled(), position) 4006 self.lexer_.styleText(self.__textEdit.getEndStyled(), position)
3519 4007
3520 def __bindName(self, line0): 4008 def __bindName(self, line0):
3521 """ 4009 """
3522 Private method to generate a dummy filename for binding a lexer. 4010 Private method to generate a dummy filename for binding a lexer.
3523 4011
3524 @param line0 first line of text to use in the generation process 4012 @param line0 first line of text to use in the generation process
3525 (string) 4013 (string)
3526 @return dummy file name to be used for binding a lexer (string) 4014 @return dummy file name to be used for binding a lexer (string)
3527 """ 4015 """
3528 bindName = "" 4016 bindName = ""
3529 line0 = line0.lower() 4017 line0 = line0.lower()
3530 4018
3531 # check first line if it does not start with #! 4019 # check first line if it does not start with #!
3532 if line0.startswith(("<html", "<!doctype html", "<?php")): 4020 if line0.startswith(("<html", "<!doctype html", "<?php")):
3533 bindName = "dummy.html" 4021 bindName = "dummy.html"
3534 elif line0.startswith(("<?xml", "<!doctype")): 4022 elif line0.startswith(("<?xml", "<!doctype")):
3535 bindName = "dummy.xml" 4023 bindName = "dummy.xml"
3536 elif line0.startswith("index: "): 4024 elif line0.startswith("index: "):
3537 bindName = "dummy.diff" 4025 bindName = "dummy.diff"
3538 elif line0.startswith("\\documentclass"): 4026 elif line0.startswith("\\documentclass"):
3539 bindName = "dummy.tex" 4027 bindName = "dummy.tex"
3540 4028
3541 if not bindName and self.filetype: 4029 if not bindName and self.filetype:
3542 # check filetype 4030 # check filetype
3543 from . import Lexers 4031 from . import Lexers
4032
3544 supportedLanguages = Lexers.getSupportedLanguages() 4033 supportedLanguages = Lexers.getSupportedLanguages()
3545 if self.filetype in supportedLanguages: 4034 if self.filetype in supportedLanguages:
3546 bindName = supportedLanguages[self.filetype][1] 4035 bindName = supportedLanguages[self.filetype][1]
3547 elif self.filetype in ["Python", "Python3", "MicroPython"]: 4036 elif self.filetype in ["Python", "Python3", "MicroPython"]:
3548 bindName = "dummy.py" 4037 bindName = "dummy.py"
3549 4038
3550 if not bindName and line0.startswith("#!"): 4039 if not bindName and line0.startswith("#!"):
3551 # #! marker detection 4040 # #! marker detection
3552 if ( 4041 if "python3" in line0 or "python" in line0:
3553 "python3" in line0 or
3554 "python" in line0
3555 ):
3556 bindName = "dummy.py" 4042 bindName = "dummy.py"
3557 self.filetype = "Python3" 4043 self.filetype = "Python3"
3558 elif ("/bash" in line0 or "/sh" in line0): 4044 elif "/bash" in line0 or "/sh" in line0:
3559 bindName = "dummy.sh" 4045 bindName = "dummy.sh"
3560 elif "ruby" in line0: 4046 elif "ruby" in line0:
3561 bindName = "dummy.rb" 4047 bindName = "dummy.rb"
3562 self.filetype = "Ruby" 4048 self.filetype = "Ruby"
3563 elif "perl" in line0: 4049 elif "perl" in line0:
3565 elif "lua" in line0: 4051 elif "lua" in line0:
3566 bindName = "dummy.lua" 4052 bindName = "dummy.lua"
3567 elif "dmd" in line0: 4053 elif "dmd" in line0:
3568 bindName = "dummy.d" 4054 bindName = "dummy.d"
3569 self.filetype = "D" 4055 self.filetype = "D"
3570 4056
3571 if not bindName: 4057 if not bindName:
3572 # mode line detection: -*- mode: python -*- 4058 # mode line detection: -*- mode: python -*-
3573 match = re.search(r"mode[:=]\s*([-\w_.]+)", line0) 4059 match = re.search(r"mode[:=]\s*([-\w_.]+)", line0)
3574 if match: 4060 if match:
3575 mode = match.group(1).lower() 4061 mode = match.group(1).lower()
3584 elif mode == "lua": 4070 elif mode == "lua":
3585 bindName = "dummy.lua" 4071 bindName = "dummy.lua"
3586 elif mode in ["dmd", "d"]: 4072 elif mode in ["dmd", "d"]:
3587 bindName = "dummy.d" 4073 bindName = "dummy.d"
3588 self.filetype = "D" 4074 self.filetype = "D"
3589 4075
3590 if not bindName: 4076 if not bindName:
3591 bindName = self.__curFile 4077 bindName = self.__curFile
3592 4078
3593 return bindName 4079 return bindName
3594 4080
3595 ########################################################## 4081 ##########################################################
3596 ## Methods needed for the search functionality 4082 ## Methods needed for the search functionality
3597 ########################################################## 4083 ##########################################################
3598 4084
3599 def getSRHistory(self, key): 4085 def getSRHistory(self, key):
3600 """ 4086 """
3601 Public method to get the search or replace history list. 4087 Public method to get the search or replace history list.
3602 4088
3603 @param key list to return (must be 'search' or 'replace') 4089 @param key list to return (must be 'search' or 'replace')
3604 @return the requested history list (list of strings) 4090 @return the requested history list (list of strings)
3605 """ 4091 """
3606 return self.srHistory[key][:] 4092 return self.srHistory[key][:]
3607 4093
3608 def textForFind(self): 4094 def textForFind(self):
3609 """ 4095 """
3610 Public method to determine the selection or the current word for the 4096 Public method to determine the selection or the current word for the
3611 next find operation. 4097 next find operation.
3612 4098
3613 @return selection or current word (string) 4099 @return selection or current word (string)
3614 """ 4100 """
3615 if self.__textEdit.hasSelectedText(): 4101 if self.__textEdit.hasSelectedText():
3616 text = self.__textEdit.selectedText() 4102 text = self.__textEdit.selectedText()
3617 if '\r' in text or '\n' in text: 4103 if "\r" in text or "\n" in text:
3618 # the selection contains at least a newline, it is 4104 # the selection contains at least a newline, it is
3619 # unlikely to be the expression to search for 4105 # unlikely to be the expression to search for
3620 return '' 4106 return ""
3621 4107
3622 return text 4108 return text
3623 4109
3624 # no selected text, determine the word at the current position 4110 # no selected text, determine the word at the current position
3625 return self.__getCurrentWord() 4111 return self.__getCurrentWord()
3626 4112
3627 def __getWord(self, line, index): 4113 def __getWord(self, line, index):
3628 """ 4114 """
3629 Private method to get the word at a position. 4115 Private method to get the word at a position.
3630 4116
3631 @param line number of line to look at 4117 @param line number of line to look at
3632 @type int 4118 @type int
3633 @param index position to look at 4119 @param index position to look at
3634 @type int 4120 @type int
3635 @return the word at that position 4121 @return the word at that position
3637 """ 4123 """
3638 wc = self.__textEdit.wordCharacters() 4124 wc = self.__textEdit.wordCharacters()
3639 if wc is None: 4125 if wc is None:
3640 pattern = r"\b[\w_]+\b" 4126 pattern = r"\b[\w_]+\b"
3641 else: 4127 else:
3642 wc = re.sub(r'\w', "", wc) 4128 wc = re.sub(r"\w", "", wc)
3643 pattern = r"\b[\w{0}]+\b".format(re.escape(wc)) 4129 pattern = r"\b[\w{0}]+\b".format(re.escape(wc))
3644 rx = ( 4130 rx = (
3645 re.compile(pattern) 4131 re.compile(pattern)
3646 if self.__textEdit.caseSensitive() else 4132 if self.__textEdit.caseSensitive()
3647 re.compile(pattern, re.IGNORECASE) 4133 else re.compile(pattern, re.IGNORECASE)
3648 ) 4134 )
3649 4135
3650 text = self.text(line) 4136 text = self.text(line)
3651 for match in rx.finditer(text): 4137 for match in rx.finditer(text):
3652 start, end = match.span() 4138 start, end = match.span()
3653 if start <= index <= end: 4139 if start <= index <= end:
3654 return match.group() 4140 return match.group()
3655 4141
3656 return "" 4142 return ""
3657 4143
3658 def __getCurrentWord(self): 4144 def __getCurrentWord(self):
3659 """ 4145 """
3660 Private method to get the word at the current position. 4146 Private method to get the word at the current position.
3661 4147
3662 @return the word at that current position 4148 @return the word at that current position
3663 """ 4149 """
3664 line, index = self.getCursorPosition() 4150 line, index = self.getCursorPosition()
3665 return self.__getWord(line, index) 4151 return self.__getWord(line, index)
3666 4152
3667 def showSearchWidget(self): 4153 def showSearchWidget(self):
3668 """ 4154 """
3669 Public method to show the search widget. 4155 Public method to show the search widget.
3670 """ 4156 """
3671 self.__replaceWidget.hide() 4157 self.__replaceWidget.hide()
3672 self.__searchWidget.show() 4158 self.__searchWidget.show()
3673 self.__searchWidget.show(self.textForFind()) 4159 self.__searchWidget.show(self.textForFind())
3674 4160
3675 def __searchNext(self): 4161 def __searchNext(self):
3676 """ 4162 """
3677 Private slot to handle the search next action. 4163 Private slot to handle the search next action.
3678 """ 4164 """
3679 if self.__replaceWidget.isVisible(): 4165 if self.__replaceWidget.isVisible():
3680 self.__replaceWidget.findNext() 4166 self.__replaceWidget.findNext()
3681 else: 4167 else:
3682 self.__searchWidget.findNext() 4168 self.__searchWidget.findNext()
3683 4169
3684 def __searchPrev(self): 4170 def __searchPrev(self):
3685 """ 4171 """
3686 Private slot to handle the search previous action. 4172 Private slot to handle the search previous action.
3687 """ 4173 """
3688 if self.__replaceWidget.isVisible(): 4174 if self.__replaceWidget.isVisible():
3689 self.__replaceWidget.findPrev() 4175 self.__replaceWidget.findPrev()
3690 else: 4176 else:
3691 self.__searchWidget.findPrev() 4177 self.__searchWidget.findPrev()
3692 4178
3693 def showReplaceWidget(self): 4179 def showReplaceWidget(self):
3694 """ 4180 """
3695 Public method to show the replace widget. 4181 Public method to show the replace widget.
3696 """ 4182 """
3697 self.__searchWidget.hide() 4183 self.__searchWidget.hide()
3698 self.__replaceWidget.show(self.textForFind()) 4184 self.__replaceWidget.show(self.textForFind())
3699 4185
3700 def __searchClearMarkers(self): 4186 def __searchClearMarkers(self):
3701 """ 4187 """
3702 Private method to clear the search markers of the active window. 4188 Private method to clear the search markers of the active window.
3703 """ 4189 """
3704 self.clearSearchIndicators() 4190 self.clearSearchIndicators()
3705 4191
3706 def activeWindow(self): 4192 def activeWindow(self):
3707 """ 4193 """
3708 Public method to fulfill the ViewManager interface. 4194 Public method to fulfill the ViewManager interface.
3709 4195
3710 @return reference to the text edit component (QsciScintillaCompat) 4196 @return reference to the text edit component (QsciScintillaCompat)
3711 """ 4197 """
3712 return self.__textEdit 4198 return self.__textEdit
3713 4199
3714 def setSearchIndicator(self, startPos, indicLength): 4200 def setSearchIndicator(self, startPos, indicLength):
3715 """ 4201 """
3716 Public method to set a search indicator for the given range. 4202 Public method to set a search indicator for the given range.
3717 4203
3718 @param startPos start position of the indicator (integer) 4204 @param startPos start position of the indicator (integer)
3719 @param indicLength length of the indicator (integer) 4205 @param indicLength length of the indicator (integer)
3720 """ 4206 """
3721 self.__textEdit.setIndicatorRange( 4207 self.__textEdit.setIndicatorRange(self.searchIndicator, startPos, indicLength)
3722 self.searchIndicator, startPos, indicLength) 4208
3723
3724 def clearSearchIndicators(self): 4209 def clearSearchIndicators(self):
3725 """ 4210 """
3726 Public method to clear all search indicators. 4211 Public method to clear all search indicators.
3727 """ 4212 """
3728 self.__textEdit.clearAllIndicators(self.searchIndicator) 4213 self.__textEdit.clearAllIndicators(self.searchIndicator)
3729 self.__markedText = "" 4214 self.__markedText = ""
3730 4215
3731 def __markOccurrences(self): 4216 def __markOccurrences(self):
3732 """ 4217 """
3733 Private method to mark all occurrences of the current word. 4218 Private method to mark all occurrences of the current word.
3734 """ 4219 """
3735 word = self.__getCurrentWord() 4220 word = self.__getCurrentWord()
3736 if not word: 4221 if not word:
3737 self.clearSearchIndicators() 4222 self.clearSearchIndicators()
3738 return 4223 return
3739 4224
3740 if self.__markedText == word: 4225 if self.__markedText == word:
3741 return 4226 return
3742 4227
3743 self.clearSearchIndicators() 4228 self.clearSearchIndicators()
3744 ok = self.__textEdit.findFirstTarget( 4229 ok = self.__textEdit.findFirstTarget(
3745 word, False, self.__textEdit.caseSensitive(), True, 0, 0) 4230 word, False, self.__textEdit.caseSensitive(), True, 0, 0
4231 )
3746 while ok: 4232 while ok:
3747 tgtPos, tgtLen = self.__textEdit.getFoundTarget() 4233 tgtPos, tgtLen = self.__textEdit.getFoundTarget()
3748 self.setSearchIndicator(tgtPos, tgtLen) 4234 self.setSearchIndicator(tgtPos, tgtLen)
3749 ok = self.__textEdit.findNextTarget() 4235 ok = self.__textEdit.findNextTarget()
3750 self.__markedText = word 4236 self.__markedText = word
3751 4237
3752 ########################################################## 4238 ##########################################################
3753 ## Methods exhibiting some QScintilla API methods 4239 ## Methods exhibiting some QScintilla API methods
3754 ########################################################## 4240 ##########################################################
3755 4241
3756 def setText(self, txt, filetype=None): 4242 def setText(self, txt, filetype=None):
3757 """ 4243 """
3758 Public method to set the text programatically. 4244 Public method to set the text programatically.
3759 4245
3760 @param txt text to be set (string) 4246 @param txt text to be set (string)
3761 @param filetype type of the source file (string) 4247 @param filetype type of the source file (string)
3762 """ 4248 """
3763 self.__textEdit.setText(txt) 4249 self.__textEdit.setText(txt)
3764 4250
3765 if filetype is None: 4251 if filetype is None:
3766 self.filetype = "" 4252 self.filetype = ""
3767 else: 4253 else:
3768 self.filetype = filetype 4254 self.filetype = filetype
3769 4255
3770 eolMode = self.__getEditorConfig("EOLMode", nodefault=True) 4256 eolMode = self.__getEditorConfig("EOLMode", nodefault=True)
3771 if eolMode is None: 4257 if eolMode is None:
3772 fileEol = self.__textEdit.detectEolString(txt) 4258 fileEol = self.__textEdit.detectEolString(txt)
3773 self.__textEdit.setEolModeByEolString(fileEol) 4259 self.__textEdit.setEolModeByEolString(fileEol)
3774 else: 4260 else:
3775 self.__textEdit.convertEols(eolMode) 4261 self.__textEdit.convertEols(eolMode)
3776 4262
3777 self.__textEdit.setModified(False) 4263 self.__textEdit.setModified(False)
3778 self.setWindowModified(False) 4264 self.setWindowModified(False)
3779 4265
3780 def gotoLine(self, line, pos=1): 4266 def gotoLine(self, line, pos=1):
3781 """ 4267 """
3782 Public slot to jump to the beginning of a line. 4268 Public slot to jump to the beginning of a line.
3783 4269
3784 @param line line number to go to 4270 @param line line number to go to
3785 @type int 4271 @type int
3786 @param pos position in line to go to 4272 @param pos position in line to go to
3787 @type int 4273 @type int
3788 """ 4274 """
3789 self.__textEdit.setCursorPosition(line - 1, pos - 1) 4275 self.__textEdit.setCursorPosition(line - 1, pos - 1)
3790 self.__textEdit.ensureLineVisible(line - 1) 4276 self.__textEdit.ensureLineVisible(line - 1)
3791 self.__textEdit.setFirstVisibleLine(line - 1) 4277 self.__textEdit.setFirstVisibleLine(line - 1)
3792 self.__textEdit.ensureCursorVisible() 4278 self.__textEdit.ensureCursorVisible()
3793 4279
3794 ####################################################################### 4280 #######################################################################
3795 ## Methods implementing the interface to EditorConfig 4281 ## Methods implementing the interface to EditorConfig
3796 ####################################################################### 4282 #######################################################################
3797 4283
3798 def __loadEditorConfig(self, fileName=""): 4284 def __loadEditorConfig(self, fileName=""):
3799 """ 4285 """
3800 Private method to load the EditorConfig properties. 4286 Private method to load the EditorConfig properties.
3801 4287
3802 @param fileName name of the file 4288 @param fileName name of the file
3803 @type str 4289 @type str
3804 """ 4290 """
3805 if not fileName: 4291 if not fileName:
3806 fileName = self.__curFile 4292 fileName = self.__curFile
3807 4293
3808 self.__editorConfig = self.__loadEditorConfigObject(fileName) 4294 self.__editorConfig = self.__loadEditorConfigObject(fileName)
3809 4295
3810 if fileName: 4296 if fileName:
3811 self.__setTabAndIndent() 4297 self.__setTabAndIndent()
3812 4298
3813 def __loadEditorConfigObject(self, fileName): 4299 def __loadEditorConfigObject(self, fileName):
3814 """ 4300 """
3815 Private method to load the EditorConfig properties for the given 4301 Private method to load the EditorConfig properties for the given
3816 file name. 4302 file name.
3817 4303
3818 @param fileName name of the file 4304 @param fileName name of the file
3819 @type str 4305 @type str
3820 @return EditorConfig dictionary 4306 @return EditorConfig dictionary
3821 @rtype dict 4307 @rtype dict
3822 """ 4308 """
3823 editorConfig = {} 4309 editorConfig = {}
3824 4310
3825 if fileName: 4311 if fileName:
3826 try: 4312 try:
3827 editorConfig = editorconfig.get_properties(fileName) 4313 editorConfig = editorconfig.get_properties(fileName)
3828 except editorconfig.EditorConfigError: 4314 except editorconfig.EditorConfigError:
3829 EricMessageBox.warning( 4315 EricMessageBox.warning(
3830 self, 4316 self,
3831 self.tr("EditorConfig Properties"), 4317 self.tr("EditorConfig Properties"),
3832 self.tr("""<p>The EditorConfig properties for file""" 4318 self.tr(
3833 """ <b>{0}</b> could not be loaded.</p>""") 4319 """<p>The EditorConfig properties for file"""
3834 .format(fileName)) 4320 """ <b>{0}</b> could not be loaded.</p>"""
3835 4321 ).format(fileName),
4322 )
4323
3836 return editorConfig 4324 return editorConfig
3837 4325
3838 def __getEditorConfig(self, option, nodefault=False, config=None): 4326 def __getEditorConfig(self, option, nodefault=False, config=None):
3839 """ 4327 """
3840 Private method to get the requested option via EditorConfig. 4328 Private method to get the requested option via EditorConfig.
3841 4329
3842 If there is no EditorConfig defined, the equivalent built-in option 4330 If there is no EditorConfig defined, the equivalent built-in option
3843 will be used (Preferences.getEditor(). The option must be given as the 4331 will be used (Preferences.getEditor(). The option must be given as the
3844 Preferences option key. The mapping to the EditorConfig option name 4332 Preferences option key. The mapping to the EditorConfig option name
3845 will be done within this method. 4333 will be done within this method.
3846 4334
3847 @param option Preferences option key 4335 @param option Preferences option key
3848 @type str 4336 @type str
3849 @param nodefault flag indicating to not get the default value from 4337 @param nodefault flag indicating to not get the default value from
3850 Preferences but return None instead 4338 Preferences but return None instead
3851 @type bool 4339 @type bool
3855 nodefault parameter was True 4343 nodefault parameter was True
3856 @rtype any 4344 @rtype any
3857 """ 4345 """
3858 if config is None: 4346 if config is None:
3859 config = self.__editorConfig 4347 config = self.__editorConfig
3860 4348
3861 if not config: 4349 if not config:
3862 if nodefault: 4350 if nodefault:
3863 return None 4351 return None
3864 else: 4352 else:
3865 value = self.__getOverrideValue(option) 4353 value = self.__getOverrideValue(option)
3866 if value is None: 4354 if value is None:
3867 # no override 4355 # no override
3868 value = Preferences.getEditor(option) 4356 value = Preferences.getEditor(option)
3869 return value 4357 return value
3870 4358
3871 try: 4359 try:
3872 if option == "EOLMode": 4360 if option == "EOLMode":
3873 value = config["end_of_line"] 4361 value = config["end_of_line"]
3874 if value == "lf": 4362 if value == "lf":
3875 value = QsciScintilla.EolMode.EolUnix 4363 value = QsciScintilla.EolMode.EolUnix
3895 value = int(value) 4383 value = int(value)
3896 elif option == "TabForIndentation": 4384 elif option == "TabForIndentation":
3897 value = config["indent_style"] == "tab" 4385 value = config["indent_style"] == "tab"
3898 except KeyError: 4386 except KeyError:
3899 value = None 4387 value = None
3900 4388
3901 if value is None and not nodefault: 4389 if value is None and not nodefault:
3902 # use Preferences as default in case of error 4390 # use Preferences as default in case of error
3903 value = self.__getOverrideValue(option) 4391 value = self.__getOverrideValue(option)
3904 if value is None: 4392 if value is None:
3905 # no override 4393 # no override
3906 value = Preferences.getEditor(option) 4394 value = Preferences.getEditor(option)
3907 4395
3908 return value 4396 return value
3909 4397
3910 def __getOverrideValue(self, option): 4398 def __getOverrideValue(self, option):
3911 """ 4399 """
3912 Private method to get an override value for the current file type. 4400 Private method to get an override value for the current file type.
3913 4401
3914 @param option Preferences option key 4402 @param option Preferences option key
3915 @type str 4403 @type str
3916 @return override value; None in case nothing is defined 4404 @return override value; None in case nothing is defined
3917 @rtype any 4405 @rtype any
3918 """ 4406 """
3922 if language in overrides: 4410 if language in overrides:
3923 if option == "TabWidth": 4411 if option == "TabWidth":
3924 return overrides[self.filetype][0] 4412 return overrides[self.filetype][0]
3925 elif option == "IndentWidth": 4413 elif option == "IndentWidth":
3926 return overrides[self.filetype][1] 4414 return overrides[self.filetype][1]
3927 4415
3928 return None 4416 return None
3929 4417
3930 ####################################################################### 4418 #######################################################################
3931 ## Methods supporting the outline view below 4419 ## Methods supporting the outline view below
3932 ####################################################################### 4420 #######################################################################
3933 4421
3934 def __resetChangeTimer(self): 4422 def __resetChangeTimer(self):
3935 """ 4423 """
3936 Private slot to reset the parse timer. 4424 Private slot to reset the parse timer.
3937 """ 4425 """
3938 self.__changeTimer.stop() 4426 self.__changeTimer.stop()
3939 self.__changeTimer.start() 4427 self.__changeTimer.start()
3940 4428
3941 def __editorChanged(self): 4429 def __editorChanged(self):
3942 """ 4430 """
3943 Private slot handling changes of the editor language or file name. 4431 Private slot handling changes of the editor language or file name.
3944 """ 4432 """
3945 supported = self.__sourceOutline.isSupportedLanguage( 4433 supported = self.__sourceOutline.isSupportedLanguage(self.getLanguage())
3946 self.getLanguage()) 4434
3947
3948 self.__sourceOutline.setVisible(supported) 4435 self.__sourceOutline.setVisible(supported)
3949 4436
3950 line, pos = self.getCursorPosition() 4437 line, pos = self.getCursorPosition()
3951 lang = self.getLanguage() 4438 lang = self.getLanguage()
3952 self.__setSbFile(line + 1, pos, language=lang) 4439 self.__setSbFile(line + 1, pos, language=lang)
3953 4440
3954 ####################################################################### 4441 #######################################################################
3955 ## Methods supporting zooming 4442 ## Methods supporting zooming
3956 ####################################################################### 4443 #######################################################################
3957 4444
3958 def __zoomIn(self): 4445 def __zoomIn(self):
3959 """ 4446 """
3960 Private method to handle the zoom in action. 4447 Private method to handle the zoom in action.
3961 """ 4448 """
3962 self.zoomIn() 4449 self.zoomIn()
3963 self.sbZoom.setValue(self.getZoom()) 4450 self.sbZoom.setValue(self.getZoom())
3964 4451
3965 def __zoomOut(self): 4452 def __zoomOut(self):
3966 """ 4453 """
3967 Private method to handle the zoom out action. 4454 Private method to handle the zoom out action.
3968 """ 4455 """
3969 self.zoomOut() 4456 self.zoomOut()
3970 self.sbZoom.setValue(self.getZoom()) 4457 self.sbZoom.setValue(self.getZoom())
3971 4458
3972 def __zoomReset(self): 4459 def __zoomReset(self):
3973 """ 4460 """
3974 Private method to reset the zoom factor. 4461 Private method to reset the zoom factor.
3975 """ 4462 """
3976 self.__zoomTo(0) 4463 self.__zoomTo(0)
3977 4464
3978 def __zoom(self): 4465 def __zoom(self):
3979 """ 4466 """
3980 Private method to handle the zoom action. 4467 Private method to handle the zoom action.
3981 """ 4468 """
3982 from QScintilla.ZoomDialog import ZoomDialog 4469 from QScintilla.ZoomDialog import ZoomDialog
4470
3983 dlg = ZoomDialog(self.getZoom(), self, None, True) 4471 dlg = ZoomDialog(self.getZoom(), self, None, True)
3984 if dlg.exec() == QDialog.DialogCode.Accepted: 4472 if dlg.exec() == QDialog.DialogCode.Accepted:
3985 value = dlg.getZoomSize() 4473 value = dlg.getZoomSize()
3986 self.__zoomTo(value) 4474 self.__zoomTo(value)
3987 4475
3988 def __zoomTo(self, value): 4476 def __zoomTo(self, value):
3989 """ 4477 """
3990 Private slot to zoom to a given value. 4478 Private slot to zoom to a given value.
3991 4479
3992 @param value zoom value to be set (integer) 4480 @param value zoom value to be set (integer)
3993 """ 4481 """
3994 self.zoomTo(value) 4482 self.zoomTo(value)
3995 self.sbZoom.setValue(self.getZoom()) 4483 self.sbZoom.setValue(self.getZoom())

eric ide

mercurial