@@ -8,34 +8,55 @@ pub use walker::GraphWalker;
88/// The maximum number of colors to use for graph lanes
99pub const MAX_LANE_COLORS : usize = 16 ;
1010
11- /// The type of connection between nodes in the graph
11+ // Yes, there are repositories where this is exceeded
12+ // Are they very rare? Yes.
13+ // On most terminals can more than 256 lanes even be represneted usefully? Not really.
14+ pub type LaneIdx = u8 ;
15+
16+ /// Convert a lane position into the compact [`LaneIdx`]
17+ /// representation. This way we can keep full granularity when computing,
18+ /// but not when storing.
19+ pub ( crate ) fn to_lane_idx ( lane : usize ) -> LaneIdx {
20+ LaneIdx :: try_from ( lane) . unwrap_or ( LaneIdx :: MAX )
21+ }
22+
23+ /// The type of connection between nodes in the graph.
1224#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
1325pub enum ConnectionType {
1426 Vertical ,
1527 VerticalDotted ,
16- Cross ,
1728 CommitNormal ,
1829 CommitBranch ,
1930 CommitMerge ,
2031 CommitStash ,
2132 CommitUncommitted ,
33+ /// a bridge turning down into a lane that starts here
2234 MergeBridgeStart ,
35+ /// a bridge passing over an empty lane slot
2336 MergeBridgeMid ,
37+ /// a bridge turning down, lane starting to its right
2438 MergeBridgeEnd ,
25- BranchDown ,
39+ /// a lane from above turning left into a commit
2640 BranchUp ,
41+ /// a lane from above turning right into a commit
2742 BranchUpRight ,
28- BranchUpMergeStart ,
29- BranchUpRightMergeEnd ,
43+ /// a continuing lane absorbing a bridge from its left
44+ TeeLeft ,
45+ /// a continuing lane absorbing a bridge from its right
46+ TeeRight ,
47+ /// a lane ending from above while a bridge passes through
48+ TeeUp ,
49+ /// a lane starting downward while a bridge passes through
50+ TeeDown ,
3051}
3152
3253#[ derive( Clone , Debug , Default ) ]
3354pub struct GraphRow {
3455 /// Number of active lanes at this commit row
35- pub lane_count : usize ,
56+ pub lane_count : LaneIdx ,
3657
3758 /// Which lane index this commit sits on
38- pub commit_lane : usize ,
59+ pub commit_lane : LaneIdx ,
3960
4061 /// Whether this is a merge commit (two parents)
4162 pub is_merge : bool ,
@@ -49,13 +70,13 @@ pub struct GraphRow {
4970 /// Connections emitted per lane:
5071 /// None = empty space
5172 /// Some((ConnectionType, `color_index`)) = draw this connector in this color
52- pub lanes : Vec < Option < ( ConnectionType , usize ) > > ,
73+ pub lanes : Vec < Option < ( ConnectionType , LaneIdx ) > > ,
5374
5475 /// Horizontal merge bridge: if this commit merges rightward,
5576 /// (`from_lane`, `to_lane`) — the span to draw ─ ╭ ╮ across
56- pub merge_bridge : Option < ( usize , usize ) > ,
77+ pub merge_bridge : Option < ( LaneIdx , LaneIdx ) > ,
5778
5879 /// Horizontal branch bridges: if this commit spawns branches,
5980 /// spans to draw ─ ╭ ╮ across
60- pub branches : Vec < ( usize , usize ) > ,
81+ pub branches : Vec < ( LaneIdx , LaneIdx ) > ,
6182}
0 commit comments