feat(display): add separator line rendering

Swadhin Biswas committed 7 months ago
f9d4ea8
1 parent 4a32f46
commit f9d4ea8
1 file changed
+50 -0
Showing 1 changed file+50-0
▼src/display/mod.rs
+50-0
98
98
print!("\x1b[{}C", img_cols + gap);
99
99
if i < info_lines.len() {
100
100
let truncated = if right_avail > 0 {
101
+ truncate_to_width(&info_lines[i], right_avail)
102
+ } else {
103
+ info_lines[i].clone()
104
+ };
105
+ println!("{}{}", truncated, reset);
106
+ } else {
107
+ println!();
108
+ }
109
+ }
110
+ }
111
+ Err(e) => {
112
+ eprintln!("Warning: kitty image failed: {}", e);
113
+ self.render_ascii(sys_info);
114
+ }
115
+ }
116
+ }
117
+ Backend::Chafa => {
118
+ // Chafa: get text lines and use them like ASCII art
119
+ match image_backend::display_chafa(image_path, max_cols, max_rows) {
120
+ Ok(img_lines) => {
121
+ self.render_side_by_side(&img_lines, &info_lines);
122
+ }
123
+ Err(e) => {
124
+ eprintln!("Warning: chafa failed: {}", e);
125
+ self.render_ascii(sys_info);
126
+ }
127
+ }
128
+ }
129
+ Backend::Sixel => {
130
+ match image_backend::display_sixel(image_path, max_cols, max_rows) {
131
+ Ok(()) => {
132
+ // Sixel prints inline; just print info lines below
133
+ let reset = if self.config.no_color { "" } else { RESET };
134
+ for line in &info_lines {
135
+ println!("{}{}", line, reset);
136
+ }
137
+ }
138
+ Err(e) => {
139
+ eprintln!("Warning: sixel failed: {}", e);
140
+ self.render_ascii(sys_info);
141
+ }
142
+ }
143
+ }
144
+ Backend::W3m => {
145
+ match image_backend::display_w3m(image_path, max_cols, max_rows) {
146
+ Ok(()) => {
147
+ // w3m renders image at position; print info offset to the right
148
+ let gap = self.config.gap;
149
+ let offset = max_cols + gap;
150
+ let reset = if self.config.no_color { "" } else { RESET };
101
151