refactor stuff into lib

[?]
May 17, 2025, 4:22 PM
XSZZB47UXR6KGYFZZQFQR63X2LDKOH6TPNNBRRGHUCI5JJ4JIWVAC

Dependencies

Change contents

  • edit in libflorescence/src/lib.rs at line 1
    [2.1776]
    [2.1777]
    pub mod cursor;
    pub mod diff;
    pub mod file;
  • file addition: file.rs (----------)
    [4.31]
    use crate::diff;
    #[derive(Debug, Clone, Hash, PartialEq, Eq)]
    pub struct Id {
    pub path: String,
    pub file_kind: Kind,
    }
    #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
    pub enum Kind {
    Untracked,
    Changed,
    }
    #[derive(Debug)]
    pub enum Diff {
    Loading,
    Loaded(diff::File),
    }
  • file addition: diff.rs (----------)
    [4.31]
    #[derive(Debug, Default)]
    pub struct State {
    pub selected_sections: Vec<usize>,
    pub expanded_unchanged_sections: Vec<usize>,
    pub collapsed_changed_sections: Vec<usize>,
    }
    /// [`File`] is not part of [`State`] so it can be stored separately (i.e. in a
    /// cache, where it's immutable once set, unlike [`State`] which can change via
    /// user action)
    #[derive(Debug)]
    pub enum File {
    Decoded(DecodedFile),
    Undecodable(UndecodableFile),
    }
    #[derive(Debug)]
    pub struct DecodedFile {
    pub combined: Combined,
    pub diffs_without_contents: Vec<DiffWithoutContents>,
    }
    #[derive(Debug)]
    pub struct UndecodableFile {
    pub diffs_with_contents: Vec<DiffWithContents>,
    pub diffs_without_contents: Vec<DiffWithoutContents>,
    }
    /// A file combined with its diffs into sections
    #[derive(Debug)]
    pub struct Combined {
    pub sections: Vec<Section>,
    pub max_line_num: usize,
    }
    #[derive(Debug)]
    pub enum DiffWithContents {
    Add,
    Edit {
    line: usize,
    deleted: bool,
    contents: String,
    },
    Replacement {
    line: usize,
    /// Deleted line
    change_contents: String,
    /// Added lines
    replacement_contents: String,
    },
    Del,
    Undel,
    }
    #[derive(Debug)]
    pub enum DiffWithoutContents {
    // _________________________________________________________________________
    // Cases that never have contents:
    Move,
    SolveNameConflict,
    UnsolveNameConflict,
    SolveOrderConflict,
    UnsolveOrderConflict,
    ResurrectZombines,
    AddRoot,
    DelRoot,
    // _________________________________________________________________________
    // Cases that normally have contents, but in these cases the contents are
    // not decodable:
    Edit {
    line: usize,
    deleted: bool,
    contents: UndecodableContents,
    },
    Replacement {
    line: usize,
    /// Deleted line
    change_contents: UndecodableContents,
    /// Added lines
    replacement_contents: UndecodableContents,
    },
    }
    #[derive(Debug)]
    pub enum UndecodableContents {
    /// Short byte sequence of unknown encoding encoded with base64 for
    /// display. Must be shorter than [`crate::repo::MAX_LEN_BASE64_DISPLAY`]
    ShortBase64(String),
    UnknownEncoding,
    }
    #[derive(Debug)]
    pub enum Section {
    Unchanged(Lines),
    /// `deleted` and `added` are together because for
    /// `ChangedFileDiffWithContents::Replacement` they begin on the same line
    /// number
    Changed {
    deleted: Lines,
    added: Lines,
    },
    }
    /// INVARIANT: There must be no new-lines in any of the strings, the source
    /// string must be split on those.
    pub type Lines = Vec<String>;
  • file addition: cursor.rs (----------)
    [4.31]
    use crate::diff;
    use crate::prelude::pijul;
    use std::collections::HashMap;
    #[derive(Debug, Clone)]
    pub enum Msg {
    Down,
    Up,
    Right,
    Left,
    Select(Select),
    }
    #[derive(Debug, Default)]
    pub struct State {
    pub selection: Option<Selection>,
    }
    #[derive(Debug)]
    pub enum Selection {
    UntrackedFile {
    ix: usize,
    path: String,
    },
    ChangedFile {
    ix: usize,
    path: String,
    },
    LogChange {
    ix: usize,
    hash: pijul::Hash,
    message: String,
    /// All the diffs in this change keyed by file path. Loaded async
    /// and set to None only while loading. The
    /// `diff::State` is also in here so that is it
    /// preserved while navigating between files.
    diffs: Option<HashMap<String, (diff::File, diff::State)>>,
    file: Option<LogChangeFileSelection>,
    },
    }
    #[derive(Debug)]
    pub struct LogChangeFileSelection {
    pub ix: usize,
    pub path: String,
    }
    #[derive(Debug, Clone)]
    pub enum Select {
    UntrackedFile {
    ix: usize,
    path: String,
    },
    ChangedFile {
    ix: usize,
    path: String,
    },
    LogChange {
    ix: usize,
    hash: pijul::Hash,
    message: String,
    },
    LogChangeFile {
    ix: usize,
    path: String,
    },
    }
  • edit in inflorescence_view/src/theme.rs at line 1
    [9.167]
    [9.168]
    // TODO rm once theme finished
    #![allow(unused_variables, dead_code)]
  • edit in inflorescence_view/src/theme.rs at line 6
    [9.201]
    [9.201]
    use iced::advanced::widget::text;
    use iced::gradient::{ColorStop, Linear};
    use iced::theme::{self, palette};
    use iced::widget::scrollable::{self, Rail};
    use iced::widget::{button, container, text_editor};
  • replacement in inflorescence_view/src/theme.rs at line 12
    [9.213][9.213:260](),[9.260][10.17:52](),[10.52][9.260:391](),[9.260][9.260:391](),[9.391][10.53:111]()
    advanced::widget::text,
    border, color,
    gradient::{ColorStop, Linear},
    theme::{self, palette},
    widget::{
    button, container,
    scrollable::{self, Rail},
    text_editor,
    },
    window, Background, Border, Color, Gradient, Radians,
    [9.213]
    [9.430]
    border, color, window, Background, Border, Color, Gradient, Radians,
  • replacement in inflorescence_view/src/testing.rs at line 6
    [7.663][7.663:708]()
    use std::{env, path::PathBuf, str::FromStr};
    [7.663]
    [7.708]
    use std::env;
    use std::path::PathBuf;
    use std::str::FromStr;
  • replacement in inflorescence_view/src/testing.rs at line 19
    [7.1006][7.1006:1113]()
    /// (default): Compare new screenshot against the stored ones. The tests with any difference will fail
    [7.1006]
    [7.1113]
    /// (default): Compare new screenshot against the stored ones. The tests
    /// with any difference will fail
  • replacement in inflorescence_view/src/testing.rs at line 23
    [7.1141][7.1141:1241]()
    /// Preview the new screenshots in single resolution without comparing against the stored ones.
    [7.1141]
    [7.1241]
    /// Preview the new screenshots in single resolution without comparing
    /// against the stored ones.
  • edit in inflorescence_view/src/diff.rs at line 1
    [6.417]
    [6.418]
    pub use libflorescence::diff::{
    Combined, DecodedFile, DiffWithContents, DiffWithoutContents, File, Lines,
    Section, State, UndecodableContents, UndecodableFile,
    };
  • replacement in inflorescence_view/src/diff.rs at line 9
    [6.483][6.483:548]()
    use iced::{alignment, Background, Color, Element, Font, Length};
    [6.483]
    [6.548]
    use iced::{alignment, Element, Font, Length};
  • edit in inflorescence_view/src/diff.rs at line 12
    [9.6347][6.564:912](),[6.564][6.564:912]()
    // TODO: maybe use theme
    const DELETED_BG_COLOR: Color = Color::from_rgba8(190, 37, 40, 0.15);
    const ADDED_BG_COLOR: Color = Color::from_rgba8(47, 148, 11, 0.15);
    #[derive(Debug, Default)]
    pub struct State {
    pub selected_sections: Vec<usize>,
    pub expanded_unchanged_sections: Vec<usize>,
    pub collapsed_changed_sections: Vec<usize>,
    }
  • edit in inflorescence_view/src/diff.rs at line 15
    [6.953][6.953:2802]()
    /// [`File`] is not part of [`State`] so it can be stored separately (i.e. in a
    /// cache, where it's immutable once set, unlike [`State`] which can change with
    /// [`Action`]s)
    #[derive(Debug)]
    pub enum File {
    Decoded(DecodedFile),
    Undecodable(UndecodableFile),
    }
    #[derive(Debug)]
    pub struct DecodedFile {
    pub combined: Combined,
    pub diffs_without_contents: Vec<DiffWithoutContents>,
    }
    #[derive(Debug)]
    pub struct UndecodableFile {
    pub diffs_with_contents: Vec<DiffWithContents>,
    pub diffs_without_contents: Vec<DiffWithoutContents>,
    }
    /// A file combined with its diffs into sections
    #[derive(Debug)]
    pub struct Combined {
    pub sections: Vec<Section>,
    pub max_line_num: usize,
    }
    #[derive(Debug)]
    pub enum DiffWithContents {
    Add,
    Edit {
    line: usize,
    deleted: bool,
    contents: String,
    },
    Replacement {
    line: usize,
    /// Deleted line
    change_contents: String,
    /// Added lines
    replacement_contents: String,
    },
    Del,
    Undel,
    }
    #[derive(Debug)]
    pub enum DiffWithoutContents {
    // _________________________________________________________________________
    // Cases that never have contents:
    Move,
    SolveNameConflict,
    UnsolveNameConflict,
    SolveOrderConflict,
    UnsolveOrderConflict,
    ResurrectZombines,
    AddRoot,
    DelRoot,
    // _________________________________________________________________________
    // Cases that normally have contents, but in these cases the contents are
    // not decodable:
    Edit {
    line: usize,
    deleted: bool,
    contents: UndecodableContents,
    },
    Replacement {
    line: usize,
    /// Deleted line
    change_contents: UndecodableContents,
    /// Added lines
    replacement_contents: UndecodableContents,
    },
    }
  • edit in inflorescence_view/src/diff.rs at line 16
    [6.2803][6.2803:3469]()
    #[derive(Debug)]
    pub enum UndecodableContents {
    /// Short byte sequence of unknown encoding encoded with base64 for
    /// display. Must be shorter than [`crate::repo::MAX_LEN_BASE64_DISPLAY`]
    ShortBase64(String),
    UnknownEncoding,
    }
    #[derive(Debug)]
    pub enum Section {
    Unchanged(Lines),
    /// `deleted` and `added` are together because for
    /// `ChangedFileDiffWithContents::Replacement` they begin on the same line
    /// number
    Changed {
    deleted: Lines,
    added: Lines,
    },
    }
    /// INVARIANT: There must be no new-lines in any of the strings, the source
    /// string must be split on those.
    pub type Lines = Vec<String>;
  • replacement in inflorescence_view/src/diff.rs at line 304
    [9.7359][9.7359:7622]()
    LineKind::Deleted => line, // TODO replace with class
    // .style(|_theme| {
    // container::background(Background::from(DELETED_BG_COLOR))
    // })
    [9.7359]
    [6.12137]
    LineKind::Deleted => line, /* TODO replace with class
    * .style(|_theme| {
    * container::background(Background::from(DELETED_BG_COLOR))
    * }) */
  • edit in inflorescence_view/src/app.rs at line 7
    [9.7661][6.12452:12453](),[6.12452][6.12452:12453](),[6.12453][10.2618:2688](),[10.2688][9.7662:7726](),[6.12512][9.7662:7726]()
    use iced::widget::{button, column, container, row, scrollable, text};
    use iced::{font, window, Border, Color, Element, Font, Length};
  • replacement in inflorescence_view/src/app.rs at line 8
    [6.12615][6.12615:12641]()
    use libflorescence::repo;
    [6.12615]
    [6.12641]
    use libflorescence::{cursor, file, repo};
  • replacement in inflorescence_view/src/app.rs at line 10
    [6.12642][6.12642:12673]()
    use iced::widget::text_editor;
    [6.12642]
    [6.12673]
    use iced::widget::{
    button, column, container, row, scrollable, text, text_editor,
    };
    use iced::{font, window, Element, Font, Length};
  • edit in inflorescence_view/src/app.rs at line 46
    [6.13379][6.13379:15355]()
    }
    pub mod file {
    use crate::diff;
    #[derive(Debug, Clone, Hash, PartialEq, Eq)]
    pub struct Id {
    pub path: String,
    pub file_kind: Kind,
    }
    #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
    pub enum Kind {
    Untracked,
    Changed,
    }
    #[derive(Debug)]
    pub enum Diff {
    Loading,
    Loaded(diff::File),
    }
    }
    pub mod cursor {
    use crate::diff;
    use libflorescence::prelude::pijul;
    use std::collections::HashMap;
    #[derive(Debug, Clone)]
    pub enum Msg {
    Down,
    Up,
    Right,
    Left,
    Select(Select),
    }
    #[derive(Debug, Default)]
    pub struct State {
    pub selection: Option<Selection>,
    }
    #[derive(Debug)]
    pub enum Selection {
    UntrackedFile {
    ix: usize,
    path: String,
    },
    ChangedFile {
    ix: usize,
    path: String,
    },
    LogChange {
    ix: usize,
    hash: pijul::Hash,
    message: String,
    /// All the diffs in this change keyed by file path. Loaded async
    /// and set to None only while loading. The
    /// `diff::State` is also in here so that is it
    /// preserved while navigating between files.
    diffs: Option<HashMap<String, (diff::File, diff::State)>>,
    file: Option<LogChangeFileSelection>,
    },
    }
    #[derive(Debug)]
    pub struct LogChangeFileSelection {
    pub ix: usize,
    pub path: String,
    }
    #[derive(Debug, Clone)]
    pub enum Select {
    UntrackedFile {
    ix: usize,
    path: String,
    },
    ChangedFile {
    ix: usize,
    path: String,
    },
    LogChange {
    ix: usize,
    hash: pijul::Hash,
    message: String,
    },
    LogChangeFile {
    ix: usize,
    path: String,
    },
    }
  • replacement in inflorescence_view/src/app/test.rs at line 4
    [7.4320][8.23:95]()
    use libflorescence::{
    prelude::pijul::{self, HashMap},
    repo,
    };
    [7.4320]
    [7.4373]
    use libflorescence::prelude::pijul::{self, HashMap};
    use libflorescence::repo;
  • replacement in inflorescence_view/src/app/test.rs at line 9
    [7.4393][7.4393:4465]()
    use std::{
    collections::{BTreeMap, BTreeSet},
    path::PathBuf,
    };
    [7.4393]
    [7.4465]
    use std::collections::{BTreeMap, BTreeSet};
    use std::path::PathBuf;
  • edit in inflorescence_view/bin/view_test_setup.rs at line 7
    [7.6300]
    [7.6300]
    use std::fs;
  • replacement in inflorescence_view/bin/view_test_setup.rs at line 9
    [7.6320][7.6320:6371]()
    use std::path::Path;
    use std::{fs, path::PathBuf};
    [7.6320]
    [7.6371]
    use std::path::{Path, PathBuf};
  • replacement in inflorescence_view/bin/view_test_setup.rs at line 16
    [7.6486][7.6486:6568]()
    // Copy stored screenshots into the preview dir to use for comparison
    [7.6486]
    [7.6568]
    // Copy stored screenshots into the preview dir to use for
    // comparison
  • replacement in inflorescence/src/file.rs at line 3
    [6.29020][6.29020:29077]()
    pub use inflorescence_view::app::file::{Diff, Id, Kind};
    [6.29020]
    [5.1869]
    pub use libflorescence::file::{Diff, Id, Kind};
  • replacement in inflorescence/src/cursor.rs at line 1
    [3.26][6.29204:29247]()
    pub use inflorescence_view::app::cursor::{
    [3.26]
    [6.29247]
    pub use libflorescence::cursor::{