@akiojin/gwt 9.0.4 → 9.2.0

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.
Files changed (67) hide show
  1. package/README.ja.md +106 -146
  2. package/README.md +103 -143
  3. package/bin/gwt.cjs +1 -1
  4. package/package.json +5 -5
  5. package/rustfmt.toml +0 -2
  6. package/scripts/check-release-flow.sh +2 -8
  7. package/scripts/postinstall.js +17 -7
  8. package/scripts/run-local-backend-tests-on-commit.sh +6 -12
  9. package/scripts/test-all.sh +1 -5
  10. package/scripts/check-e2e-coverage-threshold.mjs +0 -238
  11. package/scripts/run-local-e2e-coverage-on-commit.sh +0 -69
  12. package/scripts/run-local-e2e-on-commit.sh +0 -60
  13. package/scripts/verify-ci-node-toolchain.sh +0 -76
  14. package/scripts/voice-eval.sh +0 -48
  15. package/vendor/ratatui-core/src/backend/test.rs +0 -1077
  16. package/vendor/ratatui-core/src/backend.rs +0 -405
  17. package/vendor/ratatui-core/src/buffer/assert.rs +0 -71
  18. package/vendor/ratatui-core/src/buffer/buffer.rs +0 -1388
  19. package/vendor/ratatui-core/src/buffer/cell.rs +0 -377
  20. package/vendor/ratatui-core/src/buffer.rs +0 -9
  21. package/vendor/ratatui-core/src/layout/alignment.rs +0 -89
  22. package/vendor/ratatui-core/src/layout/constraint.rs +0 -526
  23. package/vendor/ratatui-core/src/layout/direction.rs +0 -63
  24. package/vendor/ratatui-core/src/layout/flex.rs +0 -212
  25. package/vendor/ratatui-core/src/layout/layout.rs +0 -2838
  26. package/vendor/ratatui-core/src/layout/margin.rs +0 -79
  27. package/vendor/ratatui-core/src/layout/offset.rs +0 -66
  28. package/vendor/ratatui-core/src/layout/position.rs +0 -253
  29. package/vendor/ratatui-core/src/layout/rect/iter.rs +0 -356
  30. package/vendor/ratatui-core/src/layout/rect/ops.rs +0 -136
  31. package/vendor/ratatui-core/src/layout/rect.rs +0 -1114
  32. package/vendor/ratatui-core/src/layout/size.rs +0 -147
  33. package/vendor/ratatui-core/src/layout.rs +0 -333
  34. package/vendor/ratatui-core/src/lib.rs +0 -82
  35. package/vendor/ratatui-core/src/style/anstyle.rs +0 -348
  36. package/vendor/ratatui-core/src/style/color.rs +0 -788
  37. package/vendor/ratatui-core/src/style/palette/material.rs +0 -608
  38. package/vendor/ratatui-core/src/style/palette/tailwind.rs +0 -653
  39. package/vendor/ratatui-core/src/style/palette.rs +0 -6
  40. package/vendor/ratatui-core/src/style/palette_conversion.rs +0 -82
  41. package/vendor/ratatui-core/src/style/stylize.rs +0 -668
  42. package/vendor/ratatui-core/src/style.rs +0 -1069
  43. package/vendor/ratatui-core/src/symbols/bar.rs +0 -51
  44. package/vendor/ratatui-core/src/symbols/block.rs +0 -51
  45. package/vendor/ratatui-core/src/symbols/border.rs +0 -709
  46. package/vendor/ratatui-core/src/symbols/braille.rs +0 -21
  47. package/vendor/ratatui-core/src/symbols/half_block.rs +0 -3
  48. package/vendor/ratatui-core/src/symbols/line.rs +0 -259
  49. package/vendor/ratatui-core/src/symbols/marker.rs +0 -82
  50. package/vendor/ratatui-core/src/symbols/merge.rs +0 -748
  51. package/vendor/ratatui-core/src/symbols/pixel.rs +0 -30
  52. package/vendor/ratatui-core/src/symbols/scrollbar.rs +0 -46
  53. package/vendor/ratatui-core/src/symbols/shade.rs +0 -5
  54. package/vendor/ratatui-core/src/symbols.rs +0 -15
  55. package/vendor/ratatui-core/src/terminal/frame.rs +0 -192
  56. package/vendor/ratatui-core/src/terminal/terminal.rs +0 -926
  57. package/vendor/ratatui-core/src/terminal/viewport.rs +0 -58
  58. package/vendor/ratatui-core/src/terminal.rs +0 -40
  59. package/vendor/ratatui-core/src/text/grapheme.rs +0 -84
  60. package/vendor/ratatui-core/src/text/line.rs +0 -1678
  61. package/vendor/ratatui-core/src/text/masked.rs +0 -149
  62. package/vendor/ratatui-core/src/text/span.rs +0 -904
  63. package/vendor/ratatui-core/src/text/text.rs +0 -1434
  64. package/vendor/ratatui-core/src/text.rs +0 -64
  65. package/vendor/ratatui-core/src/widgets/stateful_widget.rs +0 -193
  66. package/vendor/ratatui-core/src/widgets/widget.rs +0 -174
  67. package/vendor/ratatui-core/src/widgets.rs +0 -9
@@ -1,377 +0,0 @@
1
- use compact_str::CompactString;
2
-
3
- use crate::style::{Color, Modifier, Style};
4
- use crate::symbols::merge::MergeStrategy;
5
-
6
- /// A buffer cell
7
- #[derive(Debug, Default, Clone)]
8
- #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9
- pub struct Cell {
10
- /// The string to be drawn in the cell.
11
- ///
12
- /// This accepts unicode grapheme clusters which might take up more than one cell.
13
- ///
14
- /// This is a [`CompactString`] which is a wrapper around [`String`] that uses a small inline
15
- /// buffer for short strings.
16
- ///
17
- /// See <https://github.com/ratatui/ratatui/pull/601> for more information.
18
- symbol: Option<CompactString>,
19
-
20
- /// The foreground color of the cell.
21
- pub fg: Color,
22
-
23
- /// The background color of the cell.
24
- pub bg: Color,
25
-
26
- /// The underline color of the cell.
27
- #[cfg(feature = "underline-color")]
28
- pub underline_color: Color,
29
-
30
- /// The modifier of the cell.
31
- pub modifier: Modifier,
32
-
33
- /// Whether the cell should be skipped when copying (diffing) the buffer to the screen.
34
- pub skip: bool,
35
- }
36
-
37
- impl Cell {
38
- /// An empty `Cell`
39
- pub const EMPTY: Self = Self {
40
- symbol: None,
41
- fg: Color::Reset,
42
- bg: Color::Reset,
43
- #[cfg(feature = "underline-color")]
44
- underline_color: Color::Reset,
45
- modifier: Modifier::empty(),
46
- skip: false,
47
- };
48
-
49
- /// Creates a new `Cell` with the given symbol.
50
- ///
51
- /// This works at compile time and puts the symbol onto the stack. Fails to build when the
52
- /// symbol doesn't fit onto the stack and requires to be placed on the heap. Use
53
- /// `Self::default().set_symbol()` in that case. See [`CompactString::const_new`] for more
54
- /// details on this.
55
- pub const fn new(symbol: &'static str) -> Self {
56
- Self {
57
- symbol: Some(CompactString::const_new(symbol)),
58
- ..Self::EMPTY
59
- }
60
- }
61
-
62
- /// Gets the symbol of the cell.
63
- ///
64
- /// If the cell has no symbol, returns a single space character.
65
- #[must_use]
66
- pub fn symbol(&self) -> &str {
67
- self.symbol.as_ref().map_or(" ", |s| s.as_str())
68
- }
69
-
70
- /// Merges the symbol of the cell with the one already on the cell, using the provided
71
- /// [`MergeStrategy`].
72
- ///
73
- /// Merges [Box Drawing Unicode block] characters to create a single character representing
74
- /// their combination, useful for [border collapsing]. Currently limited to box drawing
75
- /// characters, with potential future support for others.
76
- ///
77
- /// Merging may not be perfect due to Unicode limitations; some symbol combinations might not
78
- /// produce a valid character. [`MergeStrategy`] defines how to handle such cases, e.g.,
79
- /// `Exact` for valid merges only, or `Fuzzy` for close matches.
80
- ///
81
- /// If the cell has no symbol set, it will set the symbol to the provided one rather than
82
- /// merging.
83
- ///
84
- /// # Example
85
- ///
86
- /// ```
87
- /// # use ratatui_core::buffer::Cell;
88
- /// use ratatui_core::symbols::merge::MergeStrategy;
89
- ///
90
- /// assert_eq!(
91
- /// Cell::new("┘")
92
- /// .merge_symbol("┏", MergeStrategy::Exact)
93
- /// .symbol(),
94
- /// "╆",
95
- /// );
96
- ///
97
- /// assert_eq!(
98
- /// Cell::new("╭")
99
- /// .merge_symbol("┘", MergeStrategy::Fuzzy)
100
- /// .symbol(),
101
- /// "┼",
102
- /// );
103
- /// ```
104
- ///
105
- /// [border collapsing]: https://ratatui.rs/recipes/layout/collapse-borders/
106
- /// [Box Drawing Unicode block]: https://en.wikipedia.org/wiki/Box_Drawing
107
- pub fn merge_symbol(&mut self, symbol: &str, strategy: MergeStrategy) -> &mut Self {
108
- let merged_symbol = self
109
- .symbol
110
- .as_ref()
111
- .map_or(symbol, |s| strategy.merge(s, symbol));
112
- self.symbol = Some(CompactString::new(merged_symbol));
113
- self
114
- }
115
-
116
- /// Sets the symbol of the cell.
117
- pub fn set_symbol(&mut self, symbol: &str) -> &mut Self {
118
- self.symbol = Some(CompactString::new(symbol));
119
- self
120
- }
121
-
122
- /// Appends a symbol to the cell.
123
- ///
124
- /// This is particularly useful for adding zero-width characters to the cell.
125
- pub(crate) fn append_symbol(&mut self, symbol: &str) -> &mut Self {
126
- self.symbol.get_or_insert_default().push_str(symbol);
127
- self
128
- }
129
-
130
- /// Sets the symbol of the cell to a single character.
131
- pub fn set_char(&mut self, ch: char) -> &mut Self {
132
- let mut buf = [0; 4];
133
- self.symbol = Some(CompactString::new(ch.encode_utf8(&mut buf)));
134
- self
135
- }
136
-
137
- /// Sets the foreground color of the cell.
138
- pub const fn set_fg(&mut self, color: Color) -> &mut Self {
139
- self.fg = color;
140
- self
141
- }
142
-
143
- /// Sets the background color of the cell.
144
- pub const fn set_bg(&mut self, color: Color) -> &mut Self {
145
- self.bg = color;
146
- self
147
- }
148
-
149
- /// Sets the style of the cell.
150
- ///
151
- /// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
152
- /// your own type that implements [`Into<Style>`]).
153
- pub fn set_style<S: Into<Style>>(&mut self, style: S) -> &mut Self {
154
- let style = style.into();
155
- if let Some(c) = style.fg {
156
- self.fg = c;
157
- }
158
- if let Some(c) = style.bg {
159
- self.bg = c;
160
- }
161
- #[cfg(feature = "underline-color")]
162
- if let Some(c) = style.underline_color {
163
- self.underline_color = c;
164
- }
165
- self.modifier.insert(style.add_modifier);
166
- self.modifier.remove(style.sub_modifier);
167
- self
168
- }
169
-
170
- /// Returns the style of the cell.
171
- #[must_use]
172
- pub const fn style(&self) -> Style {
173
- Style {
174
- fg: Some(self.fg),
175
- bg: Some(self.bg),
176
- #[cfg(feature = "underline-color")]
177
- underline_color: Some(self.underline_color),
178
- add_modifier: self.modifier,
179
- sub_modifier: Modifier::empty(),
180
- }
181
- }
182
-
183
- /// Sets the cell to be skipped when copying (diffing) the buffer to the screen.
184
- ///
185
- /// This is helpful when it is necessary to prevent the buffer from overwriting a cell that is
186
- /// covered by an image from some terminal graphics protocol (Sixel / iTerm / Kitty ...).
187
- pub const fn set_skip(&mut self, skip: bool) -> &mut Self {
188
- self.skip = skip;
189
- self
190
- }
191
-
192
- /// Resets the cell to the empty state.
193
- pub fn reset(&mut self) {
194
- *self = Self::EMPTY;
195
- }
196
- }
197
-
198
- impl PartialEq for Cell {
199
- /// Compares two `Cell`s for equality.
200
- ///
201
- /// Note that cells with no symbol (i.e., `Cell::EMPTY`) are considered equal to cells with a
202
- /// single space symbol. This is to ensure that empty cells are treated uniformly,
203
- /// regardless of how they were created
204
- fn eq(&self, other: &Self) -> bool {
205
- // Treat None and Some(" ") as equal
206
- let symbols_eq = self.symbol() == other.symbol();
207
-
208
- #[cfg(feature = "underline-color")]
209
- let underline_color_eq = self.underline_color == other.underline_color;
210
- #[cfg(not(feature = "underline-color"))]
211
- let underline_color_eq = true;
212
-
213
- symbols_eq
214
- && underline_color_eq
215
- && self.fg == other.fg
216
- && self.bg == other.bg
217
- && self.modifier == other.modifier
218
- && self.skip == other.skip
219
- }
220
- }
221
-
222
- impl Eq for Cell {}
223
-
224
- impl core::hash::Hash for Cell {
225
- /// Hashes the cell.
226
- ///
227
- /// This treats symbols with Some(" ") as equal to None, so that empty cells are
228
- /// treated uniformly, regardless of how they were created.
229
- fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
230
- self.symbol().hash(state);
231
- self.fg.hash(state);
232
- self.bg.hash(state);
233
- #[cfg(feature = "underline-color")]
234
- self.underline_color.hash(state);
235
- self.modifier.hash(state);
236
- self.skip.hash(state);
237
- }
238
- }
239
-
240
- impl From<char> for Cell {
241
- fn from(ch: char) -> Self {
242
- let mut cell = Self::EMPTY;
243
- cell.set_char(ch);
244
- cell
245
- }
246
- }
247
-
248
- #[cfg(test)]
249
- mod tests {
250
- use super::*;
251
-
252
- #[test]
253
- fn new() {
254
- let cell = Cell::new("あ");
255
- assert_eq!(
256
- cell,
257
- Cell {
258
- symbol: Some(CompactString::const_new("あ")),
259
- fg: Color::Reset,
260
- bg: Color::Reset,
261
- #[cfg(feature = "underline-color")]
262
- underline_color: Color::Reset,
263
- modifier: Modifier::empty(),
264
- skip: false,
265
- }
266
- );
267
- }
268
-
269
- #[test]
270
- fn empty() {
271
- let cell = Cell::EMPTY;
272
- assert_eq!(cell.symbol(), " ");
273
- }
274
-
275
- #[test]
276
- fn set_symbol() {
277
- let mut cell = Cell::EMPTY;
278
- cell.set_symbol("あ"); // Multi-byte character
279
- assert_eq!(cell.symbol(), "あ");
280
- cell.set_symbol("👨‍👩‍👧‍👦"); // Multiple code units combined with ZWJ
281
- assert_eq!(cell.symbol(), "👨‍👩‍👧‍👦");
282
- }
283
-
284
- #[test]
285
- fn append_symbol() {
286
- let mut cell = Cell::EMPTY;
287
- cell.set_symbol("あ"); // Multi-byte character
288
- cell.append_symbol("\u{200B}"); // zero-width space
289
- assert_eq!(cell.symbol(), "あ\u{200B}");
290
- }
291
-
292
- #[test]
293
- fn set_char() {
294
- let mut cell = Cell::EMPTY;
295
- cell.set_char('あ'); // Multi-byte character
296
- assert_eq!(cell.symbol(), "あ");
297
- }
298
-
299
- #[test]
300
- fn set_fg() {
301
- let mut cell = Cell::EMPTY;
302
- cell.set_fg(Color::Red);
303
- assert_eq!(cell.fg, Color::Red);
304
- }
305
-
306
- #[test]
307
- fn set_bg() {
308
- let mut cell = Cell::EMPTY;
309
- cell.set_bg(Color::Red);
310
- assert_eq!(cell.bg, Color::Red);
311
- }
312
-
313
- #[test]
314
- fn set_style() {
315
- let mut cell = Cell::EMPTY;
316
- cell.set_style(Style::new().fg(Color::Red).bg(Color::Blue));
317
- assert_eq!(cell.fg, Color::Red);
318
- assert_eq!(cell.bg, Color::Blue);
319
- }
320
-
321
- #[test]
322
- fn set_skip() {
323
- let mut cell = Cell::EMPTY;
324
- cell.set_skip(true);
325
- assert!(cell.skip);
326
- }
327
-
328
- #[test]
329
- fn reset() {
330
- let mut cell = Cell::EMPTY;
331
- cell.set_symbol("あ");
332
- cell.set_fg(Color::Red);
333
- cell.set_bg(Color::Blue);
334
- cell.set_skip(true);
335
- cell.reset();
336
- assert_eq!(cell.symbol(), " ");
337
- assert_eq!(cell.fg, Color::Reset);
338
- assert_eq!(cell.bg, Color::Reset);
339
- assert!(!cell.skip);
340
- }
341
-
342
- #[test]
343
- fn style() {
344
- let cell = Cell::EMPTY;
345
- assert_eq!(
346
- cell.style(),
347
- Style {
348
- fg: Some(Color::Reset),
349
- bg: Some(Color::Reset),
350
- #[cfg(feature = "underline-color")]
351
- underline_color: Some(Color::Reset),
352
- add_modifier: Modifier::empty(),
353
- sub_modifier: Modifier::empty(),
354
- }
355
- );
356
- }
357
-
358
- #[test]
359
- fn default() {
360
- let cell = Cell::default();
361
- assert_eq!(cell.symbol(), " ");
362
- }
363
-
364
- #[test]
365
- fn cell_eq() {
366
- let cell1 = Cell::new("あ");
367
- let cell2 = Cell::new("あ");
368
- assert_eq!(cell1, cell2);
369
- }
370
-
371
- #[test]
372
- fn cell_ne() {
373
- let cell1 = Cell::new("あ");
374
- let cell2 = Cell::new("い");
375
- assert_ne!(cell1, cell2);
376
- }
377
- }
@@ -1,9 +0,0 @@
1
- #![warn(missing_docs)]
2
- //! A module for the [`Buffer`] and [`Cell`] types.
3
-
4
- mod assert;
5
- mod buffer;
6
- mod cell;
7
-
8
- pub use buffer::Buffer;
9
- pub use cell::Cell;
@@ -1,89 +0,0 @@
1
- use strum::{Display, EnumString};
2
-
3
- /// A type alias for `HorizontalAlignment`.
4
- ///
5
- /// Prior to Ratatui 0.30.0, [`HorizontalAlignment`] was named `Alignment`. This alias is provided
6
- /// for backwards compatibility. Because this type is used almost everywhere in Ratatui related apps
7
- /// and libraries, it's unlikely that this alias will be removed in the future.
8
- pub type Alignment = HorizontalAlignment;
9
-
10
- /// Horizontal content alignment within a layout area.
11
- ///
12
- /// Prior to Ratatui 0.30.0, this type was named `Alignment`. In Ratatui 0.30.0, the name was
13
- /// changed to `HorizontalAlignment` to make it more descriptive. The old name is still available as
14
- /// an alias for backwards compatibility.
15
- ///
16
- /// This type is used throughout Ratatui to control how content is positioned horizontally within
17
- /// available space. It's commonly used with widgets to control text alignment, but can also be
18
- /// used in layout calculations.
19
- ///
20
- /// For comprehensive layout documentation and examples, see the [`layout`](crate::layout) module.
21
- #[derive(Debug, Default, Display, EnumString, Clone, Copy, Eq, PartialEq, Hash)]
22
- #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23
- pub enum HorizontalAlignment {
24
- #[default]
25
- Left,
26
- Center,
27
- Right,
28
- }
29
-
30
- /// Vertical content alignment within a layout area.
31
- ///
32
- /// This type is used to control how content is positioned vertically within available space.
33
- /// It complements [`HorizontalAlignment`] to provide full 2D positioning control.
34
- ///
35
- /// For comprehensive layout documentation and examples, see the [`layout`](crate::layout) module.
36
- #[derive(Debug, Default, Display, EnumString, Clone, Copy, Eq, PartialEq, Hash)]
37
- #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
38
- pub enum VerticalAlignment {
39
- #[default]
40
- Top,
41
- Center,
42
- Bottom,
43
- }
44
-
45
- #[cfg(test)]
46
- mod tests {
47
- use alloc::string::ToString;
48
-
49
- use strum::ParseError;
50
-
51
- use super::*;
52
-
53
- #[test]
54
- fn alignment_to_string() {
55
- assert_eq!(Alignment::Left.to_string(), "Left");
56
- assert_eq!(Alignment::Center.to_string(), "Center");
57
- assert_eq!(Alignment::Right.to_string(), "Right");
58
- }
59
-
60
- #[test]
61
- fn alignment_from_str() {
62
- assert_eq!("Left".parse::<Alignment>(), Ok(Alignment::Left));
63
- assert_eq!("Center".parse::<Alignment>(), Ok(Alignment::Center));
64
- assert_eq!("Right".parse::<Alignment>(), Ok(Alignment::Right));
65
- assert_eq!("".parse::<Alignment>(), Err(ParseError::VariantNotFound));
66
- }
67
-
68
- #[test]
69
- fn vertical_alignment_to_string() {
70
- assert_eq!(VerticalAlignment::Top.to_string(), "Top");
71
- assert_eq!(VerticalAlignment::Center.to_string(), "Center");
72
- assert_eq!(VerticalAlignment::Bottom.to_string(), "Bottom");
73
- }
74
-
75
- #[test]
76
- fn vertical_alignment_from_str() {
77
- let top = "Top".parse::<VerticalAlignment>();
78
- assert_eq!(top, Ok(VerticalAlignment::Top));
79
-
80
- let center = "Center".parse::<VerticalAlignment>();
81
- assert_eq!(center, Ok(VerticalAlignment::Center));
82
-
83
- let bottom = "Bottom".parse::<VerticalAlignment>();
84
- assert_eq!(bottom, Ok(VerticalAlignment::Bottom));
85
-
86
- let invalid = "".parse::<VerticalAlignment>();
87
- assert_eq!(invalid, Err(ParseError::VariantNotFound));
88
- }
89
- }