What the formatter has been asking for since the scroll memo landed
`nix flake check` runs fmt before anything else and main has been failing on it for two pipelines — so the publish step at the end of that job has not run either, and no tarball has been uploaded since. The objects the last two commits built were never published anywhere. Only rustfmt's output, from the toolchain the flake pins. Worth one note: it puts `use cosmic::Element` after the iced imports and so away from the comment explaining why it is cosmic's Element and not iced's. The comment now sits above the line it is not about. Moving it back means failing fmt again; the fix is to reword it where it lands, which is a change to make deliberately rather than inside a formatting commit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
12754c2 parent: 121e5f1 modified
crates/jolt-cosmic/src/lib.rs +91 -30 | @@ -36,9 +36,13 @@ use cosmic::iced::alignment::Horizontal; | ||
| 36 | 36 | use cosmic::iced::futures::channel::mpsc; |
| 37 | 37 | use cosmic::iced::futures::{Stream, StreamExt}; |
| 38 | 38 | use cosmic::iced::widget::container::Style as ContainerStyle; |
| 39 | -use cosmic::iced::widget::scrollable::{self as iced_scrollable, AbsoluteOffset, RelativeOffset, Viewport}; | |
| 39 | +use cosmic::iced::widget::scrollable::{ | |
| 40 | + self as iced_scrollable, AbsoluteOffset, RelativeOffset, Viewport, | |
| 41 | +}; | |
| 40 | 42 | use cosmic::iced::widget::text::Wrapping; |
| 41 | -use cosmic::iced::{Alignment, Background, Border, Color, ContentFit, Font, Length, Padding, Subscription}; | |
| 43 | +use cosmic::iced::{ | |
| 44 | + Alignment, Background, Border, Color, ContentFit, Font, Length, Padding, Subscription, | |
| 45 | +}; | |
| 42 | 46 | use cosmic::widget::{self, Column, Row}; |
| 43 | 47 | use cosmic::{ApplicationExt, Element}; |
| 44 | 48 | use jolt_abi::{borrowed, empty_str, guard, Scratch}; |
| @@ -404,7 +408,11 @@ fn report(memo: &mut ScrollMemo, at_end: bool) -> Option<&'static str> { | ||
| 404 | 408 | memo.told = Some(at_end); |
| 405 | 409 | // "end" or "away", the strings libvidya emits: frq's handler compares |
| 406 | 410 | // against "end". |
| 407 | - if at_end { "end" } else { "away" } | |
| 411 | + if at_end { | |
| 412 | + "end" | |
| 413 | + } else { | |
| 414 | + "away" | |
| 415 | + } | |
| 408 | 416 | }) |
| 409 | 417 | } |
| 410 | 418 | |
| @@ -531,7 +539,13 @@ fn reveal(name: String, row: i32, viewport: f32) -> Task<Message> { | ||
| 531 | 539 | "jolt-scroll: {name} row {row} at {top} (h {height}), viewport {viewport} -> {y}" |
| 532 | 540 | ); |
| 533 | 541 | } |
| 534 | - iced_scrollable::scroll_to(scroll_id(&name), AbsoluteOffset { x: None, y: Some(y) }) | |
| 542 | + iced_scrollable::scroll_to( | |
| 543 | + scroll_id(&name), | |
| 544 | + AbsoluteOffset { | |
| 545 | + x: None, | |
| 546 | + y: Some(y), | |
| 547 | + }, | |
| 548 | + ) | |
| 535 | 549 | } |
| 536 | 550 | None => { |
| 537 | 551 | if scroll_log() { |
| @@ -565,7 +579,13 @@ fn scroll_shape(t: &Tree, name: &str) -> (usize, usize) { | ||
| 565 | 579 | } |
| 566 | 580 | |
| 567 | 581 | fn snap_to_end(name: &str) -> Task<Message> { |
| 568 | - iced_scrollable::snap_to(scroll_id(name), RelativeOffset { x: None, y: Some(1.0) }) | |
| 582 | + iced_scrollable::snap_to( | |
| 583 | + scroll_id(name), | |
| 584 | + RelativeOffset { | |
| 585 | + x: None, | |
| 586 | + y: Some(1.0), | |
| 587 | + }, | |
| 588 | + ) | |
| 569 | 589 | } |
| 570 | 590 | |
| 571 | 591 | // --- the app ----------------------------------------------------------------- |
| @@ -610,9 +630,15 @@ enum Message { | ||
| 610 | 630 | /// caret, and the next key would land on that. An entry is let go once a |
| 611 | 631 | /// commit was rendered after its event: from then on the component's own |
| 612 | 632 | /// state is the answer, a draft it cleared included. |
| 613 | -fn keep_typed(tree: &mut Arc<Tree>, typed: &mut HashMap<(i32, &'static str), (u64, Prop)>, settled: u64) { | |
| 633 | +fn keep_typed( | |
| 634 | + tree: &mut Arc<Tree>, | |
| 635 | + typed: &mut HashMap<(i32, &'static str), (u64, Prop)>, | |
| 636 | + settled: u64, | |
| 637 | +) { | |
| 614 | 638 | typed.retain(|&(node, key), (seq, value)| { |
| 615 | - let Some(n) = tree.get(node) else { return false }; | |
| 639 | + let Some(n) = tree.get(node) else { | |
| 640 | + return false; | |
| 641 | + }; | |
| 616 | 642 | if *seq <= settled { |
| 617 | 643 | return false; |
| 618 | 644 | } |
| @@ -629,7 +655,15 @@ impl App { | ||
| 629 | 655 | /// working control, and its next render is what settles it. Then the event |
| 630 | 656 | /// goes to the worker, and what was written is held over any commit |
| 631 | 657 | /// rendered before the worker saw it. |
| 632 | - fn write_back(&mut self, node: i32, key: &'static str, value: Prop, event: &'static str, text: String, num: f64) { | |
| 658 | + fn write_back( | |
| 659 | + &mut self, | |
| 660 | + node: i32, | |
| 661 | + key: &'static str, | |
| 662 | + value: Prop, | |
| 663 | + event: &'static str, | |
| 664 | + text: String, | |
| 665 | + num: f64, | |
| 666 | + ) { | |
| 633 | 667 | edit(|t| t.set(node, key, value.clone())); |
| 634 | 668 | Arc::make_mut(&mut self.tree).set(node, key, value.clone()); |
| 635 | 669 | let seq = post_seq(node, event, text, num); |
| @@ -652,15 +686,12 @@ impl App { | ||
| 652 | 686 | let mut live = HashSet::new(); |
| 653 | 687 | for ask in scroll_asks(&before, &self.tree) { |
| 654 | 688 | live.insert(ask.name.clone()); |
| 655 | - let memo = self | |
| 656 | - .scrolls | |
| 657 | - .entry(ask.name.clone()) | |
| 658 | - .or_insert(ScrollMemo { | |
| 659 | - at_end: ask.stick, | |
| 660 | - told: None, | |
| 661 | - offset_y: 0.0, | |
| 662 | - height: 0.0, | |
| 663 | - }); | |
| 689 | + let memo = self.scrolls.entry(ask.name.clone()).or_insert(ScrollMemo { | |
| 690 | + at_end: ask.stick, | |
| 691 | + told: None, | |
| 692 | + offset_y: 0.0, | |
| 693 | + height: 0.0, | |
| 694 | + }); | |
| 664 | 695 | // A row asking to be shown is measured on the frame it appears, |
| 665 | 696 | // so the ask stands until the layout has a place for it — see |
| 666 | 697 | // `reveal`, which asks again rather than giving up. |
| @@ -670,7 +701,10 @@ impl App { | ||
| 670 | 701 | ScrollMove::End => tasks.push(snap_to_end(&ask.name)), |
| 671 | 702 | ScrollMove::Restore(y) => tasks.push(iced_scrollable::scroll_to( |
| 672 | 703 | scroll_id(&ask.name), |
| 673 | - AbsoluteOffset { x: None, y: Some(y) }, | |
| 704 | + AbsoluteOffset { | |
| 705 | + x: None, | |
| 706 | + y: Some(y), | |
| 707 | + }, | |
| 674 | 708 | )), |
| 675 | 709 | ScrollMove::Stay => {} |
| 676 | 710 | } |
| @@ -764,7 +798,14 @@ impl cosmic::Application for App { | ||
| 764 | 798 | Message::Click(node) => post(node, "click", String::new(), 0.0), |
| 765 | 799 | Message::Toggled(node, on) => { |
| 766 | 800 | let num = f64::from(u8::from(on)); |
| 767 | - self.write_back(node, "active", Prop::Bool(on), "toggled", String::new(), num); | |
| 801 | + self.write_back( | |
| 802 | + node, | |
| 803 | + "active", | |
| 804 | + Prop::Bool(on), | |
| 805 | + "toggled", | |
| 806 | + String::new(), | |
| 807 | + num, | |
| 808 | + ); | |
| 768 | 809 | } |
| 769 | 810 | Message::Change(node, text) => { |
| 770 | 811 | self.write_back(node, "text", Prop::Str(text.clone()), "change", text, 0.0); |
| @@ -776,8 +817,9 @@ impl cosmic::Application for App { | ||
| 776 | 817 | // worker, which collects it with `cosmic_clipboard_image_png`. |
| 777 | 818 | Message::Paste(node, text) => { |
| 778 | 819 | if self.tree.get(node).is_some_and(|n| n.str("text") == text) { |
| 779 | - return cosmic::iced::clipboard::read_data::<ClipboardPng>() | |
| 780 | - .map(move |png| cosmic::Action::App(Message::PastedPicture(node, png.map(|p| p.0)))); | |
| 820 | + return cosmic::iced::clipboard::read_data::<ClipboardPng>().map(move |png| { | |
| 821 | + cosmic::Action::App(Message::PastedPicture(node, png.map(|p| p.0))) | |
| 822 | + }); | |
| 781 | 823 | } |
| 782 | 824 | self.write_back(node, "text", Prop::Str(text.clone()), "change", text, 0.0); |
| 783 | 825 | } |
| @@ -810,15 +852,18 @@ impl cosmic::Application for App { | ||
| 810 | 852 | None => snap_to_end(&name), |
| 811 | 853 | Some(y) => iced_scrollable::scroll_to( |
| 812 | 854 | scroll_id(&name), |
| 813 | - AbsoluteOffset { x: None, y: Some(y) }, | |
| 855 | + AbsoluteOffset { | |
| 856 | + x: None, | |
| 857 | + y: Some(y), | |
| 858 | + }, | |
| 814 | 859 | ), |
| 815 | 860 | }; |
| 816 | 861 | return Task::batch([now, again]); |
| 817 | 862 | } |
| 818 | 863 | Message::Reveal(name, tries) => { |
| 819 | 864 | let viewport = self.scrolls.get(&name).map_or(0.0, |memo| memo.height); |
| 820 | - let place = asking_row(&self.tree, &name) | |
| 821 | - .and_then(|row| placements(&name).get(row)); | |
| 865 | + let place = | |
| 866 | + asking_row(&self.tree, &name).and_then(|row| placements(&name).get(row)); | |
| 822 | 867 | if let Some((top, height)) = place { |
| 823 | 868 | // Nothing written down here either, for the reason the |
| 824 | 869 | // commit path gives: where this ends up is `scrolled`'s to |
| @@ -826,7 +871,10 @@ impl cosmic::Application for App { | ||
| 826 | 871 | let y = centred_offset(top, height, viewport); |
| 827 | 872 | return iced_scrollable::scroll_to( |
| 828 | 873 | scroll_id(&name), |
| 829 | - AbsoluteOffset { x: None, y: Some(y) }, | |
| 874 | + AbsoluteOffset { | |
| 875 | + x: None, | |
| 876 | + y: Some(y), | |
| 877 | + }, | |
| 830 | 878 | ); |
| 831 | 879 | } |
| 832 | 880 | if scroll_log() { |
| @@ -989,7 +1037,9 @@ fn margins(n: &Node) -> Padding { | ||
| 989 | 1037 | /// `:width-request 0` on its message column whenever the people panel is shut, |
| 990 | 1038 | /// and taken literally that is a backlog laid out zero points wide. |
| 991 | 1039 | fn width_request(n: &Node) -> Option<f32> { |
| 992 | - n.num("width-request").filter(|w| *w > 0.0).map(|w| w as f32) | |
| 1040 | + n.num("width-request") | |
| 1041 | + .filter(|w| *w > 0.0) | |
| 1042 | + .map(|w| w as f32) | |
| 993 | 1043 | } |
| 994 | 1044 | |
| 995 | 1045 | /// `align`, or `default` where it is not set. A column starts its children at |
| @@ -1230,7 +1280,8 @@ fn element(t: &Tree, id: i32, enabled: bool, in_row: bool) -> Element<'_, Messag | ||
| 1230 | 1280 | } else { |
| 1231 | 1281 | Color::from_rgb(0.55, 0.55, 0.55) |
| 1232 | 1282 | }; |
| 1233 | - let dot = widget::container(widget::Space::new().width(8).height(8)).class(filled(colour, 4.0)); | |
| 1283 | + let dot = widget::container(widget::Space::new().width(8).height(8)) | |
| 1284 | + .class(filled(colour, 4.0)); | |
| 1234 | 1285 | Row::new() |
| 1235 | 1286 | .spacing(6) |
| 1236 | 1287 | .align_y(Alignment::Center) |
| @@ -1624,7 +1675,9 @@ pub unsafe extern "C" fn cosmic_picked_image(path: *const c_char) -> c_int { | ||
| 1624 | 1675 | } |
| 1625 | 1676 | } |
| 1626 | 1677 | }; |
| 1627 | - match image::open(&chosen).and_then(|picture| picture.save_with_format(&path, image::ImageFormat::Png)) { | |
| 1678 | + match image::open(&chosen) | |
| 1679 | + .and_then(|picture| picture.save_with_format(&path, image::ImageFormat::Png)) | |
| 1680 | + { | |
| 1628 | 1681 | Ok(()) => 1, |
| 1629 | 1682 | Err(err) => { |
| 1630 | 1683 | eprintln!("jolt-cosmic: could not take {}: {err}", chosen.display()); |
| @@ -1878,7 +1931,10 @@ mod tests { | ||
| 1878 | 1931 | let mut t = Tree::default(); |
| 1879 | 1932 | let root = t.root(); |
| 1880 | 1933 | let list = node(&mut t, root, "scroll"); |
| 1881 | - assert_eq!(scroll_name(t.get(list).unwrap(), list), format!("node-{list}")); | |
| 1934 | + assert_eq!( | |
| 1935 | + scroll_name(t.get(list).unwrap(), list), | |
| 1936 | + format!("node-{list}") | |
| 1937 | + ); | |
| 1882 | 1938 | t.set(list, "scroll-key", Prop::Str("messages-#freeq".into())); |
| 1883 | 1939 | assert_eq!(scroll_name(t.get(list).unwrap(), list), "messages-#freeq"); |
| 1884 | 1940 | } |
| @@ -1943,7 +1999,12 @@ mod tests { | ||
| 1943 | 1999 | } |
| 1944 | 2000 | |
| 1945 | 2001 | fn memo() -> ScrollMemo { |
| 1946 | - ScrollMemo { at_end: true, told: Some(true), offset_y: 0.0, height: 600.0 } | |
| 2002 | + ScrollMemo { | |
| 2003 | + at_end: true, | |
| 2004 | + told: Some(true), | |
| 2005 | + offset_y: 0.0, | |
| 2006 | + height: 600.0, | |
| 2007 | + } | |
| 1947 | 2008 | } |
| 1948 | 2009 | |
| 1949 | 2010 | #[test] |
| @@ -36,9 +36,13 @@ use cosmic::iced::alignment::Horizontal; | |||
| 36 | use cosmic::iced::futures::channel::mpsc; | 36 | use cosmic::iced::futures::channel::mpsc; |
| 37 | use cosmic::iced::futures::{Stream, StreamExt}; | 37 | use cosmic::iced::futures::{Stream, StreamExt}; |
| 38 | use cosmic::iced::widget::container::Style as ContainerStyle; | 38 | use cosmic::iced::widget::container::Style as ContainerStyle; |
| 39 | -use cosmic::iced::widget::scrollable::{self as iced_scrollable, AbsoluteOffset, RelativeOffset, Viewport}; | 39 | +use cosmic::iced::widget::scrollable::{ |
| 40 | + self as iced_scrollable, AbsoluteOffset, RelativeOffset, Viewport, | ||
| 41 | +}; | ||
| 40 | use cosmic::iced::widget::text::Wrapping; | 42 | use cosmic::iced::widget::text::Wrapping; |
| 41 | -use cosmic::iced::{Alignment, Background, Border, Color, ContentFit, Font, Length, Padding, Subscription}; | 43 | +use cosmic::iced::{ |
| 44 | + Alignment, Background, Border, Color, ContentFit, Font, Length, Padding, Subscription, | ||
| 45 | +}; | ||
| 42 | use cosmic::widget::{self, Column, Row}; | 46 | use cosmic::widget::{self, Column, Row}; |
| 43 | use cosmic::{ApplicationExt, Element}; | 47 | use cosmic::{ApplicationExt, Element}; |
| 44 | use jolt_abi::{borrowed, empty_str, guard, Scratch}; | 48 | use jolt_abi::{borrowed, empty_str, guard, Scratch}; |
| @@ -404,7 +408,11 @@ fn report(memo: &mut ScrollMemo, at_end: bool) -> Option<&'static str> { | |||
| 404 | memo.told = Some(at_end); | 408 | memo.told = Some(at_end); |
| 405 | // "end" or "away", the strings libvidya emits: frq's handler compares | 409 | // "end" or "away", the strings libvidya emits: frq's handler compares |
| 406 | // against "end". | 410 | // against "end". |
| 407 | - if at_end { "end" } else { "away" } | 411 | + if at_end { |
| 412 | + "end" | ||
| 413 | + } else { | ||
| 414 | + "away" | ||
| 415 | + } | ||
| 408 | }) | 416 | }) |
| 409 | } | 417 | } |
| 410 | 418 | ||
| @@ -531,7 +539,13 @@ fn reveal(name: String, row: i32, viewport: f32) -> Task<Message> { | |||
| 531 | "jolt-scroll: {name} row {row} at {top} (h {height}), viewport {viewport} -> {y}" | 539 | "jolt-scroll: {name} row {row} at {top} (h {height}), viewport {viewport} -> {y}" |
| 532 | ); | 540 | ); |
| 533 | } | 541 | } |
| 534 | - iced_scrollable::scroll_to(scroll_id(&name), AbsoluteOffset { x: None, y: Some(y) }) | 542 | + iced_scrollable::scroll_to( |
| 543 | + scroll_id(&name), | ||
| 544 | + AbsoluteOffset { | ||
| 545 | + x: None, | ||
| 546 | + y: Some(y), | ||
| 547 | + }, | ||
| 548 | + ) | ||
| 535 | } | 549 | } |
| 536 | None => { | 550 | None => { |
| 537 | if scroll_log() { | 551 | if scroll_log() { |
| @@ -565,7 +579,13 @@ fn scroll_shape(t: &Tree, name: &str) -> (usize, usize) { | |||
| 565 | } | 579 | } |
| 566 | 580 | ||
| 567 | fn snap_to_end(name: &str) -> Task<Message> { | 581 | fn snap_to_end(name: &str) -> Task<Message> { |
| 568 | - iced_scrollable::snap_to(scroll_id(name), RelativeOffset { x: None, y: Some(1.0) }) | 582 | + iced_scrollable::snap_to( |
| 583 | + scroll_id(name), | ||
| 584 | + RelativeOffset { | ||
| 585 | + x: None, | ||
| 586 | + y: Some(1.0), | ||
| 587 | + }, | ||
| 588 | + ) | ||
| 569 | } | 589 | } |
| 570 | 590 | ||
| 571 | // --- the app ----------------------------------------------------------------- | 591 | // --- the app ----------------------------------------------------------------- |
| @@ -610,9 +630,15 @@ enum Message { | |||
| 610 | /// caret, and the next key would land on that. An entry is let go once a | 630 | /// caret, and the next key would land on that. An entry is let go once a |
| 611 | /// commit was rendered after its event: from then on the component's own | 631 | /// commit was rendered after its event: from then on the component's own |
| 612 | /// state is the answer, a draft it cleared included. | 632 | /// state is the answer, a draft it cleared included. |
| 613 | -fn keep_typed(tree: &mut Arc<Tree>, typed: &mut HashMap<(i32, &'static str), (u64, Prop)>, settled: u64) { | 633 | +fn keep_typed( |
| 634 | + tree: &mut Arc<Tree>, | ||
| 635 | + typed: &mut HashMap<(i32, &'static str), (u64, Prop)>, | ||
| 636 | + settled: u64, | ||
| 637 | +) { | ||
| 614 | typed.retain(|&(node, key), (seq, value)| { | 638 | typed.retain(|&(node, key), (seq, value)| { |
| 615 | - let Some(n) = tree.get(node) else { return false }; | 639 | + let Some(n) = tree.get(node) else { |
| 640 | + return false; | ||
| 641 | + }; | ||
| 616 | if *seq <= settled { | 642 | if *seq <= settled { |
| 617 | return false; | 643 | return false; |
| 618 | } | 644 | } |
| @@ -629,7 +655,15 @@ impl App { | |||
| 629 | /// working control, and its next render is what settles it. Then the event | 655 | /// working control, and its next render is what settles it. Then the event |
| 630 | /// goes to the worker, and what was written is held over any commit | 656 | /// goes to the worker, and what was written is held over any commit |
| 631 | /// rendered before the worker saw it. | 657 | /// rendered before the worker saw it. |
| 632 | - fn write_back(&mut self, node: i32, key: &'static str, value: Prop, event: &'static str, text: String, num: f64) { | 658 | + fn write_back( |
| 659 | + &mut self, | ||
| 660 | + node: i32, | ||
| 661 | + key: &'static str, | ||
| 662 | + value: Prop, | ||
| 663 | + event: &'static str, | ||
| 664 | + text: String, | ||
| 665 | + num: f64, | ||
| 666 | + ) { | ||
| 633 | edit(|t| t.set(node, key, value.clone())); | 667 | edit(|t| t.set(node, key, value.clone())); |
| 634 | Arc::make_mut(&mut self.tree).set(node, key, value.clone()); | 668 | Arc::make_mut(&mut self.tree).set(node, key, value.clone()); |
| 635 | let seq = post_seq(node, event, text, num); | 669 | let seq = post_seq(node, event, text, num); |
| @@ -652,15 +686,12 @@ impl App { | |||
| 652 | let mut live = HashSet::new(); | 686 | let mut live = HashSet::new(); |
| 653 | for ask in scroll_asks(&before, &self.tree) { | 687 | for ask in scroll_asks(&before, &self.tree) { |
| 654 | live.insert(ask.name.clone()); | 688 | live.insert(ask.name.clone()); |
| 655 | - let memo = self | 689 | + let memo = self.scrolls.entry(ask.name.clone()).or_insert(ScrollMemo { |
| 656 | - .scrolls | 690 | + at_end: ask.stick, |
| 657 | - .entry(ask.name.clone()) | 691 | + told: None, |
| 658 | - .or_insert(ScrollMemo { | 692 | + offset_y: 0.0, |
| 659 | - at_end: ask.stick, | 693 | + height: 0.0, |
| 660 | - told: None, | 694 | + }); |
| 661 | - offset_y: 0.0, | ||
| 662 | - height: 0.0, | ||
| 663 | - }); | ||
| 664 | // A row asking to be shown is measured on the frame it appears, | 695 | // A row asking to be shown is measured on the frame it appears, |
| 665 | // so the ask stands until the layout has a place for it — see | 696 | // so the ask stands until the layout has a place for it — see |
| 666 | // `reveal`, which asks again rather than giving up. | 697 | // `reveal`, which asks again rather than giving up. |
| @@ -670,7 +701,10 @@ impl App { | |||
| 670 | ScrollMove::End => tasks.push(snap_to_end(&ask.name)), | 701 | ScrollMove::End => tasks.push(snap_to_end(&ask.name)), |
| 671 | ScrollMove::Restore(y) => tasks.push(iced_scrollable::scroll_to( | 702 | ScrollMove::Restore(y) => tasks.push(iced_scrollable::scroll_to( |
| 672 | scroll_id(&ask.name), | 703 | scroll_id(&ask.name), |
| 673 | - AbsoluteOffset { x: None, y: Some(y) }, | 704 | + AbsoluteOffset { |
| 705 | + x: None, | ||
| 706 | + y: Some(y), | ||
| 707 | + }, | ||
| 674 | )), | 708 | )), |
| 675 | ScrollMove::Stay => {} | 709 | ScrollMove::Stay => {} |
| 676 | } | 710 | } |
| @@ -764,7 +798,14 @@ impl cosmic::Application for App { | |||
| 764 | Message::Click(node) => post(node, "click", String::new(), 0.0), | 798 | Message::Click(node) => post(node, "click", String::new(), 0.0), |
| 765 | Message::Toggled(node, on) => { | 799 | Message::Toggled(node, on) => { |
| 766 | let num = f64::from(u8::from(on)); | 800 | let num = f64::from(u8::from(on)); |
| 767 | - self.write_back(node, "active", Prop::Bool(on), "toggled", String::new(), num); | 801 | + self.write_back( |
| 802 | + node, | ||
| 803 | + "active", | ||
| 804 | + Prop::Bool(on), | ||
| 805 | + "toggled", | ||
| 806 | + String::new(), | ||
| 807 | + num, | ||
| 808 | + ); | ||
| 768 | } | 809 | } |
| 769 | Message::Change(node, text) => { | 810 | Message::Change(node, text) => { |
| 770 | self.write_back(node, "text", Prop::Str(text.clone()), "change", text, 0.0); | 811 | self.write_back(node, "text", Prop::Str(text.clone()), "change", text, 0.0); |
| @@ -776,8 +817,9 @@ impl cosmic::Application for App { | |||
| 776 | // worker, which collects it with `cosmic_clipboard_image_png`. | 817 | // worker, which collects it with `cosmic_clipboard_image_png`. |
| 777 | Message::Paste(node, text) => { | 818 | Message::Paste(node, text) => { |
| 778 | if self.tree.get(node).is_some_and(|n| n.str("text") == text) { | 819 | if self.tree.get(node).is_some_and(|n| n.str("text") == text) { |
| 779 | - return cosmic::iced::clipboard::read_data::<ClipboardPng>() | 820 | + return cosmic::iced::clipboard::read_data::<ClipboardPng>().map(move |png| { |
| 780 | - .map(move |png| cosmic::Action::App(Message::PastedPicture(node, png.map(|p| p.0)))); | 821 | + cosmic::Action::App(Message::PastedPicture(node, png.map(|p| p.0))) |
| 822 | + }); | ||
| 781 | } | 823 | } |
| 782 | self.write_back(node, "text", Prop::Str(text.clone()), "change", text, 0.0); | 824 | self.write_back(node, "text", Prop::Str(text.clone()), "change", text, 0.0); |
| 783 | } | 825 | } |
| @@ -810,15 +852,18 @@ impl cosmic::Application for App { | |||
| 810 | None => snap_to_end(&name), | 852 | None => snap_to_end(&name), |
| 811 | Some(y) => iced_scrollable::scroll_to( | 853 | Some(y) => iced_scrollable::scroll_to( |
| 812 | scroll_id(&name), | 854 | scroll_id(&name), |
| 813 | - AbsoluteOffset { x: None, y: Some(y) }, | 855 | + AbsoluteOffset { |
| 856 | + x: None, | ||
| 857 | + y: Some(y), | ||
| 858 | + }, | ||
| 814 | ), | 859 | ), |
| 815 | }; | 860 | }; |
| 816 | return Task::batch([now, again]); | 861 | return Task::batch([now, again]); |
| 817 | } | 862 | } |
| 818 | Message::Reveal(name, tries) => { | 863 | Message::Reveal(name, tries) => { |
| 819 | let viewport = self.scrolls.get(&name).map_or(0.0, |memo| memo.height); | 864 | let viewport = self.scrolls.get(&name).map_or(0.0, |memo| memo.height); |
| 820 | - let place = asking_row(&self.tree, &name) | 865 | + let place = |
| 821 | - .and_then(|row| placements(&name).get(row)); | 866 | + asking_row(&self.tree, &name).and_then(|row| placements(&name).get(row)); |
| 822 | if let Some((top, height)) = place { | 867 | if let Some((top, height)) = place { |
| 823 | // Nothing written down here either, for the reason the | 868 | // Nothing written down here either, for the reason the |
| 824 | // commit path gives: where this ends up is `scrolled`'s to | 869 | // commit path gives: where this ends up is `scrolled`'s to |
| @@ -826,7 +871,10 @@ impl cosmic::Application for App { | |||
| 826 | let y = centred_offset(top, height, viewport); | 871 | let y = centred_offset(top, height, viewport); |
| 827 | return iced_scrollable::scroll_to( | 872 | return iced_scrollable::scroll_to( |
| 828 | scroll_id(&name), | 873 | scroll_id(&name), |
| 829 | - AbsoluteOffset { x: None, y: Some(y) }, | 874 | + AbsoluteOffset { |
| 875 | + x: None, | ||
| 876 | + y: Some(y), | ||
| 877 | + }, | ||
| 830 | ); | 878 | ); |
| 831 | } | 879 | } |
| 832 | if scroll_log() { | 880 | if scroll_log() { |
| @@ -989,7 +1037,9 @@ fn margins(n: &Node) -> Padding { | |||
| 989 | /// `:width-request 0` on its message column whenever the people panel is shut, | 1037 | /// `:width-request 0` on its message column whenever the people panel is shut, |
| 990 | /// and taken literally that is a backlog laid out zero points wide. | 1038 | /// and taken literally that is a backlog laid out zero points wide. |
| 991 | fn width_request(n: &Node) -> Option<f32> { | 1039 | fn width_request(n: &Node) -> Option<f32> { |
| 992 | - n.num("width-request").filter(|w| *w > 0.0).map(|w| w as f32) | 1040 | + n.num("width-request") |
| 1041 | + .filter(|w| *w > 0.0) | ||
| 1042 | + .map(|w| w as f32) | ||
| 993 | } | 1043 | } |
| 994 | 1044 | ||
| 995 | /// `align`, or `default` where it is not set. A column starts its children at | 1045 | /// `align`, or `default` where it is not set. A column starts its children at |
| @@ -1230,7 +1280,8 @@ fn element(t: &Tree, id: i32, enabled: bool, in_row: bool) -> Element<'_, Messag | |||
| 1230 | } else { | 1280 | } else { |
| 1231 | Color::from_rgb(0.55, 0.55, 0.55) | 1281 | Color::from_rgb(0.55, 0.55, 0.55) |
| 1232 | }; | 1282 | }; |
| 1233 | - let dot = widget::container(widget::Space::new().width(8).height(8)).class(filled(colour, 4.0)); | 1283 | + let dot = widget::container(widget::Space::new().width(8).height(8)) |
| 1284 | + .class(filled(colour, 4.0)); | ||
| 1234 | Row::new() | 1285 | Row::new() |
| 1235 | .spacing(6) | 1286 | .spacing(6) |
| 1236 | .align_y(Alignment::Center) | 1287 | .align_y(Alignment::Center) |
| @@ -1624,7 +1675,9 @@ pub unsafe extern "C" fn cosmic_picked_image(path: *const c_char) -> c_int { | |||
| 1624 | } | 1675 | } |
| 1625 | } | 1676 | } |
| 1626 | }; | 1677 | }; |
| 1627 | - match image::open(&chosen).and_then(|picture| picture.save_with_format(&path, image::ImageFormat::Png)) { | 1678 | + match image::open(&chosen) |
| 1679 | + .and_then(|picture| picture.save_with_format(&path, image::ImageFormat::Png)) | ||
| 1680 | + { | ||
| 1628 | Ok(()) => 1, | 1681 | Ok(()) => 1, |
| 1629 | Err(err) => { | 1682 | Err(err) => { |
| 1630 | eprintln!("jolt-cosmic: could not take {}: {err}", chosen.display()); | 1683 | eprintln!("jolt-cosmic: could not take {}: {err}", chosen.display()); |
| @@ -1878,7 +1931,10 @@ mod tests { | |||
| 1878 | let mut t = Tree::default(); | 1931 | let mut t = Tree::default(); |
| 1879 | let root = t.root(); | 1932 | let root = t.root(); |
| 1880 | let list = node(&mut t, root, "scroll"); | 1933 | let list = node(&mut t, root, "scroll"); |
| 1881 | - assert_eq!(scroll_name(t.get(list).unwrap(), list), format!("node-{list}")); | 1934 | + assert_eq!( |
| 1935 | + scroll_name(t.get(list).unwrap(), list), | ||
| 1936 | + format!("node-{list}") | ||
| 1937 | + ); | ||
| 1882 | t.set(list, "scroll-key", Prop::Str("messages-#freeq".into())); | 1938 | t.set(list, "scroll-key", Prop::Str("messages-#freeq".into())); |
| 1883 | assert_eq!(scroll_name(t.get(list).unwrap(), list), "messages-#freeq"); | 1939 | assert_eq!(scroll_name(t.get(list).unwrap(), list), "messages-#freeq"); |
| 1884 | } | 1940 | } |
| @@ -1943,7 +1999,12 @@ mod tests { | |||
| 1943 | } | 1999 | } |
| 1944 | 2000 | ||
| 1945 | fn memo() -> ScrollMemo { | 2001 | fn memo() -> ScrollMemo { |
| 1946 | - ScrollMemo { at_end: true, told: Some(true), offset_y: 0.0, height: 600.0 } | 2002 | + ScrollMemo { |
| 2003 | + at_end: true, | ||
| 2004 | + told: Some(true), | ||
| 2005 | + offset_y: 0.0, | ||
| 2006 | + height: 600.0, | ||
| 2007 | + } | ||
| 1947 | } | 2008 | } |
| 1948 | 2009 | ||
| 1949 | #[test] | 2010 | #[test] |
modified
crates/jolt-cosmic/src/rows.rs +3 -3 | @@ -22,12 +22,12 @@ | ||
| 22 | 22 | use std::collections::HashMap; |
| 23 | 23 | use std::sync::{Arc, Mutex}; |
| 24 | 24 | |
| 25 | -use cosmic::iced::advanced::widget::{Operation, Tree, tree}; | |
| 26 | -use cosmic::iced::advanced::{Clipboard, Layout, Shell, Widget, layout, mouse, overlay, renderer}; | |
| 25 | +use cosmic::iced::advanced::widget::{tree, Operation, Tree}; | |
| 26 | +use cosmic::iced::advanced::{layout, mouse, overlay, renderer, Clipboard, Layout, Shell, Widget}; | |
| 27 | 27 | // `cosmic::Element`, not iced's: the two differ in their theme, and this |
| 28 | 28 | // widget lives in a cosmic tree. |
| 29 | -use cosmic::Element; | |
| 30 | 29 | use cosmic::iced::{Event, Length, Rectangle, Size, Vector}; |
| 30 | +use cosmic::Element; | |
| 31 | 31 | |
| 32 | 32 | /// Where each row of one scroll area was last laid out, in points from the top |
| 33 | 33 | /// of the content, beside how tall it is. |
| @@ -22,12 +22,12 @@ | |||
| 22 | use std::collections::HashMap; | 22 | use std::collections::HashMap; |
| 23 | use std::sync::{Arc, Mutex}; | 23 | use std::sync::{Arc, Mutex}; |
| 24 | 24 | ||
| 25 | -use cosmic::iced::advanced::widget::{Operation, Tree, tree}; | 25 | +use cosmic::iced::advanced::widget::{tree, Operation, Tree}; |
| 26 | -use cosmic::iced::advanced::{Clipboard, Layout, Shell, Widget, layout, mouse, overlay, renderer}; | 26 | +use cosmic::iced::advanced::{layout, mouse, overlay, renderer, Clipboard, Layout, Shell, Widget}; |
| 27 | // `cosmic::Element`, not iced's: the two differ in their theme, and this | 27 | // `cosmic::Element`, not iced's: the two differ in their theme, and this |
| 28 | // widget lives in a cosmic tree. | 28 | // widget lives in a cosmic tree. |
| 29 | -use cosmic::Element; | ||
| 30 | use cosmic::iced::{Event, Length, Rectangle, Size, Vector}; | 29 | use cosmic::iced::{Event, Length, Rectangle, Size, Vector}; |
| 30 | +use cosmic::Element; | ||
| 31 | 31 | ||
| 32 | /// Where each row of one scroll area was last laid out, in points from the top | 32 | /// Where each row of one scroll area was last laid out, in points from the top |
| 33 | /// of the content, beside how tall it is. | 33 | /// of the content, beside how tall it is. |