dirtywords

portable text interface framework  https://pypi.python.org/pypi/dirtywords
git clone https://git.ce9e.org/dirtywords.git

commit
4c186b3ea87fc78727cf166dca45fc72a8049815
parent
d8fc29c02be56b04a9b004b04f53cb2c25b88376
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2014-10-07 18:39
minor documentation improvements

Diffstat

M dirtywords/base.py 38 +++++++++++++++++++++++++++++++++++---

1 files changed, 35 insertions, 3 deletions


diff --git a/dirtywords/base.py b/dirtywords/base.py

@@ -2,7 +2,24 @@ from time import time
    2     2 
    3     3 
    4     4 class AttrString(unicode):
    5    -1     """Unicode string with additional attributes."""
   -1     5     """Unicode string with additional attributes.
   -1     6 
   -1     7     emph
   -1     8         (bool) emphasis
   -1     9     strong
   -1    10         (bool) strong emphasis
   -1    11     underline
   -1    12         (bool) underline text
   -1    13     fg_color
   -1    14         (r, g, b) foreground color
   -1    15     bg_color
   -1    16         (r, g, b) background color
   -1    17 
   -1    18     Example::
   -1    19 
   -1    20         AttrString(u'hello world!', strong=True, fg_color=(0, 255, 0))
   -1    21 
   -1    22     """
    6    23 
    7    24     def __new__(cls, s, **kwargs):
    8    25         self = super(AttrString, cls).__new__(cls, s)
@@ -46,20 +63,35 @@ class AttrString(unicode):
   46    63 
   47    64 
   48    65 class Core(object):
   -1    66     """Minimal core on which everything else is based."""
   -1    67 
   49    68     def __init__(self, height, width):
   50    -1         """Initialize screen."""
   51    69         self.height = height
   52    70         self.width = width
   53    71         self.data = [[' ' for xx in range(width)] for yy in range(height)]
   54    72         self._pressed_keys = {}
   55    73 
   56    74     def getch(self, blocking=True):
   -1    75         """Get a character from ``stdin``."""
   57    76         # TODO: There should be some kind of abstraction for modifiers and
   58    77         # more general any non-ascii keys.
   59    78         raise NotImplementedError
   60    79 
   61    80     def get_key_events(self):
   62    -1         """Get iterator of keyup/down events."""
   -1    81         """Get iterator of keyup/-down events.
   -1    82 
   -1    83         The events are dictionaries of the form::
   -1    84 
   -1    85             {
   -1    86                 'type': 'keyup',
   -1    87                 'key': 32,
   -1    88             }
   -1    89 
   -1    90         The default implementation tries to emulate these using
   -1    91         :py:meth:`getch`.  It includes a short delay so that only one keydown
   -1    92         and one keyup event is triggered on repeated key presses.
   -1    93 
   -1    94         """
   63    95 
   64    96         # 0.  The key is not pressed. Nothing happens.
   65    97         # 1.  The key is initially pressed.