Merge branch 'dev_refactor' of gitee.com:py2cn/pyminer into dev_refactor

This commit is contained in:
hzy15610046011 2021-08-21 11:58:50 +08:00
commit 7ddd341885
2 changed files with 8 additions and 6 deletions

View File

@ -8,7 +8,7 @@ from PySide2.QtCore import Qt, SignalInstance, Signal
from PySide2.QtGui import QIcon, QPixmap, QKeyEvent
from PySide2.QtWidgets import QTableWidget, QHeaderView, QTableWidgetItem
from ...utils.base_object import CodeEditorBaseObject
from ...utils.base_object import CodeEditorBaseWidget
if TYPE_CHECKING:
from jedi.api.classes import Completion as CompletionResult
@ -18,7 +18,7 @@ logger = logging.getLogger('code_editor.auto_complete_dropdown.base')
logger.setLevel(logging.DEBUG)
class BaseAutoCompleteDropdownWidget(CodeEditorBaseObject, QTableWidget):
class BaseAutoCompleteDropdownWidget(CodeEditorBaseWidget, QTableWidget):
ROLE_NAME = 15
ROLE_TYPE = 16
ROLE_COMPLETE = 17
@ -135,3 +135,6 @@ class BaseAutoCompleteDropdownWidget(CodeEditorBaseObject, QTableWidget):
def get_text(self, row: int) -> str:
return self.item(row, 0).text()
def set_position(self, x: int, y: int):
self.setGeometry(x, y, self.sizeHint().width(), self.sizeHint().height())

View File

@ -357,10 +357,12 @@ class PMBaseCodeEdit(CodeEditorBaseWidget, QPlainTextEdit):
self.autocompletion_dropdown.hide_autocomp()
def update_handler_code(self):
"""将编辑器中的状态保存至analyzer"""
cursor = self.textCursor()
self.handler.feed(self.code, cursor.position(), (cursor.selectionStart(), cursor.selectionEnd()))
def update_from_analyzer(self, analyzer: 'BaseAnalyzer'):
"""将一个analyzer的状态写回至编辑器"""
self.code = analyzer.code
cursor = self.textCursor()
cursor.setPosition(analyzer.cursor)
@ -380,10 +382,7 @@ class PMBaseCodeEdit(CodeEditorBaseWidget, QPlainTextEdit):
# 代码提示
cursor_pos = self.cursorRect()
self.autocompletion_dropdown.setGeometry(
cursor_pos.x() + 5, cursor_pos.y() + 20,
self.autocompletion_dropdown.sizeHint().width(),
self.autocompletion_dropdown.sizeHint().height())
self.autocompletion_dropdown.set_position(cursor_pos.x() + 5, cursor_pos.y() + 20)
self._request_autocomp()
def _insert_autocomp(self, event: QModelIndex = None):