|
|
|
@ -382,10 +382,15 @@ void Window::set_menu_actions() { |
|
|
|
if(notebook.get_current_page()!=-1) { |
|
|
|
if(notebook.get_current_page()!=-1) { |
|
|
|
if(notebook.get_current_view()->get_declaration_location) { |
|
|
|
if(notebook.get_current_view()->get_declaration_location) { |
|
|
|
auto location=notebook.get_current_view()->get_declaration_location(); |
|
|
|
auto location=notebook.get_current_view()->get_declaration_location(); |
|
|
|
if(location.first.size()>0) { |
|
|
|
if(!location.file_path.empty()) { |
|
|
|
notebook.open(location.first); |
|
|
|
boost::filesystem::path declaration_file; |
|
|
|
auto line=static_cast<int>(location.second.line)-1; |
|
|
|
boost::system::error_code ec; |
|
|
|
auto index=static_cast<int>(location.second.index)-1; |
|
|
|
declaration_file=boost::filesystem::canonical(location.file_path, ec); |
|
|
|
|
|
|
|
if(ec) |
|
|
|
|
|
|
|
declaration_file=location.file_path; |
|
|
|
|
|
|
|
notebook.open(declaration_file); |
|
|
|
|
|
|
|
auto line=static_cast<int>(location.line)-1; |
|
|
|
|
|
|
|
auto index=static_cast<int>(location.index)-1; |
|
|
|
auto buffer=notebook.get_current_view()->get_buffer(); |
|
|
|
auto buffer=notebook.get_current_view()->get_buffer(); |
|
|
|
line=std::min(line, buffer->get_line_count()-1); |
|
|
|
line=std::min(line, buffer->get_line_count()-1); |
|
|
|
if(line>=0) { |
|
|
|
if(line>=0) { |
|
|
|
@ -405,6 +410,71 @@ void Window::set_menu_actions() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
menu->add_action("source_goto_usage", [this]() { |
|
|
|
|
|
|
|
if(notebook.get_current_page()!=-1) { |
|
|
|
|
|
|
|
auto current_view=notebook.get_current_view(); |
|
|
|
|
|
|
|
if(current_view->get_token && current_view->get_usages) { |
|
|
|
|
|
|
|
auto token=current_view->get_token(); |
|
|
|
|
|
|
|
if(token) { |
|
|
|
|
|
|
|
auto iter=current_view->get_buffer()->get_insert()->get_iter(); |
|
|
|
|
|
|
|
Gdk::Rectangle visible_rect; |
|
|
|
|
|
|
|
current_view->get_visible_rect(visible_rect); |
|
|
|
|
|
|
|
Gdk::Rectangle iter_rect; |
|
|
|
|
|
|
|
current_view->get_iter_location(iter, iter_rect); |
|
|
|
|
|
|
|
iter_rect.set_width(1); |
|
|
|
|
|
|
|
if(!visible_rect.intersects(iter_rect)) { |
|
|
|
|
|
|
|
current_view->get_iter_at_location(iter, 0, visible_rect.get_y()+visible_rect.get_height()/3); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
current_view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*current_view, current_view->get_buffer()->create_mark(iter))); |
|
|
|
|
|
|
|
auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//First add usages in current file
|
|
|
|
|
|
|
|
auto usages=current_view->get_usages(token); |
|
|
|
|
|
|
|
for(auto &usage: usages) { |
|
|
|
|
|
|
|
auto iter=current_view->get_buffer()->get_iter_at_line_index(usage.first.line, usage.first.index); |
|
|
|
|
|
|
|
auto row=std::to_string(iter.get_line()+1)+':'+std::to_string(iter.get_line_offset()+1)+' '+usage.second; |
|
|
|
|
|
|
|
(*rows)[row]=usage.first; |
|
|
|
|
|
|
|
current_view->selection_dialog->add_row(row); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//Then the remaining opened files
|
|
|
|
|
|
|
|
for(int page=0;page<notebook.size();page++) { |
|
|
|
|
|
|
|
auto view=notebook.get_view(page); |
|
|
|
|
|
|
|
if(view!=current_view) { |
|
|
|
|
|
|
|
if(view->get_usages) { |
|
|
|
|
|
|
|
auto usages=view->get_usages(token); |
|
|
|
|
|
|
|
for(auto &usage: usages) { |
|
|
|
|
|
|
|
auto iter=view->get_buffer()->get_iter_at_line_index(usage.first.line, usage.first.index); |
|
|
|
|
|
|
|
auto row=usage.first.file_path.filename().string()+":"+std::to_string(iter.get_line()+1)+':'+std::to_string(iter.get_line_offset()+1)+' '+usage.second; |
|
|
|
|
|
|
|
(*rows)[row]=usage.first; |
|
|
|
|
|
|
|
current_view->selection_dialog->add_row(row); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(rows->size()==0) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
current_view->selection_dialog->on_select=[this, rows](const std::string& selected, bool hide_window) { |
|
|
|
|
|
|
|
auto offset=rows->at(selected); |
|
|
|
|
|
|
|
boost::filesystem::path declaration_file; |
|
|
|
|
|
|
|
boost::system::error_code ec; |
|
|
|
|
|
|
|
declaration_file=boost::filesystem::canonical(offset.file_path, ec); |
|
|
|
|
|
|
|
if(ec) |
|
|
|
|
|
|
|
declaration_file=offset.file_path; |
|
|
|
|
|
|
|
notebook.open(declaration_file); |
|
|
|
|
|
|
|
auto view=notebook.get_current_view(); |
|
|
|
|
|
|
|
view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line_index(offset.line, offset.index)); |
|
|
|
|
|
|
|
while(g_main_context_pending(NULL)) |
|
|
|
|
|
|
|
g_main_context_iteration(NULL, false); |
|
|
|
|
|
|
|
if(notebook.get_current_page()!=-1) |
|
|
|
|
|
|
|
view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); |
|
|
|
|
|
|
|
//delayed_tooltips_connection.disconnect();
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
current_view->selection_dialog->show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
menu->add_action("source_goto_method", [this]() { |
|
|
|
menu->add_action("source_goto_method", [this]() { |
|
|
|
if(notebook.get_current_page()!=-1) { |
|
|
|
if(notebook.get_current_page()!=-1) { |
|
|
|
if(notebook.get_current_view()->goto_method) { |
|
|
|
if(notebook.get_current_view()->goto_method) { |
|
|
|
|