本文整理汇总了Python中pyqode.core.api.utils.TextHelper.current_line_text方法的典型用法代码示例。如果您正苦于以下问题:Python TextHelper.current_line_text方法的具体用法?Python TextHelper.current_line_text怎么用?Python TextHelper.current_line_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.utils.TextHelper
的用法示例。
在下文中一共展示了TextHelper.current_line_text方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __swapLine
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_line_text [as 别名]
def __swapLine(self, up: bool):
helper = TextHelper(self)
text = helper.current_line_text()
line_nbr = helper.current_line_nbr()
if up:
swap_line_nbr = line_nbr - 1
else:
swap_line_nbr = line_nbr + 1
swap_text = helper.line_text(swap_line_nbr)
if (swap_line_nbr < helper.line_count()
and line_nbr < helper.line_count()):
helper.set_line_text(line_nbr, swap_text)
helper.set_line_text(swap_line_nbr, text)
示例2: cut
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_line_text [as 别名]
def cut(self):
tc = self.textCursor()
helper = TextHelper(self)
tc.beginEditBlock()
no_selection = False
if not helper.current_line_text().strip():
tc.deleteChar()
else:
if not self.textCursor().hasSelection():
no_selection = True
TextHelper(self).select_whole_line()
super(CodeEdit, self).cut()
if no_selection:
tc.deleteChar()
tc.endEditBlock()
self.setTextCursor(tc)
示例3: cut
# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_line_text [as 别名]
def cut(self):
"""
Cuts the selected text or the whole line if no text was selected.
"""
tc = self.textCursor()
helper = TextHelper(self)
tc.beginEditBlock()
no_selection = False
sText = tc.selection().toPlainText()
if not helper.current_line_text() and sText.count("\n") > 1:
tc.deleteChar()
else:
if not self.textCursor().hasSelection():
no_selection = True
TextHelper(self).select_whole_line()
super(CodeEdit, self).cut()
if no_selection:
tc.deleteChar()
tc.endEditBlock()
self.setTextCursor(tc)