eric6/ViewManager/ViewManager.py

changeset 8129
52c76e6cb35b
parent 8037
cf0e5b8cd23a
child 8142
43248bafe9b2
child 8143
2c730d5fd177
equal deleted inserted replaced
8128:8f012c58f27e 8129:52c76e6cb35b
12 12
13 from PyQt5.QtCore import ( 13 from PyQt5.QtCore import (
14 pyqtSignal, pyqtSlot, Qt, QSignalMapper, QTimer, QFileInfo, QPoint, 14 pyqtSignal, pyqtSlot, Qt, QSignalMapper, QTimer, QFileInfo, QPoint,
15 QCoreApplication 15 QCoreApplication
16 ) 16 )
17 from PyQt5.QtGui import QColor, QKeySequence, QPalette, QPixmap 17 from PyQt5.QtGui import QKeySequence, QPixmap
18 from PyQt5.QtWidgets import ( 18 from PyQt5.QtWidgets import (
19 QLineEdit, QToolBar, QWidgetAction, QDialog, QApplication, QMenu, 19 QToolBar, QDialog, QApplication, QMenu, QWidget
20 QComboBox, QWidget
21 ) 20 )
22 from PyQt5.Qsci import QsciScintilla 21 from PyQt5.Qsci import QsciScintilla
23 22
24 from E5Gui.E5Application import e5App 23 from E5Gui.E5Application import e5App
25 from E5Gui import E5FileDialog, E5MessageBox 24 from E5Gui import E5FileDialog, E5MessageBox
34 33
35 import UI.PixmapCache 34 import UI.PixmapCache
36 import UI.Config 35 import UI.Config
37 36
38 from E5Gui.E5Action import E5Action, createActionGroup 37 from E5Gui.E5Action import E5Action, createActionGroup
39
40
41 class QuickSearchLineEdit(QLineEdit):
42 """
43 Class implementing a line edit that reacts to newline and cancel commands.
44
45 @signal escPressed() emitted after the cancel command was activated
46 @signal gotFocus() emitted when the focus is changed to this widget
47 """
48 escPressed = pyqtSignal()
49 gotFocus = pyqtSignal()
50
51 def editorCommand(self, cmd):
52 """
53 Public method to perform an editor command.
54
55 @param cmd the scintilla command to be performed
56 """
57 if cmd == QsciScintilla.SCI_NEWLINE:
58 cb = self.parent()
59 hasEntry = cb.findText(self.text()) != -1
60 if not hasEntry:
61 if cb.insertPolicy() == QComboBox.InsertAtTop:
62 cb.insertItem(0, self.text())
63 else:
64 cb.addItem(self.text())
65 self.returnPressed.emit()
66 elif cmd == QsciScintilla.SCI_CANCEL:
67 self.escPressed.emit()
68
69 def keyPressEvent(self, evt):
70 """
71 Protected method to handle the press of the ESC key.
72
73 @param evt key event (QKeyPressEvent)
74 """
75 if evt.key() == Qt.Key_Escape:
76 self.escPressed.emit()
77 else:
78 super(QuickSearchLineEdit, self).keyPressEvent(evt) # pass it on
79
80 def focusInEvent(self, evt):
81 """
82 Protected method to record the current editor widget.
83
84 @param evt focus event (QFocusEvent)
85 """
86 self.gotFocus.emit()
87 super(QuickSearchLineEdit, self).focusInEvent(evt) # pass it on
88 38
89 39
90 class ViewManager(QWidget): 40 class ViewManager(QWidget):
91 """ 41 """
92 Base class inherited by all specific view manager classes. 42 Base class inherited by all specific view manager classes.
3107 )) 3057 ))
3108 self.replaceAllAct.triggered.connect( 3058 self.replaceAllAct.triggered.connect(
3109 self.__replaceWidget.replaceAll) 3059 self.__replaceWidget.replaceAll)
3110 self.searchActions.append(self.replaceAllAct) 3060 self.searchActions.append(self.replaceAllAct)
3111 3061
3112 self.quickSearchAct = E5Action(
3113 QCoreApplication.translate('ViewManager', 'Quicksearch'),
3114 UI.PixmapCache.getIcon("quickFindNext"),
3115 QCoreApplication.translate('ViewManager', '&Quicksearch'),
3116 QKeySequence(QCoreApplication.translate(
3117 'ViewManager', "Ctrl+Shift+K", "Search|Quicksearch")),
3118 0,
3119 self.searchActGrp, 'vm_quicksearch')
3120 self.quickSearchAct.setStatusTip(QCoreApplication.translate(
3121 'ViewManager', 'Perform a quicksearch'))
3122 self.quickSearchAct.setWhatsThis(QCoreApplication.translate(
3123 'ViewManager',
3124 """<b>Quicksearch</b>"""
3125 """<p>This activates the quicksearch function of the IDE by"""
3126 """ giving focus to the quicksearch entry field. If this field"""
3127 """ is already active and contains text, it searches for the"""
3128 """ next occurrence of this text.</p>"""
3129 ))
3130 self.quickSearchAct.triggered.connect(self.__quickSearch)
3131 self.searchActions.append(self.quickSearchAct)
3132
3133 self.quickSearchBackAct = E5Action(
3134 QCoreApplication.translate(
3135 'ViewManager', 'Quicksearch backwards'),
3136 UI.PixmapCache.getIcon("quickFindPrev"),
3137 QCoreApplication.translate(
3138 'ViewManager', 'Quicksearch &backwards'),
3139 QKeySequence(QCoreApplication.translate(
3140 'ViewManager',
3141 "Ctrl+Shift+J", "Search|Quicksearch backwards")),
3142 0, self.searchActGrp, 'vm_quicksearch_backwards')
3143 self.quickSearchBackAct.setStatusTip(QCoreApplication.translate(
3144 'ViewManager',
3145 'Perform a quicksearch backwards'))
3146 self.quickSearchBackAct.setWhatsThis(QCoreApplication.translate(
3147 'ViewManager',
3148 """<b>Quicksearch backwards</b>"""
3149 """<p>This searches the previous occurrence of the quicksearch"""
3150 """ text.</p>"""
3151 ))
3152 self.quickSearchBackAct.triggered.connect(self.__quickSearchPrev)
3153 self.searchActions.append(self.quickSearchBackAct)
3154
3155 self.quickSearchExtendAct = E5Action(
3156 QCoreApplication.translate('ViewManager', 'Quicksearch extend'),
3157 UI.PixmapCache.getIcon("quickFindExtend"),
3158 QCoreApplication.translate('ViewManager', 'Quicksearch e&xtend'),
3159 QKeySequence(QCoreApplication.translate(
3160 'ViewManager', "Ctrl+Shift+H", "Search|Quicksearch extend")),
3161 0,
3162 self.searchActGrp, 'vm_quicksearch_extend')
3163 self.quickSearchExtendAct.setStatusTip(QCoreApplication.translate(
3164 'ViewManager',
3165 'Extend the quicksearch to the end of the current word'))
3166 self.quickSearchExtendAct.setWhatsThis(QCoreApplication.translate(
3167 'ViewManager',
3168 """<b>Quicksearch extend</b>"""
3169 """<p>This extends the quicksearch text to the end of the word"""
3170 """ currently found.</p>"""
3171 ))
3172 self.quickSearchExtendAct.triggered.connect(
3173 self.__quickSearchExtend)
3174 self.searchActions.append(self.quickSearchExtendAct)
3175
3176 self.gotoAct = E5Action( 3062 self.gotoAct = E5Action(
3177 QCoreApplication.translate('ViewManager', 'Goto Line'), 3063 QCoreApplication.translate('ViewManager', 'Goto Line'),
3178 UI.PixmapCache.getIcon("goto"), 3064 UI.PixmapCache.getIcon("goto"),
3179 QCoreApplication.translate('ViewManager', '&Goto Line...'), 3065 QCoreApplication.translate('ViewManager', '&Goto Line...'),
3180 QKeySequence(QCoreApplication.translate( 3066 QKeySequence(QCoreApplication.translate(
3375 """ 3261 """
3376 menu = QMenu( 3262 menu = QMenu(
3377 QCoreApplication.translate('ViewManager', '&Search'), 3263 QCoreApplication.translate('ViewManager', '&Search'),
3378 self.ui) 3264 self.ui)
3379 menu.setTearOffEnabled(True) 3265 menu.setTearOffEnabled(True)
3380 menu.addAction(self.quickSearchAct)
3381 menu.addAction(self.quickSearchBackAct)
3382 menu.addAction(self.searchAct) 3266 menu.addAction(self.searchAct)
3383 menu.addAction(self.searchNextAct) 3267 menu.addAction(self.searchNextAct)
3384 menu.addAction(self.searchPrevAct) 3268 menu.addAction(self.searchPrevAct)
3385 menu.addAction(self.searchNextWordAct) 3269 menu.addAction(self.searchNextWordAct)
3386 menu.addAction(self.searchPrevWordAct) 3270 menu.addAction(self.searchPrevWordAct)
3394 menu.addAction(self.searchOpenFilesAct) 3278 menu.addAction(self.searchOpenFilesAct)
3395 menu.addAction(self.replaceOpenFilesAct) 3279 menu.addAction(self.replaceOpenFilesAct)
3396 3280
3397 return menu 3281 return menu
3398 3282
3399 def initSearchToolbars(self, toolbarManager): 3283 def initSearchToolbar(self, toolbarManager):
3400 """ 3284 """
3401 Public method to create the Search toolbars. 3285 Public method to create the Search toolbar.
3402 3286
3403 @param toolbarManager reference to a toolbar manager object 3287 @param toolbarManager reference to a toolbar manager object
3404 (E5ToolBarManager) 3288 @type E5ToolBarManager
3405 @return a tuple of the generated toolbar (search, quicksearch) 3289 @return generated toolbar
3406 """ 3290 @rtype QToolBar
3407 qtb = QToolBar(QCoreApplication.translate( 3291 """
3408 'ViewManager', 'Quicksearch'), self.ui)
3409 qtb.setIconSize(UI.Config.ToolBarIconSize)
3410 qtb.setObjectName("QuicksearchToolbar")
3411 qtb.setToolTip(QCoreApplication.translate(
3412 'ViewManager', 'Quicksearch'))
3413
3414 self.quickFindLineEdit = QuickSearchLineEdit(self)
3415 self.quickFindtextCombo = QComboBox(self)
3416 self.quickFindtextCombo.setEditable(True)
3417 self.quickFindtextCombo.setLineEdit(self.quickFindLineEdit)
3418 self.quickFindtextCombo.setDuplicatesEnabled(False)
3419 self.quickFindtextCombo.setInsertPolicy(QComboBox.InsertAtTop)
3420 self.quickFindtextCombo.lastActive = None
3421 self.quickFindtextCombo.lastCursorPos = None
3422 self.quickFindtextCombo.lastSearchText = ""
3423 self.quickFindtextCombo._editor = self.quickFindtextCombo.lineEdit()
3424 # this allows us not to jump across searched text
3425 # just because of autocompletion enabled
3426 self.quickFindtextCombo.setMinimumWidth(250)
3427 self.quickFindtextCombo.setSizeAdjustPolicy(
3428 QComboBox.AdjustToMinimumContentsLengthWithIcon)
3429 self.quickFindtextCombo.addItem("")
3430 self.quickFindtextCombo.setWhatsThis(QCoreApplication.translate(
3431 'ViewManager',
3432 """<p>Enter the searchtext directly into this field."""
3433 """ The search will be performed case insensitive."""
3434 """ The quicksearch function is activated upon activation"""
3435 """ of the quicksearch next action (default key Ctrl+Shift+K),"""
3436 """ if this entry field does not have the input focus."""
3437 """ Otherwise it searches for the next occurrence of the"""
3438 """ text entered. The quicksearch backwards action"""
3439 """ (default key Ctrl+Shift+J) searches backward."""
3440 """ Activating the 'quicksearch extend' action"""
3441 """ (default key Ctrl+Shift+H) extends the current"""
3442 """ searchtext to the end of the currently found word."""
3443 """ The quicksearch can be ended by pressing the Return key"""
3444 """ while the quicksearch entry has the the input focus.</p>"""
3445 ))
3446 self.quickFindtextCombo._editor.returnPressed.connect(
3447 self.__quickSearchEnter)
3448 self.quickFindtextCombo._editor.textChanged.connect(
3449 self.__quickSearchText)
3450 self.quickFindtextCombo._editor.escPressed.connect(
3451 self.__quickSearchEscape)
3452 self.quickFindtextCombo._editor.gotFocus.connect(
3453 self.__quickSearchFocusIn)
3454 self.quickFindtextAction = QWidgetAction(self)
3455 self.quickFindtextAction.setDefaultWidget(self.quickFindtextCombo)
3456 self.quickFindtextAction.setObjectName("vm_quickfindtext_action")
3457 self.quickFindtextAction.setText(QCoreApplication.translate(
3458 'ViewManager', "Quicksearch Textedit"))
3459 qtb.addAction(self.quickFindtextAction)
3460 qtb.addAction(self.quickSearchAct)
3461 qtb.addAction(self.quickSearchBackAct)
3462 qtb.addAction(self.quickSearchExtendAct)
3463 self.quickFindtextCombo.setEnabled(False)
3464 self.__quickSearchToolbar = qtb
3465 self.__quickSearchToolbarVisibility = None
3466
3467 tb = QToolBar(QCoreApplication.translate('ViewManager', 'Search'), 3292 tb = QToolBar(QCoreApplication.translate('ViewManager', 'Search'),
3468 self.ui) 3293 self.ui)
3469 tb.setIconSize(UI.Config.ToolBarIconSize) 3294 tb.setIconSize(UI.Config.ToolBarIconSize)
3470 tb.setObjectName("SearchToolbar") 3295 tb.setObjectName("SearchToolbar")
3471 tb.setToolTip(QCoreApplication.translate('ViewManager', 'Search')) 3296 tb.setToolTip(QCoreApplication.translate('ViewManager', 'Search'))
3484 tb.addAction(self.gotoLastEditAct) 3309 tb.addAction(self.gotoLastEditAct)
3485 3310
3486 tb.setAllowedAreas( 3311 tb.setAllowedAreas(
3487 Qt.ToolBarAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea)) 3312 Qt.ToolBarAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea))
3488 3313
3489 toolbarManager.addToolBar(qtb, qtb.windowTitle())
3490 toolbarManager.addToolBar(tb, tb.windowTitle()) 3314 toolbarManager.addToolBar(tb, tb.windowTitle())
3491 toolbarManager.addAction(self.gotoAct, tb.windowTitle()) 3315 toolbarManager.addAction(self.gotoAct, tb.windowTitle())
3492 toolbarManager.addAction(self.gotoBraceAct, tb.windowTitle()) 3316 toolbarManager.addAction(self.gotoBraceAct, tb.windowTitle())
3493 toolbarManager.addAction(self.replaceSelectionAct, tb.windowTitle()) 3317 toolbarManager.addAction(self.replaceSelectionAct, tb.windowTitle())
3494 toolbarManager.addAction(self.replaceAllAct, tb.windowTitle()) 3318 toolbarManager.addAction(self.replaceAllAct, tb.windowTitle())
3495 toolbarManager.addAction(self.replaceAndSearchAct, tb.windowTitle()) 3319 toolbarManager.addAction(self.replaceAndSearchAct, tb.windowTitle())
3496 3320
3497 return tb, qtb 3321 return tb
3498 3322
3499 ################################################################## 3323 ##################################################################
3500 ## Initialize the view related actions, view menu and toolbar 3324 ## Initialize the view related actions, view menu and toolbar
3501 ################################################################## 3325 ##################################################################
3502 3326
5504 self.sbZoom.setEnabled(False) 5328 self.sbZoom.setEnabled(False)
5505 else: 5329 else:
5506 self.sbZoom.setEnabled(True) 5330 self.sbZoom.setEnabled(True)
5507 self.sbZoom.setValue(now.getZoom()) 5331 self.sbZoom.setValue(now.getZoom())
5508 5332
5509 if ( 5333 if not isinstance(now, (Editor, Shell)):
5510 not isinstance(now, (Editor, Shell)) and
5511 now is not self.quickFindtextCombo
5512 ):
5513 self.searchActGrp.setEnabled(False) 5334 self.searchActGrp.setEnabled(False)
5514
5515 if now is self.quickFindtextCombo:
5516 self.searchActGrp.setEnabled(True)
5517 5335
5518 if not isinstance(now, (Editor, Shell)): 5336 if not isinstance(now, (Editor, Shell)):
5519 self.__lastFocusWidget = old 5337 self.__lastFocusWidget = old
5520 5338
5521 ################################################################## 5339 ##################################################################
5738 5556
5739 @param key list to return (must be 'search' or 'replace') 5557 @param key list to return (must be 'search' or 'replace')
5740 @return the requested history list (list of strings) 5558 @return the requested history list (list of strings)
5741 """ 5559 """
5742 return self.srHistory[key] 5560 return self.srHistory[key]
5743
5744 def __quickSearch(self):
5745 """
5746 Private slot to handle the incremental quick search.
5747 """
5748 # first we have to check if quick search is active
5749 # and try to activate it if not
5750 if self.__quickSearchToolbarVisibility is None:
5751 self.__quickSearchToolbarVisibility = (
5752 self.__quickSearchToolbar.isVisible()
5753 )
5754 if not self.__quickSearchToolbar.isVisible():
5755 self.__quickSearchToolbar.show()
5756 if not self.quickFindtextCombo.lineEdit().hasFocus():
5757 aw = self.activeWindow()
5758 self.quickFindtextCombo.lastActive = aw
5759 if aw:
5760 self.quickFindtextCombo.lastCursorPos = aw.getCursorPosition()
5761 else:
5762 self.quickFindtextCombo.lastCursorPos = None
5763 tff = self.textForFind(False)
5764 if tff:
5765 self.quickFindtextCombo.lineEdit().setText(tff)
5766 self.quickFindtextCombo.lineEdit().setFocus()
5767 self.quickFindtextCombo.lineEdit().selectAll()
5768 self.__quickSearchSetEditColors(False)
5769 else:
5770 self.__quickSearchInEditor(True, False)
5771
5772 def __quickSearchFocusIn(self):
5773 """
5774 Private method to handle a focus in signal of the quicksearch lineedit.
5775 """
5776 self.quickFindtextCombo.lastActive = self.activeWindow()
5777
5778 def __quickSearchEnter(self):
5779 """
5780 Private slot to handle the incremental quick search return pressed
5781 (jump back to text).
5782 """
5783 if self.quickFindtextCombo.lastActive:
5784 self.quickFindtextCombo.lastActive.setFocus()
5785 if self.__quickSearchToolbarVisibility is not None:
5786 self.__quickSearchToolbar.setVisible(
5787 self.__quickSearchToolbarVisibility)
5788 self.__quickSearchToolbarVisibility = None
5789
5790 def __quickSearchEscape(self):
5791 """
5792 Private slot to handle the incremental quick search escape pressed
5793 (jump back to text).
5794 """
5795 if self.quickFindtextCombo.lastActive:
5796 self.quickFindtextCombo.lastActive.setFocus()
5797 aw = self.activeWindow()
5798 if aw:
5799 aw.hideFindIndicator()
5800 if self.quickFindtextCombo.lastCursorPos:
5801 aw.setCursorPosition(
5802 self.quickFindtextCombo.lastCursorPos[0],
5803 self.quickFindtextCombo.lastCursorPos[1])
5804
5805 if self.__quickSearchToolbarVisibility is not None:
5806 self.__quickSearchToolbar.setVisible(
5807 self.__quickSearchToolbarVisibility)
5808 self.__quickSearchToolbarVisibility = None
5809
5810 def __quickSearchText(self):
5811 """
5812 Private slot to handle the textChanged signal of the quicksearch edit.
5813 """
5814 self.__quickSearchInEditor(False, False)
5815
5816 def __quickSearchPrev(self):
5817 """
5818 Private slot to handle the quickFindPrev toolbutton action.
5819 """
5820 # first we have to check if quick search is active
5821 # and try to activate it if not
5822 if self.__quickSearchToolbarVisibility is None:
5823 self.__quickSearchToolbarVisibility = (
5824 self.__quickSearchToolbar.isVisible()
5825 )
5826 if not self.__quickSearchToolbar.isVisible():
5827 self.__quickSearchToolbar.show()
5828 if not self.quickFindtextCombo.lineEdit().hasFocus():
5829 aw = self.activeWindow()
5830 self.quickFindtextCombo.lastActive = aw
5831 if aw:
5832 self.quickFindtextCombo.lastCursorPos = aw.getCursorPosition()
5833 else:
5834 self.quickFindtextCombo.lastCursorPos = None
5835 tff = self.textForFind(False)
5836 if tff:
5837 self.quickFindtextCombo.lineEdit().setText(tff)
5838 self.quickFindtextCombo.lineEdit().setFocus()
5839 self.quickFindtextCombo.lineEdit().selectAll()
5840 self.__quickSearchSetEditColors(False)
5841 else:
5842 self.__quickSearchInEditor(True, True)
5843
5844 def __quickSearchMarkOccurrences(self, txt):
5845 """
5846 Private method to mark all occurrences of the search text.
5847
5848 @param txt text to search for (string)
5849 """
5850 aw = self.activeWindow()
5851
5852 lineFrom = 0
5853 indexFrom = 0
5854 lineTo = -1
5855 indexTo = -1
5856
5857 aw.clearSearchIndicators()
5858 ok = aw.findFirstTarget(txt, False, False, False,
5859 lineFrom, indexFrom, lineTo, indexTo)
5860 while ok:
5861 tgtPos, tgtLen = aw.getFoundTarget()
5862 aw.setSearchIndicator(tgtPos, tgtLen)
5863 ok = aw.findNextTarget()
5864
5865 def __quickSearchInEditor(self, again, back):
5866 """
5867 Private slot to perform a quick search.
5868
5869 @param again flag indicating a repeat of the last search (boolean)
5870 @param back flag indicating a backwards search operation (boolean)
5871 """
5872 aw = self.activeWindow()
5873 if not aw:
5874 return
5875
5876 aw.hideFindIndicator()
5877
5878 text = self.quickFindtextCombo.lineEdit().text()
5879 if not text and again:
5880 text = self.quickFindtextCombo.lastSearchText
5881 if not text:
5882 if Preferences.getEditor("QuickSearchMarkersEnabled"):
5883 aw.clearSearchIndicators()
5884 return
5885 else:
5886 self.quickFindtextCombo.lastSearchText = text
5887
5888 if Preferences.getEditor("QuickSearchMarkersEnabled"):
5889 self.__quickSearchMarkOccurrences(text)
5890
5891 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection()
5892 cline, cindex = aw.getCursorPosition()
5893 if again:
5894 if back:
5895 if indexFrom != 0:
5896 index = indexFrom - 1
5897 line = lineFrom
5898 elif lineFrom == 0:
5899 return
5900 else:
5901 line = lineFrom - 1
5902 index = aw.lineLength(line)
5903 ok = aw.findFirst(text, False, False, False, True, False,
5904 line, index)
5905 else:
5906 ok = aw.findFirst(text, False, False, False, True, not back,
5907 cline, cindex)
5908 else:
5909 ok = aw.findFirst(text, False, False, False, True, not back,
5910 lineFrom, indexFrom)
5911 if ok:
5912 sline, sindex, eline, eindex = aw.getSelection()
5913 aw.showFindIndicator(sline, sindex, eline, eindex)
5914 self.__quickSearchSetEditColors(not ok)
5915
5916 def __quickSearchSetEditColors(self, error):
5917 """
5918 Private method to set the quick search edit colors.
5919
5920 @param error flag indicating an error (boolean)
5921 """
5922 if error:
5923 palette = self.quickFindtextCombo.lineEdit().palette()
5924 palette.setColor(QPalette.Base, QColor("red"))
5925 palette.setColor(QPalette.Text, QColor("white"))
5926 self.quickFindtextCombo.lineEdit().setPalette(palette)
5927 else:
5928 palette = self.quickFindtextCombo.lineEdit().palette()
5929 palette.setColor(
5930 QPalette.Base,
5931 self.quickFindtextCombo.palette().color(QPalette.Base))
5932 palette.setColor(
5933 QPalette.Text,
5934 self.quickFindtextCombo.palette().color(QPalette.Text))
5935 self.quickFindtextCombo.lineEdit().setPalette(palette)
5936
5937 def __quickSearchExtend(self):
5938 """
5939 Private method to handle the quicksearch extend action.
5940 """
5941 aw = self.activeWindow()
5942 if aw is None:
5943 return
5944
5945 txt = self.quickFindtextCombo.lineEdit().text()
5946 if not txt:
5947 return
5948
5949 line, index = aw.getCursorPosition()
5950 text = aw.text(line)
5951
5952 rx = re.compile(r'[^\w_]')
5953 match = rx.search(text, index)
5954 if match:
5955 end = match.start()
5956 if end > index:
5957 ext = text[index:end]
5958 txt += ext
5959 self.quickFindtextCombo.lineEdit().setText(txt)
5960 5561
5961 def showSearchWidget(self): 5562 def showSearchWidget(self):
5962 """ 5563 """
5963 Public method to show the search widget. 5564 Public method to show the search widget.
5964 """ 5565 """
6722 self.printAct.setEnabled(False) 6323 self.printAct.setEnabled(False)
6723 if self.printPreviewAct: 6324 if self.printPreviewAct:
6724 self.printPreviewAct.setEnabled(False) 6325 self.printPreviewAct.setEnabled(False)
6725 self.editActGrp.setEnabled(False) 6326 self.editActGrp.setEnabled(False)
6726 self.searchActGrp.setEnabled(False) 6327 self.searchActGrp.setEnabled(False)
6727 self.quickFindtextCombo.setEnabled(False)
6728 self.viewActGrp.setEnabled(False) 6328 self.viewActGrp.setEnabled(False)
6729 self.viewFoldActGrp.setEnabled(False) 6329 self.viewFoldActGrp.setEnabled(False)
6730 self.unhighlightAct.setEnabled(False) 6330 self.unhighlightAct.setEnabled(False)
6731 self.newDocumentViewAct.setEnabled(False) 6331 self.newDocumentViewAct.setEnabled(False)
6732 self.newDocumentSplitViewAct.setEnabled(False) 6332 self.newDocumentSplitViewAct.setEnabled(False)
6769 self.printAct.setEnabled(True) 6369 self.printAct.setEnabled(True)
6770 if self.printPreviewAct: 6370 if self.printPreviewAct:
6771 self.printPreviewAct.setEnabled(True) 6371 self.printPreviewAct.setEnabled(True)
6772 self.editActGrp.setEnabled(True) 6372 self.editActGrp.setEnabled(True)
6773 self.searchActGrp.setEnabled(True) 6373 self.searchActGrp.setEnabled(True)
6774 self.quickFindtextCombo.setEnabled(True)
6775 self.viewActGrp.setEnabled(True) 6374 self.viewActGrp.setEnabled(True)
6776 self.viewFoldActGrp.setEnabled(True) 6375 self.viewFoldActGrp.setEnabled(True)
6777 self.unhighlightAct.setEnabled(True) 6376 self.unhighlightAct.setEnabled(True)
6778 self.newDocumentViewAct.setEnabled(True) 6377 self.newDocumentViewAct.setEnabled(True)
6779 if self.canSplit(): 6378 if self.canSplit():
7059 @param cmd the scintilla command to be sent 6658 @param cmd the scintilla command to be sent
7060 """ 6659 """
7061 focusWidget = QApplication.focusWidget() 6660 focusWidget = QApplication.focusWidget()
7062 if focusWidget == e5App().getObject("Shell"): 6661 if focusWidget == e5App().getObject("Shell"):
7063 e5App().getObject("Shell").editorCommand(cmd) 6662 e5App().getObject("Shell").editorCommand(cmd)
7064 elif focusWidget == self.quickFindtextCombo:
7065 self.quickFindtextCombo._editor.editorCommand(cmd)
7066 else: 6663 else:
7067 aw = self.activeWindow() 6664 aw = self.activeWindow()
7068 if aw: 6665 if aw:
7069 aw.editorCommand(cmd) 6666 aw.editorCommand(cmd)
7070 6667
7072 """ 6669 """
7073 Private method to insert a new line below the current one even if 6670 Private method to insert a new line below the current one even if
7074 cursor is not at the end of the line. 6671 cursor is not at the end of the line.
7075 """ 6672 """
7076 focusWidget = QApplication.focusWidget() 6673 focusWidget = QApplication.focusWidget()
7077 if ( 6674 if focusWidget == e5App().getObject("Shell"):
7078 focusWidget == e5App().getObject("Shell") or
7079 focusWidget == self.quickFindtextCombo
7080 ):
7081 return 6675 return
7082 else: 6676 else:
7083 aw = self.activeWindow() 6677 aw = self.activeWindow()
7084 if aw: 6678 if aw:
7085 aw.newLineBelow() 6679 aw.newLineBelow()

eric ide

mercurial