anytext 9.0.0__py3-none-any.whl
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.
- anytext/__init__.py +207 -0
- anytext/__main__.py +19 -0
- anytext/_animator.py +590 -0
- anytext/_ansi_sequences.py +454 -0
- anytext/_ansi_theme.py +72 -0
- anytext/_arrange.py +253 -0
- anytext/_async.py +329 -0
- anytext/_auto_scroll.py +30 -0
- anytext/_binary_encode.py +325 -0
- anytext/_border.py +479 -0
- anytext/_box_drawing.py +366 -0
- anytext/_callback.py +107 -0
- anytext/_cells.py +44 -0
- anytext/_color_constants.py +192 -0
- anytext/_compat.py +73 -0
- anytext/_compositor.py +1272 -0
- anytext/_context.py +28 -0
- anytext/_debug.py +26 -0
- anytext/_dispatch_key.py +68 -0
- anytext/_doc.py +191 -0
- anytext/_duration.py +44 -0
- anytext/_easing.py +131 -0
- anytext/_event_broker.py +37 -0
- anytext/_extrema.py +64 -0
- anytext/_files.py +28 -0
- anytext/_immutable_sequence_view.py +69 -0
- anytext/_import_app.py +126 -0
- anytext/_keyboard_protocol.py +143 -0
- anytext/_layout_resolve.py +85 -0
- anytext/_line_split.py +23 -0
- anytext/_log.py +23 -0
- anytext/_loop.py +86 -0
- anytext/_markup_playground.py +150 -0
- anytext/_node_list.py +236 -0
- anytext/_on.py +93 -0
- anytext/_opacity.py +42 -0
- anytext/_parser.py +126 -0
- anytext/_partition.py +27 -0
- anytext/_path.py +72 -0
- anytext/_profile.py +26 -0
- anytext/_queue.py +65 -0
- anytext/_resolve.py +347 -0
- anytext/_segment_tools.py +307 -0
- anytext/_sleep.py +5 -0
- anytext/_slug.py +140 -0
- anytext/_spatial_map.py +103 -0
- anytext/_styles_cache.py +523 -0
- anytext/_text_area_theme.py +434 -0
- anytext/_thread_worker.py +59 -0
- anytext/_time.py +56 -0
- anytext/_tree_sitter.py +44 -0
- anytext/_two_way_dict.py +72 -0
- anytext/_types.py +57 -0
- anytext/_wait.py +42 -0
- anytext/_widget_navigation.py +182 -0
- anytext/_win_sleep.py +132 -0
- anytext/_work_decorator.py +158 -0
- anytext/_wrap.py +147 -0
- anytext/_xterm_parser.py +468 -0
- anytext/actions.py +59 -0
- anytext/app.py +5028 -0
- anytext/await_complete.py +89 -0
- anytext/await_remove.py +47 -0
- anytext/binding.py +400 -0
- anytext/box_model.py +15 -0
- anytext/cache.py +314 -0
- anytext/canvas.py +284 -0
- anytext/case.py +23 -0
- anytext/clock.py +74 -0
- anytext/color.py +856 -0
- anytext/command.py +1285 -0
- anytext/compose.py +99 -0
- anytext/constants.py +184 -0
- anytext/containers.py +311 -0
- anytext/content.py +1842 -0
- anytext/coordinate.py +53 -0
- anytext/css/__init__.py +0 -0
- anytext/css/_error_tools.py +30 -0
- anytext/css/_help_renderables.py +97 -0
- anytext/css/_help_text.py +858 -0
- anytext/css/_style_properties.py +1258 -0
- anytext/css/_styles_builder.py +1316 -0
- anytext/css/constants.py +133 -0
- anytext/css/errors.py +50 -0
- anytext/css/match.py +74 -0
- anytext/css/model.py +306 -0
- anytext/css/parse.py +488 -0
- anytext/css/query.py +508 -0
- anytext/css/scalar.py +381 -0
- anytext/css/scalar_animation.py +98 -0
- anytext/css/styles.py +1528 -0
- anytext/css/stylesheet.py +737 -0
- anytext/css/tokenize.py +349 -0
- anytext/css/tokenizer.py +384 -0
- anytext/css/transition.py +16 -0
- anytext/css/types.py +92 -0
- anytext/demo/__main__.py +5 -0
- anytext/demo/_project_data.py +107 -0
- anytext/demo/_project_stargazer_updater.py +50 -0
- anytext/demo/_project_stars.py +15 -0
- anytext/demo/data.py +458 -0
- anytext/demo/demo_app.py +105 -0
- anytext/demo/game.py +589 -0
- anytext/demo/home.py +269 -0
- anytext/demo/page.py +98 -0
- anytext/demo/projects.py +137 -0
- anytext/demo/widgets.py +822 -0
- anytext/design.py +559 -0
- anytext/document/__init__.py +0 -0
- anytext/document/_document.py +473 -0
- anytext/document/_document_navigator.py +470 -0
- anytext/document/_edit.py +151 -0
- anytext/document/_history.py +183 -0
- anytext/document/_syntax_aware_document.py +234 -0
- anytext/document/_wrapped_document.py +454 -0
- anytext/dom.py +1943 -0
- anytext/driver.py +313 -0
- anytext/drivers/__init__.py +0 -0
- anytext/drivers/_byte_stream.py +157 -0
- anytext/drivers/_input_reader.py +10 -0
- anytext/drivers/_input_reader_linux.py +41 -0
- anytext/drivers/_input_reader_windows.py +35 -0
- anytext/drivers/_writer_thread.py +61 -0
- anytext/drivers/callback_driver.py +90 -0
- anytext/drivers/headless_driver.py +60 -0
- anytext/drivers/linux_async_driver.py +71 -0
- anytext/drivers/linux_driver.py +488 -0
- anytext/drivers/linux_inline_driver.py +319 -0
- anytext/drivers/web_driver.py +350 -0
- anytext/drivers/win32.py +299 -0
- anytext/drivers/windows_driver.py +133 -0
- anytext/errors.py +26 -0
- anytext/eta.py +129 -0
- anytext/events.py +996 -0
- anytext/expand_tabs.py +108 -0
- anytext/features.py +29 -0
- anytext/file_monitor.py +64 -0
- anytext/filter.py +288 -0
- anytext/fuzzy.py +224 -0
- anytext/geometry.py +1500 -0
- anytext/getters.py +225 -0
- anytext/highlight.py +238 -0
- anytext/keys.py +368 -0
- anytext/layout.py +314 -0
- anytext/layouts/__init__.py +0 -0
- anytext/layouts/factory.py +37 -0
- anytext/layouts/grid.py +376 -0
- anytext/layouts/horizontal.py +120 -0
- anytext/layouts/stream.py +149 -0
- anytext/layouts/vertical.py +124 -0
- anytext/lazy.py +141 -0
- anytext/logging.py +40 -0
- anytext/map_geometry.py +34 -0
- anytext/markup.py +463 -0
- anytext/message.py +158 -0
- anytext/message_pump.py +923 -0
- anytext/messages.py +140 -0
- anytext/notifications.py +120 -0
- anytext/pad.py +79 -0
- anytext/pilot.py +570 -0
- anytext/py.typed +0 -0
- anytext/reactive.py +532 -0
- anytext/render.py +41 -0
- anytext/renderables/__init__.py +1 -0
- anytext/renderables/_blend_colors.py +27 -0
- anytext/renderables/background_screen.py +98 -0
- anytext/renderables/bar.py +155 -0
- anytext/renderables/blank.py +42 -0
- anytext/renderables/digits.py +253 -0
- anytext/renderables/gradient.py +170 -0
- anytext/renderables/sparkline.py +165 -0
- anytext/renderables/styled.py +50 -0
- anytext/renderables/text_opacity.py +159 -0
- anytext/renderables/tint.py +86 -0
- anytext/rlock.py +45 -0
- anytext/screen.py +2193 -0
- anytext/scroll_view.py +196 -0
- anytext/scrollbar.py +411 -0
- anytext/selection.py +461 -0
- anytext/signal.py +137 -0
- anytext/strip.py +817 -0
- anytext/style.py +537 -0
- anytext/suggester.py +144 -0
- anytext/suggestions.py +38 -0
- anytext/system_commands.py +64 -0
- anytext/theme.py +544 -0
- anytext/timer.py +204 -0
- anytext/tree-sitter/highlights/bash.scm +56 -0
- anytext/tree-sitter/highlights/css.scm +91 -0
- anytext/tree-sitter/highlights/go.scm +123 -0
- anytext/tree-sitter/highlights/html.scm +25 -0
- anytext/tree-sitter/highlights/java.scm +142 -0
- anytext/tree-sitter/highlights/javascript.scm +204 -0
- anytext/tree-sitter/highlights/json.scm +32 -0
- anytext/tree-sitter/highlights/markdown.scm +51 -0
- anytext/tree-sitter/highlights/python.scm +313 -0
- anytext/tree-sitter/highlights/regex.scm +50 -0
- anytext/tree-sitter/highlights/rust.scm +155 -0
- anytext/tree-sitter/highlights/sql.scm +444 -0
- anytext/tree-sitter/highlights/toml.scm +36 -0
- anytext/tree-sitter/highlights/xml.scm +168 -0
- anytext/tree-sitter/highlights/yaml.scm +53 -0
- anytext/types.py +52 -0
- anytext/validation.py +519 -0
- anytext/visual.py +431 -0
- anytext/walk.py +223 -0
- anytext/widget.py +4956 -0
- anytext/widgets/__init__.py +116 -0
- anytext/widgets/__init__.pyi +43 -0
- anytext/widgets/_button.py +558 -0
- anytext/widgets/_checkbox.py +26 -0
- anytext/widgets/_collapsible.py +250 -0
- anytext/widgets/_content_switcher.py +132 -0
- anytext/widgets/_data_table.py +2864 -0
- anytext/widgets/_digits.py +112 -0
- anytext/widgets/_directory_tree.py +588 -0
- anytext/widgets/_footer.py +333 -0
- anytext/widgets/_header.py +228 -0
- anytext/widgets/_help_panel.py +113 -0
- anytext/widgets/_input.py +1133 -0
- anytext/widgets/_key_panel.py +182 -0
- anytext/widgets/_label.py +73 -0
- anytext/widgets/_link.py +71 -0
- anytext/widgets/_list_item.py +39 -0
- anytext/widgets/_list_view.py +396 -0
- anytext/widgets/_loading_indicator.py +93 -0
- anytext/widgets/_log.py +364 -0
- anytext/widgets/_markdown.py +1720 -0
- anytext/widgets/_markdown_viewer.py +3 -0
- anytext/widgets/_masked_input.py +707 -0
- anytext/widgets/_option_list.py +1039 -0
- anytext/widgets/_placeholder.py +186 -0
- anytext/widgets/_pretty.py +56 -0
- anytext/widgets/_progress_bar.py +385 -0
- anytext/widgets/_radio_button.py +33 -0
- anytext/widgets/_radio_set.py +315 -0
- anytext/widgets/_rich_log.py +320 -0
- anytext/widgets/_rule.py +268 -0
- anytext/widgets/_select.py +719 -0
- anytext/widgets/_selection_list.py +715 -0
- anytext/widgets/_sparkline.py +109 -0
- anytext/widgets/_static.py +95 -0
- anytext/widgets/_switch.py +221 -0
- anytext/widgets/_tab.py +3 -0
- anytext/widgets/_tab_pane.py +3 -0
- anytext/widgets/_tabbed_content.py +716 -0
- anytext/widgets/_tabs.py +874 -0
- anytext/widgets/_text_area.py +2798 -0
- anytext/widgets/_toast.py +206 -0
- anytext/widgets/_toggle_button.py +285 -0
- anytext/widgets/_tooltip.py +24 -0
- anytext/widgets/_tree.py +1601 -0
- anytext/widgets/_welcome.py +59 -0
- anytext/widgets/button.py +3 -0
- anytext/widgets/collapsible.py +3 -0
- anytext/widgets/data_table.py +29 -0
- anytext/widgets/directory_tree.py +3 -0
- anytext/widgets/input.py +3 -0
- anytext/widgets/markdown.py +17 -0
- anytext/widgets/option_list.py +3 -0
- anytext/widgets/rule.py +13 -0
- anytext/widgets/select.py +8 -0
- anytext/widgets/selection_list.py +8 -0
- anytext/widgets/tabbed_content.py +6 -0
- anytext/widgets/text_area.py +43 -0
- anytext/widgets/tree.py +21 -0
- anytext/worker.py +462 -0
- anytext/worker_manager.py +182 -0
- anytext-9.0.0.dist-info/METADATA +107 -0
- anytext-9.0.0.dist-info/RECORD +272 -0
- anytext-9.0.0.dist-info/WHEEL +4 -0
- anytext-9.0.0.dist-info/licenses/LICENSE +21 -0
anytext/__init__.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The root Anytext module.
|
|
3
|
+
|
|
4
|
+
Exposes some commonly used symbols.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import inspect
|
|
11
|
+
import weakref
|
|
12
|
+
from typing import TYPE_CHECKING, Callable
|
|
13
|
+
|
|
14
|
+
import rich.repr
|
|
15
|
+
|
|
16
|
+
from anytext import constants
|
|
17
|
+
from anytext._context import active_app
|
|
18
|
+
from anytext._log import LogGroup, LogVerbosity
|
|
19
|
+
from anytext._on import on
|
|
20
|
+
from anytext._work_decorator import work
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from typing_extensions import TypeAlias
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"__version__", # type: ignore
|
|
27
|
+
"log",
|
|
28
|
+
"on",
|
|
29
|
+
"work",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
LogCallable: TypeAlias = "Callable"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if TYPE_CHECKING:
|
|
37
|
+
from importlib.metadata import version
|
|
38
|
+
|
|
39
|
+
from anytext.app import App as _App
|
|
40
|
+
|
|
41
|
+
__version__ = version("anytext")
|
|
42
|
+
"""The version of Anytext."""
|
|
43
|
+
|
|
44
|
+
else:
|
|
45
|
+
|
|
46
|
+
def __getattr__(name: str) -> str:
|
|
47
|
+
"""Lazily get the version."""
|
|
48
|
+
if name == "__version__":
|
|
49
|
+
from importlib.metadata import version
|
|
50
|
+
|
|
51
|
+
return version("anytext")
|
|
52
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class LoggerError(Exception):
|
|
56
|
+
"""Raised when the logger failed."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@rich.repr.auto
|
|
60
|
+
class Logger:
|
|
61
|
+
"""A [logger class](/guide/devtools/#logging-handler) that logs to the Anytext [console](/guide/devtools#console)."""
|
|
62
|
+
|
|
63
|
+
def __init__(
|
|
64
|
+
self,
|
|
65
|
+
log_callable: LogCallable | None,
|
|
66
|
+
group: LogGroup = LogGroup.INFO,
|
|
67
|
+
verbosity: LogVerbosity = LogVerbosity.NORMAL,
|
|
68
|
+
app: _App | None = None,
|
|
69
|
+
) -> None:
|
|
70
|
+
self._log = log_callable
|
|
71
|
+
self._group = group
|
|
72
|
+
self._verbosity = verbosity
|
|
73
|
+
self._app = None if app is None else weakref.ref(app)
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def app(self) -> _App | None:
|
|
77
|
+
"""The associated application, or `None` if there isn't one."""
|
|
78
|
+
return None if self._app is None else self._app()
|
|
79
|
+
|
|
80
|
+
def __rich_repr__(self) -> rich.repr.Result:
|
|
81
|
+
yield self._group, LogGroup.INFO
|
|
82
|
+
yield self._verbosity, LogVerbosity.NORMAL
|
|
83
|
+
|
|
84
|
+
def __call__(self, *args: object, **kwargs) -> None:
|
|
85
|
+
if constants.LOG_FILE:
|
|
86
|
+
output = " ".join(str(arg) for arg in args)
|
|
87
|
+
if kwargs:
|
|
88
|
+
key_values = " ".join(
|
|
89
|
+
f"{key}={value!r}" for key, value in kwargs.items()
|
|
90
|
+
)
|
|
91
|
+
output = f"{output} {key_values}" if output else key_values
|
|
92
|
+
|
|
93
|
+
with open(constants.LOG_FILE, "a", encoding="utf-8") as log_file:
|
|
94
|
+
print(output, file=log_file)
|
|
95
|
+
|
|
96
|
+
app = self.app
|
|
97
|
+
if app is None:
|
|
98
|
+
try:
|
|
99
|
+
app = active_app.get()
|
|
100
|
+
except LookupError:
|
|
101
|
+
if constants.DEBUG:
|
|
102
|
+
print_args = (
|
|
103
|
+
*args,
|
|
104
|
+
*[f"{key}={value!r}" for key, value in kwargs.items()],
|
|
105
|
+
)
|
|
106
|
+
print(*print_args)
|
|
107
|
+
return
|
|
108
|
+
if not app._is_devtools_connected:
|
|
109
|
+
return
|
|
110
|
+
|
|
111
|
+
current_frame = inspect.currentframe()
|
|
112
|
+
assert current_frame is not None
|
|
113
|
+
previous_frame = current_frame.f_back
|
|
114
|
+
assert previous_frame is not None
|
|
115
|
+
caller = inspect.getframeinfo(previous_frame)
|
|
116
|
+
|
|
117
|
+
_log = self._log or app._log
|
|
118
|
+
try:
|
|
119
|
+
_log(
|
|
120
|
+
self._group,
|
|
121
|
+
self._verbosity,
|
|
122
|
+
caller,
|
|
123
|
+
*args,
|
|
124
|
+
**kwargs,
|
|
125
|
+
)
|
|
126
|
+
except LoggerError:
|
|
127
|
+
# If there is not active app, try printing
|
|
128
|
+
if constants.DEBUG:
|
|
129
|
+
print_args = (
|
|
130
|
+
*args,
|
|
131
|
+
*[f"{key}={value!r}" for key, value in kwargs.items()],
|
|
132
|
+
)
|
|
133
|
+
print(*print_args)
|
|
134
|
+
|
|
135
|
+
def verbosity(self, verbose: bool) -> Logger:
|
|
136
|
+
"""Get a new logger with selective verbosity.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
verbose: True to use HIGH verbosity, otherwise NORMAL.
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
New logger.
|
|
143
|
+
"""
|
|
144
|
+
verbosity = LogVerbosity.HIGH if verbose else LogVerbosity.NORMAL
|
|
145
|
+
return Logger(self._log, self._group, verbosity, app=self.app)
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def verbose(self) -> Logger:
|
|
149
|
+
"""A verbose logger."""
|
|
150
|
+
return Logger(self._log, self._group, LogVerbosity.HIGH, app=self.app)
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def event(self) -> Logger:
|
|
154
|
+
"""Logs events."""
|
|
155
|
+
return Logger(self._log, LogGroup.EVENT, app=self.app)
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def debug(self) -> Logger:
|
|
159
|
+
"""Logs debug messages."""
|
|
160
|
+
return Logger(self._log, LogGroup.DEBUG, app=self.app)
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def info(self) -> Logger:
|
|
164
|
+
"""Logs information."""
|
|
165
|
+
return Logger(self._log, LogGroup.INFO, app=self.app)
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def warning(self) -> Logger:
|
|
169
|
+
"""Logs warnings."""
|
|
170
|
+
return Logger(self._log, LogGroup.WARNING, app=self.app)
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def error(self) -> Logger:
|
|
174
|
+
"""Logs errors."""
|
|
175
|
+
return Logger(self._log, LogGroup.ERROR, app=self.app)
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def system(self) -> Logger:
|
|
179
|
+
"""Logs system information."""
|
|
180
|
+
return Logger(self._log, LogGroup.SYSTEM, app=self.app)
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def logging(self) -> Logger:
|
|
184
|
+
"""Logs from stdlib logging module."""
|
|
185
|
+
return Logger(self._log, LogGroup.LOGGING, app=self.app)
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def worker(self) -> Logger:
|
|
189
|
+
"""Logs worker information."""
|
|
190
|
+
return Logger(self._log, LogGroup.WORKER, app=self.app)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
log = Logger(None)
|
|
194
|
+
"""Global logger that logs to the currently active app.
|
|
195
|
+
|
|
196
|
+
Example:
|
|
197
|
+
```python
|
|
198
|
+
from anytext import log
|
|
199
|
+
log(locals())
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
!!! note
|
|
203
|
+
This logger will only work if there is an active app in the current thread.
|
|
204
|
+
Use `app.log` to write logs from a thread without an active app.
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
"""
|
anytext/__main__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from rich import print
|
|
2
|
+
from rich.panel import Panel
|
|
3
|
+
|
|
4
|
+
from anytext.demo.demo_app import DemoApp
|
|
5
|
+
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
app = DemoApp()
|
|
8
|
+
app.run()
|
|
9
|
+
print(
|
|
10
|
+
Panel.fit(
|
|
11
|
+
"[b magenta]Hope you liked the demo![/]\n\n"
|
|
12
|
+
"Please consider sponsoring me if you get value from my work.\n\n"
|
|
13
|
+
"Even the price of a ☕ can brighten my day!\n\n"
|
|
14
|
+
"https://github.com/sponsors/willmcgugan\n\n"
|
|
15
|
+
"- Will McGugan",
|
|
16
|
+
border_style="red",
|
|
17
|
+
title="Consider sponsoring",
|
|
18
|
+
)
|
|
19
|
+
)
|