Skip to content

Commit

Permalink
Merge pull request #19 from cuiwc/master
Browse files Browse the repository at this point in the history
Add two configuration options to control the error panel and markers
  • Loading branch information
lvzixun committed Jun 16, 2015
2 parents dedf721 + d09b48a commit 5c307b4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
8 changes: 7 additions & 1 deletion cc.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@
"-isystem", "/usr/local/opt/llvm/include",
"-Wall"
],
}

// do not show markers for warnings or errors on save.
"hide_error_mark": false,

// do not show the panel for warnings and errors on save.
"hide_error_panel": false,
}
28 changes: 15 additions & 13 deletions clang_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def close(self):
sublime.active_window().run_command("hide_panel", {"panel": "output.cc"})


def error_marks(self, view, digst):
def error_marks(self, view, digst, display):
self.erase_error_marks(view)

cur_filename = view.file_name()
Expand All @@ -74,21 +74,23 @@ def error_marks(self, view, digst):
if error_type in outlines and cur_filename == filename:
outlines[error_type].append(view.full_line(view.text_point(line-1, 0)))

for line_type in outlines:
if not outlines[line_type] is None:
args = [
'sublimeclang-outlines-{0}'.format(line_type),
outlines[line_type],
self.markers[line_type],
'dot',
sublime.DRAW_OUTLINED
]
view.add_regions(*args)
if display:
for line_type in outlines:
if not outlines[line_type] is None:
args = [
'sublimeclang-outlines-{0}'.format(line_type),
outlines[line_type],
self.markers[line_type],
'dot',
sublime.DRAW_OUTLINED
]
view.add_regions(*args)


def erase_error_marks(self, view):
view.erase_regions('cc-outlines-error')
view.erase_regions('cc-outlines-warning')
view.erase_regions('sublimeclang-outlines-error')
view.erase_regions('sublimeclang-outlines-warning')
view.erase_regions('sublimeclang-outlines-fatal error')


clang_error_panel = ClangErrorPanel()
7 changes: 5 additions & 2 deletions st_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ def on_post_save_async(self, view):
if not can_complete(view):
return

settings = Complete.get_settings()
hide_error_panel = settings.get('hide_error_panel') or False
hide_error_mark = settings.get('hide_error_mark') or False
file_name = view.file_name()
sym = Complete.get_symbol(file_name, view)
if self.dirty:
Expand All @@ -271,12 +274,12 @@ def on_post_save_async(self, view):

output = "\n".join([err for _, (_, _, _, _, err) in digst])
clang_error_panel.set_data(output)
clang_error_panel.error_marks(view, digst)
clang_error_panel.error_marks(view, digst, not hide_error_mark)

print(output)
window = view.window()
if not window is None and len(digst) >= 1:
window.run_command("clang_toggle_panel", {"show": True})
window.run_command("clang_toggle_panel", {"show": not hide_error_panel})


def on_query_completions(self, view, prefix, locations):
Expand Down

0 comments on commit 5c307b4

Please sign in to comment.