@ -154,10 +154,10 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
else
else
source_views . emplace_back ( new Source : : GenericView ( file_path , language ) ) ;
source_views . emplace_back ( new Source : : GenericView ( file_path , language ) ) ;
auto source_ view = source_views . back ( ) ;
auto view = source_views . back ( ) ;
source_ view- > configure ( ) ;
view - > configure ( ) ;
source_ view- > scroll_to_cursor_delayed = [ this ] ( Source : : BaseView * view , bool center , bool show_tooltips ) {
view - > scroll_to_cursor_delayed = [ this ] ( Source : : BaseView * view , bool center , bool show_tooltips ) {
if ( ! show_tooltips )
if ( ! show_tooltips )
view - > hide_tooltips ( ) ;
view - > hide_tooltips ( ) ;
while ( Gtk : : Main : : events_pending ( ) )
while ( Gtk : : Main : : events_pending ( ) )
@ -171,17 +171,17 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
view - > hide_tooltips ( ) ;
view - > hide_tooltips ( ) ;
}
}
} ;
} ;
source_ view- > update_status_location = [ this ] ( Source : : BaseView * view ) {
view - > update_status_location = [ this ] ( Source : : BaseView * view ) {
if ( get_current_view ( ) = = view ) {
if ( get_current_view ( ) = = view ) {
auto iter = view - > get_buffer ( ) - > get_insert ( ) - > get_iter ( ) ;
auto iter = view - > get_buffer ( ) - > get_insert ( ) - > get_iter ( ) ;
status_location . set_text ( " " + std : : to_string ( iter . get_line ( ) + 1 ) + " : " + std : : to_string ( iter . get_line_offset ( ) + 1 ) ) ;
status_location . set_text ( " " + std : : to_string ( iter . get_line ( ) + 1 ) + " : " + std : : to_string ( iter . get_line_offset ( ) + 1 ) ) ;
}
}
} ;
} ;
source_ view- > update_status_file_path = [ this ] ( Source : : BaseView * view ) {
view - > update_status_file_path = [ this ] ( Source : : BaseView * view ) {
if ( get_current_view ( ) = = view )
if ( get_current_view ( ) = = view )
status_file_path . set_text ( ' ' + filesystem : : get_short_path ( view - > file_path ) . string ( ) ) ;
status_file_path . set_text ( ' ' + filesystem : : get_short_path ( view - > file_path ) . string ( ) ) ;
} ;
} ;
source_ view- > update_status_branch = [ this ] ( Source : : BaseView * view ) {
view - > update_status_branch = [ this ] ( Source : : BaseView * view ) {
if ( get_current_view ( ) = = view ) {
if ( get_current_view ( ) = = view ) {
if ( ! view - > status_branch . empty ( ) )
if ( ! view - > status_branch . empty ( ) )
status_branch . set_text ( " ( " + view - > status_branch + " ) " ) ;
status_branch . set_text ( " ( " + view - > status_branch + " ) " ) ;
@ -189,7 +189,7 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
status_branch . set_text ( " " ) ;
status_branch . set_text ( " " ) ;
}
}
} ;
} ;
source_ view- > update_status_diagnostics = [ this ] ( Source : : BaseView * view ) {
view - > update_status_diagnostics = [ this ] ( Source : : BaseView * view ) {
if ( get_current_view ( ) = = view ) {
if ( get_current_view ( ) = = view ) {
std : : string diagnostic_info ;
std : : string diagnostic_info ;
@ -250,28 +250,28 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
status_diagnostics . set_markup ( diagnostic_info ) ;
status_diagnostics . set_markup ( diagnostic_info ) ;
}
}
} ;
} ;
source_ view- > update_status_state = [ this ] ( Source : : BaseView * view ) {
view - > update_status_state = [ this ] ( Source : : BaseView * view ) {
if ( get_current_view ( ) = = view )
if ( get_current_view ( ) = = view )
status_state . set_text ( view - > status_state + " " ) ;
status_state . set_text ( view - > status_state + " " ) ;
} ;
} ;
scrolled_windows . emplace_back ( new Gtk : : ScrolledWindow ( ) ) ;
scrolled_windows . emplace_back ( new Gtk : : ScrolledWindow ( ) ) ;
hboxes . emplace_back ( new Gtk : : Box ( ) ) ;
hboxes . emplace_back ( new Gtk : : Box ( ) ) ;
scrolled_windows . back ( ) - > add ( * source_ view) ;
scrolled_windows . back ( ) - > add ( * view ) ;
hboxes . back ( ) - > pack_start ( * scrolled_windows . back ( ) ) ;
hboxes . back ( ) - > pack_start ( * scrolled_windows . back ( ) ) ;
source_maps . emplace_back ( Glib : : wrap ( gtk_source_map_new ( ) ) ) ;
source_maps . emplace_back ( Glib : : wrap ( gtk_source_map_new ( ) ) ) ;
gtk_source_map_set_view ( GTK_SOURCE_MAP ( source_maps . back ( ) - > gobj ( ) ) , source_ view- > gobj ( ) ) ;
gtk_source_map_set_view ( GTK_SOURCE_MAP ( source_maps . back ( ) - > gobj ( ) ) , view - > gobj ( ) ) ;
configure ( source_views . size ( ) - 1 ) ;
configure ( source_views . size ( ) - 1 ) ;
//Set up tab label
//Set up tab label
tab_labels . emplace_back ( new TabLabel ( [ this , source_ view] ( ) {
tab_labels . emplace_back ( new TabLabel ( [ this , view ] ( ) {
auto index = get_index ( source_ view) ;
auto index = get_index ( view ) ;
if ( index ! = static_cast < size_t > ( - 1 ) )
if ( index ! = static_cast < size_t > ( - 1 ) )
close ( index ) ;
close ( index ) ;
} ) ) ;
} ) ) ;
source_ view- > update_tab_label = [ this ] ( Source : : BaseView * view ) {
view - > update_tab_label = [ this ] ( Source : : BaseView * view ) {
std : : string title = view - > file_path . filename ( ) . string ( ) ;
std : : string title = view - > file_path . filename ( ) . string ( ) ;
if ( view - > get_buffer ( ) - > get_modified ( ) )
if ( view - > get_buffer ( ) - > get_modified ( ) )
title + = ' * ' ;
title + = ' * ' ;
@ -286,21 +286,21 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
}
}
}
}
} ;
} ;
source_ view- > update_tab_label ( source_ view) ;
view - > update_tab_label ( view ) ;
//Add star on tab label when the page is not saved:
//Add star on tab label when the page is not saved:
source_ view- > get_buffer ( ) - > signal_modified_changed ( ) . connect ( [ source_ view] ( ) {
view - > get_buffer ( ) - > signal_modified_changed ( ) . connect ( [ view ] ( ) {
if ( source_ view- > update_tab_label )
if ( view - > update_tab_label )
source_ view- > update_tab_label ( source_ view) ;
view - > update_tab_label ( view ) ;
} ) ;
} ) ;
//Cursor history
//Cursor history
auto update_cursor_locations = [ this , source_ view] ( const Gtk : : TextBuffer : : iterator & iter ) {
auto update_cursor_locations = [ this , view ] ( const Gtk : : TextBuffer : : iterator & iter ) {
bool mark_moved = false ;
bool mark_moved = false ;
if ( current_cursor_location ! = static_cast < size_t > ( - 1 ) ) {
if ( current_cursor_location ! = static_cast < size_t > ( - 1 ) ) {
auto & cursor_location = cursor_locations . at ( current_cursor_location ) ;
auto & cursor_location = cursor_locations . at ( current_cursor_location ) ;
if ( cursor_location . view = = source_ view & & abs ( cursor_location . mark - > get_iter ( ) . get_line ( ) - iter . get_line ( ) ) < = 2 ) {
if ( cursor_location . view = = view & & abs ( cursor_location . mark - > get_iter ( ) . get_line ( ) - iter . get_line ( ) ) < = 2 ) {
source_ view- > get_buffer ( ) - > move_mark ( cursor_location . mark , iter ) ;
view - > get_buffer ( ) - > move_mark ( cursor_location . mark , iter ) ;
mark_moved = true ;
mark_moved = true ;
}
}
}
}
@ -311,7 +311,7 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
it = cursor_locations . erase ( it ) ;
it = cursor_locations . erase ( it ) ;
}
}
}
}
cursor_locations . emplace_back ( source_ view, source_ view- > get_buffer ( ) - > create_mark ( iter ) ) ;
cursor_locations . emplace_back ( view , view - > get_buffer ( ) - > create_mark ( iter ) ) ;
current_cursor_location = cursor_locations . size ( ) - 1 ;
current_cursor_location = cursor_locations . size ( ) - 1 ;
}
}
@ -346,7 +346,7 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
if ( current_cursor_location > = cursor_locations . size ( ) )
if ( current_cursor_location > = cursor_locations . size ( ) )
current_cursor_location = cursor_locations . size ( ) - 1 ;
current_cursor_location = cursor_locations . size ( ) - 1 ;
} ;
} ;
source_ view- > get_buffer ( ) - > signal_mark_set ( ) . connect ( [ this , update_cursor_locations ] ( const Gtk : : TextBuffer : : iterator & iter , const Glib : : RefPtr < Gtk : : TextBuffer : : Mark > & mark ) {
view - > get_buffer ( ) - > signal_mark_set ( ) . connect ( [ this , update_cursor_locations ] ( const Gtk : : TextBuffer : : iterator & iter , const Glib : : RefPtr < Gtk : : TextBuffer : : Mark > & mark ) {
if ( mark - > get_name ( ) = = " insert " ) {
if ( mark - > get_name ( ) = = " insert " ) {
if ( disable_next_update_cursor_locations ) {
if ( disable_next_update_cursor_locations ) {
disable_next_update_cursor_locations = false ;
disable_next_update_cursor_locations = false ;
@ -355,35 +355,35 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
update_cursor_locations ( iter ) ;
update_cursor_locations ( iter ) ;
}
}
} ) ;
} ) ;
source_ view- > get_buffer ( ) - > signal_changed ( ) . connect ( [ source_ view, update_cursor_locations ] {
view - > get_buffer ( ) - > signal_changed ( ) . connect ( [ view , update_cursor_locations ] {
update_cursor_locations ( source_ view- > get_buffer ( ) - > get_insert ( ) - > get_iter ( ) ) ;
update_cursor_locations ( view - > get_buffer ( ) - > get_insert ( ) - > get_iter ( ) ) ;
} ) ;
} ) ;
# ifdef JUCI_ENABLE_DEBUG
# ifdef JUCI_ENABLE_DEBUG
if ( dynamic_cast < Source : : ClangView * > ( source_ view) | | ( source_ view- > language & & source_ view- > language - > get_id ( ) = = " rust " ) ) {
if ( dynamic_cast < Source : : ClangView * > ( view ) | | ( view - > language & & view - > language - > get_id ( ) = = " rust " ) ) {
source_ view- > toggle_breakpoint = [ source_ view] ( int line_nr ) {
view - > toggle_breakpoint = [ view ] ( int line_nr ) {
if ( source_ view- > get_source_buffer ( ) - > get_source_marks_at_line ( line_nr , " debug_breakpoint " ) . size ( ) > 0 ) {
if ( view - > get_source_buffer ( ) - > get_source_marks_at_line ( line_nr , " debug_breakpoint " ) . size ( ) > 0 ) {
auto start_iter = source_ view- > get_buffer ( ) - > get_iter_at_line ( line_nr ) ;
auto start_iter = view - > get_buffer ( ) - > get_iter_at_line ( line_nr ) ;
auto end_iter = source_ view- > get_iter_at_line_end ( line_nr ) ;
auto end_iter = view - > get_iter_at_line_end ( line_nr ) ;
source_ view- > get_source_buffer ( ) - > remove_source_marks ( start_iter , end_iter , " debug_breakpoint " ) ;
view - > get_source_buffer ( ) - > remove_source_marks ( start_iter , end_iter , " debug_breakpoint " ) ;
source_ view- > get_source_buffer ( ) - > remove_source_marks ( start_iter , end_iter , " debug_breakpoint_and_stop " ) ;
view - > get_source_buffer ( ) - > remove_source_marks ( start_iter , end_iter , " debug_breakpoint_and_stop " ) ;
if ( Project : : current & & Project : : debugging )
if ( Project : : current & & Project : : debugging )
Project : : current - > debug_remove_breakpoint ( source_ view- > file_path , line_nr + 1 , source_ view- > get_buffer ( ) - > get_line_count ( ) + 1 ) ;
Project : : current - > debug_remove_breakpoint ( view - > file_path , line_nr + 1 , view - > get_buffer ( ) - > get_line_count ( ) + 1 ) ;
}
}
else {
else {
auto iter = source_ view- > get_buffer ( ) - > get_iter_at_line ( line_nr ) ;
auto iter = view - > get_buffer ( ) - > get_iter_at_line ( line_nr ) ;
source_view - > get_source_buffer ( ) - > create_source_mark ( " debug_breakpoint " , iter ) ;
gtk_ source_buffer_create_source_mark ( view - > get_source_buffer ( ) - > gobj ( ) , nullptr , " debug_breakpoint " , iter . gobj ( ) ) ; // Gsv::Buffer::create_source_mark is bugged
if ( source_ view- > get_source_buffer ( ) - > get_source_marks_at_line ( line_nr , " debug_stop " ) . size ( ) > 0 )
if ( view - > get_source_buffer ( ) - > get_source_marks_at_line ( line_nr , " debug_stop " ) . size ( ) > 0 )
source_view - > get_source_buffer ( ) - > create_source_mark ( " debug_breakpoint_and_stop " , iter ) ;
gtk_ source_buffer_create_source_mark ( view - > get_source_buffer ( ) - > gobj ( ) , nullptr , " debug_breakpoint_and_stop " , iter . gobj ( ) ) ; // Gsv::Buffer::create_source_mark is bugged
if ( Project : : current & & Project : : debugging )
if ( Project : : current & & Project : : debugging )
Project : : current - > debug_add_breakpoint ( source_ view- > file_path , line_nr + 1 ) ;
Project : : current - > debug_add_breakpoint ( view - > file_path , line_nr + 1 ) ;
}
}
} ;
} ;
}
}
# endif
# endif
source_ view- > signal_focus_in_event ( ) . connect ( [ this , source_ view] ( GdkEventFocus * ) {
view - > signal_focus_in_event ( ) . connect ( [ this , view ] ( GdkEventFocus * ) {
set_current_view ( source_ view) ;
set_current_view ( view ) ;
return false ;
return false ;
} ) ;
} ) ;
@ -415,7 +415,7 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
}
}
set_focus_child ( * source_views . back ( ) ) ;
set_focus_child ( * source_views . back ( ) ) ;
focus_view ( source_ view) ;
focus_view ( view ) ;
}
}
void Notebook : : open_uri ( const std : : string & uri ) {
void Notebook : : open_uri ( const std : : string & uri ) {