diff --git a/AGENTS.md b/AGENTS.md index 6b5bb18..6c90dee 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -256,14 +256,18 @@ and this file is for what someone changing worklane's own code needs. - **A campaign the board does not hold labels nothing**, the answer `mark_blocked` gives a dangling blocker. `campaign_cells` renders that case as `_missing_` because a metadata table is a place to report a dangling reference; a card is not - **`c` opens the campaign picker, and taking a campaign filters the tab's columns to its members.** Not a fifth tab: a campaign groups across the flow, so the shape of the answer is the statuses with fewer cards in them, which is what `campaign show` already answers the question in. Every column is kept, empty ones included. The filter is applied in `reload`, where the columns are built, so nothing downstream has to ask whether a campaign is selected — the board simply holds fewer cards, and `first_match`, `column_count` and the copy key all keep working unchanged - **`Tab::campaign` is a uuid on the tab, not on the `Board`.** A campaign belongs to one `.worklane`, so a filter carried onto another project's tab would empty it and say nothing about why. It is looked up by uuid rather than held as an index, and a selection whose campaign has left the board is cleared by `reload` rather than left filtering the board to nothing -- **The frame above the columns has two heights, and `Chrome` is what every measurement takes.** `Chrome::campaign` is an `Option`, not a bool: `None` for a tab showing the whole board, and `Collapsed` or `Expanded` for one filtered to a campaign, because both heights have to be measured the same way by everything that measures the board. `frame_rows` grew a row, so the two bools that decide the geometry became one `Chrome`, copied from `Board::chrome`: adjacent same-typed parameters are what the Rust Style rule warns about, and the draw and `follow_selection` have to measure one answer or a keypress scrolls against a board the next frame does not draw. The row indices are named (`TAB_ROW`, `CAMPAIGN_ROW`, `BOARD_ROW`, `FOOTER_ROW`), since an index written out by hand goes on meaning what it used to +- **The frame above the columns has two heights, and `Chrome` is what every measurement takes.** `Chrome::frame` is an `Option`, not a bool: `None` for a tab showing the whole board, and `Collapsed` or `Expanded` for one filtered to a campaign or a tag, because both heights have to be measured the same way by everything that measures the board. `screen_rows` grew a row, so the two bools that decide the geometry became one `Chrome`, copied from `Board::chrome`: adjacent same-typed parameters are what the Rust Style rule warns about, and the draw and `follow_selection` have to measure one answer or a keypress scrolls against a board the next frame does not draw. The row indices are named (`TAB_ROW`, `FRAME_ROW`, `BOARD_ROW`, `FOOTER_ROW`), since an index written out by hand goes on meaning what it used to. **Nothing in the geometry is named after campaigns**, because the slot is the tag filter's too: `Chrome::frame` says how tall the frame is and never which filter filled it, so a measurement of the board never has to ask - **The whole description is carried off the one read, and the cut is on the view.** `section_prose` replaced `section_opening`, which cut to the opening line at read time: the campaign file is only in hand while the campaigns directory is being read, so what that read has to carry is everything a view might want, and `CampaignRow::summary` takes the one line the picker draws back off it. Two fields, one cut from the other, are two strings free to come from different reads of the same file -- **`CAMPAIGN_PROSE_ROWS` is the collapsed height, and it is a constant rather than a height fitted to the description.** Three rows of prose plus a border either side. A frame that grew and shrank with the campaign would resize every column whenever the filter changed, and a reader would look for a card where the previous campaign's description had put it. It does not have to be right for the longest description, because scrolling is what covers the rest — which is also why three was affordable where one row was not -- **The expanded height is a share, not a second constant: half of what the frame and the columns divide.** That is the screen less the tab row and the footer, so the split is even between the two of them rather than even against rows neither gets all of. Half rather than most of it for the same reason the frame is not an overlay: the columns below are the campaign's members, and a reader inspecting the campaign has to go on seeing what it is made of. Floored, so the odd row goes to the cards. `Chrome::campaign_rows` takes the height because of this, and `frame_rows` is where it is called, since that is the one place that already has an area to take a share of — which is what keeps `Chrome` itself pure and copyable from `Board::chrome` with no screen to hand -- **The share is bounded at both ends, and `COLUMN_MIN_ROWS` is why.** `Constraint::Min(COLUMN_MIN_ROWS)` would take rows back from a frame that asked for too many, silently, and the frame's own measurement would then disagree with what is drawn — the fault `Chrome` exists to prevent. So the share is capped at what leaves the columns those rows, and floored at `CAMPAIGN_ROWS`, since expanding must never shrink the frame. On a board too short to divide, `enter` gives the collapsed height back rather than a height nothing measured. `the_expanded_share_is_bounded_at_both_ends` sweeps every height from 4 to 60, tabbed and not, because one screen that happens to work says nothing about the arithmetic +- **`FRAME_PROSE_ROWS` is the collapsed height, and it is a constant rather than a height fitted to the description.** Three rows of prose plus a border either side. A frame that grew and shrank with the campaign would resize every column whenever the filter changed, and a reader would look for a card where the previous campaign's description had put it. It does not have to be right for the longest description, because scrolling is what covers the rest — which is also why three was affordable where one row was not +- **The expanded height is a share, not a second constant: half of what the frame and the columns divide.** That is the screen less the tab row and the footer, so the split is even between the two of them rather than even against rows neither gets all of. Half rather than most of it for the same reason the frame is not an overlay: the columns below are the campaign's members, and a reader inspecting the campaign has to go on seeing what it is made of. Floored, so the odd row goes to the cards. `Chrome::frame_rows` takes the height because of this, and `screen_rows` is where it is called, since that is the one place that already has an area to take a share of — which is what keeps `Chrome` itself pure and copyable from `Board::chrome` with no screen to hand +- **The share is bounded at both ends, and `COLUMN_MIN_ROWS` is why.** `Constraint::Min(COLUMN_MIN_ROWS)` would take rows back from a frame that asked for too many, silently, and the frame's own measurement would then disagree with what is drawn — the fault `Chrome` exists to prevent. So the share is capped at what leaves the columns those rows, and floored at `FRAME_ROWS`, since expanding must never shrink the frame. On a board too short to divide, `enter` gives the collapsed height back rather than a height nothing measured. `the_expanded_share_is_bounded_at_both_ends` sweeps every height from 4 to 60, tabbed and not, because one screen that happens to work says nothing about the arithmetic - **The frame says the rest of what it has to say on its borders**, the trade the detail overlay makes with its title and its page indicator: `(id) ~codename · Name` on the top one, the standing on the bottom right, and `q board` then the page indicator on the bottom left. Every row spent here is a row of cards -- **The frame's page indicator goes on the bottom border beside `q board`, not on the top beside the title.** The title is cut against the border it sits on, so an indicator up there would shorten a long campaign name the moment its description grew past three rows; and the bottom right is the standing's, which is what the frame is *about* where the indicator is only where the reader has got to in it. Dropped before `q board` when the two cannot both fit, since with a campaign selected the footer's last slot names `ctrl-c quit` and the border is the only place that says `q` gives the board back -- **`Focus` is the third place the selection can be, and `Tab` is what holds it.** The board had a column and a card and `select_card` clamped at zero; up from the top card now reaches the frame and down returns to the column it left, since the column index is never what changed. Per tab beside the filter and the offset, so switching away and back returns to where the tab was left. `Focus::Frame` while no campaign is selected is the one state that must never exist — `select_campaign` and `reload` are what keep it from arising +- **The frame slot is shared between the two filters, not doubled.** One filter is on at a time, per `Filter`, so a tag frame is the campaign frame with its three slots filled differently: `#tag` in `tag_color` on the top border where the campaign's identity goes, how many tickets carry it on the bottom right where the standing goes, and the annotation in the prose rows. `FrameContent` is what the two are told apart into, and **`frame_content` is the one place they are told apart at all** — the borders, the colour, `q board`, the page indicator, the scroll and the focus are all the campaign frame's, and a second `match` on the filter below that is how the two frames come to behave differently in a way nobody decided +- **A tag frame draws the annotation, which is the payoff for declaring a tag.** Whoever is browsing a tag is deciding whether the next ticket belongs in it, and the sentence saying when the tag is appropriate is then on the screen at that moment rather than in `tags.md`, which they would have to know to open. An undeclared tag draws `NO_ANNOTATION` in grey, which is also the frame saying the word was never agreed on — the vocabulary file's own placeholder rather than the description section's, so the frame and the file say the same thing about the same tag. A tag declared with nothing said about it draws the same, since here the two have the same nothing to show; the picker's sections are where the difference is actionable +- **A tag has no id, so `y` on its frame copies the word.** A tag *is* its name, matched whole by `ls --tag`, so there are no seven characters to shorten and the `#` the border draws is not part of it — `--tag "#bug"` matches nothing. The footer says `y copy tag` there for the same reason: naming it an id would send the reader looking for a short id on a border that prints a word +- **The count on a tag frame is every column's, drawn or not**, the rule the standing holds. With the filter on, those columns *are* the tickets carrying the tag, so it counts what is below it without counting it a second way. The noun is spelled out and pluralised, because a bare number on a border says nothing about what was counted, and there is no derived state beside it: a tag is a word and not a piece of work, so there is no `[open]` to be in +- **The frame's page indicator goes on the bottom border beside `q board`, not on the top beside the title.** The title is cut against the border it sits on, so an indicator up there would shorten a long campaign name the moment its description grew past three rows; and the bottom right is the standing's, which is what the frame is *about* where the indicator is only where the reader has got to in it. Dropped before `q board` when the two cannot both fit, since with either filter on the footer's last slot names `ctrl-c quit` and the border is the only place that says `q` gives the board back +- **`Focus` is the third place the selection can be, and `Tab` is what holds it.** The board had a column and a card and `select_card` clamped at zero; up from the top card now reaches the frame and down returns to the column it left, since the column index is never what changed. Per tab beside the filter and the offset, so switching away and back returns to where the tab was left. `Focus::Frame` while no filter is on is the one state that must never exist — `select_filter` and `reload` are what keep it from arising, off `Filter::is_whole` rather than off which filter it is, since either draws a frame to hold it - **`Tab::selected` hands back nothing while the frame holds the selection.** Every key that acts on a card has to answer for the frame. `←→` are inert, because the frame spans the width of the board and moving the column underneath would change nothing on screen. `y` is the exception that earns its place: it copies the campaign's short id, so `y copy id` means the id of the selected thing in every state the selection can be in. No card is drawn reversed there either, since that highlight is what says which ticket a key is about - **`enter` routes on the focus through `Board::toggle_focused`: the frame's height on the frame, the overlay on a card.** It used to be inert on the frame for free, because `Tab::selected` hands back nothing and `toggle_detail` therefore had nothing to open. That is no longer an answer, and the routing is in `Board` rather than in the `main.rs` arm for the reason `dismiss` and `scroll_page` are - **`q` does not gain a layer for the expanded frame, and up and down do not take it back.** The expanded frame is the frame at its other height, not a thing laid over the board, so `q` goes on taking the campaign filter off from either height and `enter` is the only key that undoes what `enter` did. The height outlives the selection for the same reason: it is a view of the campaign the reader chose, so the columns stay short with the selection on a card. `Tab::expanded` sits beside the filter and resets where `select_campaign` and `reload` reset the focus and the offset — a different campaign opens collapsed and at the top of its own description @@ -271,8 +275,8 @@ and this file is for what someone changing worklane's own code needs. - **The frame is out of reach from under an open ticket.** With the overlay open, up and down step through the tickets and it follows, so a selection that reached the frame would have to either close it on an arrow key or leave it showing a ticket nothing is selecting. `an_open_ticket_keeps_the_scroll_keys_from_the_frame` builds that state by hand for exactly this reason: the precedence has to hold whether or not a keypress can reach it - **The standing comes from the columns, not from a walk of the tree.** While a campaign is selected the columns *are* its members, done included, so `Tab::standing` counts what is already in hand rather than paying what `campaign ls` pays per campaign. Counted over every column, drawn or not: hiding done is a change to what is drawn and never to what is counted - **The way out is on the frame's own border, not in the footer.** `q board` sits on the thing it takes away, and the footer row was already at its width naming eight keys. Dropped whole when it and the standing would meet, the rule the page indicator follows -- **`c` is named in the footer only on a closed board with nothing selected**, which is where a reader has to find it. Over an open ticket and on a filtered board it is left out: the frame's border then says how to put the campaign away, and the row has no cells to spare. Incomplete rather than wrong, which is the trade this row is allowed to make — what it must never do is name a key by what it used to do -- **The footer has three states, because the selection has three places to be.** An open ticket, the frame, and the cards. On the frame it names `↓ board`, `enter expand` or `enter collapse`, the two scroll keys and `y copy id`, and leaves out `←→` because they do nothing there. It has to say which way `enter` goes, since the key is a toggle and the frame is always at one of its two heights. `↑ frame` is not named on the board, on the same trade `c` is dropped on: the frame is drawn directly above the columns and up is the key that reaches it. Nor is the way to collapse an expanded frame named from the cards, which is the same trade again — the frame is right there and `↑` reaches it +- **`c` and `t` are named in the footer only on a closed board with nothing filtered**, which is where a reader has to find them. Over an open ticket and on a filtered board they are left out: the frame's border then says how to put the filter away, and the row has no cells to spare. The tag used to be drawn on that row in its own colour, for want of a frame to draw it in, and 2a83bd4 took that away rather than saying it twice. Incomplete rather than wrong, which is the trade this row is allowed to make — what it must never do is name a key by what it used to do +- **The footer has three states, because the selection has three places to be.** An open ticket, the frame, and the cards. On the frame it names `↓ board`, `enter expand` or `enter collapse`, the two scroll keys and `y copy id` — `y copy tag` on a tag frame — and leaves out `←→` because they do nothing there. It has to say which way `enter` goes, since the key is a toggle and the frame is always at one of its two heights. `↑ frame` is not named on the board, on the same trade `c` is dropped on: the frame is drawn directly above the columns and up is the key that reaches it. Nor is the way to collapse an expanded frame named from the cards, which is the same trade again — the frame is right there and `↑` reaches it - **`picker: Option` is the whole mode**, the shape `search` and `detail` use, and `Board::picker_key` runs beside `search_key` ahead of the action arms for the same reason: an open list owns the keyboard, so `d` must not toggle done and `q` must not quit while a campaign is being chosen. `ctrl-c` is the one key it declines and every other control combination is swallowed, or `ctrl-d` would reach the arm bound to `d` - **The picker's rows are `Tab::campaigns`, not a copy taken when it opened**, so a campaign filed elsewhere appears in an open picker on the next tick. It opens on the campaign already selected, so `c` on a filtered board says where you are as well as offering somewhere to go, and a board with no campaigns gets a `Notice` rather than an empty box that has to be dismissed to learn it was empty - **A picker row draws a real codename only.** The row opens with the short id, so the card's `~` fallback would print it twice and say nothing the second time @@ -379,7 +383,7 @@ and this file is for what someone changing worklane's own code needs. - `Card` wraps a `TicketItem` with the project it came from, `Some` only on the merge tab. Decided at reload rather than passed down to `card_lines` as a "which tab is this" flag. `TicketItem` is therefore `Clone`: the merge holds a second copy rather than re-reading every tree - **The project follows the id, on the card and on the overlay border.** Across boards the id is not an address: two projects can hold the same title, and seven characters do not say where they live. `project_label` takes what the row has left after the mark and the id and ends in an ellipsis, and it is measured before the due date, so on the merge the project wins the narrow column and the date is what `corner_line` drops - `tab` and `shift+tab` cycle rather than clamp, unlike the cards and columns: a row of tabs is a ring, and there is no end of a list to run off. Both were free of every other binding — the columns took `hjkl` and the arrows -- **The tab row is drawn only when there is more than one board**, so a single board is the view it has always been. `frame_rows()` gives it `Length(0)` otherwise, which keeps the row indices the same for both cases and is shared with `card_width` and `column_text_height` for the reason `column_areas` is: geometry reproduced by hand drifts from the draw +- **The tab row is drawn only when there is more than one board**, so a single board is the view it has always been. `screen_rows()` gives it `Length(0)` otherwise, which keeps the row indices the same for both cases and is shared with `card_width` and `column_text_height` for the reason `column_areas` is: geometry reproduced by hand drifts from the draw - `digest_of` hashes each board's `digest` into one value, so a change in any of them redraws. Do not watch only the first ### Who Wrote an Entry diff --git a/Cargo.lock b/Cargo.lock index 7337d0a..b66a1a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1503,7 +1503,7 @@ dependencies = [ [[package]] name = "worklane" -version = "0.31.3" +version = "0.31.4" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 0b77557..3be59cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "worklane" -version = "0.31.3" +version = "0.31.4" edition = "2024" [dependencies] diff --git a/src/tui.rs b/src/tui.rs index ebc1987..e7fe570 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -38,7 +38,7 @@ const ALL: &str = "all"; /// The rows of chrome above the columns, which is what the geometry depends on. /// -/// A struct rather than two bools threaded through `frame_rows`, `board_area`, +/// A struct rather than two bools threaded through `screen_rows`, `board_area`, /// `card_width` and `column_text_height`: adjacent same-typed parameters are what the /// Rust Style rule in AGENTS.md warns about, and a caller that swapped them would measure /// a board nobody is looking at. Copied from `Board::chrome`, so the draw and the @@ -47,17 +47,23 @@ const ALL: &str = "all"; pub struct Chrome { /// Whether the tab row is drawn, which is whether more than one board is monitored. pub tabbed: bool, - /// The campaign frame, at the height it is drawn, or `None` for a tab showing the whole - /// board. + /// The frame above the columns, at the height it is drawn, or `None` for a tab showing + /// the whole board. /// /// A state rather than the bool it was, because the frame has two heights now and every /// measurement of the board has to agree about which one it is at. `Option` rather than a /// third variant, so "there is no frame" stays the shape it was and the two heights are /// only ever compared with each other. - pub campaign: Option, + /// + /// Named after the frame and not after the campaign that first filled it: a tag filter + /// draws the same three rows of prose between the same two borders, so the geometry has + /// one answer and only what is drawn into it depends on which filter is on. Which + /// filter that is, [`Filter`] holds; this says nothing about it, which is what keeps + /// every measurement of the board from having to ask. + pub frame: Option, } -/// How much of the board the campaign frame is taking. +/// How much of the board the frame above the columns is taking. /// /// Collapsed is where it opens and where it goes back to. Expanded is what `enter` asks for /// while the frame holds the selection, and it outlives the selection: the height is a view @@ -72,7 +78,7 @@ impl Chrome { /// The rows of prose the campaign frame holds. /// /// A constant rather than a height fitted to the description it is drawing. Every - /// measurement of the board goes through `frame_rows`, so a frame that grew and shrank + /// measurement of the board goes through `screen_rows`, so a frame that grew and shrank /// with the campaign would resize the columns whenever the filter changed, and a reader /// would look for a card where the previous campaign's description had put it. /// @@ -82,7 +88,7 @@ impl Chrome { /// is a card and a half of the four or five rows a card takes. Scrolling is what covers /// a description longer than this, which is why the constant does not have to be right /// for the longest one. - const CAMPAIGN_PROSE_ROWS: u16 = 3; + const FRAME_PROSE_ROWS: u16 = 3; /// The rows the campaign frame takes: a border either side of its prose. /// @@ -90,12 +96,12 @@ impl Chrome { /// one, and the standing, the way out and the page indicator on the bottom, the trade /// the detail overlay already makes with its title and its own indicator. Every row /// spent here is a row of cards. - const CAMPAIGN_ROWS: u16 = Self::CAMPAIGN_PROSE_ROWS + 2; + const FRAME_ROWS: u16 = Self::FRAME_PROSE_ROWS + 2; /// The rows the frame takes out of a board `height` rows tall. /// /// The height comes in because the expanded frame is a *share* rather than a second - /// constant, and `frame_rows` is the one place that already has an area to take a share + /// constant, and `screen_rows` is the one place that already has an area to take a share /// of — which is what keeps `Chrome` itself cheap and pure and copied from /// `Board::chrome` without a screen to hand. /// @@ -109,19 +115,19 @@ impl Chrome { /// Bounded at both ends, and the upper bound is the one that matters: /// `Constraint::Min(COLUMN_MIN_ROWS)` would take the rows back silently, and the frame's /// own measurement would then disagree with what is drawn, which is the fault `Chrome` - /// exists to prevent. The lower bound is [`Self::CAMPAIGN_ROWS`], since expanding must + /// exists to prevent. The lower bound is [`Self::FRAME_ROWS`], since expanding must /// never shrink the frame — so on a board too short to divide, `enter` gives the /// collapsed frame back rather than a height nothing measured. - fn campaign_rows(self, height: u16) -> u16 { - let Some(size) = self.campaign else { return 0 }; + fn frame_rows(self, height: u16) -> u16 { + let Some(size) = self.frame else { return 0 }; let shared = height.saturating_sub(u16::from(self.tabbed) + FOOTER_ROWS); match size { - FrameSize::Collapsed => Self::CAMPAIGN_ROWS, + FrameSize::Collapsed => Self::FRAME_ROWS, FrameSize::Expanded => { - let room = shared.saturating_sub(COLUMN_MIN_ROWS).max(Self::CAMPAIGN_ROWS); - (shared / 2).clamp(Self::CAMPAIGN_ROWS, room) + let room = shared.saturating_sub(COLUMN_MIN_ROWS).max(Self::FRAME_ROWS); + (shared / 2).clamp(Self::FRAME_ROWS, room) } } } @@ -129,8 +135,8 @@ impl Chrome { /// The rows the columns are never asked to give up, and the footer's one row. /// -/// Named because two places read each of them: `frame_rows` lays them out and -/// `Chrome::campaign_rows` bounds its share against them. A share computed against a +/// Named because two places read each of them: `screen_rows` lays them out and +/// `Chrome::frame_rows` bounds its share against them. A share computed against a /// reservation written out by hand is a share that comes to disagree with the layout. const COLUMN_MIN_ROWS: u16 = 3; const FOOTER_ROWS: u16 = 1; @@ -180,9 +186,10 @@ pub enum Filter { impl Filter { /// The campaign this filters to, or nothing for a tag filter or none. /// - /// The frame, the focus and the geometry all ask this rather than whether a filter is - /// on: only a campaign draws a frame, so only a campaign can hold the selection above - /// the columns. + /// What the campaign frame draws itself from, and what tells a filter that resolves + /// against the campaigns directory from one that resolves against nothing. The frame, + /// the focus and the geometry ask [`Filter::is_whole`] instead: either filter draws a + /// frame, so either can hold the selection above the columns. pub fn campaign(&self) -> Option<&str> { match self { Filter::Campaign(uuid) => Some(uuid), @@ -496,6 +503,18 @@ impl Tab { self.campaigns.iter().find(|row| row.uuid == uuid) } + /// The selected tag, or nothing when the tab is not filtered to one. + /// + /// Looked up in the tab's own rows rather than answered from the filter string alone, + /// because the frame draws what the row carries and not just the word: the annotation + /// off the vocabulary file and the count off the cards, both read at reload. A tag the + /// board neither declares nor carries resolves to nothing, which `reload` then clears, + /// the answer `selected_campaign` gives a campaign that has left the board. + fn selected_tag(&self) -> Option<&TagRow> { + let name = self.filter.tag()?; + self.tags.iter().find(|row| row.name == name) + } + /// The columns that are drawn: all of them, or everything up to the reach of the /// visibility. /// @@ -992,11 +1011,16 @@ impl Board { /// One answer, read by the draw and by `follow_selection` alike: the frame appearing /// takes three rows off the columns, and a keypress that scrolled against the old /// height would put the selection where the next frame does not draw it. + /// + /// Off the filter being on rather than off which filter it is, since the frame is one + /// slot either of them fills. A tag frame that measured differently from a campaign one + /// would be a second geometry to keep in step with the draw, which is what `Chrome` + /// exists to stop there being. pub fn chrome(&self) -> Chrome { let tab = self.current(); Chrome { tabbed: self.tabbed(), - campaign: tab.filter.campaign().is_some().then_some(match tab.expanded { + frame: (!tab.filter.is_whole()).then_some(match tab.expanded { true => FrameSize::Expanded, false => FrameSize::Collapsed, }), @@ -1099,12 +1123,12 @@ impl Board { { tab.filter = Filter::Whole; } - // The frame goes with the campaign, both the focus and the place its prose was + // The frame goes with the filter, both the focus and the place its prose was // scrolled to: a frame that is no longer drawn must not be holding the - // selection, and the next campaign selected starts at the top of its own - // description rather than partway down the last one's. Keyed off the campaign - // rather than off there being a filter, because a tag filter draws no frame. - if tab.filter.campaign().is_none() { + // selection, and the next thing selected starts at the top of its own prose + // rather than partway down the last one's. Keyed off there being a filter at + // all, since either kind draws a frame and both are cleared just above. + if tab.filter.is_whole() { tab.focus = Focus::Cards; tab.expanded = false; tab.frame_offset = 0; @@ -1236,9 +1260,9 @@ impl Board { /// Move up and down the focused column, and on and off the frame above it. /// - /// A step up from the top card reaches the campaign frame, and a step down from the - /// frame comes back to the column the selection left, since the column index is never - /// what changed. An empty column reaches it too: a column with no card to stand on must + /// A step up from the top card reaches the frame, whichever filter drew it, and a step + /// down from the frame comes back to the column the selection left, since the column + /// index is never what changed. An empty column reaches it too: a column with no card to stand on must /// not be a column the reader is stuck in. /// /// Not from under an open ticket. There, up and down step through the tickets and the @@ -1264,7 +1288,7 @@ impl Board { }; let count = column.cards.len(); - if delta < 0 && tab.card == 0 && tab.filter.campaign().is_some() && !open { + if delta < 0 && tab.card == 0 && !tab.filter.is_whole() && !open { self.current_mut().focus = Focus::Frame; return; } @@ -1344,11 +1368,6 @@ impl Board { }; } - /// The campaign the tab in view is filtered to, or nothing for the whole board. - pub fn campaign(&self) -> Option<&CampaignRow> { - self.current().selected_campaign() - } - /// Open a picker on the filter in view, or say there is nothing to pick from. /// /// A board with nothing of that kind gets a notice rather than an empty box: the box @@ -1620,9 +1639,9 @@ impl Board { tab.column = 0; tab.card = 0; tab.offsets.iter_mut().for_each(|offset| *offset = 0); - // The frame is a different campaign's now, or gone, so the selection comes back to - // the cards and its prose starts at the top — the answer `refresh_detail` gives the - // overlay when the ticket under it changes. A tag filter never had one. + // The frame is a different campaign's or a different tag's now, or gone, so the + // selection comes back to the cards and its prose starts at the top — the answer + // `refresh_detail` gives the overlay when the ticket under it changes. tab.focus = Focus::Cards; tab.expanded = false; tab.frame_offset = 0; @@ -1762,20 +1781,35 @@ impl Board { /// `None` on an empty column, so nothing is sent rather than an empty string put on /// the clipboard over whatever the reader had there. pub fn copy_text(&self) -> Option { - // On the frame it is the campaign's id, since that is what the selection is on and - // what the frame's own top border prints. `y copy id` means the id of the selected - // thing in every state the selection can be in, rather than a key that stops - // working one row above the cards. Seven characters like a card's, and every command - // that takes a campaign resolves them. + // On the frame it is what the frame names, since that is what the selection is on + // and what its own top border prints. `y copy id` means the id of the selected thing + // in every state the selection can be in, rather than a key that stops working one + // row above the cards. if self.current().focus == Focus::Frame { - return self - .campaign() - .map(|campaign| short_id(&campaign.uuid).to_string()); + return self.frame_id(); } self.selected().map(|card| card.ticket.id.clone()) } + /// What the frame above the columns is addressed by, or nothing when none is drawn. + /// + /// A campaign's seven characters, which is what its own border prints and what every + /// command that takes a campaign resolves. A tag has no id to shorten: it *is* its name, + /// which is what `ls --tag` matches whole and case sensitively, so the whole word goes + /// on the clipboard and the hash the border draws does not — `--tag` would not match it. + fn frame_id(&self) -> Option { + let tab = self.current(); + + match &tab.filter { + Filter::Whole => None, + Filter::Campaign(_) => tab + .selected_campaign() + .map(|campaign| short_id(&campaign.uuid).to_string()), + Filter::Tag(name) => Some(name.clone()), + } + } + /// Copy the selected id through `copy`, and say what happened. /// /// The clipboard comes in as an argument rather than being reached for here, so the @@ -1854,27 +1888,35 @@ impl Board { } } - /// Scroll the campaign frame's description by whole screenfuls, one line kept for - /// overlap. + /// Scroll the frame's prose by whole screenfuls, one line kept for overlap. /// /// The overlay's arithmetic, deliberately: `scroll_step` decides the step and /// `last_offset` the clamp there, and prose wrapped into a viewport is prose wrapped /// into a viewport. Two sets of rules is how the same two keys come to move different /// distances in the two places a reader presses them. /// - /// Inert on a description that fits, since `last` is zero and the clamp leaves the - /// offset where it is — which is what leaves a short description's frame selectable - /// rather than making it a place the keys had to be kept away from. The screen comes in - /// for the reason `scroll_detail` takes it. + /// A campaign's description or a tag's annotation, whichever the frame is drawing, + /// through `frame_content` rather than a second look at the filter: the clamp has to be + /// measured against the text the draw wraps, and prose reached two ways is two texts + /// free to disagree about where the end of it is. The title it builds and this throws + /// away is a `Vec` of two spans, which is cheaper than the second dispatch would be to + /// keep in step. + /// + /// Inert on prose that fits, since `last` is zero and the clamp leaves the offset where + /// it is — which is what leaves a short description's frame selectable rather than + /// making it a place the keys had to be kept away from. The screen comes in for the + /// reason `scroll_detail` takes it. pub fn scroll_frame(&mut self, pages: isize, screen: Size) { let chrome = self.chrome(); - let Some(campaign) = self.campaign() else { + let text = frame_text_area(screen, chrome); + // The frame spans the board, so its border width is the screen's: `screen_rows` + // only ever splits vertically. + let Some(content) = frame_content(self.current(), screen.width) else { return; }; - let text = frame_text_area(screen, chrome); let step = scroll_step(text.height) as isize; - let last = last_offset(&frame_prose(campaign), text) as isize; + let last = last_offset(&content.prose, text) as isize; let tab = self.current_mut(); let at = tab.frame_offset as isize + pages.saturating_mul(step); @@ -2463,13 +2505,13 @@ pub fn digest(worklane_dir: &Path) -> u64 { pub fn draw(frame: &mut Frame, board: &Board) { let area = frame.area(); let chrome = board.chrome(); - let rows = frame_rows(area, chrome); + let rows = screen_rows(area, chrome); if chrome.tabbed { draw_tabs(frame, board, rows[TAB_ROW]); } - if chrome.campaign.is_some() { - draw_campaign(frame, board.current(), rows[CAMPAIGN_ROW]); + if chrome.frame.is_some() { + draw_frame(frame, board.current(), rows[FRAME_ROW]); } draw_columns(frame, board, rows[BOARD_ROW]); draw_footer(frame, board, rows[FOOTER_ROW]); @@ -2485,13 +2527,13 @@ pub fn draw(frame: &mut Frame, board: &Board) { } } -/// The rows of the frame, in the order `frame_rows` lays them out. +/// The rows of the frame, in the order `screen_rows` lays them out. /// /// Named rather than counted at each call site: the campaign frame arrived between the tab /// row and the columns, and an index written out by hand is an index that goes on meaning /// what it used to. const TAB_ROW: usize = 0; -const CAMPAIGN_ROW: usize = 1; +const FRAME_ROW: usize = 1; const BOARD_ROW: usize = 2; const FOOTER_ROW: usize = 3; @@ -2502,12 +2544,12 @@ const FOOTER_ROW: usize = 3; /// that comes to disagree with the draw. With one board the tab row is zero rows high and /// with no campaign selected the frame is too, so the indices hold in every state and /// rendering into a zero-height row draws nothing. -fn frame_rows(area: Rect, chrome: Chrome) -> std::rc::Rc<[Rect]> { +fn screen_rows(area: Rect, chrome: Chrome) -> std::rc::Rc<[Rect]> { Layout::default() .direction(Direction::Vertical) .constraints([ Constraint::Length(u16::from(chrome.tabbed)), - Constraint::Length(chrome.campaign_rows(area.height)), + Constraint::Length(chrome.frame_rows(area.height)), Constraint::Min(COLUMN_MIN_ROWS), Constraint::Length(FOOTER_ROWS), ]) @@ -2534,27 +2576,69 @@ fn draw_tabs(frame: &mut Frame, board: &Board, area: Rect) { ); } -/// The selected campaign above the columns: what it is called, what it is for, and how far -/// it has got. +/// What the frame above the columns draws, whichever filter put it there. /// -/// The columns below are its members, so this is the row that says whose members they are. -/// [`Chrome::CAMPAIGN_ROWS`] rows for it, of which [`Chrome::CAMPAIGN_PROSE_ROWS`] are -/// prose: the identity goes on the top border and the standing, the way out and the page -/// indicator on the bottom one, the trade the detail overlay already makes with its title -/// and its own indicator, and every row taken here is a row of cards. +/// Three fields because the frame is three slots: what it is filtered to, on the top +/// border; how much of the board that is, on the bottom right; and what it means, in the +/// rows between them. A struct rather than the draw asking which filter is on three times, +/// so a slot added later is added to both frames at once — which is the whole reason the +/// slot is shared rather than doubled. +struct FrameContent { + /// The top border: `(id) ~codename · Name` for a campaign, `#tag` for a tag. Cut by + /// hand, because ratatui truncates a block title at whatever cell it reaches. + title: Vec>, + /// The bottom right: how far the campaign has got, or how many tickets carry the tag. + /// Where the frame says what it is *about*, which is why the page indicator is on the + /// other end of that border and gives way to `q board` before it. + standing: Vec>, + /// The rows between the borders: a description or an annotation, or the grey + /// placeholder where there is neither. + prose: Text<'static>, +} + +/// What the tab's filter has to say for itself, or nothing when it is showing the whole +/// board. /// -/// The tab comes in rather than the campaign alone, because the frame draws three of the -/// tab's facts and not one: which campaign it is filtered to, how far into that campaign's -/// description the reader has scrolled, and whether the selection is on the frame or on a -/// card below it. Cyan when it holds the selection, the colour the focused column's border -/// and the overlay's already take. +/// **The one place the two filters are told apart above the columns.** Everything the draw +/// does with this is the same either way — the borders, the colour, the way out, the page +/// indicator and the scroll are all the campaign frame's, and a tag fills its slots rather +/// than inventing a second shape. A second `match` on the filter anywhere below here is how +/// the two frames come to behave differently in a way nobody decided. /// -/// The title carries the id in red, the codename in its own colour and bold, and the name -/// in green, which is the colour guideline applied rather than a decision of its own. Cut -/// by hand, like `detail_title`, because ratatui truncates a block title at whatever cell -/// it reaches and would take the id with it. -fn draw_campaign(frame: &mut Frame, tab: &Tab, area: Rect) { - let Some(campaign) = tab.selected_campaign() else { +/// Nothing, too, for a filter that resolves to no row: `reload` clears both of those, so +/// this is the answer to a draw that arrives before it rather than a state the board holds. +fn frame_content(tab: &Tab, width: u16) -> Option { + match &tab.filter { + Filter::Whole => None, + Filter::Campaign(_) => tab.selected_campaign().map(|campaign| FrameContent { + title: campaign_title(campaign, width), + standing: standing_spans(&campaign.standing), + prose: campaign_prose(campaign), + }), + Filter::Tag(_) => tab.selected_tag().map(|tag| FrameContent { + title: tag_title(&tag.name, width), + standing: count_spans(tag.count), + prose: tag_prose(tag), + }), + } +} + +/// The frame above the columns: what the tab is filtered to, what it means, and how much of +/// the board it is. +/// +/// The columns below are what the filter left, so this is the row that says what left them. +/// [`Chrome::FRAME_ROWS`] rows for it, of which [`Chrome::FRAME_PROSE_ROWS`] are prose: the +/// identity goes on the top border and the standing, the way out and the page indicator on +/// the bottom one, the trade the detail overlay already makes with its title and its own +/// indicator, and every row taken here is a row of cards. +/// +/// The tab comes in rather than the campaign or the tag alone, because the frame draws three +/// of the tab's facts and not one: what it is filtered to, how far into that filter's prose +/// the reader has scrolled, and whether the selection is on the frame or on a card below it. +/// Cyan when it holds the selection, the colour the focused column's border and the +/// overlay's already take. +fn draw_frame(frame: &mut Frame, tab: &Tab, area: Rect) { + let Some(content) = frame_content(tab, area.width) else { return; }; let focused = tab.focus == Focus::Frame; @@ -2564,34 +2648,20 @@ fn draw_campaign(frame: &mut Frame, tab: &Tab, area: Rect) { // `column_text_height` has with `draw_columns`, so a resize between a keypress and the // frame that follows it is corrected in the frame. let text = area.inner(Margin::new(1, 1)); - let prose = frame_prose(campaign); // One measurement, three derivations, the rule `wrapped_height` holds for the overlay. // Clamped here as well as on the keypress for the same two reasons: the terminal may - // have been resized since, and a tick can put a shorter description in front of a reader - // who was at the end of the old one. - let last = last_offset(&prose, text); + // have been resized since, and a tick can put shorter prose in front of a reader who was + // at the end of the old. + let last = last_offset(&content.prose, text); let offset = tab.frame_offset.min(last); - let standing = &campaign.standing; let mut block = Block::default() .borders(Borders::ALL) .border_style(Style::default().fg(match focused { true => Color::Cyan.into(), false => Color::Grey.into(), })) - .title(Line::from(campaign_title(campaign, area.width))); - - // Right-aligned on the bottom border, where the overlay already puts the one number it - // has to show. The count is plain and the derived state is orange, which is the two - // colours `campaign ls` prints the same pair in. - let mut standing_spans = vec![Span::raw(format!(" {}", standing.label()))]; - if let Some(state) = standing.state() { - standing_spans.push(Span::styled( - format!(" [{state}]"), - Style::default().fg(Color::Orange.into()), - )); - } - standing_spans.push(Span::raw(" ")); + .title(Line::from(content.title)); // The way out, on the border of the thing it undoes rather than in the footer. The // footer row is already at its width naming eight keys, and this belongs beside the @@ -2606,12 +2676,12 @@ fn draw_campaign(frame: &mut Frame, tab: &Tab, area: Rect) { let hint = " q board "; let indicator = page_indicator(offset, last, text.height, area.width).unwrap_or_default(); let room = area.width.saturating_sub(2) as usize; - let taken = spans_width(&standing_spans); + let taken = spans_width(&content.standing); // Dropped whole rather than cut, the rule the indicator follows on the overlay: half of // either reads as something else. The indicator goes first when the two cannot both fit, - // because with a campaign selected the footer's last slot names `ctrl-c quit` and this - // is the only place on the board that says `q` gives it back. + // because with a filter on the footer's last slot names `ctrl-c quit` and this is the + // only place on the board that says `q` gives it back. let both = format!("{hint}{indicator}"); let left = [both.as_str(), hint, ""] .into_iter() @@ -2622,14 +2692,14 @@ fn draw_campaign(frame: &mut Frame, tab: &Tab, area: Rect) { .title_bottom(Line::from(Span::styled(left, Style::default().fg(Color::Grey.into())))); } - block = block.title_bottom(Line::from(standing_spans).right_aligned()); + block = block.title_bottom(Line::from(content.standing).right_aligned()); // Wrapped and scrolled, where the one row it opened with was cut at the border: with - // three rows a description has somewhere to go, and `pgup` and `pgdn` reach whatever is + // three rows the prose has somewhere to go, and `pgup` and `pgdn` reach whatever is // past them. `Wrap` cannot push the frame taller than the geometry says it is — the rows // past the bottom are simply not drawn, which is what the offset is for. frame.render_widget( - Paragraph::new(prose) + Paragraph::new(content.prose) .block(block) .wrap(Wrap { trim: false }) .scroll((offset, 0)), @@ -2637,6 +2707,45 @@ fn draw_campaign(frame: &mut Frame, tab: &Tab, area: Rect) { ); } +/// How far the campaign has got, for the bottom right of its frame. +/// +/// Right-aligned where the overlay already puts the one number it has to show. The count is +/// plain and the derived state is orange, which is the two colours `campaign ls` prints the +/// same pair in. +fn standing_spans(standing: &Standing) -> Vec> { + let mut spans = vec![Span::raw(format!(" {}", standing.label()))]; + + if let Some(state) = standing.state() { + spans.push(Span::styled( + format!(" [{state}]"), + Style::default().fg(Color::Orange.into()), + )); + } + spans.push(Span::raw(" ")); + + spans +} + +/// How many tickets carry the tag, for the same corner the standing takes. +/// +/// The count off the row, which `tag_rows` took over every column of the unfiltered board, +/// done included — and with the tag filter on those columns *are* the tickets carrying it, +/// so this counts what is drawn below without counting it a second way. Hiding the done +/// column changes what is drawn and never what is counted, the rule the standing holds. +/// +/// Plain, with no derived state beside it: a tag is a word and not a piece of work, so there +/// is no `[open]` to be in. The noun is spelled out because a bare number on a border says +/// nothing about what was counted, and it is pluralised for the reason `ls` pluralises its +/// own counts. +fn count_spans(count: usize) -> Vec> { + let noun = match count == 1 { + true => "ticket", + false => "tickets", + }; + + vec![Span::raw(format!(" {count} {noun} "))] +} + /// The campaign's description as the frame draws it, or the placeholder for a campaign with /// none. /// @@ -2647,7 +2756,7 @@ fn draw_campaign(frame: &mut Frame, tab: &Tab, area: Rect) { /// One place, for the reason `wrapped_height` is one place: the draw, the scroll clamp and /// the page indicator all measure this, and prose measured twice is two heights free to /// disagree about where the end of it is. -fn frame_prose(campaign: &CampaignRow) -> Text<'static> { +fn campaign_prose(campaign: &CampaignRow) -> Text<'static> { match campaign.description.is_empty() { true => Text::from(Line::from(Span::styled( DESCRIPTION.placeholder, @@ -2657,6 +2766,63 @@ fn frame_prose(campaign: &CampaignRow) -> Text<'static> { } } +/// What the tag means, as the frame draws it, or the placeholder where the board has never +/// said. +/// +/// [`NO_ANNOTATION`] rather than the description section's placeholder, because it is what +/// the vocabulary file itself holds under a heading with nothing under it: the frame and +/// `tags.md` say the same thing about the same tag. Grey, the answer a campaign with no +/// description gets, and the frame's way of saying the tag was never declared — the reader +/// deciding whether the next ticket belongs in it is exactly who needs to know that. +/// +/// A tag declared with nothing said about it draws the same placeholder as one that was +/// never declared. The two are told apart where the difference is actionable, in the +/// picker's two sections; here they have the same nothing to show. +fn tag_prose(tag: &TagRow) -> Text<'static> { + let annotation = tag.annotation.as_deref().unwrap_or_default(); + + match annotation.is_empty() { + true => Text::from(Line::from(Span::styled( + NO_ANNOTATION, + Style::default().fg(Color::Grey.into()), + ))), + false => Text::from(annotation.to_string()), + } +} + +/// The tag frame's title: `#tag`, in the colour a card draws it in, cut to the border. +/// +/// The hash is what a card and `labels_line` already put in front of a tag, and it earns its +/// cell here for the reason it earns one there: the frame is a slot a campaign can be in +/// too, and `~v1` against `#bug` is what says at a glance which filter emptied the columns. +/// The colour is `tag_color`, a pure function of the word, so the frame, the picker row and +/// every card agree without anything being stored. +/// +/// Bare otherwise: no id, because a tag has none — it *is* its name, which is what +/// `ls --tag` matches whole — and nothing after it, because there is no longer name it is +/// shorthand for. Cut by hand like `campaign_title` and `detail_title`, since ratatui +/// truncates a block title at whatever cell it reaches. +fn tag_title(tag: &str, frame_width: u16) -> Vec> { + let room = frame_width.saturating_sub(2) as usize; + + // The hash and the space either side of it are part of what has to fit, so they are + // measured rather than added on afterwards: a title that filled the border exactly + // would otherwise be drawn one cell past it and cut by ratatui. + let whole = format!(" #{tag} "); + let text = match whole.chars().count() <= room { + true => whole, + false => match room.checked_sub(3).filter(|keep| *keep > 0) { + Some(keep) => format!(" #{} ", with_ellipsis(tag, keep)), + None => String::new(), + }, + }; + + vec![Span::styled( + text, + Style::default().fg(tag_color(tag).into()), + )] +} + /// The campaign frame's title: `(id) ~codename · Name`, cut to the border it sits on. /// /// The same shape and the same cut as `detail_title`, since both name one thing on a @@ -2815,19 +2981,19 @@ fn column_text_height(screen: Size, chrome: Chrome) -> u16 { /// The area the columns are drawn in, which is what `draw` hands to `draw_columns`. fn board_area(screen: Size, chrome: Chrome) -> Rect { - frame_rows(Rect::new(0, 0, screen.width, screen.height), chrome)[BOARD_ROW] + screen_rows(Rect::new(0, 0, screen.width, screen.height), chrome)[BOARD_ROW] } /// The rows of the campaign frame that hold prose: inside its border. /// -/// Through `frame_rows` rather than by arithmetic on [`Chrome::CAMPAIGN_PROSE_ROWS`], for +/// Through `screen_rows` rather than by arithmetic on [`Chrome::FRAME_PROSE_ROWS`], for /// the reason `board_area` is: geometry reproduced by hand is geometry that comes to /// disagree with the draw. What `scroll_frame` measures its step and its clamp against, /// which is why it takes the screen — the same relationship `column_text_height` has with /// `draw_columns`. Zero-height with no campaign selected, which is why `scroll_frame` asks /// for one before it measures. fn frame_text_area(screen: Size, chrome: Chrome) -> Rect { - frame_rows(Rect::new(0, 0, screen.width, screen.height), chrome)[CAMPAIGN_ROW] + screen_rows(Rect::new(0, 0, screen.width, screen.height), chrome)[FRAME_ROW] .inner(Margin::new(1, 1)) } @@ -3238,27 +3404,24 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) { }; // The last slot answers the same question in every state: how to get out of here. `q` - // takes off whatever is on top, so with a ticket open or a campaign selected the honest - // answer is `ctrl-c`, the only key left that quits in one press. Naming `q quit` over - // either would be the fault 1b78a24 was, a footer describing a key by what it used to - // do — and with a campaign selected it names what that press actually does instead. + // takes off whatever is on top, so with a ticket open or a filter on the honest answer + // is `ctrl-c`, the only key left that quits in one press. Naming `q quit` over either + // would be the fault 1b78a24 was, a footer describing a key by what it used to do — and + // with a filter on, the frame names what that press actually does instead. let quit = match board.detail.is_some() || !board.current().filter.is_whole() { true => "ctrl-c quit", false => "q quit", }; - // The two filters share a slot, because with one on the row has the same thing to say - // whichever it is: how to take it off, rather than how to put another on. - // // `c` and `t` are named where a reader has to find them: on the board, with nothing - // filtered. A campaign says how to leave on its own frame border, so the slot is spent - // on nothing there and the row is not at its width naming nine keys. A tag has no frame - // to say it, so the row does, and the tag itself is drawn ahead of the keys below — - // otherwise nothing on a filtered board would say why its cards are missing. + // filtered. With either filter on the slot is spent on nothing, because the frame above + // the columns names what the board is filtered to and says `q board` on its own border — + // so the row is not at its width naming nine keys to repeat what is already on screen. + // The tag used to be drawn here for want of a frame to draw it in, which is the one + // thing 2a83bd4 took away. let filter = match board.current().filter { Filter::Whole => "c campaign t tag ", - Filter::Campaign(_) => "", - Filter::Tag(_) => "q board ", + _ => "", }; // Three states, because the frame is a third place the selection can be and the row @@ -3266,7 +3429,7 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) { // what owning `pgup` and `pgdn` means. // // On the frame, `↓` is the way back to the cards and the two scroll keys are the - // frame's; `y` is named because it still copies an id, the campaign's. `enter` and `←→` + // frame's; `y` is named because it still copies what the frame names. `enter` and `←→` // are left out because they do nothing there. Incomplete rather than wrong, the trade // this row is allowed to make — what it must never do is name a key by what it used to // do. `↑ frame` is not named on the board for the same reason `c` is dropped from a @@ -3280,29 +3443,29 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) { false => "enter expand", }; + // What `y` copies where the selection is. A tag is its own id, so naming it one would + // send the reader looking for seven characters on a border that prints a word. + let copied = match board.current().filter { + Filter::Tag(_) => "y copy tag", + _ => "y copy id", + }; + let keys = match (board.detail.is_some(), board.current().focus) { (true, _) => format!( " {tabs}←→↑↓ select pgup/pgdn scroll / search y copy id enter/q close {d} {quit} " ), (false, Focus::Frame) => format!( - " {tabs}↓ board {height} pgup/pgdn scroll / search y copy id {d} {quit} " + " {tabs}↓ board {height} pgup/pgdn scroll / search {copied} {d} {quit} " ), (false, Focus::Cards) => format!( " {tabs}←→ column ↑↓ card / search {filter}y copy id enter detail {d} {quit} " ), }; - // The tag the board is filtered to, in its own colour, ahead of the keys. A span of its - // own rather than a word inside the key string, because the keys are grey and a tag is - // drawn in a `TAG_COLORS` slot or it is drawn wrong: grey already means what a reader - // skips, which is the opposite of what this word is doing there. - let mut spans = Vec::new(); - if let Some(tag) = board.current().filter.tag() { - spans.push(Span::styled(format!(" {tag}"), Style::default().fg(tag_color(tag).into()))); - } - spans.push(Span::styled(keys, Style::default().fg(Color::Grey.into()))); - - frame.render_widget(Paragraph::new(Line::from(spans)), area); + frame.render_widget( + Paragraph::new(Span::styled(keys, Style::default().fg(Color::Grey.into()))), + area, + ); } /// What the last keypress did, where the keys would otherwise be. @@ -3912,7 +4075,7 @@ mod tests { const SCREEN: Size = Size { width: 120, height: 20 }; /// One board, no campaign selected: the chrome most of these tests measure against. - const PLAIN: Chrome = Chrome { tabbed: false, campaign: None }; + const PLAIN: Chrome = Chrome { tabbed: false, frame: None }; /// The rendered buffer as lines of text, escapes and styling dropped. fn render(board: &Board, width: u16, height: u16) -> Vec { @@ -3943,12 +4106,12 @@ mod tests { /// The campaign frame's rows, cut out of the drawn buffer by its own geometry. /// - /// Through `frame_rows` for the reason `headings` goes through the layout: the frame sits + /// Through `screen_rows` for the reason `headings` goes through the layout: the frame sits /// a row lower when a tab row is drawn above it, and it grew from three rows to five when /// its prose became scrollable. A test counting rows by hand goes on measuring whichever /// rows used to be the frame. fn frame_lines(board: &Board, width: u16, height: u16) -> Vec { - let area = frame_rows(Rect::new(0, 0, width, height), board.chrome())[CAMPAIGN_ROW]; + let area = screen_rows(Rect::new(0, 0, width, height), board.chrome())[FRAME_ROW]; let lines = render(board, width, height); lines[area.y as usize..(area.y + area.height) as usize].to_vec() } @@ -7913,24 +8076,29 @@ mod tests { assert!(!board.should_quit, "q quit out from under the filter"); } - /// A tag draws no frame yet, 2a83bd4, so nothing above the columns can hold the - /// selection: `up` from the top card must not reach a frame that is not there. + /// The frame slot is one slot, so a tag holds the selection above the columns the way a + /// campaign does: `up` from the top card reaches it, and `down` comes back. #[test] - fn a_tag_filter_draws_no_frame_and_cannot_hold_the_selection() { + fn a_tag_frame_holds_the_selection_the_way_a_campaign_frame_does() { let dir = board_dir(); let mut board = tag_board(&dir); board.select_filter(Filter::Tag("bug".to_string()), SCREEN); - assert_eq!(board.chrome().campaign, None, "a tag drew a campaign frame"); + assert_eq!(board.chrome().frame, Some(FrameSize::Collapsed), "a tag drew no frame"); board.select_card(-1, SCREEN); - assert_eq!(board.current().focus, Focus::Cards, "the selection left the cards"); + assert_eq!(board.current().focus, Focus::Frame, "up from the top card stayed put"); + + board.select_card(1, SCREEN); + assert_eq!(board.current().focus, Focus::Cards, "down did not leave the frame"); } - /// The row names both filters where a reader has to find them, and says how to leave a - /// tag: the campaign frame says it on its own border and a tag has no frame to say it. + /// The row names both filters where a reader has to find them, and spends nothing on + /// either once one is on: the frame above the columns names what the board is filtered + /// to and says `q board` on its own border, so the row saying it again would be eight + /// cells spent repeating what is already on screen. #[test] - fn the_footer_names_the_tag_key_and_the_way_back() { + fn the_footer_names_the_tag_key_and_leaves_the_way_back_to_the_frame() { let dir = board_dir(); let mut board = tag_board(&dir); @@ -7940,11 +8108,333 @@ mod tests { board.select_filter(Filter::Tag("bug".to_string()), SCREEN); let filtered = footer(&board, 120, 20); - assert!(filtered.contains("bug"), "the filter does not say what it is: {filtered}"); - assert!(filtered.contains("q board"), "the way back is not named: {filtered}"); + assert!(!filtered.contains("q board"), "the row repeated the frame: {filtered}"); + assert!(!filtered.contains("t tag"), "a key that filters again: {filtered}"); assert!(filtered.contains("ctrl-c quit"), "{filtered}"); } + /// `y` on the frame copies what the frame names, and a tag is its own id: `--tag` + /// matches the word whole, and the hash the border draws is not part of it. + #[test] + fn y_on_a_tag_frame_copies_the_tag_and_not_the_hash() { + let dir = board_dir(); + let mut board = tag_board(&dir); + board.select_filter(Filter::Tag("bug".to_string()), SCREEN); + board.select_card(-1, SCREEN); + + assert_eq!(board.copy_text().as_deref(), Some("bug")); + assert!( + footer(&board, 120, 20).contains("y copy tag"), + "the row called a tag an id" + ); + } + + // ------------------------------------------------------- the tag frame -- + + /// `tag_board` filtered to `bug`, with an annotation that has somewhere to scroll. + /// + /// The same three tickets every other tag test reasons about, and `write_vocabulary` + /// again over the same three tags, which is the same file: the columns are the fixture's + /// and only the prose above them is this one's. + fn tag_frame_board(dir: &Path, lines: usize) -> Board { + tag_board(dir); + let annotation = long_description(lines); + write_vocabulary( + dir, + &[ + ("bug", annotation.as_str()), + ("chore", "Work with nothing to see."), + ("cli", "The command line surface."), + ], + ); + + let mut board = one_board(dir); + board.select_filter(Filter::Tag("bug".to_string()), SCREEN); + board + } + + /// The colour the hash on the frame's top border actually reached the screen in. + /// + /// Located on that row rather than by searching the buffer for the glyph: a card draws + /// `#bug` on its own label row, and `drawn_color` would answer about whichever card + /// holds the first one. + fn frame_title_color(board: &Board, width: u16, height: u16) -> Option { + let mut terminal = Terminal::new(TestBackend::new(width, height)).unwrap(); + terminal.draw(|frame| draw(frame, board)).unwrap(); + let buffer = terminal.backend().buffer().clone(); + + let area = screen_rows(Rect::new(0, 0, width, height), board.chrome())[FRAME_ROW]; + + (area.x..area.x + area.width) + .find(|x| buffer[(*x, area.y)].symbol() == "#") + .map(|x| buffer[(x, area.y)].fg) + } + + /// The colour the frame's first row of prose reached the screen in, which is what says + /// a placeholder is a placeholder. + fn frame_prose_color(board: &Board, width: u16, height: u16) -> ratatui::style::Color { + let mut terminal = Terminal::new(TestBackend::new(width, height)).unwrap(); + terminal.draw(|frame| draw(frame, board)).unwrap(); + let buffer = terminal.backend().buffer().clone(); + + let text = screen_rows(Rect::new(0, 0, width, height), board.chrome())[FRAME_ROW] + .inner(Margin::new(1, 1)); + + buffer[(text.x, text.y)].fg + } + + /// The payoff for declaring a tag at all: whoever is browsing one is deciding whether + /// the next ticket belongs in it, and the sentence saying when it is appropriate is on + /// the screen at that moment rather than in a file they would have to know to open. + #[test] + fn the_tag_frame_names_the_tag_and_what_it_means() { + let dir = board_dir(); + let mut board = tag_board(&dir); + board.select_filter(Filter::Tag("bug".to_string()), SCREEN); + + let rows = frame_lines(&board, 100, 24); + assert_eq!(rows.len(), Chrome::FRAME_ROWS as usize, "the frame is a different height"); + + assert!(rows[0].contains("#bug"), "no tag on the frame: {:?}", rows[0]); + assert!( + rows[1].contains("Behaviour that contradicts what the tool says."), + "no annotation: {:?}", + rows[1] + ); + // The way out, on the border of the thing it undoes, where the campaign frame puts + // it: with a filter on, the footer's last slot names `ctrl-c quit`. + let bottom = rows.len() - 1; + assert!(rows[bottom].contains("q board"), "no way out named: {:?}", rows[bottom]); + } + + /// The bottom right is what the frame is *about*: how much of the board this is. The + /// noun is spelled out and pluralised, because a bare number on a border says nothing + /// about what was counted. + #[test] + fn the_count_of_tickets_carrying_the_tag_is_on_the_bottom_border() { + let dir = board_dir(); + let mut board = tag_board(&dir); + board.select_filter(Filter::Tag("bug".to_string()), SCREEN); + + let held: usize = board.current().columns.iter().map(|c| c.cards.len()).sum(); + assert_eq!(held, 2, "the fixture changed"); + + let rows = frame_lines(&board, 100, 24); + let bottom = &rows[rows.len() - 1]; + assert!(bottom.contains("2 tickets"), "no count on the frame: {bottom:?}"); + + // And the singular, on the one tag the fixture gives a single ticket. + board.select_filter(Filter::Tag("cli".to_string()), SCREEN); + let rows = frame_lines(&board, 100, 24); + let bottom = &rows[rows.len() - 1]; + assert!( + bottom.contains("1 ticket "), + "the count did not agree with itself: {bottom:?}" + ); + } + + /// The count is every column's, drawn or not, the rule the campaign standing holds: + /// hiding done is a change to what is drawn and never to what is counted. `sync` is + /// carried by the done ticket alone, so the two answers differ here or nowhere. + #[test] + fn the_count_holds_while_the_only_column_carrying_the_tag_is_hidden() { + let dir = board_dir(); + let mut board = tag_board(&dir); + board.select_filter(Filter::Tag("sync".to_string()), SCREEN); + + assert_eq!(board.visibility, Visibility::Neither, "a terminal column is drawn"); + let rows = frame_lines(&board, 100, 24); + let bottom = &rows[rows.len() - 1]; + assert!( + bottom.contains("1 ticket "), + "the hidden column was not counted: {bottom:?}" + ); + } + + /// A tag nobody declared has no annotation, and the frame says so rather than drawing a + /// blank row: that is the frame telling you the word was never agreed on, which is the + /// other half of what the vocabulary file is for. + #[test] + fn an_undeclared_tag_draws_the_placeholder_rather_than_a_blank_row() { + let dir = board_dir(); + let mut board = tag_board(&dir); + board.select_filter(Filter::Tag("sync".to_string()), SCREEN); + + let rows = frame_lines(&board, 100, 24); + assert!(rows[1].contains(NO_ANNOTATION), "no placeholder: {:?}", rows[1]); + assert_eq!( + frame_prose_color(&board, 100, 24), + Color::Grey.into(), + "the placeholder was drawn as prose" + ); + } + + /// The colour guideline applied: `tag_color` is a pure function of the word, so the + /// frame, the picker row and every card agree without anything being stored. + #[test] + fn the_tag_on_the_frame_is_drawn_in_the_colour_a_card_draws_it_in() { + let dir = board_dir(); + let mut board = tag_board(&dir); + board.select_filter(Filter::Tag("bug".to_string()), SCREEN); + + assert_eq!( + frame_title_color(&board, 100, 24), + Some(tag_color("bug").into()), + "the tag was not drawn in its own colour" + ); + } + + /// The frame slot is shared, not doubled: one filter is on at a time, so the rows the + /// columns give up cannot depend on which of the two took them. + #[test] + fn the_tag_frame_takes_the_rows_the_campaign_frame_takes() { + let dir = board_dir(); + let mut board = tag_board(&dir); + let screen = Size { width: 100, height: 24 }; + + let plain = board_area(screen, board.chrome()); + board.select_filter(Filter::Tag("bug".to_string()), screen); + let framed = board_area(screen, board.chrome()); + + assert_eq!(framed.y, plain.y + Chrome::FRAME_ROWS, "the columns did not move down"); + assert_eq!( + framed.height, + plain.height - Chrome::FRAME_ROWS, + "the frame took its rows from somewhere else" + ); + } + + /// The frame spends its prose rows on prose, whichever filter filled it. + #[test] + fn the_tag_frame_draws_a_row_of_the_annotation_for_every_row_it_takes() { + let dir = board_dir(); + let board = tag_frame_board(&dir, 40); + + let rows = frame_lines(&board, 120, 20); + let prose = &rows[1..rows.len() - 1]; + assert_eq!(prose.len(), Chrome::FRAME_PROSE_ROWS as usize, "not all of them are prose"); + + for (at, drawn) in prose.iter().enumerate() { + let wanted = format!("Line {:03}", at + 1); + assert!(drawn.contains(&wanted), "no {wanted} on the frame: {drawn:?}"); + } + } + + /// An annotation with paragraphs in it is longer than three rows, so the two keys that + /// read a campaign's description read this one, clamped at both ends off the same + /// wrapped measurement the draw uses. One set of rules, per ebad2fa: the same keys must + /// not move different distances in the two things the frame can hold. + #[test] + fn the_scroll_keys_page_through_the_tag_frame() { + let dir = board_dir(); + let mut board = tag_frame_board(&dir, 40); + board.select_card(-1, SCREEN); + assert_eq!(board.current().focus, Focus::Frame, "up did not reach the frame"); + + board.scroll_page(1, SCREEN); + let one = board.current().frame_offset; + assert!(one > 0, "the frame did not move"); + + board.scroll_page(1, SCREEN); + assert!(board.current().frame_offset > one, "the second page did not move"); + + board.scroll_page(40, SCREEN); + let text = frame_text_area(SCREEN, board.chrome()); + let last = last_offset(&tag_prose(board.current().selected_tag().expect("no tag")), text); + assert_eq!(board.current().frame_offset, last, "the scroll ran past the annotation"); + + board.scroll_page(-40, SCREEN); + assert_eq!(board.current().frame_offset, 0, "the scroll ran off the top"); + } + + /// The page indicator earns its place here for the reason it does on the campaign frame: + /// three rows of a long annotation look exactly like the whole of a short one. + #[test] + fn a_scrollable_annotation_puts_a_page_indicator_on_the_frame() { + let dir = board_dir(); + let long = tag_frame_board(&dir, 40); + let rows = frame_lines(&long, 120, 20); + let bottom = &rows[rows.len() - 1]; + assert!(bottom.contains("pg 1/"), "no indicator on a long annotation: {bottom:?}"); + + let dir = board_dir(); + let mut short = tag_board(&dir); + short.select_filter(Filter::Tag("bug".to_string()), SCREEN); + let rows = frame_lines(&short, 120, 20); + let bottom = &rows[rows.len() - 1]; + assert!(!bottom.contains("pg "), "an indicator where nothing scrolls: {bottom:?}"); + } + + /// `q` takes the filter off from the frame as well as from the cards. The frame is the + /// view the reader put on, not a layer over it, so there is no extra press between them + /// and the board. + #[test] + fn q_gives_the_whole_board_back_from_the_tag_frame() { + let dir = board_dir(); + let mut board = tag_frame_board(&dir, 40); + board.select_card(-1, SCREEN); + assert_eq!(board.current().focus, Focus::Frame, "up did not reach the frame"); + + board.dismiss(SCREEN); + + assert!(board.current().filter.is_whole(), "the filter survived q"); + assert_eq!(board.current().focus, Focus::Cards, "the focus outlived the frame"); + assert!(!board.should_quit, "q quit out from under the filter"); + } + + /// `enter` gives a tag frame half the board and takes the rows back, the key the + /// campaign frame already has: the height is a view of the prose above the columns, and + /// an annotation with paragraphs in it is as worth half the board as a description is. + #[test] + fn enter_expands_a_tag_frame_and_gives_the_rows_back() { + let dir = board_dir(); + let mut board = tag_frame_board(&dir, 40); + board.select_card(-1, SCREEN); + + let collapsed = board.chrome().frame_rows(SCREEN.height); + assert_eq!(collapsed, Chrome::FRAME_ROWS, "the frame did not open collapsed"); + + board.toggle_focused(SCREEN); + let expanded = board.chrome().frame_rows(SCREEN.height); + assert!(expanded > collapsed, "enter did not give the frame more rows"); + // The draw and the measurement, which is what `Chrome` exists to keep as one answer. + assert_eq!( + frame_lines(&board, SCREEN.width, SCREEN.height).len(), + expanded as usize, + "the draw and the measurement disagree" + ); + + board.toggle_focused(SCREEN); + assert_eq!( + board.chrome().frame_rows(SCREEN.height), + collapsed, + "enter did not give the rows back" + ); + } + + /// A tag the board stops holding takes its frame with it, the answer `reload` gives a + /// campaign that has left: a frame that is no longer drawn must not go on holding the + /// selection. + #[test] + fn a_tag_that_leaves_the_board_takes_its_frame_and_the_selection_with_it() { + let dir = board_dir(); + let mut board = tag_board(&dir); + board.select_filter(Filter::Tag("sync".to_string()), SCREEN); + board.select_card(-1, SCREEN); + assert_eq!(board.current().focus, Focus::Frame, "up did not reach the frame"); + + std::fs::remove_file( + dir.join("done") + .join("33333333-0000-4000-8000-000000000000_three.md"), + ) + .unwrap(); + board.tick().unwrap(); + + assert!(board.current().filter.is_whole(), "the filter outlived its tag"); + assert_eq!(board.current().focus, Focus::Cards, "the focus outlived the frame"); + assert_eq!(board.chrome().frame, None, "the frame outlived the tag"); + } + /// A tag is a string and the same string on every board, so the merge tab carries one /// row per word and filtering to it cuts every project at once. A campaign cannot do /// this: its uuid resolves inside one `.worklane`. @@ -8196,11 +8686,7 @@ mod tests { board.select_filter(Filter::Campaign(V1.to_string()), SCREEN); let rows = frame_lines(&board, 100, 24); - assert_eq!( - rows.len(), - Chrome::CAMPAIGN_ROWS as usize, - "the frame is a different height" - ); + assert_eq!(rows.len(), Chrome::FRAME_ROWS as usize, "the frame is a different height"); let bottom = rows.len() - 1; assert!(rows[0].contains(short_id(V1)), "no id on the frame: {:?}", rows[0]); @@ -8242,7 +8728,11 @@ mod tests { board.select_filter(Filter::Campaign(V1.to_string()), SCREEN); assert_eq!(board.visibility, Visibility::Neither, "a column is drawn at startup"); - let standing = board.campaign().expect("no campaign selected").standing; + let standing = board + .current() + .selected_campaign() + .expect("no campaign selected") + .standing; assert_eq!((standing.done, standing.total), (1, 2)); } @@ -8271,7 +8761,11 @@ mod tests { let mut board = one_board(&dir); board.select_filter(Filter::Campaign(V1.to_string()), SCREEN); - let standing = board.campaign().expect("no campaign selected").standing; + let standing = board + .current() + .selected_campaign() + .expect("no campaign selected") + .standing; assert_eq!((standing.done, standing.total), (1, 2), "the discard was not counted"); } @@ -8288,10 +8782,10 @@ mod tests { board.select_filter(Filter::Campaign(V1.to_string()), screen); let framed = board_area(screen, board.chrome()); - assert_eq!(framed.y, plain.y + Chrome::CAMPAIGN_ROWS, "the columns did not move down"); + assert_eq!(framed.y, plain.y + Chrome::FRAME_ROWS, "the columns did not move down"); assert_eq!( framed.height, - plain.height - Chrome::CAMPAIGN_ROWS, + plain.height - Chrome::FRAME_ROWS, "the frame took its rows from somewhere else" ); } @@ -8345,19 +8839,11 @@ mod tests { let board = frame_board(&dir, 40); let rows = frame_lines(&board, 120, 20); - assert_eq!( - rows.len(), - Chrome::CAMPAIGN_ROWS as usize, - "the frame is a different height" - ); + assert_eq!(rows.len(), Chrome::FRAME_ROWS as usize, "the frame is a different height"); // The prose rows are the frame's rows less the border either side of them. let prose = &rows[1..rows.len() - 1]; - assert_eq!( - prose.len(), - Chrome::CAMPAIGN_PROSE_ROWS as usize, - "not all of them are prose" - ); + assert_eq!(prose.len(), Chrome::FRAME_PROSE_ROWS as usize, "not all of them are prose"); for (at, drawn) in prose.iter().enumerate() { let wanted = format!("Line {:03}", at + 1); @@ -8433,7 +8919,10 @@ mod tests { // rather than running on into blank rows, and the top is zero. board.scroll_page(40, SCREEN); let text = frame_text_area(SCREEN, board.chrome()); - let last = last_offset(&frame_prose(board.campaign().expect("no campaign")), text); + let last = last_offset( + &campaign_prose(board.current().selected_campaign().expect("no campaign")), + text, + ); assert_eq!(board.current().frame_offset, last, "the scroll ran past the description"); board.scroll_page(-40, SCREEN); @@ -8769,8 +9258,7 @@ mod tests { /// The rows the frame takes, as the layout gives them out. fn frame_height(board: &Board, screen: Size) -> u16 { - frame_rows(Rect::new(0, 0, screen.width, screen.height), board.chrome())[CAMPAIGN_ROW] - .height + screen_rows(Rect::new(0, 0, screen.width, screen.height), board.chrome())[FRAME_ROW].height } /// `enter` on the frame gives its prose half the board, and `enter` again gives the rows @@ -8780,7 +9268,7 @@ mod tests { let dir = board_dir(); let mut board = frame_board(&dir, 60); let collapsed = frame_height(&board, SCREEN); - assert_eq!(collapsed, Chrome::CAMPAIGN_ROWS, "the board did not open collapsed"); + assert_eq!(collapsed, Chrome::FRAME_ROWS, "the board did not open collapsed"); board.select_card(-1, SCREEN); board.toggle_focused(SCREEN); @@ -8837,18 +9325,18 @@ mod tests { for tabbed in [false, true] { let chrome = Chrome { tabbed, - campaign: Some(FrameSize::Expanded), + frame: Some(FrameSize::Expanded), }; - let rows = chrome.campaign_rows(height); + let rows = chrome.frame_rows(height); let shared = height.saturating_sub(u16::from(tabbed) + FOOTER_ROWS); assert!( - rows >= Chrome::CAMPAIGN_ROWS, + rows >= Chrome::FRAME_ROWS, "expanding shrank the frame to {rows} rows at height {height}" ); // Only where the board can hold both. Below that the frame is pinned to its // collapsed height and the layout is what apportions what is left. - if shared >= Chrome::CAMPAIGN_ROWS + COLUMN_MIN_ROWS { + if shared >= Chrome::FRAME_ROWS + COLUMN_MIN_ROWS { assert!( shared - rows >= COLUMN_MIN_ROWS, "the columns kept {} rows at height {height}", @@ -8866,10 +9354,10 @@ mod tests { let short = Size { width: 80, height: 10 }; let chrome = Chrome { tabbed: false, - campaign: Some(FrameSize::Expanded), + frame: Some(FrameSize::Expanded), }; - assert_eq!(chrome.campaign_rows(short.height), Chrome::CAMPAIGN_ROWS); + assert_eq!(chrome.frame_rows(short.height), Chrome::FRAME_ROWS); } /// Every measurement of the board agrees about the expanded height. That is what `Chrome` @@ -8882,7 +9370,7 @@ mod tests { board.select_card(-1, SCREEN); board.toggle_focused(SCREEN); - let rows = frame_rows(Rect::new(0, 0, SCREEN.width, SCREEN.height), board.chrome()); + let rows = screen_rows(Rect::new(0, 0, SCREEN.width, SCREEN.height), board.chrome()); let total: u16 = rows.iter().map(|row| row.height).sum(); assert_eq!(total, SCREEN.height, "the rows do not add up to the screen"); @@ -8890,7 +9378,7 @@ mod tests { // given. Two answers here is how a scroll comes to clamp against a frame nobody drew. assert_eq!( frame_text_area(SCREEN, board.chrome()), - rows[CAMPAIGN_ROW].inner(Margin::new(1, 1)), + rows[FRAME_ROW].inner(Margin::new(1, 1)), "the keypress and the draw measure different prose" ); assert_eq!(board_area(SCREEN, board.chrome()), rows[BOARD_ROW]); @@ -8923,7 +9411,10 @@ mod tests { // And the clamp is still the wrapped prose, not blank rows past the end of it. board.scroll_page(40, SCREEN); let text = frame_text_area(SCREEN, board.chrome()); - let last = last_offset(&frame_prose(board.campaign().expect("no campaign")), text); + let last = last_offset( + &campaign_prose(board.current().selected_campaign().expect("no campaign")), + text, + ); assert_eq!(board.current().frame_offset, last, "the scroll ran past the description"); } @@ -8956,10 +9447,7 @@ mod tests { board.toggle_focused(SCREEN); assert!(board.current().expanded, "a one line description refused to expand"); - assert!( - frame_height(&board, SCREEN) > Chrome::CAMPAIGN_ROWS, - "the frame did not grow" - ); + assert!(frame_height(&board, SCREEN) > Chrome::FRAME_ROWS, "the frame did not grow"); } /// `q` takes the campaign filter off from an expanded frame exactly as it does from a @@ -9037,7 +9525,10 @@ mod tests { // And the stored offset is inside the taller viewport, not left past its end where // the next pgup would count down from a number the frame never showed. let text = frame_text_area(SCREEN, board.chrome()); - let last = last_offset(&frame_prose(board.campaign().expect("no campaign")), text); + let last = last_offset( + &campaign_prose(board.current().selected_campaign().expect("no campaign")), + text, + ); assert!(board.current().frame_offset <= last, "the offset sits past the end"); board.toggle_focused(SCREEN); @@ -9085,7 +9576,7 @@ mod tests { board.select_filter(Filter::Campaign(BEAVER.to_string()), SCREEN); assert!(!board.current().expanded, "the new campaign opened at half the board"); - assert_eq!(frame_height(&board, SCREEN), Chrome::CAMPAIGN_ROWS); + assert_eq!(frame_height(&board, SCREEN), Chrome::FRAME_ROWS); } /// A campaign that leaves the board takes the frame with it, focus and offset both: the