55
66import curses
77import curses .textpad
8+ import functools
89from typing import Callable , List , Literal , Sequence , Tuple , Union
910
1011from .error import PanicError , ValueNotInBound
1415
1516def value_checker (initializer : Callable ) -> Callable :
1617 """A decorator which ensures that correct values are passed to
17- `` BaseTextBox` ` initializer to avoid unexpected behavior.
18+ :class:` BaseTextBox` initializer to avoid unexpected behavior.
1819 """
1920 def __init__ (self ,
2021 pos_x , pos_y ,
@@ -43,7 +44,7 @@ def __init__(self,
4344class BaseTextBox :
4445 """This class provides attributs and methods to manage a text box.
4546
46- .. NOTE ::
47+ .. note ::
4748 This class provides a general API for text boxes, it is not
4849 intended to be instantiated.
4950
@@ -97,6 +98,7 @@ def __init__(
9798 CursesTextAttributes ] = curses .A_BOLD ,
9899 downtime_chars : Sequence [str ] = ("," , "." , ":" , ";" , "!" , "?" ),
99100 downtime_chars_delay : int = 600 ):
101+ """Initializes instance of :class:`BaseTextBox`."""
100102 self .pos_x , self .pos_y = pos_x , pos_y
101103 self .height , self .width = height - 1 , width - 1
102104
@@ -118,34 +120,46 @@ def __init__(
118120 self .downtime_chars = downtime_chars
119121 self .downtime_chars_delay = downtime_chars_delay
120122
121- #: Keystroke acquisition curses method for BaseTextBox.get_input.
123+ #: Keystroke acquisition ``curses`` method for
124+ #: :method:`BaseTextBox.get_input`.
122125 self .key_detection : Literal ["getkey" ,
123126 "getch" ,
124127 "get_wch" ] = "getkey"
125128
126129 #: List of accepted key to skip dialog.
127- #: This defaults to a list contains " ".
130+ #: This defaults `[ " "]` .
128131 self .confirm_keys : List [CursesKey ] = [" " ]
129- #: List of accepted key to raise PanicError.
130- #: This defaults to an empty list.
132+
131133 self .panic_keys : List [CursesKey ] = []
134+ #: List of accepted key to raise :exception:PanicError.
135+ #: This defaults to an empty list.
132136
133137 @property
134138 def position (self ) -> Tuple [int , int ]:
135- """Return a tuple contains x;y position of ``TextBox``.
139+ < << << << HEAD
140+ """Return a tuple contains x;y position of :class:`BaseTextBox`.
141+ =======
142+ """ A property that returns a tuple contains x ;y position of
143+ :class :`BaseTextBox` .
144+ > >> >> >> 817377 f (DialogBox .char_by_char and word_by_word nows return given text argument , start to improve doc .)
136145
137146 The position represents the x ;y coordinates of the top left
138147 corner of text box .
139148
140- :returns: x;y position of ``TextBox` `.
149+ :returns : x ;y position of : class : `BaseTextBox ` .
141150 """
142151 return self.pos_x, self.pos_y
143152
144153 @property
145154 def dimensions(self) -> Tuple[int, int]:
146- """Return a tuple contains dimensions of ``TextBox``.
147-
148- :returns: Height and width of ``TextBox``.
155+ <<<<<<< HEAD
156+ """ Return a tuple contains dimensions of :class :`BaseTextBox` .
157+ == == == =
158+ """A property that return a tuple contains dimensions of
159+ :class:`BaseTextBox`.
160+ >>>>>>> 817377f (DialogBox.char_by_char and word_by_word nows return given text argument, start to improve doc.)
161+
162+ :returns: Height and width of :class:`BaseTextBox`.
149163 """
150164 return (self .height + 1 ,
151165 self .width + 1 + self .title_offsetting_y )
@@ -181,35 +195,23 @@ def framing_box(self, win: CursesWindow):
181195 curses .textpad .rectangle (win ,
182196 self .pos_y + self .title_offsetting_y ,
183197 self .pos_x ,
184- self .pos_y
185- + self .title_offsetting_y
186- + self .width ,
198+ ( self .pos_y
199+ + self .title_offsetting_y
200+ + self .width ) ,
187201 self .pos_x + self .height )
188202
189203 def get_input (self , win : CursesWindow ):
190204 """Block execution as long as a key contained in
191205 ``self.confirm_keys`` is not detected.
192206
193207 The method of key detection depends on the variable
194- ``self.key_detection_mode``. ``"key"`` will acquire the key as
195- a character and ``"code"`` as a key code. This is default to
196- ``"key"``.
208+ ``self.key_detection_mode``.
197209
198210 :param win: ``curses`` window object on which the method will
199211 have effect.
200212
201213 :raises PanicError: If a key contained in ``self.panic_keys`` is
202214 pressed.
203-
204- .. NOTE::
205- - This method uses ``window.getch`` method from ``curses``
206- module. Please refer to `curses documentation
207- <https://docs.python.org/3/library/curses.html?#curses.window.getch>`_
208- for more informations.
209- - This method uses ``window.getkey`` method from ``curses``
210- module. Please refer to `curses documentation
211- <https://docs.python.org/3/library/curses.html?#curses.window.getkey>`_
212- for more informations.
213215 """
214216 curses .flushinp ()
215217
0 commit comments