428 self.addClone(editor) |
428 self.addClone(editor) |
429 editor.addClone(self) |
429 editor.addClone(self) |
430 |
430 |
431 self.gotoLine(1) |
431 self.gotoLine(1) |
432 |
432 |
|
433 # connect the mouse hover signals |
|
434 self.SCN_DWELLSTART.connect(self.__showMouseHoverHelp) |
|
435 self.SCN_DWELLEND.connect(self.__cancelMouseHoverHelp) |
|
436 self.__mouseHoverHelp = None |
|
437 |
433 # set the text display again |
438 # set the text display again |
434 self.__setTextDisplay() |
439 self.__setTextDisplay() |
435 |
440 |
436 # set the auto-completion function |
441 # set the auto-completion function |
437 self.__acContext = True |
442 self.__acContext = True |
4690 self.setColor(Preferences.getEditorColour("EditAreaForeground")) |
4695 self.setColor(Preferences.getEditorColour("EditAreaForeground")) |
4691 self.setPaper(Preferences.getEditorColour("EditAreaBackground")) |
4696 self.setPaper(Preferences.getEditorColour("EditAreaBackground")) |
4692 |
4697 |
4693 self.setVirtualSpaceOptions( |
4698 self.setVirtualSpaceOptions( |
4694 Preferences.getEditor("VirtualSpaceOptions")) |
4699 Preferences.getEditor("VirtualSpaceOptions")) |
|
4700 |
|
4701 if Preferences.getEditor("MouseHoverHelp"): |
|
4702 self.SendScintilla(QsciScintilla.SCI_SETMOUSEDWELLTIME, |
|
4703 Preferences.getEditor("MouseHoverTimeout")) |
|
4704 else: |
|
4705 self.SendScintilla(QsciScintilla.SCI_SETMOUSEDWELLTIME, |
|
4706 QsciScintilla.SC_TIME_FOREVER) |
4695 |
4707 |
4696 # to avoid errors due to line endings by pasting |
4708 # to avoid errors due to line endings by pasting |
4697 self.SendScintilla(QsciScintilla.SCI_SETPASTECONVERTENDINGS, True) |
4709 self.SendScintilla(QsciScintilla.SCI_SETPASTECONVERTENDINGS, True) |
4698 |
4710 |
4699 self.__markerMap.setEnabled(True) |
4711 self.__markerMap.setEnabled(True) |
8826 fromStart=False) |
8838 fromStart=False) |
8827 ) |
8839 ) |
8828 docstringMenu.setActiveAction(act) |
8840 docstringMenu.setActiveAction(act) |
8829 docstringMenu.popup( |
8841 docstringMenu.popup( |
8830 self.mapToGlobal(self.getGlobalCursorPosition())) |
8842 self.mapToGlobal(self.getGlobalCursorPosition())) |
|
8843 |
|
8844 ####################################################################### |
|
8845 ## Methods implementing the mouse hover help interface |
|
8846 ####################################################################### |
|
8847 |
|
8848 @pyqtSlot(int, int, int) |
|
8849 def __showMouseHoverHelp(self, pos, x, y): |
|
8850 """ |
|
8851 Private slot showing code information about the symbol under the |
|
8852 cursor. |
|
8853 |
|
8854 @param pos mouse position into the document |
|
8855 @type int |
|
8856 @param x x-value of mouse screen position |
|
8857 @type int |
|
8858 @param y y-value of mouse screen position |
|
8859 @type int |
|
8860 """ |
|
8861 if self.__mouseHoverHelp is not None and pos >= 0: |
|
8862 line, index = self.lineIndexFromPosition(x) |
|
8863 if index > 0: |
|
8864 self.__mouseHoverHelp(self, line, index) |
|
8865 else: |
|
8866 self.__cancelMouseHoverHelp() |
|
8867 else: |
|
8868 self.__cancelMouseHoverHelp() |
|
8869 |
|
8870 def __cancelMouseHoverHelp(self): |
|
8871 """ |
|
8872 Private slot cancelling the display of mouse hover help. |
|
8873 """ |
|
8874 self.SendScintilla(QsciScintilla.SCI_CALLTIPCANCEL) |
|
8875 |
|
8876 def registerMouseHoverHelpFunction(self, func): |
|
8877 """ |
|
8878 Public method to register a mouse hover help function. |
|
8879 |
|
8880 Note: Only one plugin should provide this function. Otherwise |
|
8881 the last one wins. |
|
8882 |
|
8883 @param func function accepting a reference to the calling editor and |
|
8884 the line and column position (zero based each) |
|
8885 @type func |
|
8886 """ |
|
8887 self.__mouseHoverHelp = func |
|
8888 |
|
8889 def unregisterMouseHoverHelpFunction(self, func): |
|
8890 """ |
|
8891 Public method to unregister a mouse hover help function. |
|
8892 |
|
8893 @param func function accepting a reference to the calling editor and |
|
8894 the line and column position (zero based each) |
|
8895 @type func |
|
8896 """ |
|
8897 if self.__mouseHoverHelp is func: |
|
8898 self.__mouseHoverHelp = None |
|
8899 |
|
8900 def showMouseHoverHelpData(self, line, index, data): |
|
8901 """ |
|
8902 Public method to show the mouse hover help data. |
|
8903 |
|
8904 @param line line of mouse cursor position |
|
8905 @type int |
|
8906 @param index column of mouse cursor position |
|
8907 @type TYPE |
|
8908 @param data information text to be shown |
|
8909 @type str |
|
8910 """ |
|
8911 if data: |
|
8912 pos = self.positionFromLineIndex(line, index) |
|
8913 self.SendScintilla(QsciScintilla.SCI_CALLTIPSHOW, |
|
8914 pos, data) |
|
8915 else: |
|
8916 self.__cancelMouseHoverHelp() |