Skip to content

Commit 26631a8

Browse files
feat: update boxmux version to 0.186.31255, enhance choice rendering with overflow behaviors, and improve code styling in Svelte and Tailwind configuration
1 parent 9ad6133 commit 26631a8

File tree

7 files changed

+189
-37
lines changed

7 files changed

+189
-37
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ license = "MIT"
9191
name = "boxmux"
9292
readme = "README.md"
9393
repository = "https://github.com/jowharshamshiri/boxmux"
94-
version = "0.186.31255"
94+
version = "0.187.31283"
9595

9696
[package.metadata.deb]
9797
assets = [["target/release/boxmux", "usr/bin/", "755"], ["README.md", "usr/share/doc/boxmux/README", "644"], ["examples/*", "usr/share/doc/boxmux/examples/", "644"]]

docs/src/lib/components/document/doc-renderer.svelte

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,14 @@
6666
max-width: calc(100vw - 3rem);
6767
overflow-x: auto;
6868
display: block;
69-
background-color: #f6f8fa;
70-
border: 1px solid #d0d7de;
69+
background-color: hsl(var(--code-background));
70+
border: 1px solid hsl(var(--border));
7171
}
7272
7373
:global(ol .shiki-wrapper) {
7474
max-width: calc(100vw - 5rem);
7575
}
7676
77-
:global(.dark .shiki-wrapper) {
78-
background-color: #0d1117 !important;
79-
border-color: #30363d;
80-
}
81-
8277
/* Code highlighting styles */
8378
:global(.shiki) {
8479
background-color: transparent !important;
@@ -91,22 +86,20 @@
9186
:global(.prose pre) {
9287
padding: 0.75rem !important;
9388
margin: 0;
94-
background-color: #f6f8fa !important;
89+
background-color: hsl(var(--code-background)) !important;
90+
color: hsl(var(--code-foreground)) !important;
9591
}
9692
9793
:global(.prose :not(pre) > code) {
98-
background-color: rgb(175 184 193 / 20%);
94+
background-color: hsl(var(--code-background));
95+
color: hsl(var(--code-foreground));
9996
padding: 0.25rem;
10097
border-radius: 0.25rem;
10198
font-size: 0.875em;
10299
font-weight: 400;
103100
max-width: 100%;
104101
}
105102
106-
:global(.dark .prose :not(pre) > code) {
107-
background-color: rgb(30 41 59);
108-
}
109-
110103
/* Remove default code decorations */
111104
:global(.prose code::before),
112105
:global(.prose code::after) {

docs/tailwind.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const config: Config = {
8686
'pre code': {
8787
backgroundColor: 'transparent',
8888
padding: '0',
89-
color: 'inherit',
89+
color: 'hsl(var(--code-foreground))',
9090
fontSize: '0.875rem',
9191
lineHeight: '1.7142857'
9292
},

layouts/choice_wrapping_test.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
app:
2+
title: "Choice Wrapping Test"
3+
layouts:
4+
- name: "main"
5+
active: true
6+
children:
7+
- id: "wrap_choices"
8+
title: "Word Wrapping Choices"
9+
left: 10%
10+
top: 10%
11+
width: 30%
12+
height: 40%
13+
overflow_behavior: "wrap"
14+
border_color: "yellow"
15+
background_color: "black"
16+
choices:
17+
- content: "This is a very long choice that should wrap across multiple lines when displayed"
18+
script: "echo 'Choice 1 selected'"
19+
- content: "Another long choice with lots of text that will also wrap nicely"
20+
script: "echo 'Choice 2 selected'"
21+
- content: "Short choice"
22+
script: "echo 'Choice 3 selected'"
23+
- content: "This is an extremely long choice with even more text that should definitely wrap across multiple lines and demonstrate the wrapping behavior properly"
24+
script: "echo 'Choice 4 selected'"
25+
26+
- id: "scroll_choices"
27+
title: "Scrolling Choices"
28+
left: 50%
29+
top: 10%
30+
width: 30%
31+
height: 40%
32+
overflow_behavior: "scroll"
33+
border_color: "green"
34+
background_color: "black"
35+
choices:
36+
- content: "Choice 1 - This is a long choice that will be clipped"
37+
script: "echo 'Scroll Choice 1'"
38+
- content: "Choice 2 - Another choice"
39+
script: "echo 'Scroll Choice 2'"
40+
- content: "Choice 3 - Short"
41+
script: "echo 'Scroll Choice 3'"
42+
- content: "Choice 4 - Medium length choice here"
43+
script: "echo 'Scroll Choice 4'"
44+
- content: "Choice 5 - Extra choice"
45+
script: "echo 'Scroll Choice 5'"
46+
- content: "Choice 6 - More choices"
47+
script: "echo 'Scroll Choice 6'"
48+
- content: "Choice 7 - Even more"
49+
script: "echo 'Scroll Choice 7'"
50+
- content: "Choice 8 - Last choice"
51+
script: "echo 'Scroll Choice 8'"
52+
53+
- id: "output"
54+
title: "Output"
55+
left: 10%
56+
top: 60%
57+
width: 70%
58+
height: 30%
59+
border_color: "blue"
60+
background_color: "black"
61+
content: "Click choices above to see output here. The left box uses word wrapping, the right box uses scrolling."

src/draw_utils.rs

Lines changed: 118 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -666,31 +666,129 @@ pub fn render_muxbox(
666666
scrollbars_drawn = true;
667667
}
668668
} else {
669-
// Original choice rendering (no scroll support or other overflow behaviors)
669+
// Handle other overflow behaviors (wrap, fill, cross_out, removed) and clipping
670670
let mut y_position = bounds.top() + 1;
671-
for choice in choices {
672-
if y_position > bounds.bottom() - 1 {
673-
break; // Don't draw outside the bounds
671+
let viewable_width = bounds.width().saturating_sub(4);
672+
let viewable_height = bounds.height().saturating_sub(2);
673+
674+
if overflow_behavior == "wrap" {
675+
// Render choices with word wrapping
676+
for choice in choices {
677+
if y_position > bounds.bottom() - 1 {
678+
break; // Don't draw outside the bounds
679+
}
680+
681+
let fg_color = if choice.selected { selected_menu_fg_color } else { menu_fg_color };
682+
let bg_color = if choice.selected { selected_menu_bg_color } else { menu_bg_color };
683+
684+
let formatted_content = if choice.waiting {
685+
format!("{}...", choice.content.as_ref().unwrap())
686+
} else {
687+
choice.content.as_ref().unwrap().to_string()
688+
};
689+
690+
// Wrap the choice text
691+
let wrapped_lines = wrap_text_to_width(&formatted_content, viewable_width);
692+
693+
for wrapped_line in wrapped_lines {
694+
if y_position > bounds.bottom() - 1 {
695+
break; // Don't draw outside the bounds
696+
}
697+
698+
print_with_color_and_background_at(
699+
y_position,
700+
bounds.left() + 2,
701+
fg_color,
702+
bg_color,
703+
&wrapped_line,
704+
buffer,
705+
);
706+
y_position += 1;
707+
}
674708
}
709+
710+
// Check if wrapped choices overflow vertically and need scrollbar
711+
let total_wrapped_lines: usize = choices.iter().map(|choice| {
712+
let formatted_content = if choice.waiting {
713+
format!("{}...", choice.content.as_ref().unwrap())
714+
} else {
715+
choice.content.as_ref().unwrap().to_string()
716+
};
717+
wrap_text_to_width(&formatted_content, viewable_width).len()
718+
}).sum();
719+
720+
if total_wrapped_lines > viewable_height && *draw_border {
721+
draw_vertical_scrollbar(
722+
&bounds,
723+
total_wrapped_lines,
724+
viewable_height,
725+
vertical_scroll,
726+
border_color,
727+
bg_color,
728+
buffer,
729+
);
730+
scrollbars_drawn = true;
731+
}
732+
} else {
733+
// Original choice rendering (simple clipping for other overflow behaviors)
734+
for choice in choices {
735+
if y_position > bounds.bottom() - 1 {
736+
break; // Don't draw outside the bounds
737+
}
675738

676-
let fg_color = if choice.selected { selected_menu_fg_color } else { menu_fg_color };
677-
let bg_color = if choice.selected { selected_menu_bg_color } else { menu_bg_color };
739+
let fg_color = if choice.selected { selected_menu_fg_color } else { menu_fg_color };
740+
let bg_color = if choice.selected { selected_menu_bg_color } else { menu_bg_color };
678741

679-
let formatted_content = if choice.waiting {
680-
format!("{}...", choice.content.as_ref().unwrap())
681-
} else {
682-
choice.content.as_ref().unwrap().to_string()
683-
};
742+
let formatted_content = if choice.waiting {
743+
format!("{}...", choice.content.as_ref().unwrap())
744+
} else {
745+
choice.content.as_ref().unwrap().to_string()
746+
};
684747

685-
print_with_color_and_background_at(
686-
y_position,
687-
bounds.left() + 2,
688-
fg_color,
689-
bg_color,
690-
&formatted_content,
691-
buffer,
692-
);
693-
y_position += 1;
748+
// Apply overflow behavior to choice text
749+
let processed_content = match overflow_behavior {
750+
"fill" => {
751+
let mut filled = formatted_content.clone();
752+
while filled.len() < viewable_width {
753+
filled.push(' ');
754+
}
755+
filled.truncate(viewable_width);
756+
filled
757+
},
758+
"cross_out" => {
759+
let mut crossed = String::new();
760+
for ch in formatted_content.chars().take(viewable_width) {
761+
if ch == ' ' {
762+
crossed.push(' ');
763+
} else {
764+
crossed.push('X');
765+
}
766+
}
767+
crossed
768+
},
769+
"removed" => {
770+
continue; // Don't draw removed choices
771+
},
772+
_ => {
773+
// Default clipping behavior
774+
if formatted_content.len() > viewable_width {
775+
formatted_content.chars().take(viewable_width).collect()
776+
} else {
777+
formatted_content
778+
}
779+
}
780+
};
781+
782+
print_with_color_and_background_at(
783+
y_position,
784+
bounds.left() + 2,
785+
fg_color,
786+
bg_color,
787+
&processed_content,
788+
buffer,
789+
);
790+
y_position += 1;
791+
}
694792
}
695793
}
696794
} else if let Some(content) = content {

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.186.31255
1+
0.187.31283

0 commit comments

Comments
 (0)