本文整理匯總了Python中Vintageous.state.State.get_selected_text方法的典型用法代碼示例。如果您正苦於以下問題:Python State.get_selected_text方法的具體用法?Python State.get_selected_text怎麽用?Python State.get_selected_text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Vintageous.state.State
的用法示例。
在下文中一共展示了State.get_selected_text方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Test_get_selected_text
# 需要導入模塊: from Vintageous.state import State [as 別名]
# 或者: from Vintageous.state.State import get_selected_text [as 別名]
class Test_get_selected_text(ViewTest):
def setUp(self):
super().setUp()
sublime.set_clipboard('')
registers._REGISTER_DATA = {}
self.view.settings().erase('vintage')
self.view.settings().erase('vintageous_use_sys_clipboard')
self.regs = State(self.view).registers
self.regs.view = mock.Mock()
def testExtractsSubstrings(self):
self.regs.view.sel.return_value = [10, 20, 30]
class vi_cmd_data:
_synthetize_new_line_at_eof = False
_yanks_linewise = False
self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(self.regs.view.substr.call_count, 3)
def testReturnsFragments(self):
self.regs.view.sel.return_value = [10, 20, 30]
self.regs.view.substr.side_effect = lambda x: x
class vi_cmd_data:
_synthetize_new_line_at_eof = False
_yanks_linewise = False
rv = self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(rv, [10, 20, 30])
def testCanSynthetizeNewLineAtEof(self):
self.regs.view.substr.return_value = "AAA"
self.regs.view.sel.return_value = [sublime.Region(10, 10), sublime.Region(10, 10)]
self.regs.view.size.return_value = 0
class vi_cmd_data:
_synthetize_new_line_at_eof = True
_yanks_linewise = False
rv = self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(rv, ["AAA", "AAA\n"])
def testDoesntSynthetizeNewLineAtEofIfNotNeeded(self):
self.regs.view.substr.return_value = "AAA\n"
self.regs.view.sel.return_value = [sublime.Region(10, 10), sublime.Region(10, 10)]
self.regs.view.size.return_value = 0
class vi_cmd_data:
_synthetize_new_line_at_eof = True
_yanks_linewise = False
rv = self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(rv, ["AAA\n", "AAA\n"])
def testDoesntSynthetizeNewLineAtEofIfNotAtEof(self):
self.regs.view.substr.return_value = "AAA"
self.regs.view.sel.return_value = [sublime.Region(10, 10), sublime.Region(10, 10)]
self.regs.view.size.return_value = 100
class vi_cmd_data:
_synthetize_new_line_at_eof = True
_yanks_linewise = False
rv = self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(rv, ["AAA", "AAA"])
def testCanYankLinewise(self):
self.regs.view.substr.return_value = "AAA"
self.regs.view.sel.return_value = [sublime.Region(10, 10), sublime.Region(10, 10)]
class vi_cmd_data:
_synthetize_new_line_at_eof = False
_yanks_linewise = True
rv = self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(rv, ["AAA\n", "AAA\n"])
def testDoesNotYankLinewiseIfNonEmptyStringFollowedByNewLine(self):
self.regs.view.substr.return_value = "AAA\n"
self.regs.view.sel.return_value = [sublime.Region(10, 10), sublime.Region(10, 10)]
class vi_cmd_data:
_synthetize_new_line_at_eof = False
_yanks_linewise = True
rv = self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(rv, ["AAA\n", "AAA\n"])
def testYankLinewiseIfEmptyStringFollowedByNewLine(self):
self.regs.view.substr.return_value = "\n"
self.regs.view.sel.return_value = [sublime.Region(10, 10), sublime.Region(10, 10)]
class vi_cmd_data:
_synthetize_new_line_at_eof = False
_yanks_linewise = True
rv = self.regs.get_selected_text(vi_cmd_data)
self.assertEqual(rv, ["\n\n", "\n\n"])
#.........這裏部分代碼省略.........