當前位置: 首頁>>代碼示例>>Python>>正文


Python State.get_as_encoded_address方法代碼示例

本文整理匯總了Python中Vintageous.state.State.get_as_encoded_address方法的典型用法代碼示例。如果您正苦於以下問題:Python State.get_as_encoded_address方法的具體用法?Python State.get_as_encoded_address怎麽用?Python State.get_as_encoded_address使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Vintageous.state.State的用法示例。


在下文中一共展示了State.get_as_encoded_address方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MarksTests

# 需要導入模塊: from Vintageous.state import State [as 別名]
# 或者: from Vintageous.state.State import get_as_encoded_address [as 別名]
class MarksTests(ViewTest):
    def setUp(self):
        super().setUp()
        marks._MARKS = {}
        self.view.sel().clear()
        self.view.sel().add(sublime.Region(0, 0))
        self.marks = State(self.view).marks

    def testCanSetMark(self):
        self.marks.add('a', self.view)
        expected_win, expected_view, expected_region = (self.view.window(), self.view, (0, 0))
        actual_win, actual_view, actual_region = marks._MARKS['a']
        self.assertEqual((actual_win.id(), actual_view.view_id, actual_region),
                         (expected_win.id(), expected_view.view_id, expected_region))

    def testCanRetrieveMarkInTheCurrentBufferAsTuple(self):
        self.marks.add('a', self.view)
        # The caret's at the beginning of the buffer.
        self.assertEqual(self.marks.get_as_encoded_address('a'), sublime.Region(0, 0))

    def testCanRetrieveMarkInTheCurrentBufferAsTuple2(self):
        set_text(self.view, ''.join(('foo bar\n') * 10))
        self.view.sel().clear()
        self.view.sel().add(sublime.Region(30, 30))
        self.marks.add('a', self.view)
        self.assertEqual(self.marks.get_as_encoded_address('a'), sublime.Region(24, 24))

    def testCanRetrieveMarkInADifferentBufferAsEncodedMark(self):
        view = View(id_=self.view.view_id + 1, fname=r'C:\foo.txt')

        marks._MARKS['a'] = (Window(), view, (0, 0))
        expected = "{0}:{1}".format(r'C:\foo.txt', "0:0")
        self.assertEqual(self.marks.get_as_encoded_address('a'), expected)

    def testCanRetrieveMarkInAnUntitledBufferAsEncodedMark(self):
        view = View(id_=self.view.view_id + 1, fname='', buffer_id=999)

        marks._MARKS['a'] = (Window(), view, (0, 0))
        expected = "<untitled {0}>:{1}".format(999, "0:0")
        self.assertEqual(self.marks.get_as_encoded_address('a'), expected)

    def testCanRetrieveSingleQuoteMark(self):
        location = self.marks.get_as_encoded_address("'")
        self.assertEqual(location, '<command _vi_double_single_quote>')
開發者ID:DamnWidget,項目名稱:Vintageous,代碼行數:46,代碼來源:test_marks.py


注:本文中的Vintageous.state.State.get_as_encoded_address方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。