Browse Source

Improved syntax highlighting.

merge-requests/365/head
eidheim 10 years ago
parent
commit
7196ff5c58
  1. 21
      src/source.cc

21
src/source.cc

@ -962,10 +962,23 @@ void Source::ClangViewParse::update_syntax() {
auto kind=(int)token.get_cursor().get_kind(); auto kind=(int)token.get_cursor().get_kind();
if(kind==101 || kind==102) if(kind==101 || kind==102)
kind=(int)token.get_cursor().get_referenced().get_kind(); kind=(int)token.get_cursor().get_referenced().get_kind();
ranges.emplace_back(token.offsets, kind); //TODO: Need to get type of referenced token if any else if(kind==500) {
auto iter=get_buffer()->get_iter_at_line_index(token.offsets.first.line-1, token.offsets.first.index-1);
if(iter.backward_char() && *iter=='<')
token.offsets.first.index--;
iter=get_buffer()->get_iter_at_line_index(token.offsets.second.line-1, token.offsets.second.index-1);
if(*iter=='>' || *iter=='.' || *iter=='/')
token.offsets.second.index++;
}
ranges.emplace_back(token.offsets, kind);
}
else if(token.get_kind()==3) { // LiteralToken
int kind=109;
if(*get_buffer()->get_iter_at_line(token.offsets.first.line-1)=='#') {
kind=500;
}
ranges.emplace_back(token.offsets, kind);
} }
else if(token.get_kind()==3) // LiteralToken
ranges.emplace_back(token.offsets, 109);
else if(token.get_kind()==4) // CommentToken else if(token.get_kind()==4) // CommentToken
ranges.emplace_back(token.offsets, 705); ranges.emplace_back(token.offsets, 705);
} }
@ -1544,7 +1557,7 @@ Source::ClangViewAutocomplete(file_path, project_path) {
Source::ClangView::ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language): ClangViewRefactor(file_path, project_path) { Source::ClangView::ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language): ClangViewRefactor(file_path, project_path) {
if(language) { if(language) {
get_source_buffer()->set_highlight_syntax(false); get_source_buffer()->set_highlight_syntax(true);
get_source_buffer()->set_language(language); get_source_buffer()->set_language(language);
} }

Loading…
Cancel
Save