Esempio n. 1
0
 def __init__(self):
     """Constructor."""
     self.var = OrderedDict()
     self.current = None
     self.hilite = False
     self.dirty = False
Esempio n. 2
0
 def __init__(self):
     """Constructor."""
     self.var = OrderedDict()
     self.current = None
     self.hilite = False
     self.dirty = False
Esempio n. 3
0
class Varobj(object):
    """The Simple varobj class.

    Instance attributes:
        var: dict
            dictionary of {name:value}, name: str, value: int
        current: str
            the currently hilited name
        hilite: boolean
            when True, current is hilited
        dirty: boolean
            True when there is a change in the varobj instance

    """

    def __init__(self):
        """Constructor."""
        self.var = OrderedDict()
        self.current = None
        self.hilite = False
        self.dirty = False

    def add(self, name):
        """Add a varobj."""
        self.var[name] = 1
        self.current = name
        self.hilite = True
        self.dirty = True

    def _next(self):
        """Return the next candidate for hilite."""
        size = len(self.var)
        if size == 0:
            return None
        l = self.var.keys()
        try:
            i = (l.index(self.current) + 1) % size
            return l[i]
        except ValueError:
            return l[0]

    def next(self):
        """Set next name to hilite and increment its value."""
        self.current = self._next()
        if self.current is not None:
            self.var[self.current] += 1
            self.hilite = True
            self.dirty = True

    def delete(self, name):
        """Delete a varobj."""
        try:
            del self.var[name]
            self.dirty = True
            if name == self.current:
                self.current = None
                self.hilite = False
        except KeyError:
            return False
        return True

    def stale(self):
        """Make all varobjs stale."""
        self.hilite = False

    def clear(self):
        """Clear all varobjs."""
        if self.var:
            self.dirty = True
        self.var.clear()
        self.current = None
        self.hilite = False

    def __str__(self):
        """Return a string representation of the varobj."""
        varstr = ''
        for (name, value) in self.var.iteritems():
            if name == self.current and self.hilite:
                hilite = '*'
            else:
                hilite = '='
            varstr += '%12s ={%s} %d\n' % (name, hilite, value)
        self.dirty = False
        return varstr
Esempio n. 4
0
class Varobj(object):
    """The Simple varobj class.

    Instance attributes:
        var: dict
            dictionary of {name:value}, name: str, value: int
        current: str
            the currently hilited name
        hilite: boolean
            when True, current is hilited
        dirty: boolean
            True when there is a change in the varobj instance

    """
    def __init__(self):
        """Constructor."""
        self.var = OrderedDict()
        self.current = None
        self.hilite = False
        self.dirty = False

    def add(self, name):
        """Add a varobj."""
        self.var[name] = 1
        self.current = name
        self.hilite = True
        self.dirty = True

    def _next(self):
        """Return the next candidate for hilite."""
        size = len(self.var)
        if size == 0:
            return None
        l = self.var.keys()
        try:
            i = (l.index(self.current) + 1) % size
            return l[i]
        except ValueError:
            return l[0]

    def next(self):
        """Set next name to hilite and increment its value."""
        self.current = self._next()
        if self.current is not None:
            self.var[self.current] += 1
            self.hilite = True
            self.dirty = True

    def delete(self, name):
        """Delete a varobj."""
        try:
            del self.var[name]
            self.dirty = True
            if name == self.current:
                self.current = None
                self.hilite = False
        except KeyError:
            return False
        return True

    def stale(self):
        """Make all varobjs stale."""
        self.hilite = False

    def clear(self):
        """Clear all varobjs."""
        if self.var:
            self.dirty = True
        self.var.clear()
        self.current = None
        self.hilite = False

    def __str__(self):
        """Return a string representation of the varobj."""
        varstr = ''
        for (name, value) in self.var.iteritems():
            if name == self.current and self.hilite:
                hilite = '*'
            else:
                hilite = '='
            varstr += '%12s ={%s} %d\n' % (name, hilite, value)
        self.dirty = False
        return varstr