txtwrap 2.0.0__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,16 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txtwrap
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: A simple text wrapping tool.
5
5
  Author: azzammuhyala
6
+ Author-email: azzammuhyala@gmail.com
6
7
  License: MIT
7
8
  Keywords: wrap,wrapper,wrapping,wrapped,wrapping tool,text wrap,text wrapper,simple wrap,align,aligner,aligning,aligned
8
9
  Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.3
10
11
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
11
12
  Classifier: License :: OSI Approved :: MIT License
12
- Requires-Python: >=3.8
13
+ Requires-Python: >=3.3
13
14
  Description-Content-Type: text/markdown
14
15
 
15
16
  # TxTWrap🔡
@@ -19,16 +20,16 @@ A tool for wrapping a text.🔨
19
20
  - `LOREM_IPSUM_WORDS`
20
21
  - `LOREM_IPSUM_SENTENCES`
21
22
  - `LOREM_IPSUM_PARAGRAPHS`
22
- - `TextWrapper` (New)
23
- - `mono` (from TextWrapper)
24
- - `word` (from TextWrapper)
25
- - `wrap` (from TextWrapper)
26
- - `align` (from TextWrapper)
27
- - `fillstr` (from TextWrapper)
28
- - `printwrap` (from fillstr)
29
- - `indent` (from TextWrapper)
30
- - `dedent` (from TextWrapper)
31
- - `shorten` (from TextWrapper)
23
+ - `TextWrapper` (Updated)
24
+ - `mono`
25
+ - `word` (Updated)
26
+ - `wrap` (Updated)
27
+ - `align` (Updated)
28
+ - `fillstr` (Updated)
29
+ - `printwrap` (Updated)
30
+ - `indent`
31
+ - `dedent`
32
+ - `shorten` (Updated)
32
33
 
33
34
  ## Documents📄
34
35
 
@@ -40,21 +41,22 @@ class TextWrapper:
40
41
 
41
42
  self,
42
43
  width: Union[int, float] = 70,
43
- start: int = 0,
44
+ start: SupportsIndex = 0,
44
45
  linegap: Union[int, float] = 0,
45
- sizefunc: Callable[[str], Tuple[Union[int, float],
46
- Union[int, float]]] = lambda s : (len(s), 1),
47
- predicate: Callable[[str], bool] = lambda line: line.strip(),
48
46
  method: Literal['mono', 'word'] = 'word',
49
- alignment: Literal['left', 'center', 'right', 'fill'] = 'left',
47
+ alignment: Literal['left', 'center', 'right', 'fill',
48
+ 'fill-left', 'fill-center', 'fill-right'] = 'left',
50
49
  fillchar: str = ' ',
51
50
  placeholder: str = '...',
52
51
  prefix: Optional[str] = None,
52
+ separator: Optional[str] = None,
53
53
  preserve_empty: bool = True,
54
54
  use_minimum_width: bool = True,
55
- break_on_hyphens: bool = True,
56
55
  justify_last_line: bool = False,
57
- strip_space: bool = True
56
+ break_on_hyphens: bool = True,
57
+ sizefunc: Callable[[str], Tuple[Union[int, float],
58
+ Union[int, float]]] = lambda s : (len(s), 1),
59
+ predicate: Callable[[str], bool] = lambda line: line.strip()
58
60
 
59
61
  ) -> None
60
62
  ```
@@ -68,22 +70,15 @@ class TextWrapper:
68
70
  > **linegap** : _int | float_
69
71
  => The gap between lines (specific to the align method). Default: 0.
70
72
 
71
- > **sizefunc** : _(str) -> tuple[int | float, int | float]_
72
- => A function to calculate the width and height of the text. The default is a lambda function
73
- returning the text length as width and 1 as height.
74
-
75
- > **predicate** : _(str) -> bool_
76
- => A function to filter lines (specific to indent and dedent methods). The default is a lambda
77
- function that trims empty lines from the left and right.
78
-
79
73
  > **method** : _Literal['mono', 'word']_
80
74
  => The text wrapping method. Default: 'word'.
81
75
 
82
- > **alignment** : _Literal['left', 'center', 'right', 'fill']_
76
+ > **alignment** : _Literal['left', 'center', 'right', 'fill',
77
+ 'fill-left', 'fill-center', 'fill-right']_
83
78
  => The text alignment (specific to align and fillstr method). Default: 'left'.
84
79
 
85
80
  > **fillchar** : _str_
86
- => The character used for padding (specific to the fillstr method). Default: ' '.
81
+ => The character used for padding. Default: ' '.
87
82
 
88
83
  > **placeholder** : _str_
89
84
  => The placeholder used when shortening text (specific to the shorten method). Default: '...'.
@@ -93,60 +88,72 @@ function that trims empty lines from the left and right.
93
88
  beginning of each line. For dedent, it is optional and removes the prefix from the beginning of each
94
89
  line). Default: None.
95
90
 
91
+ > **separator** : _Optional[str]_
92
+ => The separator used between words. Default: None.
93
+
96
94
  > **preserve_empty** : _bool_
97
95
  => Whether to retain empty lines. Default: True.
98
96
 
99
97
  > **use_minimum_width** : _bool_
100
- => Whether to use the minimum detected width (specific to the align method). Default: True.
101
-
102
- > **break_on_hyphens** : _bool_
103
- => Whether to allow breaking words at hyphens (-) (specific to align and fillstr methods).
98
+ => Whether to use the minimum detected width (specific to the align and fillstr methods).
104
99
  Default: True.
105
100
 
106
101
  > **justify_last_line** : _bool_
107
102
  => Whether to adjust the alignment of the last line (applies to align and fillstr methods, but only
108
103
  for non-wrapped text and only for fill alignment). Default: False.
109
104
 
110
- > **strip_space** : _bool_
111
- => Whether to remove excessive spaces (applies only to the shorten method and does not affect other
112
- wrapping methods). Default: True.
105
+ > **break_on_hyphens** : _bool_
106
+ => Whether to allow breaking words at hyphens (-) (specific to align and fillstr methods).
107
+ Default: True.
108
+
109
+ > **sizefunc** : _(str) -> tuple[int | float, int | float]_
110
+ => A function to calculate the width and height of the text. The default is a lambda function
111
+ returning the text length as width and 1 as height.
112
+
113
+ > **predicate** : _(str) -> bool_
114
+ => A function to filter lines (specific to indent and dedent methods). The default is a lambda
115
+ function that trims empty lines from the left and right.
113
116
 
114
117
  ### Mod📦 `python -m txtwrap`
115
118
  ```
116
- usage: txtwrap [-h] [-v] [-f <str (1 character)>] [-w <int>] [-m {word|mono|indent|dedent|shorten}]
117
- [-a {left|center|right|fill}] [-n] [-x <str>] [-s <int>] [-p <str>] [-b] [-j] [-r]
118
- text
119
+ usage: txtwrap [-h] [-v] [-w <int>] [-s <int>] [-m {word|mono|indent|dedent|shorten}]
120
+ [-a {left|center|right|fill|fill-left|fill-center|fill-right}] [-f <str>] [-p <str>]
121
+ [-x <str>] [-r <str>] [-n] [-i] [-j] [-b] text
119
122
 
120
123
  Command-line tool for wrapping, aligning, or shortening text.
121
124
 
122
125
  positional arguments:
123
- text Text to be wrapped, aligned, or shorted
126
+ text Target text
124
127
 
125
128
  options:
126
129
  -h, --help show this help message and exit
127
130
  -v, --version Show the version of the txtwrap
128
- -f <str (1 character)>, --fillchar <str (1 character)>
129
- Fill character (default: " ")
130
131
  -w <int>, --width <int>
131
132
  Width of the text wrapping (default: current width terminal or 70)
133
+ -s <int>, --start <int>
134
+ start index of the text to be shorten (default: 0)
132
135
  -m {word|mono|indent|dedent|shorten}, --method {word|mono|indent|dedent|shorten}
133
136
  Method to be applied to the text (default: "word")
134
- -a {left|center|right|fill}, --alignment {left|center|right|fill}
137
+ -a {left|center|right|fill|fill-left|fill-center|fill-right},
138
+ --alignment {left|center|right|fill|fill-left|fill-center|fill-right}
135
139
  Alignment of the text (default: "left")
136
- -n, --neglect-empty Neglect empty lines in the text
137
- -x <str>, --prefix <str>
138
- Prefix to be added (indent) or remove (dedent) to the text
139
- -s <int>, --start <int>
140
- start index of the text to be shorten (default: 0)
140
+ -f <str>, --fillchar <str>
141
+ Fill character (default: " ")
141
142
  -p <str>, --placeholder <str>
142
143
  Placeholder to be used when shortening the text (default: "...")
144
+ -x <str>, --prefix <str>
145
+ Prefix to be added (indent) or remove (dedent) to the text
146
+ -r <str>, --separator <str>
147
+ The separator used between words
148
+ -n, --neglect-empty Neglect empty lines in the text
149
+ -i, --use-minimum-width
150
+ Whether to use the minimum detected width
151
+ -j, --justify-last-line
152
+ Whether to adjust the alignment of the last line
143
153
  -b, --not-break-on-hyphens
144
154
  Doesn't break on hyphens
145
- -j, --justify-last-line
146
- Justify the last line of the text
147
- -r, --no-strip Do not strip the space in the text
148
155
 
149
- for example: python|py -m txtwrap "Lorem ipsum odor amet, consectetuer adipiscing elit." -w 20 ^
156
+ for example: python|py -m txtwrap "Lorem ipsum odor amet, consectetuer adipiscing elit." -w 20 `
150
157
  -m word -a center
151
158
  ```
152
159
 
@@ -168,26 +175,27 @@ def render_wrap(
168
175
  background: Optional[pygame.Color] = None,
169
176
  linegap: int = 0,
170
177
  method: Literal['word', 'mono'] = 'word',
171
- alignment: Literal['left', 'center', 'right', 'fill'] = 'left',
178
+ alignment: Literal['left', 'center', 'right', 'fill',
179
+ 'fill-left', 'fill-center', 'fill-right'] = 'left',
172
180
  preserve_empty: bool = True,
173
- break_on_hyphens: bool = True,
174
181
  use_minimum_width: bool = True,
175
182
  justify_last_line: bool = False,
183
+ break_on_hyphens: bool = True
176
184
 
177
185
  ) -> pygame.Surface:
178
186
 
179
187
  align_info = align(
180
- text_or_wrapped=str(text),
188
+ text=text,
181
189
  width=width,
182
190
  linegap=linegap,
183
- sizefunc=font.size,
184
191
  method=method,
185
192
  alignment=alignment,
186
193
  preserve_empty=preserve_empty,
187
- break_on_hyphens=break_on_hyphens,
188
194
  use_minimum_width=use_minimum_width,
189
195
  justify_last_line=justify_last_line,
190
- return_details=True
196
+ break_on_hyphens=break_on_hyphens,
197
+ return_details=True,
198
+ sizefunc=font.size
191
199
  )
192
200
 
193
201
  surface = pygame.Surface(align_info['size'], pygame.SRCALPHA)
@@ -205,13 +213,14 @@ pygame.init()
205
213
  pygame.display.set_caption("Lorem Ipsum")
206
214
 
207
215
  running = True
208
- wscrn, hscrn = 600, 600
209
- screen = pygame.display.set_mode((wscrn, hscrn))
216
+ width, height = 800, 600
217
+ screen = pygame.display.set_mode((width, height))
210
218
  clock = pygame.time.Clock()
219
+
211
220
  surface = render_wrap(
212
- font=pygame.font.Font(None, 20),
221
+ font=pygame.font.SysFont('Arial', 18),
213
222
  text=LOREM_IPSUM_PARAGRAPHS,
214
- width=wscrn,
223
+ width=width,
215
224
  antialias=True,
216
225
  color='#ffffff',
217
226
  background='#303030',
@@ -219,7 +228,7 @@ surface = render_wrap(
219
228
  )
220
229
 
221
230
  wsurf, hsurf = surface.get_size()
222
- pos = ((wscrn - wsurf) / 2, (hscrn - hsurf) / 2)
231
+ pos = ((width - wsurf) / 2, (height - hsurf) / 2)
223
232
 
224
233
  while running:
225
234
  for event in pygame.event.get():
@@ -235,24 +244,26 @@ while running:
235
244
  ```py
236
245
  from txtwrap import printwrap, LOREM_IPSUM_WORDS
237
246
 
238
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='left')
239
- print('=' * 20)
240
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='center')
241
- print('=' * 20)
242
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='right')
243
- print('=' * 20)
244
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='fill')
247
+ width = 20
248
+
249
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='left')
250
+ print('=' * width)
251
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='center')
252
+ print('=' * width)
253
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='right')
254
+ print('=' * width)
255
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='fill') # or alignment='fill-left'
256
+ print('=' * width)
257
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='fill-center')
258
+ print('=' * width)
259
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='fill-right')
245
260
  ```
246
261
 
247
262
  ### Short a long text🔤
248
263
  ```py
249
264
  from txtwrap import shorten, LOREM_IPSUM_SENTENCES
250
265
 
251
- short_lorem = shorten(LOREM_IPSUM_SENTENCES, width=20, placeholder='…')
252
- test = shorten(' Helllo, \t\n World!!\f', width=20, placeholder='…', strip_space=True)
253
-
254
- print(short_lorem)
255
- print(test)
266
+ print(shorten(LOREM_IPSUM_SENTENCES, width=20, placeholder='…'))
256
267
  ```
257
268
 
258
269
  ### Bonus🎁 - Print a colorfull text to terminal🔥
@@ -5,16 +5,16 @@ A tool for wrapping a text.🔨
5
5
  - `LOREM_IPSUM_WORDS`
6
6
  - `LOREM_IPSUM_SENTENCES`
7
7
  - `LOREM_IPSUM_PARAGRAPHS`
8
- - `TextWrapper` (New)
9
- - `mono` (from TextWrapper)
10
- - `word` (from TextWrapper)
11
- - `wrap` (from TextWrapper)
12
- - `align` (from TextWrapper)
13
- - `fillstr` (from TextWrapper)
14
- - `printwrap` (from fillstr)
15
- - `indent` (from TextWrapper)
16
- - `dedent` (from TextWrapper)
17
- - `shorten` (from TextWrapper)
8
+ - `TextWrapper` (Updated)
9
+ - `mono`
10
+ - `word` (Updated)
11
+ - `wrap` (Updated)
12
+ - `align` (Updated)
13
+ - `fillstr` (Updated)
14
+ - `printwrap` (Updated)
15
+ - `indent`
16
+ - `dedent`
17
+ - `shorten` (Updated)
18
18
 
19
19
  ## Documents📄
20
20
 
@@ -26,21 +26,22 @@ class TextWrapper:
26
26
 
27
27
  self,
28
28
  width: Union[int, float] = 70,
29
- start: int = 0,
29
+ start: SupportsIndex = 0,
30
30
  linegap: Union[int, float] = 0,
31
- sizefunc: Callable[[str], Tuple[Union[int, float],
32
- Union[int, float]]] = lambda s : (len(s), 1),
33
- predicate: Callable[[str], bool] = lambda line: line.strip(),
34
31
  method: Literal['mono', 'word'] = 'word',
35
- alignment: Literal['left', 'center', 'right', 'fill'] = 'left',
32
+ alignment: Literal['left', 'center', 'right', 'fill',
33
+ 'fill-left', 'fill-center', 'fill-right'] = 'left',
36
34
  fillchar: str = ' ',
37
35
  placeholder: str = '...',
38
36
  prefix: Optional[str] = None,
37
+ separator: Optional[str] = None,
39
38
  preserve_empty: bool = True,
40
39
  use_minimum_width: bool = True,
41
- break_on_hyphens: bool = True,
42
40
  justify_last_line: bool = False,
43
- strip_space: bool = True
41
+ break_on_hyphens: bool = True,
42
+ sizefunc: Callable[[str], Tuple[Union[int, float],
43
+ Union[int, float]]] = lambda s : (len(s), 1),
44
+ predicate: Callable[[str], bool] = lambda line: line.strip()
44
45
 
45
46
  ) -> None
46
47
  ```
@@ -54,22 +55,15 @@ class TextWrapper:
54
55
  > **linegap** : _int | float_
55
56
  => The gap between lines (specific to the align method). Default: 0.
56
57
 
57
- > **sizefunc** : _(str) -> tuple[int | float, int | float]_
58
- => A function to calculate the width and height of the text. The default is a lambda function
59
- returning the text length as width and 1 as height.
60
-
61
- > **predicate** : _(str) -> bool_
62
- => A function to filter lines (specific to indent and dedent methods). The default is a lambda
63
- function that trims empty lines from the left and right.
64
-
65
58
  > **method** : _Literal['mono', 'word']_
66
59
  => The text wrapping method. Default: 'word'.
67
60
 
68
- > **alignment** : _Literal['left', 'center', 'right', 'fill']_
61
+ > **alignment** : _Literal['left', 'center', 'right', 'fill',
62
+ 'fill-left', 'fill-center', 'fill-right']_
69
63
  => The text alignment (specific to align and fillstr method). Default: 'left'.
70
64
 
71
65
  > **fillchar** : _str_
72
- => The character used for padding (specific to the fillstr method). Default: ' '.
66
+ => The character used for padding. Default: ' '.
73
67
 
74
68
  > **placeholder** : _str_
75
69
  => The placeholder used when shortening text (specific to the shorten method). Default: '...'.
@@ -79,60 +73,72 @@ function that trims empty lines from the left and right.
79
73
  beginning of each line. For dedent, it is optional and removes the prefix from the beginning of each
80
74
  line). Default: None.
81
75
 
76
+ > **separator** : _Optional[str]_
77
+ => The separator used between words. Default: None.
78
+
82
79
  > **preserve_empty** : _bool_
83
80
  => Whether to retain empty lines. Default: True.
84
81
 
85
82
  > **use_minimum_width** : _bool_
86
- => Whether to use the minimum detected width (specific to the align method). Default: True.
87
-
88
- > **break_on_hyphens** : _bool_
89
- => Whether to allow breaking words at hyphens (-) (specific to align and fillstr methods).
83
+ => Whether to use the minimum detected width (specific to the align and fillstr methods).
90
84
  Default: True.
91
85
 
92
86
  > **justify_last_line** : _bool_
93
87
  => Whether to adjust the alignment of the last line (applies to align and fillstr methods, but only
94
88
  for non-wrapped text and only for fill alignment). Default: False.
95
89
 
96
- > **strip_space** : _bool_
97
- => Whether to remove excessive spaces (applies only to the shorten method and does not affect other
98
- wrapping methods). Default: True.
90
+ > **break_on_hyphens** : _bool_
91
+ => Whether to allow breaking words at hyphens (-) (specific to align and fillstr methods).
92
+ Default: True.
93
+
94
+ > **sizefunc** : _(str) -> tuple[int | float, int | float]_
95
+ => A function to calculate the width and height of the text. The default is a lambda function
96
+ returning the text length as width and 1 as height.
97
+
98
+ > **predicate** : _(str) -> bool_
99
+ => A function to filter lines (specific to indent and dedent methods). The default is a lambda
100
+ function that trims empty lines from the left and right.
99
101
 
100
102
  ### Mod📦 `python -m txtwrap`
101
103
  ```
102
- usage: txtwrap [-h] [-v] [-f <str (1 character)>] [-w <int>] [-m {word|mono|indent|dedent|shorten}]
103
- [-a {left|center|right|fill}] [-n] [-x <str>] [-s <int>] [-p <str>] [-b] [-j] [-r]
104
- text
104
+ usage: txtwrap [-h] [-v] [-w <int>] [-s <int>] [-m {word|mono|indent|dedent|shorten}]
105
+ [-a {left|center|right|fill|fill-left|fill-center|fill-right}] [-f <str>] [-p <str>]
106
+ [-x <str>] [-r <str>] [-n] [-i] [-j] [-b] text
105
107
 
106
108
  Command-line tool for wrapping, aligning, or shortening text.
107
109
 
108
110
  positional arguments:
109
- text Text to be wrapped, aligned, or shorted
111
+ text Target text
110
112
 
111
113
  options:
112
114
  -h, --help show this help message and exit
113
115
  -v, --version Show the version of the txtwrap
114
- -f <str (1 character)>, --fillchar <str (1 character)>
115
- Fill character (default: " ")
116
116
  -w <int>, --width <int>
117
117
  Width of the text wrapping (default: current width terminal or 70)
118
+ -s <int>, --start <int>
119
+ start index of the text to be shorten (default: 0)
118
120
  -m {word|mono|indent|dedent|shorten}, --method {word|mono|indent|dedent|shorten}
119
121
  Method to be applied to the text (default: "word")
120
- -a {left|center|right|fill}, --alignment {left|center|right|fill}
122
+ -a {left|center|right|fill|fill-left|fill-center|fill-right},
123
+ --alignment {left|center|right|fill|fill-left|fill-center|fill-right}
121
124
  Alignment of the text (default: "left")
122
- -n, --neglect-empty Neglect empty lines in the text
123
- -x <str>, --prefix <str>
124
- Prefix to be added (indent) or remove (dedent) to the text
125
- -s <int>, --start <int>
126
- start index of the text to be shorten (default: 0)
125
+ -f <str>, --fillchar <str>
126
+ Fill character (default: " ")
127
127
  -p <str>, --placeholder <str>
128
128
  Placeholder to be used when shortening the text (default: "...")
129
+ -x <str>, --prefix <str>
130
+ Prefix to be added (indent) or remove (dedent) to the text
131
+ -r <str>, --separator <str>
132
+ The separator used between words
133
+ -n, --neglect-empty Neglect empty lines in the text
134
+ -i, --use-minimum-width
135
+ Whether to use the minimum detected width
136
+ -j, --justify-last-line
137
+ Whether to adjust the alignment of the last line
129
138
  -b, --not-break-on-hyphens
130
139
  Doesn't break on hyphens
131
- -j, --justify-last-line
132
- Justify the last line of the text
133
- -r, --no-strip Do not strip the space in the text
134
140
 
135
- for example: python|py -m txtwrap "Lorem ipsum odor amet, consectetuer adipiscing elit." -w 20 ^
141
+ for example: python|py -m txtwrap "Lorem ipsum odor amet, consectetuer adipiscing elit." -w 20 `
136
142
  -m word -a center
137
143
  ```
138
144
 
@@ -154,26 +160,27 @@ def render_wrap(
154
160
  background: Optional[pygame.Color] = None,
155
161
  linegap: int = 0,
156
162
  method: Literal['word', 'mono'] = 'word',
157
- alignment: Literal['left', 'center', 'right', 'fill'] = 'left',
163
+ alignment: Literal['left', 'center', 'right', 'fill',
164
+ 'fill-left', 'fill-center', 'fill-right'] = 'left',
158
165
  preserve_empty: bool = True,
159
- break_on_hyphens: bool = True,
160
166
  use_minimum_width: bool = True,
161
167
  justify_last_line: bool = False,
168
+ break_on_hyphens: bool = True
162
169
 
163
170
  ) -> pygame.Surface:
164
171
 
165
172
  align_info = align(
166
- text_or_wrapped=str(text),
173
+ text=text,
167
174
  width=width,
168
175
  linegap=linegap,
169
- sizefunc=font.size,
170
176
  method=method,
171
177
  alignment=alignment,
172
178
  preserve_empty=preserve_empty,
173
- break_on_hyphens=break_on_hyphens,
174
179
  use_minimum_width=use_minimum_width,
175
180
  justify_last_line=justify_last_line,
176
- return_details=True
181
+ break_on_hyphens=break_on_hyphens,
182
+ return_details=True,
183
+ sizefunc=font.size
177
184
  )
178
185
 
179
186
  surface = pygame.Surface(align_info['size'], pygame.SRCALPHA)
@@ -191,13 +198,14 @@ pygame.init()
191
198
  pygame.display.set_caption("Lorem Ipsum")
192
199
 
193
200
  running = True
194
- wscrn, hscrn = 600, 600
195
- screen = pygame.display.set_mode((wscrn, hscrn))
201
+ width, height = 800, 600
202
+ screen = pygame.display.set_mode((width, height))
196
203
  clock = pygame.time.Clock()
204
+
197
205
  surface = render_wrap(
198
- font=pygame.font.Font(None, 20),
206
+ font=pygame.font.SysFont('Arial', 18),
199
207
  text=LOREM_IPSUM_PARAGRAPHS,
200
- width=wscrn,
208
+ width=width,
201
209
  antialias=True,
202
210
  color='#ffffff',
203
211
  background='#303030',
@@ -205,7 +213,7 @@ surface = render_wrap(
205
213
  )
206
214
 
207
215
  wsurf, hsurf = surface.get_size()
208
- pos = ((wscrn - wsurf) / 2, (hscrn - hsurf) / 2)
216
+ pos = ((width - wsurf) / 2, (height - hsurf) / 2)
209
217
 
210
218
  while running:
211
219
  for event in pygame.event.get():
@@ -221,24 +229,26 @@ while running:
221
229
  ```py
222
230
  from txtwrap import printwrap, LOREM_IPSUM_WORDS
223
231
 
224
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='left')
225
- print('=' * 20)
226
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='center')
227
- print('=' * 20)
228
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='right')
229
- print('=' * 20)
230
- printwrap(LOREM_IPSUM_WORDS, width=20, alignment='fill')
232
+ width = 20
233
+
234
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='left')
235
+ print('=' * width)
236
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='center')
237
+ print('=' * width)
238
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='right')
239
+ print('=' * width)
240
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='fill') # or alignment='fill-left'
241
+ print('=' * width)
242
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='fill-center')
243
+ print('=' * width)
244
+ printwrap(LOREM_IPSUM_WORDS, width=width, alignment='fill-right')
231
245
  ```
232
246
 
233
247
  ### Short a long text🔤
234
248
  ```py
235
249
  from txtwrap import shorten, LOREM_IPSUM_SENTENCES
236
250
 
237
- short_lorem = shorten(LOREM_IPSUM_SENTENCES, width=20, placeholder='…')
238
- test = shorten(' Helllo, \t\n World!!\f', width=20, placeholder='…', strip_space=True)
239
-
240
- print(short_lorem)
241
- print(test)
251
+ print(shorten(LOREM_IPSUM_SENTENCES, width=20, placeholder='…'))
242
252
  ```
243
253
 
244
254
  ### Bonus🎁 - Print a colorfull text to terminal🔥
@@ -5,20 +5,21 @@ with open('README.md', encoding='utf-8') as readme:
5
5
 
6
6
  setup(
7
7
  name='txtwrap',
8
- version='2.0.0',
8
+ version='2.1.0',
9
9
  description='A simple text wrapping tool.',
10
10
  long_description=long_description,
11
11
  long_description_content_type='text/markdown',
12
12
  author='azzammuhyala',
13
+ author_email='azzammuhyala@gmail.com',
13
14
  license='MIT',
14
- python_requires='>=3.8',
15
+ python_requires='>=3.3',
15
16
  packages=find_packages(),
16
17
  include_package_data=True,
17
18
  keywords=['wrap', 'wrapper', 'wrapping', 'wrapped', 'wrapping tool', 'text wrap',
18
19
  'text wrapper', 'simple wrap', 'align', 'aligner', 'aligning', 'aligned'],
19
20
  classifiers=[
20
21
  'Programming Language :: Python :: 3',
21
- 'Programming Language :: Python :: 3.8',
22
+ 'Programming Language :: Python :: 3.3',
22
23
  'Topic :: Software Development :: Libraries :: Python Modules',
23
24
  'License :: OSI Approved :: MIT License'
24
25
  ]
@@ -2,7 +2,7 @@
2
2
  A simple text wrapping tool.
3
3
  """
4
4
 
5
- # Supports only in Python 3.8+
5
+ # Supports only in Python 3.3+
6
6
 
7
7
  from .txtwrap import (
8
8
  version,