diff --git a/src/terminal.cc b/src/terminal.cc index cda8257..98d9bfa 100644 --- a/src/terminal.cc +++ b/src/terminal.cc @@ -4,17 +4,6 @@ #include "info.h" #include "notebook.h" #include -//Temporary fix for current Arch Linux boost linking problem -#ifdef __GNUC_PREREQ -#if __GNUC_PREREQ(5,1) -#include -#define REGEX_NS std -#endif -#endif -#ifndef REGEX_NS -#include -#define REGEX_NS boost -#endif Terminal::InProgress::InProgress(const std::string& start_msg): stop(false) { start(start_msg); @@ -51,6 +40,8 @@ void Terminal::InProgress::cancel(const std::string& msg) { Terminal::get().async_print(line_nr-1, msg); } +const REGEX_NS::regex Terminal::link_regex("^([A-Z]:)?([^:]+):([0-9]+):([0-9]+)$"); + Terminal::Terminal() { bold_tag=get_buffer()->create_tag(); bold_tag->property_weight()=PANGO_WEIGHT_BOLD; @@ -206,8 +197,12 @@ void Terminal::apply_link_tags(Gtk::TextIter start_iter, Gtk::TextIter end_iter) if(offset!=2) #endif ++colons; - if(colons==3 && possible_path) - get_buffer()->apply_tag(link_tag, start_path_iter, iter); + if(colons==3 && possible_path) { + REGEX_NS::smatch sm; + if(REGEX_NS::regex_match(get_buffer()->get_text(start_path_iter, iter).raw(), sm, link_regex)) + get_buffer()->apply_tag(link_tag, start_path_iter, iter); + possible_path=false; + } } } } @@ -355,9 +350,8 @@ bool Terminal::on_button_press_event(GdkEventButton* button_event) { if(iter.has_tag(link_tag) && start_iter.backward_to_tag_toggle(link_tag) && end_iter.forward_to_tag_toggle(link_tag)) { std::string path_str=get_buffer()->get_text(start_iter, end_iter); - const static REGEX_NS::regex path_regex("^([A-Z]:)?([^:]+):([0-9]+):([0-9]+)$"); REGEX_NS::smatch sm; - if(REGEX_NS::regex_match(path_str, sm, path_regex)) { + if(REGEX_NS::regex_match(path_str, sm, link_regex)) { auto path_str=sm[1].str()+sm[2].str(); auto path=boost::filesystem::path(path_str); boost::system::error_code ec; diff --git a/src/terminal.h b/src/terminal.h index 566d39d..832132c 100644 --- a/src/terminal.h +++ b/src/terminal.h @@ -11,6 +11,17 @@ #include "process.hpp" #include "dispatcher.h" #include +//Temporary fix for current Arch Linux boost linking problem +#ifdef __GNUC_PREREQ +#if __GNUC_PREREQ(5,1) +#include +#define REGEX_NS std +#endif +#endif +#ifndef REGEX_NS +#include +#define REGEX_NS boost +#endif class Terminal : public Gtk::TextView { public: @@ -63,6 +74,7 @@ private: Glib::RefPtr link_mouse_cursor; Glib::RefPtr default_mouse_cursor; size_t deleted_lines=0; + const static REGEX_NS::regex link_regex; void apply_link_tags(Gtk::TextIter start_iter, Gtk::TextIter end_iter); std::vector > processes;