eric6/QScintilla/Editor.py

changeset 8002
6002378278c9
parent 8000
47b15df088e4
child 8004
38d359e2ded7
equal deleted inserted replaced
8001:3b33b7d493ff 8002:6002378278c9
8689 Private method to test, if the user might want to insert a docstring. 8689 Private method to test, if the user might want to insert a docstring.
8690 8690
8691 @param cursorPosition current cursor position (line and column) 8691 @param cursorPosition current cursor position (line and column)
8692 @type tuple of (int, int) 8692 @type tuple of (int, int)
8693 """ 8693 """
8694 if self.getDocstringGenerator().isDocstringIntro(cursorPosition): 8694 if (
8695 lineText = self.text(cursorPosition[0]) 8695 Preferences.getEditor("DocstringAutoGenerate") and
8696 self.getDocstringGenerator().isDocstringIntro(cursorPosition)
8697 ):
8698 lineText2Cursor = self.text(cursorPosition[0])[:cursorPosition[1]]
8696 8699
8697 QTimer.singleShot( 8700 QTimer.singleShot(
8698 300, 8701 300,
8699 lambda: self.__popupDocstringMenu(lineText, cursorPosition) 8702 lambda: self.__popupDocstringMenu(lineText2Cursor,
8703 cursorPosition)
8700 ) 8704 )
8701 8705
8702 def __popupDocstringMenu(self, lastLineText, lastCursorPosition): 8706 def __popupDocstringMenu(self, lastLineText, lastCursorPosition):
8703 """ 8707 """
8704 Private slot to pop up a menu asking the user, if a docstring should be 8708 Private slot to pop up a menu asking the user, if a docstring should be
8712 """ 8716 """
8713 cursorPosition = self.getCursorPosition() 8717 cursorPosition = self.getCursorPosition()
8714 if lastCursorPosition != cursorPosition: 8718 if lastCursorPosition != cursorPosition:
8715 return 8719 return
8716 8720
8717 if self.text(cursorPosition[0]) != lastLineText: 8721 if self.text(cursorPosition[0])[:cursorPosition[1]] != lastLineText:
8718 return 8722 return
8719 8723
8720 generator = self.getDocstringGenerator() 8724 generator = self.getDocstringGenerator()
8721 if generator.hasFunctionDefinition(cursorPosition): 8725 if generator.hasFunctionDefinition(cursorPosition):
8722 from .DocstringGenerator.BaseDocstringGenerator import ( 8726 from .DocstringGenerator.BaseDocstringGenerator import (

eric ide

mercurial