XSZZB47UXR6KGYFZZQFQR63X2LDKOH6TPNNBRRGHUCI5JJ4JIWVAC 6YZAVBWU6E5FYOI5JGEIPXGZLIKAW6LS2AOFIQWEE5DMOPPCD5PQC WT3GA27PQ2AOAIGK65O3Q4DMX4AZDVNULBLRL6GF4QW6QCASUEAAC CALXOZXANFZ64NBZBTR2KYTZ6ZLLCJXNFAEALBB2EYAVDVJJ6X6AC BFN2VHZS7VCBUHQ4S3CQ3LFQV2V4M6VANNAF32XMRFQVWRGYSZ6AC 23SFYK4Q5NKBPJG53PQNPWQH6UOUU2YKJEL7RLXYBRLJOJYV7AWQC OPXFZKEBDHZZLXEJ2JRDYBOJH6YIN7UZNZYHVHMWMQVDTE2ZD53QC 3QVNMRNMI63L2VOFVTMPCVPXH3J4JXLXVTIIPNOMACQCPCAPWILQC MYGIBRRHHXPKVRAMQQRJTZH74L2XOK3SF7J57JPCRKSVRLZ2D6NQC PKJCFSBMXXA2H3US47IJEB7QMIYLEKTLGWQUYEZSKCDODDQTD6HQC 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),}
#[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>;
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,},}
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,
// 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>,}
/// [`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,},}
#[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>;
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))* }) */
}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,},}