279 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) |
279 self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) |
280 |
280 |
281 self.__textEdit = MiniScintilla(self) |
281 self.__textEdit = MiniScintilla(self) |
282 self.__textEdit.clearSearchIndicators = self.clearSearchIndicators |
282 self.__textEdit.clearSearchIndicators = self.clearSearchIndicators |
283 self.__textEdit.setSearchIndicator = self.setSearchIndicator |
283 self.__textEdit.setSearchIndicator = self.setSearchIndicator |
|
284 self.__textEdit.highlightSearchSelection = self.highlightSearchSelection |
|
285 self.__textEdit.clearSearchSelectionHighlight = ( |
|
286 self.clearSearchSelectionHighlight |
|
287 ) |
284 self.__textEdit.setUtf8(True) |
288 self.__textEdit.setUtf8(True) |
285 |
289 |
286 self.getCursorPosition = self.__textEdit.getCursorPosition |
290 self.getCursorPosition = self.__textEdit.getCursorPosition |
287 self.text = self.__textEdit.text |
291 self.text = self.__textEdit.text |
288 self.getZoom = self.__textEdit.getZoom |
292 self.getZoom = self.__textEdit.getZoom |
292 |
296 |
293 self.__curFile = filename |
297 self.__curFile = filename |
294 self.__lastLine = 0 |
298 self.__lastLine = 0 |
295 |
299 |
296 self.srHistory = {"search": [], "replace": []} |
300 self.srHistory = {"search": [], "replace": []} |
297 self.__searchWidget = SearchReplaceWidget(False, self, self) |
301 self.__searchReplaceWidget = SearchReplaceWidget(self, self) |
298 self.__replaceWidget = SearchReplaceWidget(True, self, self) |
|
299 |
302 |
300 self.__sourceOutline = EditorOutlineView(self, populate=False) |
303 self.__sourceOutline = EditorOutlineView(self, populate=False) |
301 self.__sourceOutline.setMaximumWidth( |
304 self.__sourceOutline.setMaximumWidth( |
302 Preferences.getEditor("SourceOutlineWidth") |
305 Preferences.getEditor("SourceOutlineWidth") |
303 ) |
306 ) |
310 |
313 |
311 centralWidget = QWidget() |
314 centralWidget = QWidget() |
312 layout = QVBoxLayout() |
315 layout = QVBoxLayout() |
313 layout.setContentsMargins(1, 1, 1, 1) |
316 layout.setContentsMargins(1, 1, 1, 1) |
314 layout.addLayout(hlayout) |
317 layout.addLayout(hlayout) |
315 layout.addWidget(self.__searchWidget) |
318 layout.addWidget(self.__searchReplaceWidget) |
316 layout.addWidget(self.__replaceWidget) |
|
317 centralWidget.setLayout(layout) |
319 centralWidget.setLayout(layout) |
318 self.setCentralWidget(centralWidget) |
320 self.setCentralWidget(centralWidget) |
319 self.__searchWidget.hide() |
321 self.__searchReplaceWidget.hide() |
320 self.__replaceWidget.hide() |
|
321 |
322 |
322 self.lexer_ = None |
323 self.lexer_ = None |
323 self.apiLanguage = "" |
324 self.apiLanguage = "" |
324 self.filetype = "" |
325 self.filetype = "" |
325 |
326 |
359 |
360 |
360 self.__textEdit.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
361 self.__textEdit.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
361 self.__textEdit.customContextMenuRequested.connect(self.__contextMenuRequested) |
362 self.__textEdit.customContextMenuRequested.connect(self.__contextMenuRequested) |
362 |
363 |
363 self.__textEdit.selectionChanged.connect( |
364 self.__textEdit.selectionChanged.connect( |
364 lambda: self.__searchWidget.selectionChanged(self.__textEdit) |
365 lambda: self.__searchReplaceWidget.selectionChanged(self.__textEdit) |
365 ) |
|
366 self.__textEdit.selectionChanged.connect( |
|
367 lambda: self.__replaceWidget.selectionChanged(self.__textEdit) |
|
368 ) |
366 ) |
369 |
367 |
370 if filename: |
368 if filename: |
371 self.__loadFile(filename, filetype) |
369 self.__loadFile(filename, filetype) |
372 else: |
370 else: |
2690 """<p>Replace the found occurrence of text in the current""" |
2688 """<p>Replace the found occurrence of text in the current""" |
2691 """ editor and search for the next one. The previously entered""" |
2689 """ editor and search for the next one. The previously entered""" |
2692 """ search text and options are reused.</p>""", |
2690 """ search text and options are reused.</p>""", |
2693 ) |
2691 ) |
2694 ) |
2692 ) |
2695 self.replaceAndSearchAct.triggered.connect(self.__replaceWidget.replaceSearch) |
2693 self.replaceAndSearchAct.triggered.connect( |
|
2694 self.__searchReplaceWidget.replaceSearch |
|
2695 ) |
2696 self.searchActions.append(self.replaceAndSearchAct) |
2696 self.searchActions.append(self.replaceAndSearchAct) |
2697 |
2697 |
2698 self.replaceSelectionAct = EricAction( |
2698 self.replaceSelectionAct = EricAction( |
2699 QCoreApplication.translate("ViewManager", "Replace Occurrence"), |
2699 QCoreApplication.translate("ViewManager", "Replace Occurrence"), |
2700 EricPixmapCache.getIcon("editReplace"), |
2700 EricPixmapCache.getIcon("editReplace"), |
2717 """<b>Replace Occurrence</b>""" |
2717 """<b>Replace Occurrence</b>""" |
2718 """<p>Replace the found occurrence of the search text in the""" |
2718 """<p>Replace the found occurrence of the search text in the""" |
2719 """ current editor.</p>""", |
2719 """ current editor.</p>""", |
2720 ) |
2720 ) |
2721 ) |
2721 ) |
2722 self.replaceSelectionAct.triggered.connect(self.__replaceWidget.replace) |
2722 self.replaceSelectionAct.triggered.connect(self.__searchReplaceWidget.replace) |
2723 self.searchActions.append(self.replaceSelectionAct) |
2723 self.searchActions.append(self.replaceSelectionAct) |
2724 |
2724 |
2725 self.replaceAllAct = EricAction( |
2725 self.replaceAllAct = EricAction( |
2726 QCoreApplication.translate("ViewManager", "Replace All"), |
2726 QCoreApplication.translate("ViewManager", "Replace All"), |
2727 EricPixmapCache.getIcon("editReplaceAll"), |
2727 EricPixmapCache.getIcon("editReplaceAll"), |
2744 """<b>Replace All</b>""" |
2744 """<b>Replace All</b>""" |
2745 """<p>Replace all occurrences of the search text in the current""" |
2745 """<p>Replace all occurrences of the search text in the current""" |
2746 """ editor.</p>""", |
2746 """ editor.</p>""", |
2747 ) |
2747 ) |
2748 ) |
2748 ) |
2749 self.replaceAllAct.triggered.connect(self.__replaceWidget.replaceAll) |
2749 self.replaceAllAct.triggered.connect(self.__searchReplaceWidget.replaceAll) |
2750 self.searchActions.append(self.replaceAllAct) |
2750 self.searchActions.append(self.replaceAllAct) |
2751 |
2751 |
2752 def __createViewActions(self): |
2752 def __createViewActions(self): |
2753 """ |
2753 """ |
2754 Private method to create the View actions. |
2754 Private method to create the View actions. |
3583 self.searchIndicator = QsciScintilla.INDIC_CONTAINER |
3583 self.searchIndicator = QsciScintilla.INDIC_CONTAINER |
3584 self.__textEdit.indicatorDefine( |
3584 self.__textEdit.indicatorDefine( |
3585 self.searchIndicator, |
3585 self.searchIndicator, |
3586 QsciScintilla.INDIC_BOX, |
3586 QsciScintilla.INDIC_BOX, |
3587 Preferences.getEditorColour("SearchMarkers"), |
3587 Preferences.getEditorColour("SearchMarkers"), |
|
3588 ) |
|
3589 |
|
3590 self.searchSelectionIndicator = QsciScintilla.INDIC_CONTAINER + 1 |
|
3591 self.__textEdit.indicatorDefine( |
|
3592 self.searchSelectionIndicator, |
|
3593 QsciScintilla.INDIC_FULLBOX, |
|
3594 Preferences.getEditorColour("SearchSelectionMarker"), |
3588 ) |
3595 ) |
3589 |
3596 |
3590 self.__textEdit.setCursorFlashTime(QApplication.cursorFlashTime()) |
3597 self.__textEdit.setCursorFlashTime(QApplication.cursorFlashTime()) |
3591 |
3598 |
3592 if Preferences.getEditor("OverrideEditAreaColours"): |
3599 if Preferences.getEditor("OverrideEditAreaColours"): |
4140 |
4147 |
4141 def showSearchWidget(self): |
4148 def showSearchWidget(self): |
4142 """ |
4149 """ |
4143 Public method to show the search widget. |
4150 Public method to show the search widget. |
4144 """ |
4151 """ |
4145 self.__replaceWidget.hide() |
4152 self.__searchReplaceWidget.show(text=self.textForFind(), replaceMode=False) |
4146 self.__searchWidget.show() |
|
4147 self.__searchWidget.show(self.textForFind()) |
|
4148 |
4153 |
4149 def __searchNext(self): |
4154 def __searchNext(self): |
4150 """ |
4155 """ |
4151 Private slot to handle the search next action. |
4156 Private slot to handle the search next action. |
4152 """ |
4157 """ |
4153 if self.__replaceWidget.isVisible(): |
4158 self.__searchReplaceWidget.findNext() |
4154 self.__replaceWidget.findNext() |
|
4155 else: |
|
4156 self.__searchWidget.findNext() |
|
4157 |
4159 |
4158 def __searchPrev(self): |
4160 def __searchPrev(self): |
4159 """ |
4161 """ |
4160 Private slot to handle the search previous action. |
4162 Private slot to handle the search previous action. |
4161 """ |
4163 """ |
4162 if self.__replaceWidget.isVisible(): |
4164 self.__searchReplaceWidget.findPrev() |
4163 self.__replaceWidget.findPrev() |
|
4164 else: |
|
4165 self.__searchWidget.findPrev() |
|
4166 |
4165 |
4167 def showReplaceWidget(self): |
4166 def showReplaceWidget(self): |
4168 """ |
4167 """ |
4169 Public method to show the replace widget. |
4168 Public method to show the replace widget. |
4170 """ |
4169 """ |
4171 self.__searchWidget.hide() |
4170 self.__searchReplaceWidget.show(text=self.textForFind(), replaceMode=True) |
4172 self.__replaceWidget.show(self.textForFind()) |
|
4173 |
4171 |
4174 def __searchClearMarkers(self): |
4172 def __searchClearMarkers(self): |
4175 """ |
4173 """ |
4176 Private method to clear the search markers of the active window. |
4174 Private method to clear the search markers of the active window. |
4177 """ |
4175 """ |
4198 """ |
4196 """ |
4199 Public method to clear all search indicators. |
4197 Public method to clear all search indicators. |
4200 """ |
4198 """ |
4201 self.__textEdit.clearAllIndicators(self.searchIndicator) |
4199 self.__textEdit.clearAllIndicators(self.searchIndicator) |
4202 self.__markedText = "" |
4200 self.__markedText = "" |
|
4201 |
|
4202 def highlightSearchSelection(self, startLine, startIndex, endLine, endIndex): |
|
4203 """ |
|
4204 Public method to set a highlight for the selection at the start of a search. |
|
4205 |
|
4206 @param startLine line of the selection start |
|
4207 @type int |
|
4208 @param startIndex index of the selection start |
|
4209 @type int |
|
4210 @param endLine line of the selection end |
|
4211 @type int |
|
4212 @param endIndex index of the selection end |
|
4213 @type int |
|
4214 """ |
|
4215 self.__textEdit.setIndicator( |
|
4216 self.searchSelectionIndicator, startLine, startIndex, endLine, endIndex |
|
4217 ) |
|
4218 |
|
4219 def clearSearchSelectionHighlight(self): |
|
4220 """ |
|
4221 Public method to clear all highlights. |
|
4222 """ |
|
4223 self.__textEdit.clearAllIndicators(self.searchSelectionIndicator) |
4203 |
4224 |
4204 def __markOccurrences(self): |
4225 def __markOccurrences(self): |
4205 """ |
4226 """ |
4206 Private method to mark all occurrences of the current word. |
4227 Private method to mark all occurrences of the current word. |
4207 """ |
4228 """ |