Yuya Nishihara committed 86653e6

annotate: show annotate menu even if no character exists under mouse cursor

lineAt() strictly checks the existence of character, but we want more relaxed
version. It can be achieved by using SCI_POSITIONFROMPOINT in place of

Tested compatibility with Ubuntu 10.10.

Comments (0)

Files changed (2)


     def menuRequest(self, point):
         menu = self.sci.createStandardContextMenu()
-        line = self.sci.lineAt(point)
+        line = self.sci.lineNearPoint(point)
         point = self.sci.viewport().mapToGlobal(point)
         selection = self.sci.selectedText()


             tabs = findTabIndentsInLines(hglib.fromunicode(self.text()))
         super(Scintilla, self).setIndentationsUseTabs(tabs)
+    def lineNearPoint(self, point):
+        """Return the closest line to the pixel position; similar to lineAt(),
+        but returns valid line number even if no character fount at point"""
+        # lineAt() uses the strict request, SCI_POSITIONFROMPOINTCLOSE
+        chpos = self.SendScintilla(self.SCI_POSITIONFROMPOINT,
+                                   point.x(), point.y())
+        return self.SendScintilla(self.SCI_LINEFROMPOSITION, chpos)
     # compability mode with QScintilla from Ubuntu 10.04
     if not hasattr(QsciScintilla, 'HiddenIndicator'):
         HiddenIndicator = QsciScintilla.INDIC_HIDDEN
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.