コード例 #1
0
ファイル: lineeditor.py プロジェクト: Aumnren/evennia
    def display_buffer(self, buf=None, offset=0, linenums=True):
        """
        This displays the line editor buffer, or selected parts of it.

        If buf is set and is not the full buffer, offset should define
        the starting line number, to get the linenum display right.
        """
        if buf == None:
            buf = self.buffer
        if utils.is_iter(buf):
            buf = "\n".join(buf)

        lines = buf.split('\n')
        nlines = len(lines)
        nwords = len(buf.split())
        nchars = len(buf)

        sep = self.sep
        header = "{n" + sep * 10 + "Line Editor [%s]" % self.key + sep * (78-25-len(self.key))
        footer = "{n" + sep * 10 + "[l:%02i w:%03i c:%04i]" % (nlines, nwords, nchars) + sep * 12 + "(:h for help)" + sep * 23
        if linenums:
            main = "\n".join("{b%02i|{n %s" % (iline + 1 + offset, line) for iline, line in enumerate(lines))
        else:
            main = "\n".join(lines)
        string = "%s\n%s\n%s" % (header, main, footer)
        return string
コード例 #2
0
    def display_buffer(self, buf=None, offset=0, linenums=True):
        """
        This displays the line editor buffer, or selected parts of it.

        If buf is set and is not the full buffer, offset should define
        the starting line number, to get the linenum display right.
        """
        if buf == None:
            buf = self.buffer
        if utils.is_iter(buf):
            buf = "\n".join(buf)

        lines = buf.split('\n')
        nlines = len(lines)
        nwords = len(buf.split())
        nchars = len(buf)

        sep = self.sep
        header = "{n" + sep * 10 + "Line Editor [%s]" % self.key + sep * (
            78 - 25 - len(self.key))
        footer = "{n" + sep * 10 + "[l:%02i w:%03i c:%04i]" % (
            nlines, nwords, nchars) + sep * 12 + "(:h for help)" + sep * 23
        if linenums:
            main = "\n".join("{b%02i|{n %s" % (iline + 1 + offset, line)
                             for iline, line in enumerate(lines))
        else:
            main = "\n".join(lines)
        string = "%s\n%s\n%s" % (header, main, footer)
        return string
コード例 #3
0
ファイル: lineeditor.py プロジェクト: Aumnren/evennia
    def update_buffer(self, buf):
        """
        This should be called when the buffer has been changed somehow.
        It will handle unsaved flag and undo updating.
        """
        if utils.is_iter(buf):
            buf = "\n".join(buf)

        if buf != self.buffer:
            self.buffer = buf
            self.update_undo()
            self.unsaved = True
コード例 #4
0
    def update_buffer(self, buf):
        """
        This should be called when the buffer has been changed somehow.
        It will handle unsaved flag and undo updating.
        """
        if utils.is_iter(buf):
            buf = "\n".join(buf)

        if buf != self.buffer:
            self.buffer = buf
            self.update_undo()
            self.unsaved = True
コード例 #5
0
ファイル: menusystem.py プロジェクト: OthersGames/asylum-jam
    def __init__(self, caller, nodes=None, startnode="START", endnode="END", exec_end="look"):
        """
        We specify startnode/endnode so that the system knows where to
        enter and where to exit the menu tree. If nodes is given, it
        shuld be a list of valid node objects to add to the tree.

        exec_end - if not None, will execute the given command string
                   directly after the menu system has been exited.
        """
        self.tree = {}
        self.startnode = startnode
        self.endnode = endnode
        self.exec_end = exec_end
        self.caller = caller
        if nodes and utils.is_iter(nodes):
            for node in nodes:
                self.add(node)
コード例 #6
0
    def __init__(self, caller, nodes=None,
                 startnode="START", endnode="END", exec_end="look"):
        """
        We specify startnode/endnode so that the system knows where to
        enter and where to exit the menu tree. If nodes is given, it
        shuld be a list of valid node objects to add to the tree.

        exec_end - if not None, will execute the given command string
                   directly after the menu system has been exited.
        """
        self.tree = {}
        self.startnode = startnode
        self.endnode = endnode
        self.exec_end = exec_end
        self.caller = caller
        if nodes and utils.is_iter(nodes):
            for node in nodes:
                self.add(node)