refactor stuff into lib
[?]
May 17, 2025, 4:22 PM
XSZZB47UXR6KGYFZZQFQR63X2LDKOH6TPNNBRRGHUCI5JJ4JIWVACDependencies
- [2]
6YZAVBWUInitial commit - [3]
WT3GA27Padd cursor with selection - [4]
CALXOZXAflatten crates dir - [5]
BFN2VHZSrefactor file stuff into sub-mod - [6]
23SFYK4Qbig view refactor into a new crate - [7]
OPXFZKEBview tests setup - [8]
3QVNMRNMtest non-empty repo app view - [9]
MYGIBRRHwip custom theme - [10]
PKJCFSBMtheme improvements - [11]
NWJD6VM6mv libflowers libflorescence - [12]
AMPZ2BXKshow changed files diffs (only Edit atm) - [13]
ZVI4AWERwoot contents_diff - [14]
4ELJZGRJload and store all change diffs at once - [15]
QMAUTRB6refactor diff - [16]
OQ6HSAWHshow record log - [17]
L6KSEFQImove cursor related stuff into its module - [18]
HOJZI52Yrename flowers_ui to inflorescence
Change contents
- edit in libflorescence/src/lib.rs at line 1
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 linechange_contents: String,/// Added linesreplacement_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 linechange_contents: UndecodableContents,/// Added linesreplacement_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/// numberChanged {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
// TODO rm once theme finished#![allow(unused_variables, dead_code)] - edit in inflorescence_view/src/theme.rs at line 6
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,border, color, window, Background, Border, Color, Gradient, Radians, - replacement in inflorescence_view/src/testing.rs at line 6
use std::{env, path::PathBuf, str::FromStr};use std::env;use std::path::PathBuf;use std::str::FromStr; - replacement in inflorescence_view/src/testing.rs at line 19
/// (default): Compare new screenshot against the stored ones. The tests with any difference will fail/// (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
/// Preview the new screenshots in single resolution without comparing against the stored ones./// Preview the new screenshots in single resolution without comparing/// against the stored ones. - edit in inflorescence_view/src/diff.rs at line 1
pub use libflorescence::diff::{Combined, DecodedFile, DiffWithContents, DiffWithoutContents, File, Lines,Section, State, UndecodableContents, UndecodableFile,}; - replacement in inflorescence_view/src/diff.rs at line 9
use iced::{alignment, Background, Color, Element, Font, Length};use iced::{alignment, Element, Font, Length}; - edit in inflorescence_view/src/diff.rs at line 12
// TODO: maybe use themeconst 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
/// [`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 linechange_contents: String,/// Added linesreplacement_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 linechange_contents: UndecodableContents,/// Added linesreplacement_contents: UndecodableContents,},} - edit in inflorescence_view/src/diff.rs at line 16
#[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/// numberChanged {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
LineKind::Deleted => line, // TODO replace with class// .style(|_theme| {// container::background(Background::from(DELETED_BG_COLOR))// })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
use libflorescence::repo;use libflorescence::{cursor, file, repo}; - replacement in inflorescence_view/src/app.rs at line 10
use iced::widget::text_editor;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
}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
use libflorescence::{prelude::pijul::{self, HashMap},repo,};use libflorescence::prelude::pijul::{self, HashMap};use libflorescence::repo; - replacement in inflorescence_view/src/app/test.rs at line 9
use std::{collections::{BTreeMap, BTreeSet},path::PathBuf,};use std::collections::{BTreeMap, BTreeSet};use std::path::PathBuf; - edit in inflorescence_view/bin/view_test_setup.rs at line 7
use std::fs; - replacement in inflorescence_view/bin/view_test_setup.rs at line 9
use std::path::Path;use std::{fs, path::PathBuf};use std::path::{Path, PathBuf}; - replacement in inflorescence_view/bin/view_test_setup.rs at line 16
// Copy stored screenshots into the preview dir to use for comparison// Copy stored screenshots into the preview dir to use for// comparison - replacement in inflorescence/src/file.rs at line 3
pub use inflorescence_view::app::file::{Diff, Id, Kind};pub use libflorescence::file::{Diff, Id, Kind}; - replacement in inflorescence/src/cursor.rs at line 1
pub use inflorescence_view::app::cursor::{pub use libflorescence::cursor::{