1- pub mod styles;
1+ mod marks;
2+ mod styles;
23
34#[ cfg( feature ="ansi_term" ) ]
45use crate :: renderers:: ascii_default:: styles:: color:: Style ;
@@ -15,8 +16,10 @@ use crate::display_list::line::DisplayMarkType;
1516use crate :: display_list:: line:: DisplayRawLine ;
1617use crate :: display_list:: line:: DisplaySourceLine ;
1718use crate :: DisplayList ;
19+ use marks:: MarkKind ;
1820use std:: cmp;
1921use std:: io:: Write ;
22+ use std:: iter:: repeat;
2023use std:: marker:: PhantomData ;
2124use styles:: Style as StyleTrait ;
2225use styles:: StyleType ;
@@ -81,16 +84,17 @@ impl<S: StyleTrait> Renderer<S> {
8184 line,
8285} =>{
8386let style =& [ StyleType :: LineNo , StyleType :: Emphasis ] ;
87+ let vertical_mark =MarkKind :: get ( MarkKind :: Vertical ) ;
8488if let Some ( lineno) = lineno{
8589S :: fmt (
8690 w,
87- format_args ! ( "{:>width$}| " , lineno, width = lineno_max) ,
91+ format_args ! ( "{:>width$}{} " , lineno, vertical_mark , width = lineno_max) ,
8892 style,
8993) ?;
9094} else {
9195S :: fmt (
9296 w,
93- format_args ! ( "{:>width$}| " , "" , width = lineno_max) ,
97+ format_args ! ( "{:>width$}{} " , "" , vertical_mark , width = lineno_max) ,
9498 style,
9599) ?;
96100}
@@ -123,13 +127,14 @@ impl<S: StyleTrait> Renderer<S> {
123127let indent =if range. start ==0 { 0 } else { range. start +1 } ;
124128write ! ( w, "{:>width$}" , "" , width = indent) ?;
125129if range. start ==0 {
130+ let horizontal_mark =MarkKind :: get ( MarkKind :: Horizontal ) ;
126131S :: fmt (
127132 w,
128133format_args ! (
129- "{:_>width$} {}" ,
130- "^" ,
134+ "{}{} {}" ,
135+ repeat( horizontal_mark) . take( 5 ) . collect:: <String >( ) ,
136+ MarkKind :: get( MarkKind :: UpLeft ) ,
131137 annotation. label,
132- width = range. len( ) +1
133138) ,
134139& styles,
135140)
@@ -154,7 +159,15 @@ impl<S: StyleTrait> Renderer<S> {
154159match line{
155160DisplayRawLine :: Origin { path, pos} =>{
156161write ! ( w, "{:>width$}" , "" , width = lineno_max) ?;
157- S :: fmt ( w, "-->" , & [ StyleType :: Emphasis , StyleType :: LineNo ] ) ?;
162+ S :: fmt (
163+ w,
164+ format_args ! (
165+ "{}{}>" ,
166+ MarkKind :: get( MarkKind :: Horizontal ) ,
167+ MarkKind :: get( MarkKind :: Horizontal ) ,
168+ ) ,
169+ & [ StyleType :: Emphasis , StyleType :: LineNo ] ,
170+ ) ?;
158171write ! ( w, " {}" , path) ?;
159172if let Some ( line) = pos. 0 {
160173write ! ( w, ":{}" , line) ?;
@@ -198,10 +211,11 @@ impl<S: StyleTrait> Renderer<S> {
198211) -> std:: io:: Result < ( ) > {
199212let ( _, style) =self . get_annotation_type_style ( & display_mark. annotation_type ) ;
200213let ch =match display_mark. mark_type {
201- DisplayMarkType :: AnnotationStart =>'/' ,
202- DisplayMarkType :: AnnotationThrough =>'|' ,
214+ DisplayMarkType :: AnnotationStart =>MarkKind :: get ( MarkKind :: DownRight ) ,
215+ DisplayMarkType :: AnnotationEnd =>MarkKind :: get ( MarkKind :: UpRight ) ,
216+ DisplayMarkType :: AnnotationThrough =>MarkKind :: get ( MarkKind :: Vertical ) ,
203217} ;
204- S :: fmt ( w, ch, & [ style] )
218+ S :: fmt ( w, ch, & [ StyleType :: Emphasis , style] )
205219}
206220}
207221