@ -2,7 +2,7 @@ use std::fmt::Write;
use crate ::{
use crate ::{
editor ::GutterType ,
editor ::GutterType ,
graphics ::{ Color, Style, UnderlineStyle } ,
graphics ::{ Style, UnderlineStyle } ,
Document , Editor , Theme , View ,
Document , Editor , Theme , View ,
} ;
} ;
@ -245,9 +245,9 @@ pub fn breakpoints<'doc>(
theme : & Theme ,
theme : & Theme ,
_is_focused : bool ,
_is_focused : bool ,
) -> GutterFn < ' doc > {
) -> GutterFn < ' doc > {
let warning = theme . get ( "warning" ) ;
let error = theme . get ( "error" ) ;
let error = theme . get ( "error" ) ;
let info = theme . get ( "info" ) ;
let info = theme . get ( "info" ) ;
let breakpoint_style = theme . get ( "ui.debug.breakpoint" ) ;
let breakpoints = doc . path ( ) . and_then ( | path | editor . breakpoints . get ( path ) ) ;
let breakpoints = doc . path ( ) . and_then ( | path | editor . breakpoints . get ( path ) ) ;
@ -265,30 +265,52 @@ pub fn breakpoints<'doc>(
. iter ( )
. iter ( )
. find ( | breakpoint | breakpoint . line = = line ) ? ;
. find ( | breakpoint | breakpoint . line = = line ) ? ;
let mut style = if breakpoint . condition . is_some ( ) & & breakpoint . log_message . is_some ( ) {
let style = if breakpoint . condition . is_some ( ) & & breakpoint . log_message . is_some ( ) {
error . underline_style ( UnderlineStyle ::Line )
error . underline_style ( UnderlineStyle ::Line )
} else if breakpoint . condition . is_some ( ) {
} else if breakpoint . condition . is_some ( ) {
error
error
} else if breakpoint . log_message . is_some ( ) {
} else if breakpoint . log_message . is_some ( ) {
info
info
} else {
} else {
warning
breakpoint_style
} ;
} ;
if ! breakpoint . verified {
let sym = if breakpoint . verified { "●" } else { "◯" } ;
// Faded colors
write! ( out , "{}" , sym ) . unwrap ( ) ;
style = if let Some ( Color ::Rgb ( r , g , b ) ) = style . fg {
Some ( style )
style . fg ( Color ::Rgb (
} ,
( ( r as f32 ) * 0.4 ) . floor ( ) as u8 ,
)
( ( g as f32 ) * 0.4 ) . floor ( ) as u8 ,
}
( ( b as f32 ) * 0.4 ) . floor ( ) as u8 ,
) )
fn execution_pause_indicator < ' doc > (
} else {
editor : & ' doc Editor ,
style . fg ( Color ::Gray )
doc : & ' doc Document ,
theme : & Theme ,
is_focused : bool ,
) -> GutterFn < ' doc > {
let style = theme . get ( "ui.debug.active" ) ;
let current_stack_frame = editor . current_stack_frame ( ) ;
let frame_line = current_stack_frame . map ( | frame | frame . line - 1 ) ;
let frame_source_path = current_stack_frame . map ( | frame | {
frame
. source
. as_ref ( )
. and_then ( | source | source . path . as_ref ( ) )
} ) ;
let should_display_for_current_doc =
doc . path ( ) . is_some ( ) & & frame_source_path . unwrap_or ( None ) = = doc . path ( ) ;
Box ::new (
move | line : usize , _selected : bool , first_visual_line : bool , out : & mut String | {
if ! first_visual_line
| | ! is_focused
| | line ! = frame_line ?
| | ! should_display_for_current_doc
{
return None ;
}
}
} ;
let sym = if breakpoint . verified { "▲" } else { "⊚" } ;
let sym = "▶" ;
write! ( out , "{}" , sym ) . unwrap ( ) ;
write! ( out , "{}" , sym ) . unwrap ( ) ;
Some ( style )
Some ( style )
} ,
} ,
@ -304,9 +326,11 @@ pub fn diagnostics_or_breakpoints<'doc>(
) -> GutterFn < ' doc > {
) -> GutterFn < ' doc > {
let mut diagnostics = diagnostic ( editor , doc , view , theme , is_focused ) ;
let mut diagnostics = diagnostic ( editor , doc , view , theme , is_focused ) ;
let mut breakpoints = breakpoints ( editor , doc , view , theme , is_focused ) ;
let mut breakpoints = breakpoints ( editor , doc , view , theme , is_focused ) ;
let mut execution_pause_indicator = execution_pause_indicator ( editor , doc , theme , is_focused ) ;
Box ::new ( move | line , selected , first_visual_line : bool , out | {
Box ::new ( move | line , selected , first_visual_line : bool , out | {
breakpoints ( line , selected , first_visual_line , out )
execution_pause_indicator ( line , selected , first_visual_line , out )
. or_else ( | | breakpoints ( line , selected , first_visual_line , out ) )
. or_else ( | | diagnostics ( line , selected , first_visual_line , out ) )
. or_else ( | | diagnostics ( line , selected , first_visual_line , out ) )
} )
} )
}
}