tui-utilities 1.1.5__tar.gz → 1.1.6__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.

Potentially problematic release.


This version of tui-utilities might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tui_utilities
3
- Version: 1.1.5
3
+ Version: 1.1.6
4
4
  Summary: Personal-use console utilities library
5
5
  Author-email: Guido Iván Gross <grossguidoivan@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tui_utilities"
3
- version = "1.1.5"
3
+ version = "1.1.6"
4
4
  description = "Personal-use console utilities library"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}
@@ -20,7 +20,8 @@ def _style(
20
20
  top_padding = None,
21
21
  right_padding = None,
22
22
  bottom_padding = None,
23
- left_padding = None
23
+ left_padding = None,
24
+ plain_text = False
24
25
  ):
25
26
  def apply_text_styles(object):
26
27
  styleable = Text()
@@ -62,27 +63,32 @@ def _style(
62
63
  if current_segment: styleable.append(current_segment, style = style)
63
64
  return styleable
64
65
 
65
- def apply_alignment(alignable): return Align(alignable, alignment) if alignment else alignable
66
+ def apply_alignment(alignable): return Align(alignable, alignment)
66
67
 
67
68
  def apply_padding(paddable):
68
- if not padding and not top_padding and not right_padding and not bottom_padding and not left_padding: return paddable
69
69
  final_padding = (
70
- top_padding if top_padding else padding,
71
- (right_padding if right_padding else padding) * 2,
72
- bottom_padding if bottom_padding else padding,
73
- (left_padding if left_padding else padding) * 2
70
+ top_padding if top_padding is not None else padding,
71
+ (right_padding if right_padding is not None else padding) * 2,
72
+ bottom_padding if bottom_padding is not None else padding,
73
+ (left_padding if left_padding is not None else padding) * 2
74
74
  )
75
75
  return Padding(paddable, final_padding)
76
76
 
77
+ needs_layout = (
78
+ alignment is not None or
79
+ padding is not None or
80
+ top_padding is not None or
81
+ right_padding is not None or
82
+ bottom_padding is not None or
83
+ left_padding is not None
84
+ )
77
85
  if isinstance(object, (str, list)):
78
86
  styled = apply_text_styles(object)
79
- aligned = apply_alignment(styled)
80
- padded = apply_padding(aligned)
81
- return padded
87
+ if not needs_layout: return styled
88
+ return apply_padding(apply_alignment(styled))
82
89
  if isinstance(object, RenderableType):
83
- aligned = apply_alignment(object)
84
- padded = apply_padding(aligned)
85
- return padded
90
+ if not needs_layout: return object
91
+ return apply_padding(apply_alignment(object))
86
92
  styled = apply_text_styles(str(object))
87
93
  aligned = apply_alignment(styled)
88
94
  padded = apply_padding(aligned)
@@ -104,6 +110,7 @@ def print(
104
110
  left_padding = None,
105
111
  separator = " ",
106
112
  end = "\n",
113
+ plain_text = False,
107
114
  **kwargs
108
115
  ):
109
116
  renderables = []
@@ -121,7 +128,8 @@ def print(
121
128
  top_padding = top_padding,
122
129
  right_padding = right_padding,
123
130
  bottom_padding = bottom_padding,
124
- left_padding = left_padding
131
+ left_padding = left_padding,
132
+ plain_text = plain_text
125
133
  ))
126
134
  _console.print(*renderables, sep = separator, end = end, **kwargs)
127
135
 
@@ -141,7 +149,8 @@ def input(
141
149
  italic = italic,
142
150
  underline = underline,
143
151
  strike = strike,
144
- reverse = reverse
152
+ reverse = reverse,
153
+ plain_text = True
145
154
  )).strip()
146
155
 
147
156
  def clear_console(): os.system("cls")
@@ -159,7 +168,8 @@ def wait_for_key(
159
168
  top_padding = None,
160
169
  right_padding = None,
161
170
  bottom_padding = None,
162
- left_padding = None
171
+ left_padding = None,
172
+ plain_text = True
163
173
  ):
164
174
  print(
165
175
  f"\n{text}",
@@ -175,6 +185,7 @@ def wait_for_key(
175
185
  right_padding = right_padding,
176
186
  bottom_padding = bottom_padding,
177
187
  left_padding = left_padding,
178
- end = ""
188
+ end = "",
189
+ plain_text = plain_text
179
190
  )
180
191
  readchar.readkey()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tui_utilities
3
- Version: 1.1.5
3
+ Version: 1.1.6
4
4
  Summary: Personal-use console utilities library
5
5
  Author-email: Guido Iván Gross <grossguidoivan@gmail.com>
6
6
  License: MIT
File without changes
File without changes