src/eric7/ViewManager/ViewManager.py

branch
eric7
changeset 10436
f6881d10e995
parent 10394
056d1b2cd3c4
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
148 def setReferences(self, ui, dbs): 148 def setReferences(self, ui, dbs):
149 """ 149 """
150 Public method to set some references needed later on. 150 Public method to set some references needed later on.
151 151
152 @param ui reference to the main user interface 152 @param ui reference to the main user interface
153 @type UserInterface
153 @param dbs reference to the debug server object 154 @param dbs reference to the debug server object
155 @type DebugServer
154 """ 156 """
155 from eric7.QScintilla.SearchReplaceWidget import SearchReplaceSlidingWidget 157 from eric7.QScintilla.SearchReplaceWidget import SearchReplaceSlidingWidget
156 158
157 self.ui = ui 159 self.ui = ui
158 self.dbs = dbs 160 self.dbs = dbs
164 166
165 def searchReplaceWidget(self): 167 def searchReplaceWidget(self):
166 """ 168 """
167 Public method to get a reference to the search widget. 169 Public method to get a reference to the search widget.
168 170
169 @return reference to the search widget (SearchReplaceSlidingWidget) 171 @return reference to the search widget
172 @rtype SearchReplaceSlidingWidget
170 """ 173 """
171 return self.__searchReplaceWidget 174 return self.__searchReplaceWidget
172 175
173 def __loadRecent(self): 176 def __loadRecent(self):
174 """ 177 """
191 194
192 def getMostRecent(self): 195 def getMostRecent(self):
193 """ 196 """
194 Public method to get the most recently opened file. 197 Public method to get the most recently opened file.
195 198
196 @return path of the most recently opened file (string) 199 @return path of the most recently opened file
200 @rtype str
197 """ 201 """
198 if len(self.recent): 202 if len(self.recent):
199 return self.recent[0] 203 return self.recent[0]
200 else: 204 else:
201 return None 205 return None
206 """ 210 """
207 Public method to transfer statusbar info from the user interface to 211 Public method to transfer statusbar info from the user interface to
208 viewmanager. 212 viewmanager.
209 213
210 @param sbLine reference to the line number part of the statusbar 214 @param sbLine reference to the line number part of the statusbar
211 (QLabel) 215 @type QLabel
212 @param sbPos reference to the character position part of the statusbar 216 @param sbPos reference to the character position part of the statusbar
213 (QLabel) 217 @type QLabel
214 @param sbWritable reference to the writability indicator part of 218 @param sbWritable reference to the writability indicator part of
215 the statusbar (QLabel) 219 the statusbar
220 @type QLabel
216 @param sbEncoding reference to the encoding indicator part of the 221 @param sbEncoding reference to the encoding indicator part of the
217 statusbar (QLabel) 222 statusbar
223 @type QLabel
218 @param sbLanguage reference to the language indicator part of the 224 @param sbLanguage reference to the language indicator part of the
219 statusbar (QLabel) 225 statusbar
226 @type QLabel
220 @param sbEol reference to the eol indicator part of the statusbar 227 @param sbEol reference to the eol indicator part of the statusbar
221 (QLabel) 228 @type QLabel
222 @param sbZoom reference to the zoom widget (EricZoomWidget) 229 @param sbZoom reference to the zoom widget
230 @type EricZoomWidget
223 """ 231 """
224 self.sbLine = sbLine 232 self.sbLine = sbLine
225 self.sbPos = sbPos 233 self.sbPos = sbPos
226 self.sbWritable = sbWritable 234 self.sbWritable = sbWritable
227 self.sbEnc = sbEncoding 235 self.sbEnc = sbEncoding
241 249
242 def __showLanguagesMenu(self, pos): 250 def __showLanguagesMenu(self, pos):
243 """ 251 """
244 Private slot to show the Languages menu of the current editor. 252 Private slot to show the Languages menu of the current editor.
245 253
246 @param pos position the menu should be shown at (QPoint) 254 @param pos position the menu should be shown at
255 @type QPoint
247 """ 256 """
248 aw = self.activeWindow() 257 aw = self.activeWindow()
249 if aw is not None: 258 if aw is not None:
250 menu = aw.getMenu("Languages") 259 menu = aw.getMenu("Languages")
251 if menu is not None: 260 if menu is not None:
253 262
254 def __showEolMenu(self, pos): 263 def __showEolMenu(self, pos):
255 """ 264 """
256 Private slot to show the EOL menu of the current editor. 265 Private slot to show the EOL menu of the current editor.
257 266
258 @param pos position the menu should be shown at (QPoint) 267 @param pos position the menu should be shown at
268 @type QPoint
259 """ 269 """
260 aw = self.activeWindow() 270 aw = self.activeWindow()
261 if aw is not None: 271 if aw is not None:
262 menu = aw.getMenu("Eol") 272 menu = aw.getMenu("Eol")
263 if menu is not None: 273 if menu is not None:
265 275
266 def __showEncodingsMenu(self, pos): 276 def __showEncodingsMenu(self, pos):
267 """ 277 """
268 Private slot to show the Encodings menu of the current editor. 278 Private slot to show the Encodings menu of the current editor.
269 279
270 @param pos position the menu should be shown at (QPoint) 280 @param pos position the menu should be shown at
281 @type QPoint
271 """ 282 """
272 aw = self.activeWindow() 283 aw = self.activeWindow()
273 if aw is not None: 284 if aw is not None:
274 menu = aw.getMenu("Encodings") 285 menu = aw.getMenu("Encodings")
275 if menu is not None: 286 if menu is not None:
282 def canCascade(self): 293 def canCascade(self):
283 """ 294 """
284 Public method to signal if cascading of managed windows is available. 295 Public method to signal if cascading of managed windows is available.
285 296
286 @return flag indicating cascading of windows is available 297 @return flag indicating cascading of windows is available
298 @rtype bool
287 @exception NotImplementedError Not implemented 299 @exception NotImplementedError Not implemented
288 """ 300 """
289 raise NotImplementedError("Not implemented") 301 raise NotImplementedError("Not implemented")
290 302
291 return False 303 return False
293 def canTile(self): 305 def canTile(self):
294 """ 306 """
295 Public method to signal if tiling of managed windows is available. 307 Public method to signal if tiling of managed windows is available.
296 308
297 @return flag indicating tiling of windows is available 309 @return flag indicating tiling of windows is available
310 @rtype bool
298 @exception NotImplementedError Not implemented 311 @exception NotImplementedError Not implemented
299 """ 312 """
300 raise NotImplementedError("Not implemented") 313 raise NotImplementedError("Not implemented")
301 314
302 return False 315 return False
320 def activeWindow(self): 333 def activeWindow(self):
321 """ 334 """
322 Public method to return the active (i.e. current) window. 335 Public method to return the active (i.e. current) window.
323 336
324 @return reference to the active editor 337 @return reference to the active editor
338 @rtype Editor
325 @exception NotImplementedError Not implemented 339 @exception NotImplementedError Not implemented
326 """ 340 """
327 raise NotImplementedError("Not implemented") 341 raise NotImplementedError("Not implemented")
328 342
329 return None # __IGNORE_WARNING_M831__ 343 return None # __IGNORE_WARNING_M831__
339 def _removeView(self, win): 353 def _removeView(self, win):
340 """ 354 """
341 Protected method to remove a view (i.e. window). 355 Protected method to remove a view (i.e. window).
342 356
343 @param win editor window to be removed 357 @param win editor window to be removed
358 @type EditorAssembly
344 @exception NotImplementedError Not implemented 359 @exception NotImplementedError Not implemented
345 """ 360 """
346 raise NotImplementedError("Not implemented") 361 raise NotImplementedError("Not implemented")
347 362
348 def _addView(self, win, fn=None, noName="", addNext=False, indexes=None): 363 def _addView(self, win, fn=None, noName="", addNext=False, indexes=None):
368 def _showView(self, win, fn=None): 383 def _showView(self, win, fn=None):
369 """ 384 """
370 Protected method to show a view (i.e. window). 385 Protected method to show a view (i.e. window).
371 386
372 @param win editor assembly to be shown 387 @param win editor assembly to be shown
388 @type EditorAssembly
373 @param fn filename of this editor 389 @param fn filename of this editor
390 @type str
374 @exception NotImplementedError Not implemented 391 @exception NotImplementedError Not implemented
375 """ 392 """
376 raise NotImplementedError("Not implemented") 393 raise NotImplementedError("Not implemented")
377 394
378 def showWindowMenu(self, windowMenu): 395 def showWindowMenu(self, windowMenu):
379 """ 396 """
380 Public method to set up the viewmanager part of the Window menu. 397 Public method to set up the viewmanager part of the Window menu.
381 398
382 @param windowMenu reference to the window menu 399 @param windowMenu reference to the window menu
400 @type QMenu
383 @exception NotImplementedError Not implemented 401 @exception NotImplementedError Not implemented
384 """ 402 """
385 raise NotImplementedError("Not implemented") 403 raise NotImplementedError("Not implemented")
386 404
387 def _initWindowActions(self): 405 def _initWindowActions(self):
396 def setEditorName(self, editor, newName): 414 def setEditorName(self, editor, newName):
397 """ 415 """
398 Public method to change the displayed name of the editor. 416 Public method to change the displayed name of the editor.
399 417
400 @param editor editor window to be changed 418 @param editor editor window to be changed
401 @param newName new name to be shown (string) 419 @type Editor
420 @param newName new name to be shown
421 @type str
402 @exception NotImplementedError Not implemented 422 @exception NotImplementedError Not implemented
403 """ 423 """
404 raise NotImplementedError("Not implemented") 424 raise NotImplementedError("Not implemented")
405 425
406 def _modificationStatusChanged(self, m, editor): 426 def _modificationStatusChanged(self, m, editor):
407 """ 427 """
408 Protected slot to handle the modificationStatusChanged signal. 428 Protected slot to handle the modificationStatusChanged signal.
409 429
410 @param m flag indicating the modification status (boolean) 430 @param m flag indicating the modification status
431 @type bool
411 @param editor editor window changed 432 @param editor editor window changed
433 @type Editor
412 @exception NotImplementedError Not implemented 434 @exception NotImplementedError Not implemented
413 """ 435 """
414 raise NotImplementedError("Not implemented") 436 raise NotImplementedError("Not implemented")
415 437
416 def mainWidget(self): 438 def mainWidget(self):
428 450
429 def canSplit(self): 451 def canSplit(self):
430 """ 452 """
431 Public method to signal if splitting of the view is available. 453 Public method to signal if splitting of the view is available.
432 454
433 @return flag indicating splitting of the view is available. 455 @return flag indicating splitting of the view is available
456 @rtype bool
434 """ 457 """
435 return False 458 return False
436 459
437 def addSplit(self): 460 def addSplit(self):
438 """ 461 """
474 497
475 def getSplitOrientation(self): 498 def getSplitOrientation(self):
476 """ 499 """
477 Public method to get the orientation of the split view. 500 Public method to get the orientation of the split view.
478 501
479 @return orientation of the split (Qt.Orientation.Horizontal or 502 @return orientation of the split
480 Qt.Orientation.Vertical) 503 @rtype Qt.Orientation
481 """ 504 """
482 return Qt.Orientation.Vertical 505 return Qt.Orientation.Vertical
483 506
484 def setSplitOrientation(self, orientation): 507 def setSplitOrientation(self, orientation):
485 """ 508 """
486 Public method used to set the orientation of the split view. 509 Public method used to set the orientation of the split view.
487 510
488 @param orientation orientation of the split 511 @param orientation orientation of the split
489 (Qt.Orientation.Horizontal or Qt.Orientation.Vertical) 512 @type Qt.Orientation
490 """ 513 """
491 pass 514 pass
492 515
493 def nextSplit(self): 516 def nextSplit(self):
494 """ 517 """
504 527
505 def eventFilter(self, qobject, event): 528 def eventFilter(self, qobject, event):
506 """ 529 """
507 Public method called to filter an event. 530 Public method called to filter an event.
508 531
509 @param qobject object, that generated the event (QObject) 532 @param qobject object, that generated the event
510 @param event the event, that was generated by object (QEvent) 533 @type QObject
534 @param event the event, that was generated by object
535 @type QEvent
511 @return flag indicating if event was filtered out 536 @return flag indicating if event was filtered out
537 @rtype bool
512 """ 538 """
513 return False 539 return False
514 540
515 ##################################################################### 541 #####################################################################
516 ## methods above need to be implemented by a subclass, that supports 542 ## methods above need to be implemented by a subclass, that supports
851 def initFileMenu(self): 877 def initFileMenu(self):
852 """ 878 """
853 Public method to create the File menu. 879 Public method to create the File menu.
854 880
855 @return the generated menu 881 @return the generated menu
882 @rtype QMenu
856 """ 883 """
857 menu = QMenu(QCoreApplication.translate("ViewManager", "&File"), self.ui) 884 menu = QMenu(QCoreApplication.translate("ViewManager", "&File"), self.ui)
858 self.recentMenu = QMenu( 885 self.recentMenu = QMenu(
859 QCoreApplication.translate("ViewManager", "Open &Recent Files"), menu 886 QCoreApplication.translate("ViewManager", "Open &Recent Files"), menu
860 ) 887 )
896 def initFileToolbar(self, toolbarManager): 923 def initFileToolbar(self, toolbarManager):
897 """ 924 """
898 Public method to create the File toolbar. 925 Public method to create the File toolbar.
899 926
900 @param toolbarManager reference to a toolbar manager object 927 @param toolbarManager reference to a toolbar manager object
901 (EricToolBarManager) 928 @type EricToolBarManager
902 @return the generated toolbar 929 @return the generated toolbar
930 @rtype QToolBar
903 """ 931 """
904 tb = QToolBar(QCoreApplication.translate("ViewManager", "File"), self.ui) 932 tb = QToolBar(QCoreApplication.translate("ViewManager", "File"), self.ui)
905 tb.setObjectName("FileToolbar") 933 tb.setObjectName("FileToolbar")
906 tb.setToolTip(QCoreApplication.translate("ViewManager", "File")) 934 tb.setToolTip(QCoreApplication.translate("ViewManager", "File"))
907 935
922 950
923 def __initContextMenuExporters(self): 951 def __initContextMenuExporters(self):
924 """ 952 """
925 Private method used to setup the Exporters sub menu. 953 Private method used to setup the Exporters sub menu.
926 954
927 @return reference to the generated menu (QMenu) 955 @return reference to the generated menu
956 @rtype QMenu
928 """ 957 """
929 menu = QMenu(QCoreApplication.translate("ViewManager", "Export as")) 958 menu = QMenu(QCoreApplication.translate("ViewManager", "Export as"))
930 959
931 supportedExporters = Exporters.getSupportedFormats() 960 supportedExporters = Exporters.getSupportedFormats()
932 for exporter in sorted(supportedExporters): 961 for exporter in sorted(supportedExporters):
3345 def initEditMenu(self): 3374 def initEditMenu(self):
3346 """ 3375 """
3347 Public method to create the Edit menu. 3376 Public method to create the Edit menu.
3348 3377
3349 @return the generated menu 3378 @return the generated menu
3379 @rtype QMenu
3350 """ 3380 """
3351 autocompletionMenu = QMenu( 3381 autocompletionMenu = QMenu(
3352 QCoreApplication.translate("ViewManager", "Complete"), self.ui 3382 QCoreApplication.translate("ViewManager", "Complete"), self.ui
3353 ) 3383 )
3354 autocompletionMenu.setTearOffEnabled(True) 3384 autocompletionMenu.setTearOffEnabled(True)
3407 def initEditToolbar(self, toolbarManager): 3437 def initEditToolbar(self, toolbarManager):
3408 """ 3438 """
3409 Public method to create the Edit toolbar. 3439 Public method to create the Edit toolbar.
3410 3440
3411 @param toolbarManager reference to a toolbar manager object 3441 @param toolbarManager reference to a toolbar manager object
3412 (EricToolBarManager) 3442 @type EricToolBarManager
3413 @return the generated toolbar 3443 @return the generated toolbar
3444 @rtype QToolBar
3414 """ 3445 """
3415 tb = QToolBar(QCoreApplication.translate("ViewManager", "Edit"), self.ui) 3446 tb = QToolBar(QCoreApplication.translate("ViewManager", "Edit"), self.ui)
3416 tb.setObjectName("EditToolbar") 3447 tb.setObjectName("EditToolbar")
3417 tb.setToolTip(QCoreApplication.translate("ViewManager", "Edit")) 3448 tb.setToolTip(QCoreApplication.translate("ViewManager", "Edit"))
3418 3449
4545 def initViewMenu(self): 4576 def initViewMenu(self):
4546 """ 4577 """
4547 Public method to create the View menu. 4578 Public method to create the View menu.
4548 4579
4549 @return the generated menu 4580 @return the generated menu
4581 @rtype QMenu
4550 """ 4582 """
4551 menu = QMenu(QCoreApplication.translate("ViewManager", "&View"), self.ui) 4583 menu = QMenu(QCoreApplication.translate("ViewManager", "&View"), self.ui)
4552 menu.setTearOffEnabled(True) 4584 menu.setTearOffEnabled(True)
4553 menu.addActions(self.viewActGrp.actions()) 4585 menu.addActions(self.viewActGrp.actions())
4554 menu.addSeparator() 4586 menu.addSeparator()
4575 def initViewToolbar(self, toolbarManager): 4607 def initViewToolbar(self, toolbarManager):
4576 """ 4608 """
4577 Public method to create the View toolbar. 4609 Public method to create the View toolbar.
4578 4610
4579 @param toolbarManager reference to a toolbar manager object 4611 @param toolbarManager reference to a toolbar manager object
4580 (EricToolBarManager) 4612 @type EricToolBarManager
4581 @return the generated toolbar 4613 @return the generated toolbar
4614 @rtype QToolBar
4582 """ 4615 """
4583 tb = QToolBar(QCoreApplication.translate("ViewManager", "View"), self.ui) 4616 tb = QToolBar(QCoreApplication.translate("ViewManager", "View"), self.ui)
4584 tb.setObjectName("ViewToolbar") 4617 tb.setObjectName("ViewToolbar")
4585 tb.setToolTip(QCoreApplication.translate("ViewManager", "View")) 4618 tb.setToolTip(QCoreApplication.translate("ViewManager", "View"))
4586 4619
4742 def initMacroMenu(self): 4775 def initMacroMenu(self):
4743 """ 4776 """
4744 Public method to create the Macro menu. 4777 Public method to create the Macro menu.
4745 4778
4746 @return the generated menu 4779 @return the generated menu
4780 @rtype QMenu
4747 """ 4781 """
4748 menu = QMenu(QCoreApplication.translate("ViewManager", "&Macros"), self.ui) 4782 menu = QMenu(QCoreApplication.translate("ViewManager", "&Macros"), self.ui)
4749 menu.setTearOffEnabled(True) 4783 menu.setTearOffEnabled(True)
4750 menu.addActions(self.macroActGrp.actions()) 4784 menu.addActions(self.macroActGrp.actions())
4751 4785
5118 def initBookmarkMenu(self): 5152 def initBookmarkMenu(self):
5119 """ 5153 """
5120 Public method to create the Bookmark menu. 5154 Public method to create the Bookmark menu.
5121 5155
5122 @return the generated menu 5156 @return the generated menu
5157 @rtype QMenu
5123 """ 5158 """
5124 menu = QMenu(QCoreApplication.translate("ViewManager", "&Bookmarks"), self.ui) 5159 menu = QMenu(QCoreApplication.translate("ViewManager", "&Bookmarks"), self.ui)
5125 self.bookmarksMenu = QMenu( 5160 self.bookmarksMenu = QMenu(
5126 QCoreApplication.translate("ViewManager", "&Bookmarks"), menu 5161 QCoreApplication.translate("ViewManager", "&Bookmarks"), menu
5127 ) 5162 )
5159 def initBookmarkToolbar(self, toolbarManager): 5194 def initBookmarkToolbar(self, toolbarManager):
5160 """ 5195 """
5161 Public method to create the Bookmark toolbar. 5196 Public method to create the Bookmark toolbar.
5162 5197
5163 @param toolbarManager reference to a toolbar manager object 5198 @param toolbarManager reference to a toolbar manager object
5164 (EricToolBarManager) 5199 @type EricToolBarManager
5165 @return the generated toolbar 5200 @return the generated toolbar
5201 @rtype QToolBar
5166 """ 5202 """
5167 tb = QToolBar(QCoreApplication.translate("ViewManager", "Bookmarks"), self.ui) 5203 tb = QToolBar(QCoreApplication.translate("ViewManager", "Bookmarks"), self.ui)
5168 tb.setObjectName("BookmarksToolbar") 5204 tb.setObjectName("BookmarksToolbar")
5169 tb.setToolTip(QCoreApplication.translate("ViewManager", "Bookmarks")) 5205 tb.setToolTip(QCoreApplication.translate("ViewManager", "Bookmarks"))
5170 5206
5271 5307
5272 def addToExtrasMenu(self, menu): 5308 def addToExtrasMenu(self, menu):
5273 """ 5309 """
5274 Public method to add some actions to the Extras menu. 5310 Public method to add some actions to the Extras menu.
5275 5311
5276 @param menu reference to the menu to add actions to (QMenu) 5312 @param menu reference to the menu to add actions to
5313 @type QMenu
5277 """ 5314 """
5278 self.__editSpellingMenu = QMenu( 5315 self.__editSpellingMenu = QMenu(
5279 QCoreApplication.translate("ViewManager", "Edit Dictionary") 5316 QCoreApplication.translate("ViewManager", "Edit Dictionary")
5280 ) 5317 )
5281 self.__editProjectPwlAct = self.__editSpellingMenu.addAction( 5318 self.__editProjectPwlAct = self.__editSpellingMenu.addAction(
5305 def initSpellingToolbar(self, toolbarManager): 5342 def initSpellingToolbar(self, toolbarManager):
5306 """ 5343 """
5307 Public method to create the Spelling toolbar. 5344 Public method to create the Spelling toolbar.
5308 5345
5309 @param toolbarManager reference to a toolbar manager object 5346 @param toolbarManager reference to a toolbar manager object
5310 (EricToolBarManager) 5347 @type EricToolBarManager
5311 @return the generated toolbar 5348 @return the generated toolbar
5349 @rtype QToolBar
5312 """ 5350 """
5313 tb = QToolBar(QCoreApplication.translate("ViewManager", "Spelling"), self.ui) 5351 tb = QToolBar(QCoreApplication.translate("ViewManager", "Spelling"), self.ui)
5314 tb.setObjectName("SpellingToolbar") 5352 tb.setObjectName("SpellingToolbar")
5315 tb.setToolTip(QCoreApplication.translate("ViewManager", "Spelling")) 5353 tb.setToolTip(QCoreApplication.translate("ViewManager", "Spelling"))
5316 5354
5348 5386
5349 def openFiles(self, prog): 5387 def openFiles(self, prog):
5350 """ 5388 """
5351 Public slot to open some files. 5389 Public slot to open some files.
5352 5390
5353 @param prog name of file to be opened (string) 5391 @param prog name of file to be opened
5392 @type str
5354 """ 5393 """
5355 prog = os.path.abspath(prog) 5394 prog = os.path.abspath(prog)
5356 # Open up the new files. 5395 # Open up the new files.
5357 self.openSourceFile(prog) 5396 self.openSourceFile(prog)
5358 5397
5481 5520
5482 def closeCurrentWindow(self): 5521 def closeCurrentWindow(self):
5483 """ 5522 """
5484 Public method to close the current window. 5523 Public method to close the current window.
5485 5524
5486 @return flag indicating success (boolean) 5525 @return flag indicating success
5526 @rtype bool
5487 """ 5527 """
5488 aw = self.activeWindow() 5528 aw = self.activeWindow()
5489 if aw is None: 5529 if aw is None:
5490 return False 5530 return False
5491 5531
5532 def closeEditorWindow(self, editor): 5572 def closeEditorWindow(self, editor):
5533 """ 5573 """
5534 Public method to close an arbitrary source editor. 5574 Public method to close an arbitrary source editor.
5535 5575
5536 @param editor editor to be closed 5576 @param editor editor to be closed
5577 @type Editor
5537 """ 5578 """
5538 if editor is None: 5579 if editor is None:
5539 return 5580 return
5540 5581
5541 res = self.closeEditor(editor) 5582 res = self.closeEditor(editor)
5634 def __connectEditor(self, editor): 5675 def __connectEditor(self, editor):
5635 """ 5676 """
5636 Private method to establish all editor connections. 5677 Private method to establish all editor connections.
5637 5678
5638 @param editor reference to the editor object to be connected 5679 @param editor reference to the editor object to be connected
5680 @type Editor
5639 """ 5681 """
5640 editor.modificationStatusChanged.connect(self._modificationStatusChanged) 5682 editor.modificationStatusChanged.connect(self._modificationStatusChanged)
5641 editor.cursorChanged.connect( 5683 editor.cursorChanged.connect(
5642 lambda fn, line, pos: self.__cursorChanged(fn, line, pos, editor) 5684 lambda fn, line, pos: self.__cursorChanged(fn, line, pos, editor)
5643 ) 5685 )
5697 def cloneEditor(self, caller, filetype, fn): 5739 def cloneEditor(self, caller, filetype, fn):
5698 """ 5740 """
5699 Public method to clone an editor displaying the given document. 5741 Public method to clone an editor displaying the given document.
5700 5742
5701 @param caller reference to the editor calling this method 5743 @param caller reference to the editor calling this method
5702 @param filetype type of the source file (string) 5744 @type Editor
5745 @param filetype type of the source file
5746 @type str
5703 @param fn filename of this view 5747 @param fn filename of this view
5704 @return reference to the new editor object (Editor.Editor) and the new 5748 @type str
5705 editor assembly object (EditorAssembly.EditorAssembly) 5749 @return reference to the new editor object and the new editor
5750 assembly object
5751 @rtype tuple of (Editor, EditorAssembly)
5706 """ 5752 """
5707 from eric7.QScintilla.EditorAssembly import EditorAssembly 5753 from eric7.QScintilla.EditorAssembly import EditorAssembly
5708 5754
5709 assembly = EditorAssembly( 5755 assembly = EditorAssembly(
5710 self.dbs, 5756 self.dbs,
5729 def addToRecentList(self, fn): 5775 def addToRecentList(self, fn):
5730 """ 5776 """
5731 Public slot to add a filename to the list of recently opened files. 5777 Public slot to add a filename to the list of recently opened files.
5732 5778
5733 @param fn name of the file to be added 5779 @param fn name of the file to be added
5780 @type str
5734 """ 5781 """
5735 for recent in self.recent[:]: 5782 for recent in self.recent[:]:
5736 if FileSystemUtilities.samepath(fn, recent): 5783 if FileSystemUtilities.samepath(fn, recent):
5737 self.recent.remove(recent) 5784 self.recent.remove(recent)
5738 self.recent.insert(0, fn) 5785 self.recent.insert(0, fn)
5744 def showDebugSource(self, fn, line): 5791 def showDebugSource(self, fn, line):
5745 """ 5792 """
5746 Public method to open the given file and highlight the given line in 5793 Public method to open the given file and highlight the given line in
5747 it. 5794 it.
5748 5795
5749 @param fn filename of editor to update (string) 5796 @param fn filename of editor to update
5750 @param line line number to highlight (int) 5797 @type str
5798 @param line line number to highlight
5799 @type int
5751 """ 5800 """
5752 if not fn.startswith("<"): 5801 if not fn.startswith("<"):
5753 self.openSourceFile(fn, line) 5802 self.openSourceFile(fn, line)
5754 self.setFileLine(fn, line) 5803 self.setFileLine(fn, line)
5755 5804
5756 def setFileLine(self, fn, line, error=False, syntaxError=False): 5805 def setFileLine(self, fn, line, error=False, syntaxError=False):
5757 """ 5806 """
5758 Public method to update the user interface when the current program 5807 Public method to update the user interface when the current program
5759 or line changes. 5808 or line changes.
5760 5809
5761 @param fn filename of editor to update (string) 5810 @param fn filename of editor to update
5762 @param line line number to highlight (int) 5811 @type str
5763 @param error flag indicating an error highlight (boolean) 5812 @param line line number to highlight
5813 @type int
5814 @param error flag indicating an error highlight
5815 @type bool
5764 @param syntaxError flag indicating a syntax error 5816 @param syntaxError flag indicating a syntax error
5817 @type bool
5765 """ 5818 """
5766 try: 5819 try:
5767 newWin, self.currentEditor = self.getEditor(fn) 5820 newWin, self.currentEditor = self.getEditor(fn)
5768 except (OSError, UnicodeDecodeError): 5821 except (OSError, UnicodeDecodeError):
5769 return 5822 return
5795 zoom=None, 5848 zoom=None,
5796 ): 5849 ):
5797 """ 5850 """
5798 Private method to set the file info in the status bar. 5851 Private method to set the file info in the status bar.
5799 5852
5800 @param fn filename to display (string) 5853 @param fn filename to display
5801 @param line line number to display (int) 5854 @type str
5802 @param pos character position to display (int) 5855 @param line line number to display
5803 @param encoding encoding name to display (string) 5856 @type int
5804 @param language language to display (string) 5857 @param pos character position to display
5805 @param eol eol indicator to display (string) 5858 @type int
5806 @param zoom zoom value (integer) 5859 @param encoding encoding name to display
5860 @type str
5861 @param language language to display
5862 @type str
5863 @param eol eol indicator to display
5864 @type str
5865 @param zoom zoom value
5866 @type int
5807 """ 5867 """
5808 if not fn: 5868 if not fn:
5809 fn = "" 5869 fn = ""
5810 writ = " " 5870 writ = " "
5811 else: 5871 else:
5868 5928
5869 def __eolPixmap(self, eolIndicator): 5929 def __eolPixmap(self, eolIndicator):
5870 """ 5930 """
5871 Private method to get an EOL pixmap for an EOL string. 5931 Private method to get an EOL pixmap for an EOL string.
5872 5932
5873 @param eolIndicator eol indicator string (string) 5933 @param eolIndicator eol indicator string
5874 @return pixmap for the eol indicator (QPixmap) 5934 @type str
5935 @return pixmap for the eol indicator
5936 @rtype QPixmap
5875 """ 5937 """
5876 if eolIndicator == "LF": 5938 if eolIndicator == "LF":
5877 pixmap = EricPixmapCache.getPixmap("eolLinux") 5939 pixmap = EricPixmapCache.getPixmap("eolLinux")
5878 elif eolIndicator == "CR": 5940 elif eolIndicator == "CR":
5879 pixmap = EricPixmapCache.getPixmap("eolMac") 5941 pixmap = EricPixmapCache.getPixmap("eolMac")
5893 """ 5955 """
5894 Public method to switch off all highlights or the highlight of 5956 Public method to switch off all highlights or the highlight of
5895 the current editor. 5957 the current editor.
5896 5958
5897 @param current flag indicating only the current editor should be 5959 @param current flag indicating only the current editor should be
5898 unhighlighted (boolean) 5960 unhighlighted
5961 @type bool
5899 """ 5962 """
5900 if current: 5963 if current:
5901 if self.currentEditor is not None: 5964 if self.currentEditor is not None:
5902 self.currentEditor.highlight() 5965 self.currentEditor.highlight()
5903 else: 5966 else:
5906 5969
5907 def getOpenFilenames(self): 5970 def getOpenFilenames(self):
5908 """ 5971 """
5909 Public method returning a list of the filenames of all editors. 5972 Public method returning a list of the filenames of all editors.
5910 5973
5911 @return list of all opened filenames (list of strings) 5974 @return list of all opened filenames
5975 @rtype list of str
5912 """ 5976 """
5913 filenames = [] 5977 filenames = []
5914 for editor in self.editors: 5978 for editor in self.editors:
5915 fn = editor.getFileName() 5979 fn = editor.getFileName()
5916 if fn is not None and fn not in filenames and os.path.exists(fn): 5980 if fn is not None and fn not in filenames and os.path.exists(fn):
5974 6038
5975 def getOpenEditors(self): 6039 def getOpenEditors(self):
5976 """ 6040 """
5977 Public method to get references to all open editors. 6041 Public method to get references to all open editors.
5978 6042
5979 @return list of references to all open editors (list of 6043 @return list of references to all open editors
5980 QScintilla.editor) 6044 @rtype list of Editor
5981 """ 6045 """
5982 return self.editors 6046 return self.editors
5983 6047
5984 def getOpenEditorsCount(self): 6048 def getOpenEditorsCount(self):
5985 """ 6049 """
5986 Public method to get the number of open editors. 6050 Public method to get the number of open editors.
5987 6051
5988 @return number of open editors (integer) 6052 @return number of open editors
6053 @rtype int
5989 """ 6054 """
5990 return len(self.editors) 6055 return len(self.editors)
5991 6056
5992 def getOpenEditor(self, fn): 6057 def getOpenEditor(self, fn):
5993 """ 6058 """
6010 Public method to return a list of all editors displaying the given file. 6075 Public method to return a list of all editors displaying the given file.
6011 6076
6012 @param fn filename to look for 6077 @param fn filename to look for
6013 @type str 6078 @type str
6014 @return list of references to the editors displaying this file 6079 @return list of references to the editors displaying this file
6080 @rtype list of Editor
6015 """ 6081 """
6016 return [ 6082 return [
6017 ed 6083 ed
6018 for ed in self.editors 6084 for ed in self.editors
6019 if FileSystemUtilities.samepath(fn, ed.getFileName()) 6085 if FileSystemUtilities.samepath(fn, ed.getFileName())
6022 def getOpenEditorCount(self, fn): 6088 def getOpenEditorCount(self, fn):
6023 """ 6089 """
6024 Public method to return the count of editors displaying the given file. 6090 Public method to return the count of editors displaying the given file.
6025 6091
6026 @param fn filename to look for 6092 @param fn filename to look for
6027 @return count of editors displaying this file (integer) 6093 @type str
6094 @return count of editors displaying this file
6095 @rtype int
6028 """ 6096 """
6029 return len(self.getOpenEditorList(fn)) 6097 return len(self.getOpenEditorList(fn))
6030 6098
6031 def getOpenEditorsForSession(self): 6099 def getOpenEditorsForSession(self):
6032 """ 6100 """
6044 6112
6045 def getActiveName(self): 6113 def getActiveName(self):
6046 """ 6114 """
6047 Public method to retrieve the filename of the active window. 6115 Public method to retrieve the filename of the active window.
6048 6116
6049 @return filename of active window (string) 6117 @return filename of active window
6118 @rtype str
6050 """ 6119 """
6051 aw = self.activeWindow() 6120 aw = self.activeWindow()
6052 if aw: 6121 if aw:
6053 return aw.getFileName() 6122 return aw.getFileName()
6054 else: 6123 else:
6056 6125
6057 def saveEditor(self, fn): 6126 def saveEditor(self, fn):
6058 """ 6127 """
6059 Public method to save a named editor file. 6128 Public method to save a named editor file.
6060 6129
6061 @param fn filename of editor to be saved (string) 6130 @param fn filename of editor to be saved
6062 @return flag indicating success (boolean) 6131 @type str
6132 @return flag indicating success
6133 @rtype bool
6063 """ 6134 """
6064 for editor in self.editors: 6135 for editor in self.editors:
6065 if FileSystemUtilities.samepath(fn, editor.getFileName()): 6136 if FileSystemUtilities.samepath(fn, editor.getFileName()):
6066 break 6137 break
6067 else: 6138 else:
6076 def saveEditorEd(self, ed): 6147 def saveEditorEd(self, ed):
6077 """ 6148 """
6078 Public slot to save the contents of an editor. 6149 Public slot to save the contents of an editor.
6079 6150
6080 @param ed editor to be saved 6151 @param ed editor to be saved
6081 @return flag indicating success (boolean) 6152 @type Editor
6153 @return flag indicating success
6154 @rtype bool
6082 """ 6155 """
6083 if ed: 6156 if ed:
6084 if not ed.isModified(): 6157 if not ed.isModified():
6085 return True 6158 return True
6086 else: 6159 else:
6101 def saveAsEditorEd(self, ed): 6174 def saveAsEditorEd(self, ed):
6102 """ 6175 """
6103 Public slot to save the contents of an editor to a new file. 6176 Public slot to save the contents of an editor to a new file.
6104 6177
6105 @param ed editor to be saved 6178 @param ed editor to be saved
6179 @type Editor
6106 """ 6180 """
6107 if ed: 6181 if ed:
6108 ok = ed.saveFileAs() 6182 ok = ed.saveFileAs()
6109 if ok: 6183 if ok:
6110 self.setEditorName(ed, ed.getFileName()) 6184 self.setEditorName(ed, ed.getFileName())
6120 """ 6194 """
6121 Public slot to save the contents of an editor to a new copy of 6195 Public slot to save the contents of an editor to a new copy of
6122 the file. 6196 the file.
6123 6197
6124 @param ed editor to be saved 6198 @param ed editor to be saved
6199 @type Editor
6125 """ 6200 """
6126 if ed: 6201 if ed:
6127 ed.saveFileCopy() 6202 ed.saveFileCopy()
6128 6203
6129 def saveCopyCurrentEditor(self): 6204 def saveCopyCurrentEditor(self):
6137 def saveEditorsList(self, editors): 6212 def saveEditorsList(self, editors):
6138 """ 6213 """
6139 Public slot to save a list of editors. 6214 Public slot to save a list of editors.
6140 6215
6141 @param editors list of editors to be saved 6216 @param editors list of editors to be saved
6217 @type list of Editor
6142 """ 6218 """
6143 for editor in editors: 6219 for editor in editors:
6144 ok = editor.saveFile() 6220 ok = editor.saveFile()
6145 if ok: 6221 if ok:
6146 self.setEditorName(editor, editor.getFileName()) 6222 self.setEditorName(editor, editor.getFileName())
6156 6232
6157 def __exportMenuTriggered(self, act): 6233 def __exportMenuTriggered(self, act):
6158 """ 6234 """
6159 Private method to handle the selection of an export format. 6235 Private method to handle the selection of an export format.
6160 6236
6161 @param act reference to the action that was triggered (QAction) 6237 @param act reference to the action that was triggered
6238 @type QAction
6162 """ 6239 """
6163 aw = self.activeWindow() 6240 aw = self.activeWindow()
6164 if aw: 6241 if aw:
6165 exporterFormat = act.data() 6242 exporterFormat = act.data()
6166 aw.exportFile(exporterFormat) 6243 aw.exportFile(exporterFormat)
6290 6367
6291 def __openSourceFile(self, act): 6368 def __openSourceFile(self, act):
6292 """ 6369 """
6293 Private method to open a file from the list of recently opened files. 6370 Private method to open a file from the list of recently opened files.
6294 6371
6295 @param act reference to the action that triggered (QAction) 6372 @param act reference to the action that triggered
6373 @type QAction
6296 """ 6374 """
6297 file = act.data() 6375 file = act.data()
6298 if file: 6376 if file:
6299 self.openSourceFile(file) 6377 self.openSourceFile(file)
6300 6378
6376 6454
6377 def projectFileRenamed(self, oldfn, newfn): 6455 def projectFileRenamed(self, oldfn, newfn):
6378 """ 6456 """
6379 Public slot to handle the projectFileRenamed signal. 6457 Public slot to handle the projectFileRenamed signal.
6380 6458
6381 @param oldfn old filename of the file (string) 6459 @param oldfn old filename of the file
6382 @param newfn new filename of the file (string) 6460 @type str
6461 @param newfn new filename of the file
6462 @type str
6383 """ 6463 """
6384 editor = self.getOpenEditor(oldfn) 6464 editor = self.getOpenEditor(oldfn)
6385 if editor: 6465 if editor:
6386 editor.fileRenamed(newfn) 6466 editor.fileRenamed(newfn)
6387 6467
6396 """ 6476 """
6397 Public method to set a flag enabling the editors to perform focus in 6477 Public method to set a flag enabling the editors to perform focus in
6398 checks. 6478 checks.
6399 6479
6400 @param enabled flag indicating focus in checks should be performed 6480 @param enabled flag indicating focus in checks should be performed
6401 (boolean) 6481 @type bool
6402 """ 6482 """
6403 self.editorsCheckFocusIn = enabled 6483 self.editorsCheckFocusIn = enabled
6404 6484
6405 def editorsCheckFocusInEnabled(self): 6485 def editorsCheckFocusInEnabled(self):
6406 """ 6486 """
6407 Public method returning the flag indicating editors should perform 6487 Public method returning the flag indicating editors should perform
6408 focus in checks. 6488 focus in checks.
6409 6489
6410 @return flag indicating focus in checks should be performed (boolean) 6490 @return flag indicating focus in checks should be performed
6491 @rtype bool
6411 """ 6492 """
6412 return self.editorsCheckFocusIn 6493 return self.editorsCheckFocusIn
6413 6494
6414 def __findLocation(self): 6495 def __findLocation(self):
6415 """ 6496 """
6646 """ 6727 """
6647 Public method to determine the selection or the current word for the 6728 Public method to determine the selection or the current word for the
6648 next find operation. 6729 next find operation.
6649 6730
6650 @param getCurrentWord flag indicating to return the current word, if 6731 @param getCurrentWord flag indicating to return the current word, if
6651 no selected text was found (boolean) 6732 no selected text was found
6652 @return selection or current word (string) 6733 @type bool
6734 @return selection or current word
6735 @rtype str
6653 """ 6736 """
6654 aw = self.activeWindow() 6737 aw = self.activeWindow()
6655 if aw is None: 6738 if aw is None:
6656 return "" 6739 return ""
6657 6740
6660 def getSRHistory(self, key): 6743 def getSRHistory(self, key):
6661 """ 6744 """
6662 Public method to get the search or replace history list. 6745 Public method to get the search or replace history list.
6663 6746
6664 @param key list to return (must be 'search' or 'replace') 6747 @param key list to return (must be 'search' or 'replace')
6665 @return the requested history list (list of strings) 6748 @type str
6749 @return the requested history list
6750 @rtype list of str
6666 """ 6751 """
6667 return self.srHistory[key] 6752 return self.srHistory[key]
6668 6753
6669 def showSearchWidget(self): 6754 def showSearchWidget(self):
6670 """ 6755 """
6830 6915
6831 def __zoomTo(self, value): 6916 def __zoomTo(self, value):
6832 """ 6917 """
6833 Private slot to zoom to a given value. 6918 Private slot to zoom to a given value.
6834 6919
6835 @param value zoom value to be set (integer) 6920 @param value zoom value to be set
6921 @type int
6836 """ 6922 """
6837 aw = ( 6923 aw = (
6838 ericApp().getObject("Shell") 6924 ericApp().getObject("Shell")
6839 if QApplication.focusWidget() == ericApp().getObject("Shell") 6925 if QApplication.focusWidget() == ericApp().getObject("Shell")
6840 else self.activeWindow() 6926 else self.activeWindow()
6918 7004
6919 def __splitOrientation(self, checked): 7005 def __splitOrientation(self, checked):
6920 """ 7006 """
6921 Private method to handle the split orientation action. 7007 Private method to handle the split orientation action.
6922 7008
6923 @param checked flag indicating the checked state of the action 7009 @param checked flag indicating the checked state of the action.
6924 (boolean). True means splitting horizontally. 7010 True means splitting horizontally.
7011 @type bool
6925 """ 7012 """
6926 if checked: 7013 if checked:
6927 self.setSplitOrientation(Qt.Orientation.Horizontal) 7014 self.setSplitOrientation(Qt.Orientation.Horizontal)
6928 self.splitViewAct.setIcon(EricPixmapCache.getIcon("splitHorizontal")) 7015 self.splitViewAct.setIcon(EricPixmapCache.getIcon("splitHorizontal"))
6929 self.splitRemoveAct.setIcon(EricPixmapCache.getIcon("remsplitHorizontal")) 7016 self.splitRemoveAct.setIcon(EricPixmapCache.getIcon("remsplitHorizontal"))
6941 7028
6942 def __previewEditor(self, checked): 7029 def __previewEditor(self, checked):
6943 """ 7030 """
6944 Private slot to handle a change of the preview selection state. 7031 Private slot to handle a change of the preview selection state.
6945 7032
6946 @param checked state of the action (boolean) 7033 @param checked state of the action
7034 @type bool
6947 """ 7035 """
6948 Preferences.setUI("ShowFilePreview", checked) 7036 Preferences.setUI("ShowFilePreview", checked)
6949 self.previewStateChanged.emit(checked) 7037 self.previewStateChanged.emit(checked)
6950 7038
6951 def __astViewer(self, checked): 7039 def __astViewer(self, checked):
6952 """ 7040 """
6953 Private slot to handle a change of the AST Viewer selection state. 7041 Private slot to handle a change of the AST Viewer selection state.
6954 7042
6955 @param checked state of the action (boolean) 7043 @param checked state of the action
7044 @type bool
6956 """ 7045 """
6957 self.astViewerStateChanged.emit(checked) 7046 self.astViewerStateChanged.emit(checked)
6958 7047
6959 def __disViewer(self, checked): 7048 def __disViewer(self, checked):
6960 """ 7049 """
6961 Private slot to handle a change of the DIS Viewer selection state. 7050 Private slot to handle a change of the DIS Viewer selection state.
6962 7051
6963 @param checked state of the action (boolean) 7052 @param checked state of the action
7053 @type bool
6964 """ 7054 """
6965 self.disViewerStateChanged.emit(checked) 7055 self.disViewerStateChanged.emit(checked)
6966 7056
6967 ################################################################## 7057 ##################################################################
6968 ## Below are the action methods for the macro menu 7058 ## Below are the action methods for the macro menu
7074 7164
7075 def __bookmarkSelected(self, act): 7165 def __bookmarkSelected(self, act):
7076 """ 7166 """
7077 Private method to handle the bookmark selected signal. 7167 Private method to handle the bookmark selected signal.
7078 7168
7079 @param act reference to the action that triggered (QAction) 7169 @param act reference to the action that triggered
7170 @type QAction
7080 """ 7171 """
7081 bmList = act.data() 7172 bmList = act.data()
7082 filename = bmList[0] 7173 filename = bmList[0]
7083 line = bmList[1] 7174 line = bmList[1]
7084 self.openSourceFile(filename, line) 7175 self.openSourceFile(filename, line)
7088 Private slot to handle the bookmarkToggled signal. 7179 Private slot to handle the bookmarkToggled signal.
7089 7180
7090 It checks some bookmark actions and reemits the signal. 7181 It checks some bookmark actions and reemits the signal.
7091 7182
7092 @param editor editor that sent the signal 7183 @param editor editor that sent the signal
7184 @type Editor
7093 """ 7185 """
7094 if editor.hasBookmarks(): 7186 if editor.hasBookmarks():
7095 self.bookmarkNextAct.setEnabled(True) 7187 self.bookmarkNextAct.setEnabled(True)
7096 self.bookmarkPreviousAct.setEnabled(True) 7188 self.bookmarkPreviousAct.setEnabled(True)
7097 self.bookmarkClearAct.setEnabled(True) 7189 self.bookmarkClearAct.setEnabled(True)
7119 Protected slot to handle the syntaxerrorToggled signal. 7211 Protected slot to handle the syntaxerrorToggled signal.
7120 7212
7121 It checks some syntax error actions and reemits the signal. 7213 It checks some syntax error actions and reemits the signal.
7122 7214
7123 @param editor editor that sent the signal 7215 @param editor editor that sent the signal
7216 @type Editor
7124 """ 7217 """
7125 if editor.hasSyntaxErrors(): 7218 if editor.hasSyntaxErrors():
7126 self.syntaxErrorGotoAct.setEnabled(True) 7219 self.syntaxErrorGotoAct.setEnabled(True)
7127 self.syntaxErrorClearAct.setEnabled(True) 7220 self.syntaxErrorClearAct.setEnabled(True)
7128 else: 7221 else:
7172 def __coverageMarkersShown(self, shown): 7265 def __coverageMarkersShown(self, shown):
7173 """ 7266 """
7174 Private slot to handle the coverageMarkersShown signal. 7267 Private slot to handle the coverageMarkersShown signal.
7175 7268
7176 @param shown flag indicating whether the markers were shown or cleared 7269 @param shown flag indicating whether the markers were shown or cleared
7270 @type bool
7177 """ 7271 """
7178 if shown: 7272 if shown:
7179 self.notcoveredNextAct.setEnabled(True) 7273 self.notcoveredNextAct.setEnabled(True)
7180 self.notcoveredPreviousAct.setEnabled(True) 7274 self.notcoveredPreviousAct.setEnabled(True)
7181 else: 7275 else:
7185 def __taskMarkersUpdated(self, editor): 7279 def __taskMarkersUpdated(self, editor):
7186 """ 7280 """
7187 Private slot to handle the taskMarkersUpdated signal. 7281 Private slot to handle the taskMarkersUpdated signal.
7188 7282
7189 @param editor editor that sent the signal 7283 @param editor editor that sent the signal
7284 @type Editor
7190 """ 7285 """
7191 if editor.hasTaskMarkers(): 7286 if editor.hasTaskMarkers():
7192 self.taskNextAct.setEnabled(True) 7287 self.taskNextAct.setEnabled(True)
7193 self.taskPreviousAct.setEnabled(True) 7288 self.taskPreviousAct.setEnabled(True)
7194 else: 7289 else:
7210 def __changeMarkersUpdated(self, editor): 7305 def __changeMarkersUpdated(self, editor):
7211 """ 7306 """
7212 Private slot to handle the changeMarkersUpdated signal. 7307 Private slot to handle the changeMarkersUpdated signal.
7213 7308
7214 @param editor editor that sent the signal 7309 @param editor editor that sent the signal
7310 @type Editor
7215 """ 7311 """
7216 if editor.hasChangeMarkers(): 7312 if editor.hasChangeMarkers():
7217 self.changeNextAct.setEnabled(True) 7313 self.changeNextAct.setEnabled(True)
7218 self.changePreviousAct.setEnabled(True) 7314 self.changePreviousAct.setEnabled(True)
7219 else: 7315 else:
7303 7399
7304 def __editSpellingDictionary(self, dictionaryFile): 7400 def __editSpellingDictionary(self, dictionaryFile):
7305 """ 7401 """
7306 Private slot to edit the given spelling dictionary. 7402 Private slot to edit the given spelling dictionary.
7307 7403
7308 @param dictionaryFile file name of the dictionary to edit (string) 7404 @param dictionaryFile file name of the dictionary to edit
7405 @type str
7309 """ 7406 """
7310 if os.path.exists(dictionaryFile): 7407 if os.path.exists(dictionaryFile):
7311 try: 7408 try:
7312 with open(dictionaryFile, "r", encoding="utf-8") as f: 7409 with open(dictionaryFile, "r", encoding="utf-8") as f:
7313 data = f.read() 7410 data = f.read()
7488 """ 7585 """
7489 Protected slot to check some actions for their enable/disable status 7586 Protected slot to check some actions for their enable/disable status
7490 and set the statusbar info. 7587 and set the statusbar info.
7491 7588
7492 @param editor editor window 7589 @param editor editor window
7590 @type Editor
7493 @param setSb flag indicating an update of the status bar is wanted 7591 @param setSb flag indicating an update of the status bar is wanted
7494 (boolean) 7592 @type bool
7495 """ 7593 """
7496 if editor is not None: 7594 if editor is not None:
7497 self.saveAct.setEnabled( 7595 self.saveAct.setEnabled(
7498 editor.isModified() 7596 editor.isModified()
7499 and not FileSystemUtilities.isRemoteFileName(editor.getFileName()) 7597 and not FileSystemUtilities.isRemoteFileName(editor.getFileName())
7703 Private slot to handle the breakpointToggled signal. 7801 Private slot to handle the breakpointToggled signal.
7704 7802
7705 It simply reemits the signal. 7803 It simply reemits the signal.
7706 7804
7707 @param editor editor that sent the signal 7805 @param editor editor that sent the signal
7806 @type Editor
7708 """ 7807 """
7709 self.breakpointToggled.emit(editor) 7808 self.breakpointToggled.emit(editor)
7710 7809
7711 def getActions(self, actionSetType): 7810 def getActions(self, actionSetType):
7712 """ 7811 """
7713 Public method to get a list of all actions. 7812 Public method to get a list of all actions.
7714 7813
7715 @param actionSetType string denoting the action set to get. 7814 @param actionSetType string denoting the action set to get.
7716 It must be one of "edit", "file", "search", "view", "window", 7815 It must be one of "edit", "file", "search", "view", "window",
7717 "macro", "bookmark" or "spelling". 7816 "macro", "bookmark" or "spelling".
7718 @return list of all actions (list of EricAction) 7817 @type str
7818 @return list of all actions
7819 @rtype list of EricAction
7719 """ 7820 """
7720 try: 7821 try:
7721 return self.__actions[actionSetType][:] 7822 return self.__actions[actionSetType][:]
7722 except KeyError: 7823 except KeyError:
7723 return [] 7824 return []
7725 def __editorCommand(self, cmd): 7826 def __editorCommand(self, cmd):
7726 """ 7827 """
7727 Private method to send an editor command to the active window. 7828 Private method to send an editor command to the active window.
7728 7829
7729 @param cmd the scintilla command to be sent 7830 @param cmd the scintilla command to be sent
7831 @type int
7730 """ 7832 """
7731 focusWidget = QApplication.focusWidget() 7833 focusWidget = QApplication.focusWidget()
7732 if focusWidget == ericApp().getObject("Shell"): 7834 if focusWidget == ericApp().getObject("Shell"):
7733 ericApp().getObject("Shell").editorCommand(cmd) 7835 ericApp().getObject("Shell").editorCommand(cmd)
7734 else: 7836 else:
7891 using the following search order, until a match is found:<br /> 7993 using the following search order, until a match is found:<br />
7892 1: Directory of currently active editor<br /> 7994 1: Directory of currently active editor<br />
7893 2: Directory of currently active Project<br /> 7995 2: Directory of currently active Project<br />
7894 3: CWD 7996 3: CWD
7895 7997
7896 @return name of directory to start (string) 7998 @return name of directory to start
7999 @rtype str
7897 """ 8000 """
7898 # if we have an active source, return its path 8001 # if we have an active source, return its path
7899 if self.activeWindow() is not None and self.activeWindow().getFileName(): 8002 if self.activeWindow() is not None and self.activeWindow().getFileName():
7900 return os.path.dirname(self.activeWindow().getFileName()) 8003 return os.path.dirname(self.activeWindow().getFileName())
7901 8004
7912 dialog. 8015 dialog.
7913 8016
7914 The appropriate filename filter is determined by file extension of 8017 The appropriate filename filter is determined by file extension of
7915 the currently active editor. 8018 the currently active editor.
7916 8019
7917 @return name of the filename filter (string) or None 8020 @return name of the filename filter
8021 @rtype str
7918 """ 8022 """
7919 if self.activeWindow() is not None and self.activeWindow().getFileName(): 8023 if self.activeWindow() is not None and self.activeWindow().getFileName():
7920 ext = os.path.splitext(self.activeWindow().getFileName())[1] 8024 ext = os.path.splitext(self.activeWindow().getFileName())[1]
7921 rx = re.compile(r".*\*\.{0}[ )].*".format(ext[1:])) 8025 rx = re.compile(r".*\*\.{0}[ )].*".format(ext[1:]))
7922 filters = Lexers.getOpenFileFiltersList() 8026 filters = Lexers.getOpenFileFiltersList()
7938 8042
7939 def getAPIsManager(self): 8043 def getAPIsManager(self):
7940 """ 8044 """
7941 Public method to get a reference to the APIs manager. 8045 Public method to get a reference to the APIs manager.
7942 8046
7943 @return the APIs manager object (eric7.QScintilla.APIsManager) 8047 @return the APIs manager object
8048 @rtype QScintilla.APIsManager
7944 """ 8049 """
7945 return self.apisManager 8050 return self.apisManager
7946 8051
7947 ####################################################################### 8052 #######################################################################
7948 ## Cooperation related methods 8053 ## Cooperation related methods
7950 8055
7951 def setCooperationClient(self, client): 8056 def setCooperationClient(self, client):
7952 """ 8057 """
7953 Public method to set a reference to the cooperation client. 8058 Public method to set a reference to the cooperation client.
7954 8059
7955 @param client reference to the cooperation client (CooperationClient) 8060 @param client reference to the cooperation client
8061 @type CooperationClient
7956 """ 8062 """
7957 self.__cooperationClient = client 8063 self.__cooperationClient = client
7958 8064
7959 def isConnected(self): 8065 def isConnected(self):
7960 """ 8066 """
7961 Public method to check the connection status of the IDE. 8067 Public method to check the connection status of the IDE.
7962 8068
7963 @return flag indicating the connection status (boolean) 8069 @return flag indicating the connection status
8070 @rtype bool
7964 """ 8071 """
7965 return self.__cooperationClient.hasConnections() 8072 return self.__cooperationClient.hasConnections()
7966 8073
7967 def send(self, fileName, message): 8074 def send(self, fileName, message):
7968 """ 8075 """
7969 Public method to send an editor command to remote editors. 8076 Public method to send an editor command to remote editors.
7970 8077
7971 @param fileName file name of the editor (string) 8078 @param fileName file name of the editor
7972 @param message command message to be sent (string) 8079 @type str
8080 @param message command message to be sent
8081 @type str
7973 """ 8082 """
7974 project = ericApp().getObject("Project") 8083 project = ericApp().getObject("Project")
7975 if project.isProjectFile(fileName): 8084 if project.isProjectFile(fileName):
7976 self.__cooperationClient.sendEditorCommand( 8085 self.__cooperationClient.sendEditorCommand(
7977 project.getHash(), project.getRelativeUniversalPath(fileName), message 8086 project.getHash(), project.getRelativeUniversalPath(fileName), message
7979 8088
7980 def receive(self, projectHash, fileName, command): 8089 def receive(self, projectHash, fileName, command):
7981 """ 8090 """
7982 Public slot to handle received editor commands. 8091 Public slot to handle received editor commands.
7983 8092
7984 @param projectHash hash of the project (string) 8093 @param projectHash hash of the project
7985 @param fileName project relative file name of the editor (string) 8094 @type str
7986 @param command command string (string) 8095 @param fileName project relative file name of the editor
8096 @type str
8097 @param command command string
8098 @type str
7987 """ 8099 """
7988 project = ericApp().getObject("Project") 8100 project = ericApp().getObject("Project")
7989 if projectHash == project.getHash(): 8101 if projectHash == project.getHash():
7990 fn = project.getAbsoluteUniversalPath(fileName) 8102 fn = project.getAbsoluteUniversalPath(fileName)
7991 editor = self.getOpenEditor(fn) 8103 editor = self.getOpenEditor(fn)
7994 8106
7995 def shareConnected(self, connected): 8107 def shareConnected(self, connected):
7996 """ 8108 """
7997 Public slot to handle a change of the connected state. 8109 Public slot to handle a change of the connected state.
7998 8110
7999 @param connected flag indicating the connected state (boolean) 8111 @param connected flag indicating the connected state
8112 @type bool
8000 """ 8113 """
8001 for editor in self.getOpenEditors(): 8114 for editor in self.getOpenEditors():
8002 editor.shareConnected(connected) 8115 editor.shareConnected(connected)
8003 8116
8004 def shareEditor(self, share): 8117 def shareEditor(self, share):
8005 """ 8118 """
8006 Public slot to set the shared status of the current editor. 8119 Public slot to set the shared status of the current editor.
8007 8120
8008 @param share flag indicating the share status (boolean) 8121 @param share flag indicating the share status
8122 @type bool
8009 """ 8123 """
8010 aw = self.activeWindow() 8124 aw = self.activeWindow()
8011 if aw is not None: 8125 if aw is not None:
8012 fn = aw.getFileName() 8126 fn = aw.getFileName()
8013 if fn and ericApp().getObject("Project").isProjectFile(fn): 8127 if fn and ericApp().getObject("Project").isProjectFile(fn):
8050 8164
8051 def insertSymbol(self, txt): 8165 def insertSymbol(self, txt):
8052 """ 8166 """
8053 Public slot to insert a symbol text into the active window. 8167 Public slot to insert a symbol text into the active window.
8054 8168
8055 @param txt text to be inserted (string) 8169 @param txt text to be inserted
8170 @type str
8056 """ 8171 """
8057 if self.__lastFocusWidget == ericApp().getObject("Shell"): 8172 if self.__lastFocusWidget == ericApp().getObject("Shell"):
8058 ericApp().getObject("Shell").insert(txt) 8173 ericApp().getObject("Shell").insert(txt)
8059 else: 8174 else:
8060 aw = self.activeWindow() 8175 aw = self.activeWindow()
8069 8184
8070 def insertNumber(self, txt): 8185 def insertNumber(self, txt):
8071 """ 8186 """
8072 Public slot to insert a number text into the active window. 8187 Public slot to insert a number text into the active window.
8073 8188
8074 @param txt text to be inserted (string) 8189 @param txt text to be inserted
8190 @type str
8075 """ 8191 """
8076 if self.__lastFocusWidget == ericApp().getObject("Shell"): 8192 if self.__lastFocusWidget == ericApp().getObject("Shell"):
8077 aw = ericApp().getObject("Shell") 8193 aw = ericApp().getObject("Shell")
8078 if aw.hasSelectedText(): 8194 if aw.hasSelectedText():
8079 aw.removeSelectedText() 8195 aw.removeSelectedText()
8089 8205
8090 def getNumber(self): 8206 def getNumber(self):
8091 """ 8207 """
8092 Public method to get a number from the active window. 8208 Public method to get a number from the active window.
8093 8209
8094 @return selected text of the active window (string) 8210 @return selected text of the active window
8211 @rtype str
8095 """ 8212 """
8096 txt = "" 8213 txt = ""
8097 if self.__lastFocusWidget == ericApp().getObject("Shell"): 8214 if self.__lastFocusWidget == ericApp().getObject("Shell"):
8098 aw = ericApp().getObject("Shell") 8215 aw = ericApp().getObject("Shell")
8099 if aw.hasSelectedText(): 8216 if aw.hasSelectedText():

eric ide

mercurial