File: mirror.py

package info (click to toggle)
vim-ultisnips 3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,924 kB
  • sloc: python: 8,353; sh: 64; makefile: 38
file content (35 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
# encoding: utf-8

"""A Mirror object contains the same text as its related tabstop."""

from UltiSnips.text_objects.base import NoneditableTextObject


class Mirror(NoneditableTextObject):

    """See module docstring."""

    def __init__(self, parent, tabstop, token):
        NoneditableTextObject.__init__(self, parent, token)
        self._ts = tabstop

    def _update(self, done, buf):
        if self._ts.is_killed:
            self.overwrite(buf, "")
            self._parent._del_child(self)  # pylint:disable=protected-access
            return True

        if self._ts not in done:
            return False

        self.overwrite(buf, self._get_text())
        return True

    def _get_text(self):
        """Returns the text used for mirroring.

        Overwritten by base classes.

        """
        return self._ts.current_text