kitbuf 0.4.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.
- kitbuf-0.4.0/Cargo.lock +156 -0
- kitbuf-0.4.0/Cargo.toml +82 -0
- kitbuf-0.4.0/LICENSE-APACHE +202 -0
- kitbuf-0.4.0/LICENSE-MIT +21 -0
- kitbuf-0.4.0/PKG-INFO +92 -0
- kitbuf-0.4.0/README.md +119 -0
- kitbuf-0.4.0/examples/fireworks.rs +491 -0
- kitbuf-0.4.0/examples/mandelbrot.rs +401 -0
- kitbuf-0.4.0/examples/plasma.rs +74 -0
- kitbuf-0.4.0/pyproject.toml +28 -0
- kitbuf-0.4.0/python/Cargo.toml +18 -0
- kitbuf-0.4.0/python/LICENSE-APACHE +202 -0
- kitbuf-0.4.0/python/LICENSE-MIT +21 -0
- kitbuf-0.4.0/python/README.md +74 -0
- kitbuf-0.4.0/python/src/events.rs +163 -0
- kitbuf-0.4.0/python/src/lib.rs +214 -0
- kitbuf-0.4.0/python/src/pixels.rs +65 -0
- kitbuf-0.4.0/python/tests/test_kitbuf.py +101 -0
- kitbuf-0.4.0/python/tests/typing_api.py +45 -0
- kitbuf-0.4.0/src/input.rs +702 -0
- kitbuf-0.4.0/src/kitbuf/__init__.py +5 -0
- kitbuf-0.4.0/src/kitbuf/__init__.pyi +156 -0
- kitbuf-0.4.0/src/kitbuf/py.typed +0 -0
- kitbuf-0.4.0/src/kitty.rs +578 -0
- kitbuf-0.4.0/src/lib.rs +18 -0
- kitbuf-0.4.0/src/overlay.rs +463 -0
- kitbuf-0.4.0/src/sys.rs +231 -0
- kitbuf-0.4.0/src/window.rs +999 -0
- kitbuf-0.4.0/tests/pty.rs +477 -0
kitbuf-0.4.0/Cargo.lock
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "adler2"
|
|
7
|
+
version = "2.0.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "heck"
|
|
13
|
+
version = "0.5.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "kitbuf"
|
|
19
|
+
version = "0.4.0"
|
|
20
|
+
dependencies = [
|
|
21
|
+
"libc",
|
|
22
|
+
"miniz_oxide",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[[package]]
|
|
26
|
+
name = "kitbuf-python"
|
|
27
|
+
version = "0.4.0"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"kitbuf",
|
|
30
|
+
"pyo3",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[[package]]
|
|
34
|
+
name = "libc"
|
|
35
|
+
version = "0.2.191"
|
|
36
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
37
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
38
|
+
|
|
39
|
+
[[package]]
|
|
40
|
+
name = "miniz_oxide"
|
|
41
|
+
version = "0.9.1"
|
|
42
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
43
|
+
checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
|
|
44
|
+
dependencies = [
|
|
45
|
+
"adler2",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[[package]]
|
|
49
|
+
name = "once_cell"
|
|
50
|
+
version = "1.21.4"
|
|
51
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
52
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
53
|
+
|
|
54
|
+
[[package]]
|
|
55
|
+
name = "portable-atomic"
|
|
56
|
+
version = "1.15.0"
|
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
58
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "proc-macro2"
|
|
62
|
+
version = "1.0.107"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
65
|
+
dependencies = [
|
|
66
|
+
"unicode-ident",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[[package]]
|
|
70
|
+
name = "pyo3"
|
|
71
|
+
version = "0.30.1"
|
|
72
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
73
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
74
|
+
dependencies = [
|
|
75
|
+
"libc",
|
|
76
|
+
"once_cell",
|
|
77
|
+
"portable-atomic",
|
|
78
|
+
"pyo3-build-config",
|
|
79
|
+
"pyo3-ffi",
|
|
80
|
+
"pyo3-macros",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[[package]]
|
|
84
|
+
name = "pyo3-build-config"
|
|
85
|
+
version = "0.30.1"
|
|
86
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
88
|
+
dependencies = [
|
|
89
|
+
"target-lexicon",
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
[[package]]
|
|
93
|
+
name = "pyo3-ffi"
|
|
94
|
+
version = "0.30.1"
|
|
95
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
96
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
97
|
+
dependencies = [
|
|
98
|
+
"libc",
|
|
99
|
+
"pyo3-build-config",
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[[package]]
|
|
103
|
+
name = "pyo3-macros"
|
|
104
|
+
version = "0.30.1"
|
|
105
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
106
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
107
|
+
dependencies = [
|
|
108
|
+
"proc-macro2",
|
|
109
|
+
"pyo3-macros-backend",
|
|
110
|
+
"quote",
|
|
111
|
+
"syn",
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
[[package]]
|
|
115
|
+
name = "pyo3-macros-backend"
|
|
116
|
+
version = "0.30.1"
|
|
117
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
118
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
119
|
+
dependencies = [
|
|
120
|
+
"heck",
|
|
121
|
+
"proc-macro2",
|
|
122
|
+
"quote",
|
|
123
|
+
"syn",
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
[[package]]
|
|
127
|
+
name = "quote"
|
|
128
|
+
version = "1.0.47"
|
|
129
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
130
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
131
|
+
dependencies = [
|
|
132
|
+
"proc-macro2",
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
[[package]]
|
|
136
|
+
name = "syn"
|
|
137
|
+
version = "3.0.10"
|
|
138
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
139
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
140
|
+
dependencies = [
|
|
141
|
+
"proc-macro2",
|
|
142
|
+
"quote",
|
|
143
|
+
"unicode-ident",
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
[[package]]
|
|
147
|
+
name = "target-lexicon"
|
|
148
|
+
version = "0.13.6"
|
|
149
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
150
|
+
checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
|
|
151
|
+
|
|
152
|
+
[[package]]
|
|
153
|
+
name = "unicode-ident"
|
|
154
|
+
version = "1.0.27"
|
|
155
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
156
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
kitbuf-0.4.0/Cargo.toml
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
members = ["python"]
|
|
3
|
+
|
|
4
|
+
[workspace.package]
|
|
5
|
+
version = "0.4.0"
|
|
6
|
+
edition = "2024"
|
|
7
|
+
rust-version = "1.100.1"
|
|
8
|
+
license = "MIT OR Apache-2.0"
|
|
9
|
+
repository = "https://github.com/fornwall/kitbuf"
|
|
10
|
+
|
|
11
|
+
[package]
|
|
12
|
+
name = "kitbuf"
|
|
13
|
+
version.workspace = true
|
|
14
|
+
edition.workspace = true
|
|
15
|
+
rust-version.workspace = true
|
|
16
|
+
description = "A full-screen pixel canvas in the terminal, drawn with the kitty graphics protocol"
|
|
17
|
+
license.workspace = true
|
|
18
|
+
repository.workspace = true
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
keywords = ["terminal", "kitty", "ghostty", "framebuffer", "graphics"]
|
|
21
|
+
categories = ["command-line-interface", "graphics", "rendering"]
|
|
22
|
+
include = ["/src", "/examples", "/tests", "/README.md", "/LICENSE-*"]
|
|
23
|
+
|
|
24
|
+
[package.metadata.docs.rs]
|
|
25
|
+
# The crate is empty on other platforms.
|
|
26
|
+
targets = ["x86_64-unknown-linux-gnu"]
|
|
27
|
+
|
|
28
|
+
[target.'cfg(unix)'.dependencies]
|
|
29
|
+
libc = "0.2"
|
|
30
|
+
miniz_oxide = { version = "0.9.1", default-features = false, features = ["with-alloc"] }
|
|
31
|
+
|
|
32
|
+
[lints.rust]
|
|
33
|
+
let_underscore_drop = "warn"
|
|
34
|
+
meta_variable_misuse = "warn"
|
|
35
|
+
missing_debug_implementations = "warn"
|
|
36
|
+
missing_docs = "warn"
|
|
37
|
+
non_ascii_idents = "warn"
|
|
38
|
+
redundant_imports = "warn"
|
|
39
|
+
redundant_lifetimes = "warn"
|
|
40
|
+
rust_2018_idioms = { level = "warn", priority = -1 }
|
|
41
|
+
single_use_lifetimes = "warn"
|
|
42
|
+
trivial_casts = "warn"
|
|
43
|
+
trivial_numeric_casts = "warn"
|
|
44
|
+
unit_bindings = "warn"
|
|
45
|
+
unnameable_types = "warn"
|
|
46
|
+
unreachable_pub = "warn"
|
|
47
|
+
unused_import_braces = "warn"
|
|
48
|
+
unused_lifetimes = "warn"
|
|
49
|
+
unused_macro_rules = "warn"
|
|
50
|
+
unused_qualifications = "warn"
|
|
51
|
+
|
|
52
|
+
[lints.clippy]
|
|
53
|
+
all = { level = "warn", priority = -1 }
|
|
54
|
+
pedantic = { level = "warn", priority = -1 }
|
|
55
|
+
nursery = { level = "warn", priority = -1 }
|
|
56
|
+
cargo = { level = "warn", priority = -1 }
|
|
57
|
+
# Selected restriction lints.
|
|
58
|
+
allow_attributes = "warn"
|
|
59
|
+
allow_attributes_without_reason = "warn"
|
|
60
|
+
dbg_macro = "warn"
|
|
61
|
+
get_unwrap = "warn"
|
|
62
|
+
missing_assert_message = "warn"
|
|
63
|
+
multiple_unsafe_ops_per_block = "warn"
|
|
64
|
+
print_stderr = "warn"
|
|
65
|
+
print_stdout = "warn"
|
|
66
|
+
redundant_type_annotations = "warn"
|
|
67
|
+
todo = "warn"
|
|
68
|
+
undocumented_unsafe_blocks = "warn"
|
|
69
|
+
unimplemented = "warn"
|
|
70
|
+
unnecessary_safety_comment = "warn"
|
|
71
|
+
unnecessary_safety_doc = "warn"
|
|
72
|
+
unwrap_used = "warn"
|
|
73
|
+
# Conflicts with rustc's `unreachable_pub`, which is the one kept.
|
|
74
|
+
redundant_pub_crate = "allow"
|
|
75
|
+
# Pixel math converts between integer and float types all the time.
|
|
76
|
+
cast_possible_truncation = "allow"
|
|
77
|
+
cast_possible_wrap = "allow"
|
|
78
|
+
cast_precision_loss = "allow"
|
|
79
|
+
cast_sign_loss = "allow"
|
|
80
|
+
# The default x86-64 target lacks the `fma` feature, so `mul_add` becomes a call
|
|
81
|
+
# to `fmaf` that blocks inlining and vectorization (16x slower in a simple loop).
|
|
82
|
+
suboptimal_flops = "allow"
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
kitbuf-0.4.0/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fredrik Fornwall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
kitbuf-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kitbuf
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Classifier: Operating System :: MacOS
|
|
5
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
6
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
7
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
8
|
+
Classifier: Programming Language :: Rust
|
|
9
|
+
Classifier: Typing :: Typed
|
|
10
|
+
License-File: LICENSE-APACHE
|
|
11
|
+
License-File: LICENSE-MIT
|
|
12
|
+
Summary: A full-screen pixel canvas in the terminal, drawn with the kitty graphics protocol
|
|
13
|
+
License-Expression: MIT OR Apache-2.0
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
16
|
+
Project-URL: Repository, https://github.com/fornwall/kitbuf
|
|
17
|
+
|
|
18
|
+
# kitbuf for Python
|
|
19
|
+
|
|
20
|
+
Draw pixels in a full-screen terminal window, including over SSH. kitbuf handles
|
|
21
|
+
keyboard and mouse input, resize events, text overlays, and sending changed
|
|
22
|
+
regions to the terminal. It requires Ghostty 1.4+ or kitty 0.49+.
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
python -m pip install kitbuf
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from array import array
|
|
30
|
+
from kitbuf import Event, Window
|
|
31
|
+
|
|
32
|
+
with Window(continuous=False) as window:
|
|
33
|
+
for event in window:
|
|
34
|
+
match event:
|
|
35
|
+
case Event.Redraw():
|
|
36
|
+
width, height = window.size()
|
|
37
|
+
pixels = array("I", [0x204060]) * (width * height)
|
|
38
|
+
window.text(1, 0, "Press Escape to quit")
|
|
39
|
+
window.present(pixels)
|
|
40
|
+
case Event.Key(key="escape"):
|
|
41
|
+
break
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Drawing
|
|
45
|
+
|
|
46
|
+
`window.present(pixels)` takes a C-contiguous buffer of native-endian
|
|
47
|
+
32-bit pixels. Red occupies bits 16–23, green bits 8–15, and blue bits 0–7.
|
|
48
|
+
Rows run from top to bottom. On the supported little-endian platforms a
|
|
49
|
+
pixel occupies four bytes in blue, green, red, unused order.
|
|
50
|
+
|
|
51
|
+
Use an `array("I")`, a `bytearray`, a `memoryview`, or a contiguous NumPy
|
|
52
|
+
`uint32` array shaped `(height, width)`. The buffer belongs to the caller
|
|
53
|
+
and can be reused as soon as `present` returns. Allocate it once per canvas
|
|
54
|
+
size and recreate it on `Event.Resize`.
|
|
55
|
+
|
|
56
|
+
To draw with Pycairo, create a surface over the same buffer, then flush the
|
|
57
|
+
surface before presenting each frame.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from math import tau
|
|
61
|
+
import cairo
|
|
62
|
+
|
|
63
|
+
width, height = window.size()
|
|
64
|
+
pixels = bytearray(width * height * 4)
|
|
65
|
+
surface = cairo.ImageSurface.create_for_data(
|
|
66
|
+
pixels, cairo.Format.RGB24, width, height, width * 4
|
|
67
|
+
)
|
|
68
|
+
ctx = cairo.Context(surface)
|
|
69
|
+
ctx.set_source_rgb(1, 0.3, 0)
|
|
70
|
+
ctx.arc(width / 2, height / 2, 20, 0, tau)
|
|
71
|
+
ctx.fill()
|
|
72
|
+
surface.flush()
|
|
73
|
+
window.present(pixels)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For Skia, wrap the same buffer in a raster surface using BGRA8888 and opaque
|
|
77
|
+
alpha. Both drawing libraries are optional. [Skia raster surfaces](https://skia-python.github.io/skia-python/reference/skia.Surfaces.html#skia.Surfaces.MakeRasterDirect)
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
The extension uses PyO3 and maturin. With a virtual environment active and
|
|
82
|
+
Rust installed, run these commands from the repository root.
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
python -m pip install ./python
|
|
86
|
+
python -I -m unittest discover -s python/tests
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
CI builds wheels for GIL-enabled CPython 3.11+ on Linux (x86-64 and AArch64)
|
|
90
|
+
and macOS (Apple Silicon). For a headless run, set `KITBUF_SNAPSHOT=frame.png` and
|
|
91
|
+
`KITBUF_SNAPSHOT_FRAMES=1` to write the first frame to disk.
|
|
92
|
+
|
kitbuf-0.4.0/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# kitbuf
|
|
2
|
+
|
|
3
|
+
[](https://crates.io/crates/kitbuf)
|
|
4
|
+
[](https://pypi.org/project/kitbuf/)
|
|
5
|
+
[](https://docs.rs/kitbuf)
|
|
6
|
+
|
|
7
|
+
A full-screen pixel canvas in the terminal, drawn with the [kitty graphics protocol].
|
|
8
|
+
|
|
9
|
+
The canvas has a pixel size, a framebuffer, keyboard and mouse input with pixel
|
|
10
|
+
positions, text drawn on top and an OK / Cancel dialog. It uses only the
|
|
11
|
+
terminal's input and output streams, so it works over ssh.
|
|
12
|
+
|
|
13
|
+
Requires Ghostty 1.4+ or kitty 0.49+; opening a window in another terminal
|
|
14
|
+
returns an error saying what is missing. Unix only: on other platforms the
|
|
15
|
+
crate is empty.
|
|
16
|
+
|
|
17
|
+
The [Python bindings](https://github.com/fornwall/kitbuf/tree/main/python)
|
|
18
|
+
accept pixel buffers from the standard library, `NumPy`, Cairo, and Skia.
|
|
19
|
+
With a Python 3.11+ virtual environment active and Rust installed, run
|
|
20
|
+
`python -m pip install ./python` from the repository root.
|
|
21
|
+
|
|
22
|
+
```rust,no_run
|
|
23
|
+
use kitbuf::{Event, Key, Window, rgb};
|
|
24
|
+
|
|
25
|
+
fn main() -> std::io::Result<()> {
|
|
26
|
+
let mut window = Window::builder().scale(3).show_fps(true).open()?;
|
|
27
|
+
let mut t = 0u32;
|
|
28
|
+
while let Some(event) = window.next_event() {
|
|
29
|
+
match event {
|
|
30
|
+
Event::Key(k) if k.key == Key::Escape => window.dialog("Quit?"),
|
|
31
|
+
Event::Dialog { ok: true } => break,
|
|
32
|
+
Event::Redraw => {
|
|
33
|
+
let (width, _) = window.size();
|
|
34
|
+
for (i, pixel) in window.pixels().iter_mut().enumerate() {
|
|
35
|
+
let (x, y) = ((i % width) as u32, (i / width) as u32);
|
|
36
|
+
*pixel = rgb((x + t) as u8, (y + t) as u8, 128);
|
|
37
|
+
}
|
|
38
|
+
window.text(1, 0, "hello from the terminal");
|
|
39
|
+
window.present()?;
|
|
40
|
+
t += 1;
|
|
41
|
+
}
|
|
42
|
+
_ => {}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
Ok(())
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
- `Window::open()`, `Window::builder()`: Enter the alternate screen, until the window is dropped. Builder options: `scale` (default 2), `max_fps` (default 60), `continuous` (default true), `show_fps`, `background`.
|
|
52
|
+
- `next_event()`: Waits for `Event::Redraw` (time to draw a frame), `Key` (press, repeat, release), `Mouse` (canvas pixel position), `Resize`, `Focus` or `Dialog`. `None` after ctrl+c.
|
|
53
|
+
- `set_continuous(false)`, `request_redraw()`: Redraw only when asked, and use no CPU while waiting for input.
|
|
54
|
+
- `size()`, `pixels()`: Canvas size and `0x00RRGGBB` pixels, kept between frames.
|
|
55
|
+
- `is_key_down(key)`, `mouse_pos()`: Polled input state.
|
|
56
|
+
- `text(col, row, text)`, `cells()`: Text over the canvas for the next frame, styled with `Text`, and the terminal size in cells.
|
|
57
|
+
- `dialog(message)`: OK / Cancel dialog, answered with `Event::Dialog { ok }`.
|
|
58
|
+
- `present()`: Show the frame drawn on `Event::Redraw`.
|
|
59
|
+
- `set_scale(scale)`, `set_show_fps(show)`: Change the pixel size or toggle the frame rate counter.
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
cargo run --release --example plasma
|
|
65
|
+
cargo run --release --example fireworks # click to launch
|
|
66
|
+
cargo run --release --example mandelbrot # scroll to zoom, drag to pan
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
With `KITBUF_SNAPSHOT=out.png` a program runs headless and saves the canvas as a
|
|
70
|
+
PNG after `KITBUF_SNAPSHOT_FRAMES` frames (default 60) at `KITBUF_SNAPSHOT_SIZE`
|
|
71
|
+
(default `1600x900`).
|
|
72
|
+
|
|
73
|
+
## How it works
|
|
74
|
+
|
|
75
|
+
- **Startup:** probes for kitty graphics with animation frames, the kitty
|
|
76
|
+
keyboard protocol, SGR-pixel mouse (mode 1016), in-band resize (mode 2048),
|
|
77
|
+
the cell size and the terminal version.
|
|
78
|
+
- **Frames:** the canvas is one image. Changed regions are PNG-encoded in
|
|
79
|
+
parallel per horizontal band and sent as in-place frame edits (`a=f`) inside
|
|
80
|
+
synchronized output (mode 2026). Unchanged frames send no image data.
|
|
81
|
+
Regions with at most 256 colors are sent as indices into a sorted palette,
|
|
82
|
+
packed into 1, 2, 4 or 8 bits per pixel, which can halve their size. zlib
|
|
83
|
+
level 6 favors size over speed, since bandwidth limits frame rates over ssh.
|
|
84
|
+
The protocol sends images as base64, which `ssh -C` mostly compresses away:
|
|
85
|
+
it cuts the bytes sent by 25-30%.
|
|
86
|
+
- **Flow control:** input takes priority over redraws. At most two frames await
|
|
87
|
+
a terminal reply. If replies go missing, a small query checks which frames
|
|
88
|
+
reached the terminal. On terminals that answer both mode queries at startup,
|
|
89
|
+
large uploads also check progress at graphics chunk or text command boundaries
|
|
90
|
+
about every 64 KiB. One more burst can travel while the reply comes back.
|
|
91
|
+
- **Text:** terminal cells, diffed against the previous frame.
|
|
92
|
+
- **Exit:** discards queued frames, cancels an active upload and restores local
|
|
93
|
+
tty settings. Deleting the image, leaving the alternate screen and draining
|
|
94
|
+
replies share a 500 ms deadline. A stalled connection can delay or prevent
|
|
95
|
+
visible cleanup. With `panic = "abort"`, run `reset` after a panic.
|
|
96
|
+
|
|
97
|
+
Dependencies: `libc` and `miniz_oxide`.
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
|
|
101
|
+
Rust 1.100.1+. Warnings are errors, and clippy's pedantic, nursery and cargo lints
|
|
102
|
+
are enabled.
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
cargo clippy --all-targets && cargo test
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
To release both packages, update the version in `[workspace.package]`, refresh
|
|
109
|
+
`Cargo.lock`, and tag that commit with `v` followed by the version. Pushing
|
|
110
|
+
the tag triggers trusted publishing to crates.io from `release.yml` and to
|
|
111
|
+
the Python Package Index from `ci.yml`. Both use the GitHub `release` environment.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
[Apache-2.0] or [MIT], at your option.
|
|
116
|
+
|
|
117
|
+
[kitty graphics protocol]: https://sw.kovidgoyal.net/kitty/graphics-protocol/
|
|
118
|
+
[Apache-2.0]: https://github.com/fornwall/kitbuf/blob/main/LICENSE-APACHE
|
|
119
|
+
[MIT]: https://github.com/fornwall/kitbuf/blob/main/LICENSE-MIT
|