Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        """
        Class constructor.

        :param int width: width of window.
        :param int yloc: y-location of window.
        :param int xloc: x-location of window.
        :param int max_length: maximum length of input (may be larger than width).
        :param dict colors: color theme, only key value of ``highlight`` is used.
        :param dict glyphs: bordering window character glyphs.
        :param dict keyset: command keys, global ``PC_KEYSET`` is used by default.
        """
        self._term = getterminal()
        self._horiz_shift = 0
        self._horiz_pos = 0
        # self._enable_scrolling = False
        self._horiz_lastshift = 0
        self._scroll_pct = kwargs.pop('scroll_pct', 25.0)
        self._margin_pct = kwargs.pop('margin_pct', 10.0)
        self._carriage_returned = False
        self._max_length = kwargs.pop('max_length', 0)
        self._quit = False
        self._bell = False
        self.content = kwargs.pop('content', u'')
        self._input_length = self._term.length(self.content)
        # there are some flaws about how a 'height' of a window must be
        # '3', even though we only want 1; we must also offset (y, x) by
        # 1 and width by 2: issue #161.
        kwargs['height'] = 3
        self.init_keystrokes(keyset=kwargs.pop('keyset', PC_KEYSET.copy()))
        AnsiWindow.__init__(self, *args, **kwargs)
Esempio n. 2
0
    def __init__(self, yloc, xloc, width, left, right, **kwargs):
        """
        Class initializer.

        Initialize a selector of width, y x, and left/right values.

        :param int width: width of window.
        :param int yloc: y-location of selector.
        :param int xloc: x-location of selector.
        :param dict colors: color theme, only key value of ``selected``
                            and ``unselected`` is used.
        :param dict keyset: command keys, global ``VI_KEYSET`` is
                            used by default, augmented by application
                            keys such as home, end, pgup, etc.
        :param str left: text string of left-side selection.
        :param str right: text string of right-side selection.
        """
        self._left = self._selection = left
        self._right = right
        self._moved = False
        self._quit = False
        self._selected = False

        self.init_keystrokes(keyset=kwargs.pop('keyset', VI_KEYSET.copy()))

        AnsiWindow.__init__(self, height=1, width=width,
                            yloc=yloc, xloc=xloc, **kwargs)
Esempio n. 3
0
    def __init__(self, *args, **kwargs):
        """
        Class initializer.

        Initialize a lightbar of height, width, y and x, and position.

        :param int width: width of window.
        :param int height: height of window.
        :param int yloc: y-location of window.
        :param int xloc: x-location of window.
        :param dict colors: color theme, only key value of ``highlight``
                            is used.
        :param dict glyphs: bordering window character glyphs.
        :param dict keyset: command keys, global ``NETHACK_KEYSET`` is
                            used by default, augmented by application
                            keys such as home, end, pgup, etc.
        :param list content: Lightbar content as list of tuples, an empty list
                             is used by default.  Tuples must be in form of
                             ``(key, str)``.  ``key`` may have any suitable
                             significance for the caller.  ``str``, however,
                             must be of a unicode terminal sequence.
        """
        self._selected = False
        self._quit = False
        self._vitem_idx = self._vitem_shift = -1
        self.content = kwargs.pop('content', list())

        pos = kwargs.pop('position', (0, 0)) or (0, 0)

        self.init_keystrokes(
            keyset=kwargs.pop('keyset', NETHACK_KEYSET.copy()))

        AnsiWindow.__init__(self, *args, **kwargs)
        self.position = pos
Esempio n. 4
0
 def init_theme(self, colors=None, glyphs=None):
     """ Set color and bordering glyphs theme. """
     AnsiWindow.init_theme(self, colors, glyphs)
     if 'highlight' not in self.colors:
         self.colors['highlight'] = self._term.yellow_reverse
     if 'strip' not in self.glyphs:
         self.glyphs['strip'] = u'$ '
Esempio n. 5
0
    def __init__(self, yloc, xloc, width, left, right, **kwargs):
        """
        Class initializer.

        Initialize a selector of width, y x, and left/right values.

        :param int width: width of window.
        :param int yloc: y-location of selector.
        :param int xloc: x-location of selector.
        :param dict colors: color theme, only key value of ``selected``
                            and ``unselected`` is used.
        :param dict keyset: command keys, global ``VI_KEYSET`` is
                            used by default, augmented by application
                            keys such as home, end, pgup, etc.
        :param str left: text string of left-side selection.
        :param str right: text string of right-side selection.
        """
        self._left = self._selection = left
        self._right = right
        self._moved = False
        self._quit = False
        self._selected = False

        self.init_keystrokes(keyset=kwargs.pop('keyset', VI_KEYSET.copy()))

        AnsiWindow.__init__(self,
                            height=1,
                            width=width,
                            yloc=yloc,
                            xloc=xloc,
                            **kwargs)
Esempio n. 6
0
    def __init__(self, *args, **kwargs):
        """
        Class initializer.

        :param int width: width of window.
        :param int yloc: y-location of window.
        :param int xloc: x-location of window.
        :param int max_length: maximum length of input (even when scrolled).
        :param dict colors: color theme.
        :param dict glyphs: bordering window character glyphs.
        :param dict keyset: command keys, global ``PC_KEYSET`` is default.
        """
        self._term = getterminal()
        self._horiz_shift = 0
        self._horiz_pos = 0
        # self._enable_scrolling = False
        self._horiz_lastshift = 0
        self._scroll_pct = kwargs.pop('scroll_pct', 25.0)
        self._margin_pct = kwargs.pop('margin_pct', 10.0)
        self._carriage_returned = False
        self._max_length = kwargs.pop('max_length', 0)
        self._quit = False
        self._bell = False
        self.content = kwargs.pop('content', u'')
        self._input_length = self._term.length(self.content)
        # there are some flaws about how a 'height' of a window must be
        # '3', even though we only want 1; we must also offset (y, x) by
        # 1 and width by 2: issue #161.
        kwargs['height'] = 3
        self.init_keystrokes(keyset=kwargs.pop('keyset', PC_KEYSET.copy()))
        AnsiWindow.__init__(self, *args, **kwargs)
Esempio n. 7
0
 def init_theme(self, colors=None, glyphs=None):
     """ Set color and bordering glyphs theme. """
     AnsiWindow.init_theme(self, colors, glyphs)
     if 'highlight' not in self.colors:
         self.colors['highlight'] = self._term.yellow_reverse
     if 'strip' not in self.glyphs:
         self.glyphs['strip'] = u'$ '
Esempio n. 8
0
    def __init__(self, *args, **kwargs):
        """
        Class initializer.

        Initialize a lightbar of height, width, y and x, and position.

        :param int width: width of window.
        :param int height: height of window.
        :param int yloc: y-location of window.
        :param int xloc: x-location of window.
        :param dict colors: color theme, only key value of ``highlight``
                            is used.
        :param dict glyphs: bordering window character glyphs.
        :param dict keyset: command keys, global ``NETHACK_KEYSET`` is
                            used by default, augmented by application
                            keys such as home, end, pgup, etc.
        :param list content: Lightbar content as list of tuples, an empty list
                             is used by default.  Tuples must be in form of
                             ``(key, str)``.  ``key`` may have any suitable
                             significance for the caller.  ``str``, however,
                             must be of a unicode terminal sequence.
        """
        self._selected = False
        self._quit = False
        self._vitem_idx = self._vitem_shift = -1
        self.content = kwargs.pop('content', list())

        pos = kwargs.pop('position', (0, 0)) or (0, 0)

        self.init_keystrokes(
            keyset=kwargs.pop('keyset', NETHACK_KEYSET.copy()))

        AnsiWindow.__init__(self, *args, **kwargs)
        self.position = pos
Esempio n. 9
0
 def init_theme(self, colors=None, glyphs=None):
     """
     Initialize color['highlight'].
     """
     from x84.bbs.session import getterminal
     colors = colors or {'highlight': getterminal().reverse_yellow}
     glyphs = glyphs or {'strip': u' $'}
     AnsiWindow.init_theme(self, colors, glyphs)
Esempio n. 10
0
File: lightbar.py Progetto: hick/x84
 def init_theme(self, colors=None, glyphs=None):
     """
     Initialize color['highlight'].
     """
     from x84.bbs.session import getterminal
     colors = colors or {'highlight': getterminal().reverse_yellow}
     glyphs = glyphs or {'strip': u' $'}
     AnsiWindow.init_theme(self, colors, glyphs)
Esempio n. 11
0
File: editor.py Progetto: hick/x84
 def init_theme(self, colors=None, glyphs=None):
     AnsiWindow.init_theme(self, colors, glyphs)
     if 'highlight' not in self.colors:
         from x84.bbs.session import getterminal
         term = getterminal()
         self.colors['highlight'] = term.yellow_reverse
     if 'strip' not in self.glyphs:
         self.glyphs['strip'] = u'$ '
Esempio n. 12
0
 def init_theme(self):
     """
     Initialize color['highlight'].
     """
     from x84.bbs.session import getterminal
     self.colors['highlight'] = getterminal().reverse_green
     self.glyphs['strip'] = u' $'  # indicates content was stripped
     AnsiWindow.init_theme(self)
Esempio n. 13
0
 def init_theme(self, colors=None, glyphs=None):
     from x84.bbs.session import getterminal
     term = getterminal()
     colors = colors or {
         'selected': term.reverse_yellow,
         'unselected': term.bold_black,
     }
     AnsiWindow.init_theme(self, colors=colors, glyphs=glyphs)
Esempio n. 14
0
 def init_theme(self):
     """
     Initialize color['highlight'].
     """
     from x84.bbs.session import getterminal
     self.colors['highlight'] = getterminal().reverse_green
     self.glyphs['strip'] = u' $'  # indicates content was stripped
     AnsiWindow.init_theme(self)
Esempio n. 15
0
File: selector.py Progetto: hick/x84
 def init_theme(self, colors=None, glyphs=None):
     from x84.bbs.session import getterminal
     term = getterminal()
     colors = colors or {
         'selected': term.reverse_yellow,
         'unselected': term.bold_black,
     }
     AnsiWindow.init_theme(self, colors=colors, glyphs=glyphs)
Esempio n. 16
0
File: editor.py Progetto: hick/x84
 def init_theme(self, colors=None, glyphs=None):
     AnsiWindow.init_theme(self, colors, glyphs)
     if 'highlight' not in self.colors:
         from x84.bbs.session import getterminal
         term = getterminal()
         self.colors['highlight'] = term.yellow_reverse
     if 'strip' not in self.glyphs:
         self.glyphs['strip'] = u'$ '
Esempio n. 17
0
 def init_theme(self):
     """
     Initialize colors['highlight'] as REVERSE and glyphs['strip'] as '$ '.
     """
     import x84.bbs.session
     term = x84.bbs.session.getterminal()
     AnsiWindow.init_theme(self)
     self.colors['highlight'] = term.yellow_reverse
     self.glyphs['strip'] = '$ '
Esempio n. 18
0
 def init_theme(self):
     """
     Initialize colors['selected'] and colors['unselected'].
     """
     from x84.bbs.session import getterminal
     term = getterminal()
     AnsiWindow.init_theme(self)
     self.colors['selected'] = term.reverse
     self.colors['unselected'] = term.normal
Esempio n. 19
0
 def __init__(self, height, width, yloc, xloc):
     """
     Initialize a pager of height, width, y, and x position.
     """
     AnsiWindow.__init__(self, height, width, yloc, xloc)
     self._position = self._position_last = 0
     self._quit = False
     self.content = list()
     self.keyset = VI_KEYSET.copy()
     self.init_keystrokes()
Esempio n. 20
0
 def __init__(self, height, width, yloc, xloc):
     """
     Initialize a pager of height, width, y, and x position.
     """
     AnsiWindow.__init__(self, height, width, yloc, xloc)
     self._position = self._position_last = 0
     self._quit = False
     self.content = list()
     self.keyset = VI_KEYSET.copy()
     self.init_keystrokes()
Esempio n. 21
0
    def init_theme(self):
        """
        Initialize colors['highlight'] as REVERSE and glyphs['strip'] as '$ '.
        """
        import x84.bbs.session

        term = x84.bbs.session.getterminal()
        AnsiWindow.init_theme(self)
        self.colors["highlight"] = term.yellow_reverse
        self.glyphs["strip"] = "$ "
Esempio n. 22
0
    def __init__(self, *args, **kwargs):
        """
        Initialize a lightbar of height, width, y and x, and position.
        """
        self._selected = False
        self._quit = False
        pos = kwargs.pop('position', (0, 0)) or (0, 0)

        self.init_keystrokes(
            keyset=kwargs.pop('keyset', NETHACK_KEYSET.copy()))

        AnsiWindow.__init__(self, *args, **kwargs)
        self.position = pos
Esempio n. 23
0
File: lightbar.py Progetto: hick/x84
    def __init__(self, *args, **kwargs):
        """
        Initialize a lightbar of height, width, y and x, and position.
        """
        self._selected = False
        self._quit = False
        pos = kwargs.pop('position', (0, 0)) or (0, 0)

        self.init_keystrokes(
            keyset=kwargs.pop('keyset', NETHACK_KEYSET.copy()))

        AnsiWindow.__init__(self, *args, **kwargs)
        self.position = pos
Esempio n. 24
0
 def __init__(self, height, width, yloc, xloc):
     """
     Initialize a lightbar of height, width, y and x position.
     """
     AnsiWindow.__init__(self, height, width, yloc, xloc)
     self._vitem_idx = 0
     self._vitem_shift = 0
     self._vitem_lastidx = 0
     self._vitem_lastshift = 0
     self._selected = False
     self._quit = False
     self.keyset = NETHACK_KEYSET
     self.init_keystrokes()
     self.init_theme()
Esempio n. 25
0
 def __init__(self, height, width, yloc, xloc):
     """
     Initialize a lightbar of height, width, y and x position.
     """
     AnsiWindow.__init__(self, height, width, yloc, xloc)
     self._vitem_idx = 0
     self._vitem_shift = 0
     self._vitem_lastidx = 0
     self._vitem_lastshift = 0
     self._selected = False
     self._quit = False
     self.keyset = NETHACK_KEYSET
     self.init_keystrokes()
     self.init_theme()
Esempio n. 26
0
 def __init__(self, yloc, xloc, width, left, right):
     """
     Set screen position of Selector UI and display width of both. The
     highlighted selection is displayed using the self.highlight attribute,
     in order (left, right). The default selection is left.
     """
     self._left = self._selection = left
     self._right = right
     self._moved = False
     self._quit = False
     self._selected = False
     AnsiWindow.__init__(self, 1, width, yloc, xloc)  # height is 1
     self.init_theme()
     self.keyset = VI_KEYSET
     self.init_keystrokes()
Esempio n. 27
0
File: pager.py Progetto: hick/x84
    def __init__(self, *args, **kwargs):
        """
        Initialize a pager of height, width, y, and x position.
        """
        self._quit = False

        self.init_keystrokes(keyset=kwargs.pop('keyset', VI_KEYSET.copy()))

        content = kwargs.pop('content', u'') or u''
        position = kwargs.pop('position', 0) or 0

        AnsiWindow.__init__(self, *args, **kwargs)

        self.position = position
        self.content = content
Esempio n. 28
0
    def __init__(self, yloc, xloc, width, left, right, **kwargs):
        """
        Set screen position of Selector UI and display width of both. The
        highlighted selection is displayed using the self.highlight attribute,
        in order (left, right). The default selection is left.
        """
        self._left = self._selection = left
        self._right = right
        self._moved = False
        self._quit = False
        self._selected = False

        self.init_keystrokes(keyset=kwargs.pop('keyset', VI_KEYSET.copy()))

        AnsiWindow.__init__(self, height=1, width=width,
                            yloc=yloc, xloc=xloc, **kwargs)
Esempio n. 29
0
    def __init__(self, *args, **kwargs):
        """
        Class initializer.

        :param int width: width of window.
        :param int height: height of window.
        :param int yloc: y-location of window.
        :param int xloc: x-location of window.
        :param str content: initial pager contents.
        :param dict colors: color theme.
        :param dict glyphs: bordering window character glyphs.
        :param dict keyset: command keys, global ``VI_KEYSET`` is default.
        """
        self._quit = False
        self.init_keystrokes(keyset=kwargs.pop('keyset', VI_KEYSET.copy()))
        _content = kwargs.pop('content', u'') or u''
        AnsiWindow.__init__(self, *args, **kwargs)
        self.content = _content
        self._position = self.position = kwargs.pop('position', 0) or 0
Esempio n. 30
0
 def __init__(self, width, yloc, xloc):
     """
     Construct a Line editor at (y,x) location of width (n).
     """
     self._horiz_shift = 0
     self._horiz_pos = 0
     self._enable_scrolling = False
     self._horiz_lastshift = 0
     self._scroll_pct = 35.0
     self._margin_pct = 20.0
     self._carriage_returned = False
     self._max_length = 0
     self._quit = False
     self._bell = False
     self.content = u''
     self.keyset = PC_KEYSET
     height = 3  # TODO: 2 of 3 for top and bottom border
     # (optionaly displayed .. is this best x/y coord?
     #   once working, lets set default as borderless!)
     AnsiWindow.__init__(self, height, width, yloc, xloc)
     self.init_keystrokes()
     self.init_theme()
Esempio n. 31
0
 def __init__(self, width, yloc, xloc):
     """
     Construct a Line editor at (y,x) location of width (n).
     """
     self._horiz_shift = 0
     self._horiz_pos = 0
     self._enable_scrolling = False
     self._horiz_lastshift = 0
     self._scroll_pct = 35.0
     self._margin_pct = 20.0
     self._carriage_returned = False
     self._max_length = 0
     self._quit = False
     self._bell = False
     self.content = u""
     self.keyset = PC_KEYSET
     height = 3  # TODO: 2 of 3 for top and bottom border
     # (optionaly displayed .. is this best x/y coord?
     #   once working, lets set default as borderless!)
     AnsiWindow.__init__(self, height, width, yloc, xloc)
     self.init_keystrokes()
     self.init_theme()
Esempio n. 32
0
File: editor.py Progetto: hick/x84
    def __init__(self, *args, **kwargs):
        """
        Construct a Line editor at (y,x) location of width (n).
        """
        self._horiz_shift = 0
        self._horiz_pos = 0
        self._enable_scrolling = False
        self._horiz_lastshift = 0
        self._scroll_pct = 35.0
        self._margin_pct = 20.0
        self._carriage_returned = False
        self._max_length = 0
        self._quit = False
        self._bell = False
        self.content = u''
        kwargs['height'] = 3

        self.init_keystrokes(keyset=kwargs.pop('keyset', PC_KEYSET.copy()))

        #height = 3  # TODO: 2 of 3 for top and bottom border
        # (optionally displayed .. is this best x/y coord?
        #   once working, lets set default as borderless!)
        AnsiWindow.__init__(self, *args, **kwargs)
Esempio n. 33
0
File: editor.py Progetto: hick/x84
    def __init__(self, *args, **kwargs):
        """
        Construct a Line editor at (y,x) location of width (n).
        """
        self._horiz_shift = 0
        self._horiz_pos = 0
        self._enable_scrolling = False
        self._horiz_lastshift = 0
        self._scroll_pct = 35.0
        self._margin_pct = 20.0
        self._carriage_returned = False
        self._max_length = 0
        self._quit = False
        self._bell = False
        self.content = u''
        kwargs['height'] = 3

        self.init_keystrokes(keyset=kwargs.pop('keyset', PC_KEYSET.copy()))

        #height = 3  # TODO: 2 of 3 for top and bottom border
        # (optionally displayed .. is this best x/y coord?
        #   once working, lets set default as borderless!)
        AnsiWindow.__init__(self, *args, **kwargs)
Esempio n. 34
0
 def init_theme(self, colors=None, glyphs=None):
     """ Set color and bordering glyphs theme. """
     colors = colors or {'highlight': getterminal().reverse_yellow}
     glyphs = glyphs or {'strip': u' $'}
     AnsiWindow.init_theme(self, colors, glyphs)
Esempio n. 35
0
 def init_theme(self, colors=None, glyphs=None):
     """ Set color and bordering glyphs theme. """
     colors = colors or {'highlight': getterminal().reverse_yellow}
     glyphs = glyphs or {'strip': u' $'}
     AnsiWindow.init_theme(self, colors, glyphs)