| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
use makeover_layout as layout; |
| 13 |
use makeover_tui::{piece, table, text}; |
| 14 |
use std::time::SystemTime; |
| 15 |
|
| 16 |
use quasi_router::{ |
| 17 |
Act, Action, Bar, Cell, Chart, Clock, Field, Figure, Image, Meter, Node, Outline, Rest, Row, |
| 18 |
Tag, |
| 19 |
}; |
| 20 |
use ratatui::buffer::Buffer; |
| 21 |
use ratatui::layout::Rect; |
| 22 |
use ratatui::style::{Modifier, Style}; |
| 23 |
use ratatui::text::{Line, Span}; |
| 24 |
|
| 25 |
use crate::{Local, Pass, Tui, View, below}; |
| 26 |
|
| 27 |
|
| 28 |
pub(crate) fn height(tui: &Tui, node: &Node, width: u16, local: &Local<'_>) -> u16 { |
| 29 |
match node { |
| 30 |
Node::Heading { text: content, .. } | Node::Text { text: content, .. } => { |
| 31 |
text::height(content, width) |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
Node::Rich { source, .. } => { |
| 40 |
text::spans_height(&rich_spans(tui, source, rich_base(tui)), width) |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
Node::Act(act) => { |
| 46 |
act.asks |
| 47 |
.iter() |
| 48 |
.map(|field| field_height(tui, &field.as_asked(), width, local)) |
| 49 |
.sum::<u16>() |
| 50 |
+ text::line_height(&act_line(tui, act, false), width) |
| 51 |
+ act_note_height(tui, act, width) |
| 52 |
} |
| 53 |
Node::Link { text: label, .. } => text::height(label, width), |
| 54 |
Node::Token(tag) => text::line_height(&Line::from(tag_span(tui, tag, false)), width), |
| 55 |
Node::Figure(figure) => figure_height(tui, figure, width), |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
Node::Since { .. } | Node::Until { .. } | Node::Age { .. } => 1, |
| 61 |
Node::Image(picture) => image_height(picture, width), |
| 62 |
Node::Notice { text: content, .. } => text::height(content, width), |
| 63 |
Node::StandIn { message, act, .. } => { |
| 64 |
text::height(message, width) + act.as_ref().map_or(0, |_| 1) |
| 65 |
} |
| 66 |
Node::Field(field) => field_height(tui, field, width, local), |
| 67 |
Node::Form { fields, .. } => { |
| 68 |
fields |
| 69 |
.iter() |
| 70 |
.map(|field| field_height(tui, field, width, local)) |
| 71 |
.sum::<u16>() |
| 72 |
|
| 73 |
+ 1 |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
Node::Table { |
| 79 |
columns, |
| 80 |
rows, |
| 81 |
more, |
| 82 |
.. |
| 83 |
} if columns.is_empty() => { |
| 84 |
let gutter = list_gutter(rows); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
let branches = rows.iter().any(|row| row.open.is_some()); |
| 90 |
crate::outline::showing(rows, local.view()) |
| 91 |
.map(|(_, row)| { |
| 92 |
let body = width |
| 93 |
.saturating_sub(gutter) |
| 94 |
.saturating_sub(crate::outline::lead(row.depth, branches)); |
| 95 |
let cap = row_lines(row); |
| 96 |
let kept = fitted(tui, row, &[], body, cap); |
| 97 |
text::line_height(&row_line_of(tui, row, &[], &kept), body).clamp(1, cap) |
| 98 |
}) |
| 99 |
.sum::<u16>() |
| 100 |
+ u16::from(more.is_some()) |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
Node::Timeline { entries, .. } => entries |
| 115 |
.iter() |
| 116 |
.map(|entry| { |
| 117 |
let body = width.saturating_sub(TIMELINE_GUTTER); |
| 118 |
let cap = row_lines(&entry.row); |
| 119 |
let kept = fitted(tui, &entry.row, &[], body, cap); |
| 120 |
text::line_height(&row_line_of(tui, &entry.row, &[], &kept), body).clamp(1, cap) |
| 121 |
}) |
| 122 |
.sum::<u16>(), |
| 123 |
Node::Table { |
| 124 |
columns, |
| 125 |
rows, |
| 126 |
more, |
| 127 |
.. |
| 128 |
} => { |
| 129 |
|
| 130 |
|
| 131 |
table_height(columns, crate::outline::showing(rows, local.view()).count()) |
| 132 |
+ u16::from(more.is_some()) |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
Node::Code { runs, .. } => { |
| 139 |
text::spans_height(&code_spans(tui, runs, rich_base(tui)), width) |
| 140 |
} |
| 141 |
Node::Meter(meter) => text::line_height(&meter_line(tui, meter), width), |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
Node::Chart { axis, bars, .. } => chart_lines(tui, axis, bars) |
| 146 |
.iter() |
| 147 |
.map(|line| text::line_height(line, width)) |
| 148 |
.sum(), |
| 149 |
Node::Stats { figures, .. } => figures |
| 150 |
.iter() |
| 151 |
.map(|(figure, _)| figure_height(tui, figure, width)) |
| 152 |
.sum(), |
| 153 |
Node::Region(slot) => crate::region::height(tui, slot, width, local), |
| 154 |
|
| 155 |
|
| 156 |
_ => text::height(UNDRAWN, width), |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
#[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 174 |
pub(crate) enum Want { |
| 175 |
|
| 176 |
Cells(u16), |
| 177 |
|
| 178 |
Rest, |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
pub(crate) fn want(tui: &Tui, node: &Node) -> Want { |
| 183 |
|
| 184 |
fn spans_wide(line: &Line<'_>) -> u16 { |
| 185 |
u16::try_from( |
| 186 |
line.spans |
| 187 |
.iter() |
| 188 |
.map(|span| span.content.chars().count()) |
| 189 |
.sum::<usize>(), |
| 190 |
) |
| 191 |
.unwrap_or(u16::MAX) |
| 192 |
} |
| 193 |
fn chars_wide(text: &str) -> u16 { |
| 194 |
u16::try_from(text.chars().count()).unwrap_or(u16::MAX) |
| 195 |
} |
| 196 |
|
| 197 |
match node { |
| 198 |
Node::Heading { text, .. } | Node::Text { text, .. } | Node::Notice { text, .. } => { |
| 199 |
Want::Cells(chars_wide(text)) |
| 200 |
} |
| 201 |
Node::Link { text, .. } => Want::Cells(chars_wide(text)), |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
Node::Act(act) if act.asks.is_empty() => { |
| 206 |
Want::Cells(spans_wide(&act_line(tui, act, false))) |
| 207 |
} |
| 208 |
Node::Token(tag) => Want::Cells(spans_wide(&Line::from(tag_span(tui, tag, false)))), |
| 209 |
Node::Figure(figure) => { |
| 210 |
Want::Cells(chars_wide(&figure.value) + 1 + chars_wide(&figure.caption)) |
| 211 |
} |
| 212 |
Node::Since { .. } | Node::Until { .. } | Node::Age { .. } => Want::Cells(CLOCK_CELLS), |
| 213 |
Node::Meter(meter) => Want::Cells(spans_wide(&meter_line(tui, meter))), |
| 214 |
|
| 215 |
|
| 216 |
Node::Chart { axis, bars, .. } => Want::Cells( |
| 217 |
chart_lines(tui, axis, bars) |
| 218 |
.iter() |
| 219 |
.map(spans_wide) |
| 220 |
.max() |
| 221 |
.unwrap_or(0), |
| 222 |
), |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
Node::Field(field) => match field.width { |
| 229 |
layout::Width::Fill => Want::Rest, |
| 230 |
_ => Want::Cells(chars_wide(&field.label) + FIELD_BOX_CELLS), |
| 231 |
}, |
| 232 |
_ => Want::Rest, |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
const CLOCK_CELLS: u16 = 16; |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
const FIELD_BOX_CELLS: u16 = 12; |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
pub(crate) const UNDRAWN: &str = "(not drawn: this terminal does not know this yet)"; |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
pub(crate) const UNFILLED: &str = "(not drawn: this host has no fill for this)"; |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
pub(crate) fn draw(pass: &mut Pass<'_>, node: &Node, area: Rect, buf: &mut Buffer) -> u16 { |
| 280 |
if area.width == 0 || area.height == 0 { |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
count(pass, node); |
| 286 |
return 0; |
| 287 |
} |
| 288 |
|
| 289 |
let tui = pass.tui; |
| 290 |
match node { |
| 291 |
Node::Heading { level, text: title } => { |
| 292 |
text::draw(title, tui.style().heading(*level), area, buf) |
| 293 |
} |
| 294 |
|
| 295 |
Node::Text { |
| 296 |
text: content, |
| 297 |
tone, |
| 298 |
} => text::draw(content, tui.style().tone(*tone), area, buf), |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
Node::Rich { source, .. } => { |
| 310 |
text::draw_spans(&rich_spans(tui, source, rich_base(tui)), area, buf) |
| 311 |
} |
| 312 |
|
| 313 |
Node::Code { runs, .. } => { |
| 314 |
text::draw_spans(&code_spans(tui, runs, rich_base(tui)), area, buf) |
| 315 |
} |
| 316 |
|
| 317 |
Node::Act(act) => { |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
let mut used = 0; |
| 325 |
for field in &act.asks { |
| 326 |
used += draw_field(pass, &field.as_asked(), below(area, used), buf); |
| 327 |
} |
| 328 |
let area = below(area, used); |
| 329 |
let focused = claim_act(pass, act); |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
if pass.view.busy(&act.action) { |
| 335 |
used += text::draw_line(&busy_line(pass, tui, act, focused), area, buf); |
| 336 |
return used + draw_act_note(tui, act, below(area, used), buf); |
| 337 |
} |
| 338 |
let chosen = commit_count(pass, act.over.as_deref()); |
| 339 |
used += text::draw_line(&commit_line(tui, act, chosen, focused), area, buf); |
| 340 |
used + draw_act_note(tui, act, below(area, used), buf) |
| 341 |
} |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
Node::Link { text: label, .. } => { |
| 348 |
let focused = pass.claim(); |
| 349 |
text::draw( |
| 350 |
label, |
| 351 |
tui.style().focused(focused, link_style(tui)), |
| 352 |
area, |
| 353 |
buf, |
| 354 |
) |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
Node::Since { at } => clock_draw(tui, Clock::Since, *at, area, buf), |
| 362 |
Node::Until { at } => clock_draw(tui, Clock::Until, *at, area, buf), |
| 363 |
Node::Age { at } => clock_draw(tui, Clock::Age, *at, area, buf), |
| 364 |
|
| 365 |
Node::Token(tag) => { |
| 366 |
let focused = claim_tag(pass, tag); |
| 367 |
text::draw_line(&Line::from(tag_span(tui, tag, focused)), area, buf) |
| 368 |
} |
| 369 |
|
| 370 |
Node::Figure(figure) => draw_figure(tui, figure, area, buf), |
| 371 |
|
| 372 |
Node::Image(picture) => draw_image(tui, picture, area, buf), |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
Node::Notice { |
| 379 |
tone, |
| 380 |
text: content, |
| 381 |
act, |
| 382 |
.. |
| 383 |
} => { |
| 384 |
let style = tui.style().tone(*tone).add_modifier(Modifier::BOLD); |
| 385 |
let used = text::draw(content, style, area, buf); |
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
match act { |
| 391 |
Some(act) => { |
| 392 |
let focused = claim_act(pass, act); |
| 393 |
let line = if pass.view.busy(&act.action) { |
| 394 |
busy_line(pass, tui, act, focused) |
| 395 |
} else { |
| 396 |
act_line(tui, act, focused) |
| 397 |
}; |
| 398 |
used + text::draw_line(&line, below(area, used), buf) |
| 399 |
} |
| 400 |
None => used, |
| 401 |
} |
| 402 |
} |
| 403 |
|
| 404 |
Node::StandIn { |
| 405 |
state, |
| 406 |
message, |
| 407 |
act, |
| 408 |
.. |
| 409 |
} => { |
| 410 |
let style = match state { |
| 411 |
layout::Readiness::Failed => tui.style().tone(layout::Tone::Danger), |
| 412 |
_ => Style::default().fg(tui.theme().content_muted), |
| 413 |
}; |
| 414 |
let used = text::draw(message, style, area, buf); |
| 415 |
match act { |
| 416 |
Some(act) => { |
| 417 |
let focused = claim_act(pass, act); |
| 418 |
let line = if pass.view.busy(&act.action) { |
| 419 |
busy_line(pass, tui, act, focused) |
| 420 |
} else { |
| 421 |
act_line(tui, act, focused) |
| 422 |
}; |
| 423 |
used + text::draw_line(&line, below(area, used), buf) |
| 424 |
} |
| 425 |
None => used, |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
Node::Field(field) => draw_field(pass, field, area, buf), |
| 430 |
|
| 431 |
Node::Form { submit, fields, .. } => { |
| 432 |
let mut used = 0; |
| 433 |
for field in fields { |
| 434 |
used += draw_field(pass, field, below(area, used), buf); |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
let focused = pass.claim(); |
| 440 |
used + text::draw_line( |
| 441 |
&Line::from(vec![Span::styled( |
| 442 |
format!("[ {submit} ]"), |
| 443 |
tui.style().focused( |
| 444 |
focused, |
| 445 |
Style::default() |
| 446 |
.fg(tui.theme().selection_on) |
| 447 |
.bg(tui.theme().action_primary), |
| 448 |
), |
| 449 |
)]), |
| 450 |
below(area, used), |
| 451 |
buf, |
| 452 |
) |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
Node::Table { |
| 459 |
columns, |
| 460 |
rows, |
| 461 |
more, |
| 462 |
.. |
| 463 |
} if columns.is_empty() => { |
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
let gutter = list_gutter(rows); |
| 470 |
|
| 471 |
|
| 472 |
let branches = rows.iter().any(|row| row.open.is_some()); |
| 473 |
let folded = crate::outline::folds(rows, Some(pass.view)); |
| 474 |
let mut used = 0; |
| 475 |
for (row, folded) in rows.iter().zip(folded) { |
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
if folded { |
| 480 |
continue; |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
let focused = claim_row(pass, row); |
| 486 |
let parts = claim_parts(pass, row); |
| 487 |
let at = below(area, used); |
| 488 |
if at.height == 0 { |
| 489 |
continue; |
| 490 |
} |
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
let lead = crate::outline::lead(row.depth, branches); |
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
let cap = row_lines(row); |
| 500 |
let kept = fitted( |
| 501 |
tui, |
| 502 |
row, |
| 503 |
&parts, |
| 504 |
at.width.saturating_sub(gutter).saturating_sub(lead), |
| 505 |
cap, |
| 506 |
); |
| 507 |
let line = row_line_of(tui, row, &parts, &kept); |
| 508 |
draw_gutter(tui, pass.view, row, focused, at, buf); |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
if let Some(described) = row.open { |
| 515 |
let open = pass.view.open(&row.key(), described); |
| 516 |
buf.set_stringn( |
| 517 |
at.x + gutter + lead.saturating_sub(crate::outline::STEP), |
| 518 |
at.y, |
| 519 |
crate::outline::chevron(open), |
| 520 |
1, |
| 521 |
tui.style() |
| 522 |
.focused(focused, Style::default().fg(tui.theme().content_secondary)), |
| 523 |
); |
| 524 |
} |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
let body = Rect { |
| 530 |
x: at.x + gutter + lead, |
| 531 |
width: at.width.saturating_sub(gutter).saturating_sub(lead), |
| 532 |
height: at.height.min(cap), |
| 533 |
..at |
| 534 |
}; |
| 535 |
let drew = text::draw_line(&line, body, buf).max(1); |
| 536 |
ellipsis_if_cut(tui, &line, body, buf); |
| 537 |
used += drew; |
| 538 |
} |
| 539 |
match more { |
| 540 |
Some(rest) => used + draw_rest(pass, tui, rest, below(area, used), buf), |
| 541 |
None => used, |
| 542 |
} |
| 543 |
} |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
Node::Timeline { track, entries, .. } => { |
| 556 |
let mut used = 0; |
| 557 |
for entry in entries { |
| 558 |
let focused = claim_row(pass, &entry.row); |
| 559 |
let parts = claim_parts(pass, &entry.row); |
| 560 |
let entry_cap = row_lines(&entry.row); |
| 561 |
let kept = fitted( |
| 562 |
tui, |
| 563 |
&entry.row, |
| 564 |
&parts, |
| 565 |
area.width.saturating_sub(TIMELINE_GUTTER), |
| 566 |
entry_cap, |
| 567 |
); |
| 568 |
let line = row_line_of(tui, &entry.row, &parts, &kept); |
| 569 |
let at = below(area, used); |
| 570 |
if at.height == 0 { |
| 571 |
continue; |
| 572 |
} |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
let minute = entry.placement.at(); |
| 578 |
let clock = format!("{:02}:{:02} ", (minute / 60) % 24, minute % 60); |
| 579 |
let style = if focused { |
| 580 |
tui.style().muted.add_modifier(Modifier::REVERSED) |
| 581 |
} else { |
| 582 |
tui.style().muted |
| 583 |
}; |
| 584 |
buf.set_span( |
| 585 |
at.x, |
| 586 |
at.y, |
| 587 |
&Span::styled(clock, style), |
| 588 |
TIMELINE_GUTTER.min(at.width), |
| 589 |
); |
| 590 |
|
| 591 |
let body = Rect { |
| 592 |
x: at.x + TIMELINE_GUTTER, |
| 593 |
width: at.width.saturating_sub(TIMELINE_GUTTER), |
| 594 |
height: at.height.min(entry_cap), |
| 595 |
..at |
| 596 |
}; |
| 597 |
let drew = text::draw_line(&line, body, buf).max(1); |
| 598 |
ellipsis_if_cut(tui, &line, body, buf); |
| 599 |
used += drew; |
| 600 |
} |
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
let _ = track; |
| 607 |
used |
| 608 |
} |
| 609 |
Node::Table { |
| 610 |
columns, |
| 611 |
rows, |
| 612 |
more, |
| 613 |
.. |
| 614 |
} => { |
| 615 |
let used = draw_table(pass, columns, rows, area, buf); |
| 616 |
|
| 617 |
|
| 618 |
match more { |
| 619 |
Some(rest) => used + draw_rest(pass, tui, rest, below(area, used), buf), |
| 620 |
None => used, |
| 621 |
} |
| 622 |
} |
| 623 |
|
| 624 |
Node::Meter(meter) => text::draw_line(&meter_line(tui, meter), area, buf), |
| 625 |
|
| 626 |
Node::Chart { axis, bars, .. } => { |
| 627 |
let mut used = 0; |
| 628 |
for line in chart_lines(tui, axis, bars) { |
| 629 |
used += text::draw_line(&line, below(area, used), buf); |
| 630 |
} |
| 631 |
used |
| 632 |
} |
| 633 |
|
| 634 |
Node::Stats { figures, .. } => { |
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
let mut used = 0; |
| 641 |
for (figure, _) in figures { |
| 642 |
used += draw_figure(tui, figure, below(area, used), buf); |
| 643 |
} |
| 644 |
used |
| 645 |
} |
| 646 |
|
| 647 |
Node::Region(slot) => crate::region::draw(pass, slot, area, buf), |
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
_ => text::draw( |
| 653 |
UNDRAWN, |
| 654 |
Style::default().fg(tui.theme().content_muted), |
| 655 |
area, |
| 656 |
buf, |
| 657 |
), |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
fn count(pass: &mut Pass<'_>, node: &Node) { |
| 664 |
let mut found = Vec::new(); |
| 665 |
|
| 666 |
crate::focus::node_spots(node, "", &pass.local(), &mut found); |
| 667 |
pass.seq += found.len(); |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
fn claim_act(pass: &mut Pass<'_>, act: &Act) -> bool { |
| 672 |
!act.state.is_some_and(layout::State::suppresses_interaction) && pass.claim() |
| 673 |
} |
| 674 |
|
| 675 |
|
| 676 |
fn claim_tag(pass: &mut Pass<'_>, tag: &Tag) -> bool { |
| 677 |
matches!(tag.kind, layout::Token::Chip { .. }) && tag.action.is_some() && pass.claim() |
| 678 |
} |
| 679 |
|
| 680 |
|
| 681 |
fn claim_row(pass: &mut Pass<'_>, row: &Row) -> bool { |
| 682 |
let reachable = row.activate.is_some() |
| 683 |
|| row.toggle.is_some() |
| 684 |
|| row.selected.is_some() |
| 685 |
|| !row.menu.is_empty(); |
| 686 |
reachable && pass.claim() |
| 687 |
} |
| 688 |
|
| 689 |
|
| 690 |
fn claim_parts(pass: &mut Pass<'_>, row: &Row) -> Vec<bool> { |
| 691 |
row.cells |
| 692 |
.iter() |
| 693 |
.map(|cell| { |
| 694 |
cell.content.iter().any(|node| match node { |
| 695 |
Node::Act(act) => claim_act(pass, act), |
| 696 |
Node::Link { .. } => pass.claim(), |
| 697 |
Node::Token(tag) => claim_tag(pass, tag), |
| 698 |
_ => false, |
| 699 |
}) |
| 700 |
}) |
| 701 |
.collect() |
| 702 |
} |
| 703 |
|
| 704 |
|
| 705 |
fn link_style(tui: &Tui) -> Style { |
| 706 |
Style::default() |
| 707 |
.fg(tui.theme().action_primary) |
| 708 |
.add_modifier(Modifier::UNDERLINED) |
| 709 |
} |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
const TIMELINE_GUTTER: u16 = 6; |
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
pub(crate) struct RestPiece<'a> { |
| 732 |
|
| 733 |
pub words: String, |
| 734 |
|
| 735 |
|
| 736 |
pub action: Option<&'a Action>, |
| 737 |
} |
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
pub(crate) fn rest_pieces(rest: &Rest) -> Vec<RestPiece<'_>> { |
| 764 |
let mut pieces = vec![RestPiece { |
| 765 |
words: "Prev".to_string(), |
| 766 |
action: rest.back.as_ref(), |
| 767 |
}]; |
| 768 |
|
| 769 |
if rest.jumps.is_empty() { |
| 770 |
let paging = rest.as_layout(); |
| 771 |
pieces.push(RestPiece { |
| 772 |
words: match (paging.page(), paging.pages_total()) { |
| 773 |
(Some(page), Some(total)) => format!("{page} / {total}"), |
| 774 |
_ => match paging.remaining() { |
| 775 |
Some(0) => "No more".to_string(), |
| 776 |
Some(remaining) => format!("{remaining} more"), |
| 777 |
None => "More".to_string(), |
| 778 |
}, |
| 779 |
}, |
| 780 |
action: None, |
| 781 |
}); |
| 782 |
} else { |
| 783 |
for jump in &rest.jumps { |
| 784 |
pieces.push(RestPiece { |
| 785 |
words: jump.page.to_string(), |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
action: if jump.here { None } else { Some(&jump.action) }, |
| 790 |
}); |
| 791 |
} |
| 792 |
} |
| 793 |
|
| 794 |
pieces.push(RestPiece { |
| 795 |
words: "Next".to_string(), |
| 796 |
action: rest.forward.as_ref(), |
| 797 |
}); |
| 798 |
pieces |
| 799 |
} |
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
fn draw_rest(pass: &mut Pass<'_>, tui: &Tui, rest: &Rest, area: Rect, buf: &mut Buffer) -> u16 { |
| 807 |
let mut spans = Vec::new(); |
| 808 |
for piece in rest_pieces(rest) { |
| 809 |
if !spans.is_empty() { |
| 810 |
spans.push(Span::raw(" ")); |
| 811 |
} |
| 812 |
let style = match piece.action { |
| 813 |
Some(_) => { |
| 814 |
let focused = pass.claim(); |
| 815 |
tui.style() |
| 816 |
.focused(focused, Style::default().fg(tui.theme().action_primary)) |
| 817 |
} |
| 818 |
|
| 819 |
|
| 820 |
None => Style::default().fg(tui.theme().content_muted), |
| 821 |
}; |
| 822 |
spans.push(Span::styled(piece.words, style)); |
| 823 |
} |
| 824 |
text::draw_line(&Line::from(spans), area, buf) |
| 825 |
} |
| 826 |
|
| 827 |
fn list_gutter(rows: &[Row]) -> u16 { |
| 828 |
if rows.iter().any(|row| row.selected.is_some()) { |
| 829 |
4 |
| 830 |
} else if rows |
| 831 |
.iter() |
| 832 |
.any(|row| row.current || row.activate.is_some() || !row.menu.is_empty()) |
| 833 |
{ |
| 834 |
2 |
| 835 |
} else { |
| 836 |
0 |
| 837 |
} |
| 838 |
} |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
fn draw_gutter(tui: &Tui, view: &View, row: &Row, focused: bool, area: Rect, buf: &mut Buffer) { |
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
let tick = match (row.selected, row.value.as_deref()) { |
| 854 |
(Some(_), Some(value)) if view.is_ticked(value) => "[x]", |
| 855 |
(Some(_), Some(_)) => "[ ]", |
| 856 |
(Some(true), None) => "[x]", |
| 857 |
(Some(false), None) => "[ ]", |
| 858 |
(None, _) => "", |
| 859 |
}; |
| 860 |
if !tick.is_empty() { |
| 861 |
buf.set_stringn( |
| 862 |
area.x, |
| 863 |
area.y, |
| 864 |
tick, |
| 865 |
3, |
| 866 |
tui.style() |
| 867 |
.focused(focused, Style::default().fg(tui.theme().content_secondary)), |
| 868 |
); |
| 869 |
return; |
| 870 |
} |
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
if row.chosen == Some(true) && !(row.current || focused) { |
| 876 |
buf.set_stringn( |
| 877 |
area.x, |
| 878 |
area.y, |
| 879 |
"*", |
| 880 |
1, |
| 881 |
tui.style() |
| 882 |
.focused(focused, Style::default().fg(tui.theme().action_primary)), |
| 883 |
); |
| 884 |
return; |
| 885 |
} |
| 886 |
if row.current || focused { |
| 887 |
buf.set_stringn( |
| 888 |
area.x, |
| 889 |
area.y, |
| 890 |
">", |
| 891 |
1, |
| 892 |
tui.style() |
| 893 |
.focused(focused, Style::default().fg(tui.theme().action_primary)), |
| 894 |
); |
| 895 |
} |
| 896 |
} |
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
fn row_line_of(tui: &Tui, row: &Row, focus: &[bool], kept: &[usize]) -> Line<'static> { |
| 910 |
let mut spans = Vec::new(); |
| 911 |
for &index in kept { |
| 912 |
let Some(cell) = row.cells.get(index) else { |
| 913 |
continue; |
| 914 |
}; |
| 915 |
if !spans.is_empty() { |
| 916 |
spans.push(Span::raw(" ")); |
| 917 |
} |
| 918 |
let focused = focus.get(index).copied().unwrap_or(false); |
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
debug_assert!( |
| 929 |
matches!(cell.key, quasi_router::CellKey::Role(_)), |
| 930 |
"a cell keyed to a declared column reached a list row, which draws over the \ |
| 931 |
default column set and has no column to style it from. Key: {:?}", |
| 932 |
cell.key, |
| 933 |
); |
| 934 |
let style = match &cell.key { |
| 935 |
quasi_router::CellKey::Role(role) => part_style(tui, *role), |
| 936 |
_ => part_style(tui, quasi_router::layout::RowPart::Primary), |
| 937 |
}; |
| 938 |
for node in &cell.content { |
| 939 |
spans.extend(inline_spans(tui, node, style, focused)); |
| 940 |
} |
| 941 |
} |
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
Line::from(spans) |
| 946 |
} |
| 947 |
|
| 948 |
|
| 949 |
fn kept_all(row: &Row) -> Vec<usize> { |
| 950 |
(0..row.cells.len()).collect() |
| 951 |
} |
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
fn fitted(tui: &Tui, row: &Row, focus: &[bool], width: u16, cap: u16) -> Vec<usize> { |
| 977 |
let all = kept_all(row); |
| 978 |
let fits = |
| 979 |
|kept: &[usize]| text::line_height(&row_line_of(tui, row, focus, kept), width) <= cap; |
| 980 |
if fits(&all) { |
| 981 |
return all; |
| 982 |
} |
| 983 |
|
| 984 |
let mut kept = all.clone(); |
| 985 |
for tier in [layout::Priority::Optional, layout::Priority::Secondary] { |
| 986 |
kept.retain(|&index| { |
| 987 |
row.cells.get(index).is_none_or(|cell| { |
| 988 |
cell.content.iter().any(|n| matches!(n, Node::Act(_))) || cell.worth() != tier |
| 989 |
}) |
| 990 |
}); |
| 991 |
if fits(&kept) { |
| 992 |
return kept; |
| 993 |
} |
| 994 |
} |
| 995 |
all |
| 996 |
} |
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
fn ellipsis_if_cut(tui: &Tui, line: &Line<'_>, body: Rect, buf: &mut Buffer) { |
| 1009 |
if body.width == 0 || body.height == 0 { |
| 1010 |
return; |
| 1011 |
} |
| 1012 |
if text::line_height(line, body.width) <= body.height { |
| 1013 |
return; |
| 1014 |
} |
| 1015 |
buf.set_stringn( |
| 1016 |
body.x + body.width - 1, |
| 1017 |
body.y + body.height - 1, |
| 1018 |
"\u{2026}", |
| 1019 |
1, |
| 1020 |
tui.style().muted, |
| 1021 |
); |
| 1022 |
} |
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
fn row_lines(row: &Row) -> u16 { |
| 1036 |
row.cells |
| 1037 |
.iter() |
| 1038 |
.map(|cell| u16::from(cell.room().lines())) |
| 1039 |
.max() |
| 1040 |
.unwrap_or(1) |
| 1041 |
.max(1) |
| 1042 |
} |
| 1043 |
|
| 1044 |
|
| 1045 |
fn part_style(tui: &Tui, role: layout::RowPart) -> Style { |
| 1046 |
let theme = tui.theme(); |
| 1047 |
match role { |
| 1048 |
layout::RowPart::Primary => Style::default().fg(theme.content_primary), |
| 1049 |
layout::RowPart::Secondary => Style::default().fg(theme.content_secondary), |
| 1050 |
layout::RowPart::Meta => Style::default().fg(theme.content_muted), |
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
_ => Style::default().fg(theme.content_primary), |
| 1055 |
} |
| 1056 |
} |
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
fn lexeme_span(tui: &Tui, run: &quasi_router::screen::Lexeme, base: Style) -> Span<'static> { |
| 1076 |
let theme = tui.theme(); |
| 1077 |
let style = match run.syntax { |
| 1078 |
layout::Syntax::Plain => base, |
| 1079 |
layout::Syntax::Comment => base.fg(theme.content_muted), |
| 1080 |
layout::Syntax::String => base.fg(theme.status_success), |
| 1081 |
layout::Syntax::Keyword => base.fg(theme.action_primary), |
| 1082 |
layout::Syntax::Constant => base.fg(theme.status_warning), |
| 1083 |
layout::Syntax::Entity => base.fg(theme.status_info), |
| 1084 |
layout::Syntax::Variable => base.fg(theme.status_danger), |
| 1085 |
layout::Syntax::Support => base.fg(theme.content_secondary), |
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
_ => base, |
| 1090 |
}; |
| 1091 |
Span::styled(run.text.clone(), style) |
| 1092 |
} |
| 1093 |
|
| 1094 |
|
| 1095 |
fn code_spans(tui: &Tui, runs: &[quasi_router::screen::Lexeme], base: Style) -> Vec<Span<'static>> { |
| 1096 |
runs.iter().map(|run| lexeme_span(tui, run, base)).collect() |
| 1097 |
} |
| 1098 |
|
| 1099 |
|
| 1100 |
fn inline_spans(tui: &Tui, node: &Node, inherited: Style, focused: bool) -> Vec<Span<'static>> { |
| 1101 |
match node { |
| 1102 |
Node::Text { text, tone } => { |
| 1103 |
let style = match tone { |
| 1104 |
layout::Tone::Neutral => inherited, |
| 1105 |
other => tui.style().tone(*other), |
| 1106 |
}; |
| 1107 |
vec![Span::styled(text.clone(), style)] |
| 1108 |
} |
| 1109 |
Node::Rich { source, .. } => rich_spans(tui, source, inherited), |
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
Node::Code { runs, .. } => code_spans(tui, runs, inherited), |
| 1114 |
Node::Token(tag) => vec![tag_span(tui, tag, focused)], |
| 1115 |
Node::Act(act) => act_line(tui, act, focused).spans, |
| 1116 |
Node::Link { text, .. } => vec![Span::styled( |
| 1117 |
text.clone(), |
| 1118 |
tui.style().focused(focused, link_style(tui)), |
| 1119 |
)], |
| 1120 |
Node::Meter(meter) => meter_line(tui, meter).spans, |
| 1121 |
Node::Figure(figure) => vec![Span::styled( |
| 1122 |
format!("{} {}", figure.value, figure.caption), |
| 1123 |
inherited, |
| 1124 |
)], |
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
Node::Since { at } => vec![Span::styled(clock_text(Clock::Since, *at), inherited)], |
| 1130 |
Node::Until { at } => vec![Span::styled(clock_text(Clock::Until, *at), inherited)], |
| 1131 |
Node::Age { at } => vec![Span::styled(clock_text(Clock::Age, *at), inherited)], |
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
other => vec![Span::styled( |
| 1136 |
format!("{other:?}"), |
| 1137 |
Style::default().fg(tui.theme().status_danger), |
| 1138 |
)], |
| 1139 |
} |
| 1140 |
} |
| 1141 |
|
| 1142 |
|
| 1143 |
fn clock_draw(tui: &Tui, clock: Clock, at: SystemTime, area: Rect, buf: &mut Buffer) -> u16 { |
| 1144 |
text::draw( |
| 1145 |
&clock_text(clock, at), |
| 1146 |
tui.style().tone(layout::Tone::Neutral), |
| 1147 |
area, |
| 1148 |
buf, |
| 1149 |
) |
| 1150 |
} |
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
fn clock_text(clock: Clock, at: SystemTime) -> String { |
| 1158 |
crate::clock::text(clock, at, SystemTime::now()) |
| 1159 |
} |
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
fn rich_base(tui: &Tui) -> Style { |
| 1164 |
Style::default().fg(tui.theme().content_primary) |
| 1165 |
} |
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
fn rich_spans(tui: &Tui, source: &str, base: Style) -> Vec<Span<'static>> { |
| 1174 |
let mut spans = Vec::new(); |
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
let mut starting = true; |
| 1180 |
for run in docengine::render_runs(source) { |
| 1181 |
if starting && let Some(marker) = marker(run.block) { |
| 1182 |
spans.push(Span::styled( |
| 1183 |
marker, |
| 1184 |
Style::default().fg(tui.theme().content_muted), |
| 1185 |
)); |
| 1186 |
} |
| 1187 |
starting = run.text.ends_with('\n'); |
| 1188 |
let style = style_of(tui, base, &run); |
| 1189 |
spans.push(Span::styled(run.text, style)); |
| 1190 |
} |
| 1191 |
spans |
| 1192 |
} |
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
fn marker(block: docengine::Block) -> Option<&'static str> { |
| 1200 |
match block { |
| 1201 |
docengine::Block::Item => Some("- "), |
| 1202 |
docengine::Block::Quote => Some("> "), |
| 1203 |
docengine::Block::Prose | docengine::Block::Heading(_) => None, |
| 1204 |
} |
| 1205 |
} |
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
fn style_of(tui: &Tui, base: Style, run: &docengine::TextRun) -> Style { |
| 1213 |
let ground = match run.block { |
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
docengine::Block::Heading(1) => tui.style().heading(layout::Heading::Page), |
| 1218 |
docengine::Block::Heading(2) => tui.style().heading(layout::Heading::Section), |
| 1219 |
docengine::Block::Heading(_) => tui.style().heading(layout::Heading::Subsection), |
| 1220 |
docengine::Block::Quote => Style::default().fg(tui.theme().content_secondary), |
| 1221 |
docengine::Block::Prose | docengine::Block::Item => base, |
| 1222 |
}; |
| 1223 |
mark(tui, ground, run.emphasis) |
| 1224 |
} |
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
fn mark(tui: &Tui, base: Style, emphasis: docengine::Emphasis) -> Style { |
| 1234 |
if emphasis.is_plain() { |
| 1235 |
return base; |
| 1236 |
} |
| 1237 |
let mut style = base; |
| 1238 |
if emphasis.strong { |
| 1239 |
style = style.add_modifier(Modifier::BOLD); |
| 1240 |
} |
| 1241 |
if emphasis.italic { |
| 1242 |
style = style.add_modifier(Modifier::ITALIC); |
| 1243 |
} |
| 1244 |
if emphasis.struck { |
| 1245 |
style = style.add_modifier(Modifier::CROSSED_OUT); |
| 1246 |
} |
| 1247 |
if emphasis.code { |
| 1248 |
style = style.bg(tui.theme().surface_sunken); |
| 1249 |
} |
| 1250 |
style |
| 1251 |
} |
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
fn tag_span(tui: &Tui, tag: &Tag, focused: bool) -> Span<'static> { |
| 1271 |
piece::token( |
| 1272 |
tui.style(), |
| 1273 |
&tag.label, |
| 1274 |
tag.kind, |
| 1275 |
tag.tone, |
| 1276 |
tag.latched, |
| 1277 |
focused, |
| 1278 |
) |
| 1279 |
} |
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
fn act_line(tui: &Tui, act: &Act, focused: bool) -> Line<'static> { |
| 1288 |
piece::act(tui.style(), &act.as_layout(), focused) |
| 1289 |
} |
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
fn busy_line(pass: &Pass<'_>, tui: &Tui, act: &Act, focused: bool) -> Line<'static> { |
| 1308 |
let mut described = act.as_layout(); |
| 1309 |
described.state = Some(layout::State::Disabled); |
| 1310 |
let mut line = piece::act(tui.style(), &described, focused); |
| 1311 |
let Some(awaiting) = act.action.awaiting else { |
| 1312 |
return line; |
| 1313 |
}; |
| 1314 |
let progress = pass.view.progress_at(std::time::Instant::now()); |
| 1315 |
let lit = |
| 1316 |
makeover_tui::activity_lit(progress.elapsed.unwrap_or_default(), tui.reduced_motion()); |
| 1317 |
line.spans.push(Span::raw(" ")); |
| 1318 |
line.spans |
| 1319 |
.extend(piece::awaiting(tui.style(), awaiting, progress, lit).spans); |
| 1320 |
line |
| 1321 |
} |
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
fn commit_count(pass: &Pass<'_>, over: Option<&str>) -> Option<usize> { |
| 1327 |
over.map(|_| pass.view.ticks().count()) |
| 1328 |
} |
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
fn commit_line(tui: &Tui, act: &Act, chosen: Option<usize>, focused: bool) -> Line<'static> { |
| 1346 |
let Some(chosen) = chosen else { |
| 1347 |
return act_line(tui, act, focused); |
| 1348 |
}; |
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
let label = if chosen == 0 { |
| 1355 |
act.label.clone() |
| 1356 |
} else { |
| 1357 |
format!("{} ({chosen})", act.label) |
| 1358 |
}; |
| 1359 |
let state = if chosen == 0 { |
| 1360 |
Some(layout::State::Disabled) |
| 1361 |
} else { |
| 1362 |
act.state |
| 1363 |
}; |
| 1364 |
|
| 1365 |
piece::act( |
| 1366 |
tui.style(), |
| 1367 |
&layout::Act { |
| 1368 |
label: &label, |
| 1369 |
key: act.key.as_deref(), |
| 1370 |
tone: act.tone, |
| 1371 |
state, |
| 1372 |
|
| 1373 |
|
| 1374 |
hint: act.hint.as_deref(), |
| 1375 |
}, |
| 1376 |
focused, |
| 1377 |
) |
| 1378 |
} |
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
fn act_note_height(tui: &Tui, act: &Act, width: u16) -> u16 { |
| 1385 |
act_note(tui, act).map_or(0, |note| text::line_height(¬e, width)) |
| 1386 |
} |
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
fn draw_act_note(tui: &Tui, act: &Act, area: Rect, buf: &mut Buffer) -> u16 { |
| 1398 |
act_note(tui, act).map_or(0, |note| text::draw_line(¬e, area, buf)) |
| 1399 |
} |
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
fn act_note(tui: &Tui, act: &Act) -> Option<Line<'static>> { |
| 1409 |
piece::act_note(tui.style(), &act.as_layout()) |
| 1410 |
} |
| 1411 |
|
| 1412 |
|
| 1413 |
fn meter_line(tui: &Tui, meter: &Meter) -> Line<'static> { |
| 1414 |
piece::meter(tui.style(), &meter.as_layout()) |
| 1415 |
} |
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
fn chart_lines(tui: &Tui, axis: &Chart, bars: &[Bar]) -> Vec<Line<'static>> { |
| 1423 |
let borrowed: Vec<_> = bars.iter().map(Bar::as_layout).collect(); |
| 1424 |
piece::chart(tui.style(), &axis.as_layout(), &borrowed) |
| 1425 |
} |
| 1426 |
|
| 1427 |
|
| 1428 |
fn figure_height(_tui: &Tui, figure: &Figure, width: u16) -> u16 { |
| 1429 |
piece::figure_height(&figure.as_layout(), width) |
| 1430 |
} |
| 1431 |
|
| 1432 |
fn draw_figure(tui: &Tui, figure: &Figure, area: Rect, buf: &mut Buffer) -> u16 { |
| 1433 |
piece::figure(tui.style(), &figure.as_layout(), area, buf) |
| 1434 |
} |
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
fn image_height(picture: &Image, width: u16) -> u16 { |
| 1447 |
if !picture.speaks() { |
| 1448 |
return 0; |
| 1449 |
} |
| 1450 |
text::height(&picture.alt, width) |
| 1451 |
+ picture |
| 1452 |
.caption |
| 1453 |
.as_ref() |
| 1454 |
.map_or(0, |c| text::height(c, width)) |
| 1455 |
} |
| 1456 |
|
| 1457 |
fn draw_image(tui: &Tui, picture: &Image, area: Rect, buf: &mut Buffer) -> u16 { |
| 1458 |
if !picture.speaks() { |
| 1459 |
return 0; |
| 1460 |
} |
| 1461 |
|
| 1462 |
let used = text::draw(&picture.alt, tui.style().muted, area, buf); |
| 1463 |
let Some(caption) = &picture.caption else { |
| 1464 |
return used; |
| 1465 |
}; |
| 1466 |
|
| 1467 |
|
| 1468 |
used + text::draw(caption, tui.style().secondary, below(area, used), buf) |
| 1469 |
} |
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
fn field_height(tui: &Tui, field: &Field, width: u16, local: &Local<'_>) -> u16 { |
| 1474 |
|
| 1475 |
|
| 1476 |
if local.field_out(&field.name) { |
| 1477 |
return 0; |
| 1478 |
} |
| 1479 |
let Some(repeat) = &field.repeats else { |
| 1480 |
return one_field_height(tui, field, width); |
| 1481 |
}; |
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
let standing = local.standing(field); |
| 1487 |
let slots: u16 = (0..standing) |
| 1488 |
.map(|at| { |
| 1489 |
field |
| 1490 |
.instance_fields(at) |
| 1491 |
.iter() |
| 1492 |
.map(|slot| one_field_height(tui, slot, width)) |
| 1493 |
.sum::<u16>() |
| 1494 |
+ repeat_slot_extra(tui, field, at, width) |
| 1495 |
+ u16::from(repeat.fewer(standing)) |
| 1496 |
}) |
| 1497 |
.sum(); |
| 1498 |
field |
| 1499 |
.error |
| 1500 |
.as_ref() |
| 1501 |
.map_or(0, |error| text::height(error, width)) |
| 1502 |
+ slots |
| 1503 |
+ u16::from(repeat.add.label().is_some() && repeat.more(standing)) |
| 1504 |
} |
| 1505 |
|
| 1506 |
fn one_field_height(tui: &Tui, field: &Field, width: u16) -> u16 { |
| 1507 |
field.with_layout(|field| piece::field_height(tui.style(), &field, width)) |
| 1508 |
} |
| 1509 |
|
| 1510 |
fn draw_field(pass: &mut Pass<'_>, field: &Field, area: Rect, buf: &mut Buffer) -> u16 { |
| 1511 |
|
| 1512 |
|
| 1513 |
if pass.local().field_out(&field.name) { |
| 1514 |
return 0; |
| 1515 |
} |
| 1516 |
let Some(repeat) = field.repeats.clone() else { |
| 1517 |
return draw_one_field(pass, field, area, buf); |
| 1518 |
}; |
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
let tui = pass.tui; |
| 1524 |
let standing = pass.view.standing(field); |
| 1525 |
|
| 1526 |
|
| 1527 |
let mut used = field.error.as_ref().map_or(0, |error| { |
| 1528 |
text::draw(error, tui.style().tone(layout::Tone::Danger), area, buf) |
| 1529 |
}); |
| 1530 |
for at in 0..standing { |
| 1531 |
for slot in field.instance_fields(at) { |
| 1532 |
used += draw_one_field(pass, &slot, crate::below(area, used), buf); |
| 1533 |
} |
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
if let Some(slot) = repeat.instances.get(at) { |
| 1538 |
if let Some(error) = &slot.error { |
| 1539 |
used += text::draw( |
| 1540 |
error, |
| 1541 |
tui.style().tone(layout::Tone::Danger), |
| 1542 |
crate::below(area, used), |
| 1543 |
buf, |
| 1544 |
); |
| 1545 |
} |
| 1546 |
if let quasi_router::Progress::Working(Some(meter)) = &slot.progress { |
| 1547 |
used += text::draw_line(&meter_line(tui, meter), crate::below(area, used), buf); |
| 1548 |
} |
| 1549 |
} |
| 1550 |
if repeat.fewer(standing) { |
| 1551 |
used += draw_repeat_control(pass, &repeat.remove, crate::below(area, used), buf); |
| 1552 |
} |
| 1553 |
} |
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
if let Some(label) = repeat.add.label().filter(|_| repeat.more(standing)) { |
| 1558 |
used += draw_repeat_control(pass, label, crate::below(area, used), buf); |
| 1559 |
} |
| 1560 |
used |
| 1561 |
} |
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
fn repeat_slot_extra(tui: &Tui, field: &Field, at: usize, width: u16) -> u16 { |
| 1570 |
let Some(slot) = field |
| 1571 |
.repeats |
| 1572 |
.as_ref() |
| 1573 |
.and_then(|repeat| repeat.instances.get(at)) |
| 1574 |
else { |
| 1575 |
return 0; |
| 1576 |
}; |
| 1577 |
slot.error |
| 1578 |
.as_ref() |
| 1579 |
.map_or(0, |error| text::height(error, width)) |
| 1580 |
+ match &slot.progress { |
| 1581 |
quasi_router::Progress::Working(Some(meter)) => { |
| 1582 |
text::line_height(&meter_line(tui, meter), width) |
| 1583 |
} |
| 1584 |
_ => 0, |
| 1585 |
} |
| 1586 |
} |
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
fn draw_repeat_control(pass: &mut Pass<'_>, label: &str, area: Rect, buf: &mut Buffer) -> u16 { |
| 1595 |
let focused = pass.claim(); |
| 1596 |
let tui = pass.tui; |
| 1597 |
text::draw_line( |
| 1598 |
&Line::from(vec![Span::styled( |
| 1599 |
format!("[ {label} ]"), |
| 1600 |
tui.style() |
| 1601 |
.focused(focused, Style::default().fg(tui.theme().action_primary)), |
| 1602 |
)]), |
| 1603 |
area, |
| 1604 |
buf, |
| 1605 |
) |
| 1606 |
} |
| 1607 |
|
| 1608 |
fn draw_one_field(pass: &mut Pass<'_>, field: &Field, area: Rect, buf: &mut Buffer) -> u16 { |
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
if matches!(field.kind, layout::FieldKind::Hidden) { |
| 1613 |
return 0; |
| 1614 |
} |
| 1615 |
let focused = pass.claim(); |
| 1616 |
let tui = pass.tui; |
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
let held = pass.view.showing(&field.name, field.value.as_deref()); |
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
let upper = field |
| 1632 |
.upper_name |
| 1633 |
.as_deref() |
| 1634 |
.map(|name| pass.view.showing(name, field.upper_value.as_deref())); |
| 1635 |
let held = match (field.kind, upper) { |
| 1636 |
(layout::FieldKind::Checkbox, _) => piece::Held::On(held == Node::SELECTED), |
| 1637 |
(layout::FieldKind::Interval, Some(upper)) => piece::Held::Between { lower: held, upper }, |
| 1638 |
_ => piece::Held::Text(held), |
| 1639 |
}; |
| 1640 |
|
| 1641 |
let used = field |
| 1642 |
.with_layout(|described| piece::field(tui.style(), &described, held, focused, area, buf)); |
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
if pass.view.suggesting(&field.name).is_some() { |
| 1650 |
pass.suggesting = Some(crate::below(area, used)); |
| 1651 |
} |
| 1652 |
|
| 1653 |
used |
| 1654 |
} |
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
pub(crate) fn draw_suggestions(tui: &Tui, view: &View, area: Rect, buf: &mut Buffer) { |
| 1668 |
let Some(open) = view.suggesting_here() else { |
| 1669 |
return; |
| 1670 |
}; |
| 1671 |
for (at, choice) in open.options.iter().enumerate() { |
| 1672 |
let Ok(row) = u16::try_from(at) else { |
| 1673 |
return; |
| 1674 |
}; |
| 1675 |
if row >= area.height { |
| 1676 |
return; |
| 1677 |
} |
| 1678 |
let here = Rect { |
| 1679 |
height: 1, |
| 1680 |
..crate::below(area, row) |
| 1681 |
}; |
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
buf.set_style(here, tui.style().sunken); |
| 1686 |
let style = tui |
| 1687 |
.style() |
| 1688 |
.focused(open.at == Some(at), tui.style().content); |
| 1689 |
let mut spans = vec![Span::styled(choice.label.clone(), style)]; |
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
if let Some(detail) = &choice.detail { |
| 1695 |
spans.push(Span::styled(format!(" {detail}"), tui.style().muted)); |
| 1696 |
} |
| 1697 |
text::draw_line(&Line::from(spans), here, buf); |
| 1698 |
} |
| 1699 |
} |
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
const TICK_COLUMN: &str = "select"; |
| 1709 |
|
| 1710 |
fn table_height(_columns: &[quasi_router::Column], shown: usize) -> u16 { |
| 1711 |
1 + u16::try_from(shown).unwrap_or(u16::MAX) |
| 1712 |
} |
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
fn draw_table( |
| 1722 |
pass: &mut Pass<'_>, |
| 1723 |
columns: &[quasi_router::Column], |
| 1724 |
rows: &[Row], |
| 1725 |
area: Rect, |
| 1726 |
buf: &mut Buffer, |
| 1727 |
) -> u16 { |
| 1728 |
use ratatui::widgets::{StatefulWidget, TableState}; |
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
|
| 1750 |
let shown: Vec<&Row> = crate::outline::showing(rows, Some(pass.view)) |
| 1751 |
.map(|(_, cells)| cells) |
| 1752 |
.collect(); |
| 1753 |
let rows = shown.as_slice(); |
| 1754 |
|
| 1755 |
let mut focused = None; |
| 1756 |
for (index, cells) in rows.iter().enumerate() { |
| 1757 |
if crate::focus::row_reachable(cells) && pass.claim() { |
| 1758 |
focused = Some(index); |
| 1759 |
} |
| 1760 |
} |
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
let lit = focused.and_then(|index| { |
| 1766 |
let at = pass.view.inside()?; |
| 1767 |
let cells = rows.get(index)?; |
| 1768 |
crate::focus::inside(cells).get(at).copied() |
| 1769 |
}); |
| 1770 |
|
| 1771 |
let tui = pass.tui; |
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
let branches = rows.iter().any(|row| row.open.is_some()); |
| 1782 |
let ticks = rows.iter().any(|row| row.selected.is_some()); |
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
let chooses = rows.iter().any(|row| row.chosen.is_some()); |
| 1788 |
let gutter = ticks || chooses; |
| 1789 |
let mut named: Vec<layout::Column<'_>> = |
| 1790 |
Vec::with_capacity(columns.len() + usize::from(gutter)); |
| 1791 |
if gutter { |
| 1792 |
named.push(layout::Column { |
| 1793 |
width: layout::Width::Fixed, |
| 1794 |
priority: layout::Priority::Essential, |
| 1795 |
..layout::Column::new(TICK_COLUMN) |
| 1796 |
}); |
| 1797 |
} |
| 1798 |
named.extend(columns.iter().map(quasi_router::Column::as_layout)); |
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
let sizing = table::Sizing { |
| 1804 |
lengths: &[], |
| 1805 |
fallback: 12, |
| 1806 |
}; |
| 1807 |
|
| 1808 |
let body: Vec<Vec<table::Cell<'_>>> = |
| 1809 |
rows.iter() |
| 1810 |
.enumerate() |
| 1811 |
.map(|(index, cells)| { |
| 1812 |
let mut row: Vec<table::Cell<'_>> = |
| 1813 |
Vec::with_capacity(columns.len() + usize::from(gutter)); |
| 1814 |
if gutter { |
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
let drawn = match (cells.selected, cells.value.as_deref()) { |
| 1822 |
(Some(_), Some(value)) if pass.view.is_ticked(value) => "[x]", |
| 1823 |
(Some(_), _) => "[ ]", |
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
(None, _) if cells.chosen == Some(true) => " * ", |
| 1829 |
(None, _) => "", |
| 1830 |
}; |
| 1831 |
row.push(table::Cell::new(TICK_COLUMN, Line::from(drawn))); |
| 1832 |
} |
| 1833 |
row.extend(columns.iter().zip(&cells.cells).enumerate().map( |
| 1834 |
|(at, (column, cell))| { |
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
let within = lit.filter(|(col, _)| Some(index) == focused && *col == at); |
| 1839 |
let mut line = cell_line(tui, cell, within.map(|(_, part)| part)); |
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
if at == 0 && branches { |
| 1846 |
let mark = match cells.open { |
| 1847 |
Some(described) => { |
| 1848 |
let open = pass.view.open(&cells.key(), described); |
| 1849 |
format!("{} ", crate::outline::chevron(open)) |
| 1850 |
} |
| 1851 |
None => " ".to_string(), |
| 1852 |
}; |
| 1853 |
let indent = " ".repeat( |
| 1854 |
usize::from(cells.depth.level) * usize::from(crate::outline::STEP), |
| 1855 |
); |
| 1856 |
line.spans.insert(0, Span::raw(format!("{indent}{mark}"))); |
| 1857 |
} |
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
if at == 0 |
| 1868 |
&& let Some(change) = cells.change |
| 1869 |
{ |
| 1870 |
let (sign, style) = match change { |
| 1871 |
layout::Change::Added => { |
| 1872 |
("+", Style::default().fg(tui.theme().status_success)) |
| 1873 |
} |
| 1874 |
layout::Change::Removed => { |
| 1875 |
("-", Style::default().fg(tui.theme().status_danger)) |
| 1876 |
} |
| 1877 |
|
| 1878 |
|
| 1879 |
|
| 1880 |
_ => (" ", Style::default()), |
| 1881 |
}; |
| 1882 |
line.spans.insert(0, Span::styled(sign, style)); |
| 1883 |
} |
| 1884 |
table::Cell::new(column.name.as_str(), line).part(cell_part(cell)) |
| 1885 |
}, |
| 1886 |
)); |
| 1887 |
row |
| 1888 |
}) |
| 1889 |
.collect(); |
| 1890 |
|
| 1891 |
let widget = table::table(&named, &body, &sizing, &tui.table, area.width); |
| 1892 |
let height = table_height(columns, rows.len()).min(area.height); |
| 1893 |
let within = Rect { height, ..area }; |
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
|
| 1903 |
let mut state = TableState::default(); |
| 1904 |
if let Some(index) = focused.or_else(|| rows.iter().position(|cells| cells.current)) { |
| 1905 |
state.select(Some(index)); |
| 1906 |
} |
| 1907 |
StatefulWidget::render(widget, within, buf, &mut state); |
| 1908 |
height |
| 1909 |
} |
| 1910 |
|
| 1911 |
|
| 1912 |
|
| 1913 |
|
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
|
| 1918 |
fn cell_line(tui: &Tui, cell: &Cell, lit: Option<usize>) -> Line<'static> { |
| 1919 |
let mut spans = Vec::new(); |
| 1920 |
for (at, part) in cell.content.iter().enumerate() { |
| 1921 |
if !spans.is_empty() { |
| 1922 |
spans.push(Span::raw(" ")); |
| 1923 |
} |
| 1924 |
spans.extend(inline_spans( |
| 1925 |
tui, |
| 1926 |
part, |
| 1927 |
Style::default().fg(tui.theme().content_primary), |
| 1928 |
lit == Some(at), |
| 1929 |
)); |
| 1930 |
} |
| 1931 |
Line::from(spans) |
| 1932 |
} |
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
fn cell_part(cell: &Cell) -> layout::CellPart { |
| 1941 |
if cell.content.iter().any(|part| matches!(part, Node::Act(_))) { |
| 1942 |
return layout::CellPart::Actions; |
| 1943 |
} |
| 1944 |
if cell |
| 1945 |
.content |
| 1946 |
.iter() |
| 1947 |
.any(|part| matches!(part, Node::Link { .. })) |
| 1948 |
{ |
| 1949 |
return layout::CellPart::Link; |
| 1950 |
} |
| 1951 |
if cell |
| 1952 |
.content |
| 1953 |
.iter() |
| 1954 |
.any(|part| matches!(part, Node::Token(_))) |
| 1955 |
{ |
| 1956 |
return layout::CellPart::Tokens; |
| 1957 |
} |
| 1958 |
layout::CellPart::Value |
| 1959 |
} |
| 1960 |
|