eric7/QScintilla/QsciScintillaCompat.py

branch
eric7
changeset 8489
45af30c5561d
parent 8481
02865597d820
child 8581
a6c893c8b7af
equal deleted inserted replaced
8488:b9168b90f830 8489:45af30c5561d
9 9
10 import contextlib 10 import contextlib
11 11
12 from PyQt6.QtCore import pyqtSignal, Qt, QPoint 12 from PyQt6.QtCore import pyqtSignal, Qt, QPoint
13 from PyQt6.QtGui import QPalette, QColor 13 from PyQt6.QtGui import QPalette, QColor
14 from PyQt6.QtWidgets import QApplication 14 from PyQt6.QtWidgets import QApplication, QListWidget
15 from PyQt6.Qsci import ( 15 from PyQt6.Qsci import (
16 QsciScintillaBase, QsciScintilla, 16 QsciScintillaBase, QsciScintilla,
17 QSCINTILLA_VERSION as QSCIQSCINTILLA_VERSION 17 QSCINTILLA_VERSION as QSCIQSCINTILLA_VERSION
18 ) 18 )
19 19
1508 1508
1509 ########################################################################### 1509 ###########################################################################
1510 ## replacements for buggy methods 1510 ## replacements for buggy methods
1511 ########################################################################### 1511 ###########################################################################
1512 1512
1513 def showUserList(self, listId, lst):
1514 """
1515 Public method to show a user supplied list.
1516
1517 @param listId id of the list (integer)
1518 @param lst list to be show (list of strings)
1519 """
1520 if listId <= 0:
1521 return
1522
1523 # Setup seperator for user lists
1524 self.SendScintilla(
1525 QsciScintilla.SCI_AUTOCSETSEPARATOR, ord(self.UserSeparator))
1526 self.SendScintilla(
1527 QsciScintilla.SCI_USERLISTSHOW, listId,
1528 self._encodeString(self.UserSeparator.join(lst)))
1529
1530 self.updateUserListSize()
1531
1532 def autoCompleteFromDocument(self):
1533 """
1534 Public method to resize list box after creation.
1535 """
1536 super().autoCompleteFromDocument()
1537 self.updateUserListSize()
1538
1539 def autoCompleteFromAPIs(self):
1540 """
1541 Public method to resize list box after creation.
1542 """
1543 super().autoCompleteFromAPIs()
1544 self.updateUserListSize()
1545
1546 def autoCompleteFromAll(self):
1547 """
1548 Public method to resize list box after creation.
1549 """
1550 super().autoCompleteFromAll()
1551 self.updateUserListSize()
1552
1553 ###########################################################################
1554 ## work-around for buggy behavior
1555 ###########################################################################
1556
1557 def updateUserListSize(self):
1558 """
1559 Public method to resize the completion list to fit with contents.
1560 """
1561 children = self.findChildren(QListWidget)
1562 if children:
1563 userListWidget = children[-1]
1564 hScrollbar = userListWidget.horizontalScrollBar()
1565 if hScrollbar.isVisible():
1566 hScrollbarHeight = hScrollbar.sizeHint().height()
1567
1568 geom = userListWidget.geometry()
1569 geom.setHeight(geom.height() + hScrollbarHeight)
1570
1571 charPos = self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
1572 currentYPos = self.SendScintilla(
1573 QsciScintilla.SCI_POINTYFROMPOSITION, 0, charPos)
1574 if geom.y() < currentYPos:
1575 geom.setY(geom.y() - hScrollbarHeight)
1576 moveY = True
1577 else:
1578 moveY = False
1579
1580 userListWidget.setGeometry(geom)
1581 if moveY:
1582 userListWidget.move(geom.x(), geom.y() - hScrollbarHeight)
1583
1513 def __completionListSelected(self, listId, txt): 1584 def __completionListSelected(self, listId, txt):
1514 """ 1585 """
1515 Private slot to handle the selection from the completion list. 1586 Private slot to handle the selection from the completion list.
1516 1587
1517 Note: This works around an issue of some window managers taking 1588 Note: This works around an issue of some window managers taking

eric ide

mercurial