Yes, it is possible. The on_navigate()
handler receives the href
value. It can be used to run any kind of function based on the href
.
def navigate(href):
# allow navigate() to manipulate the outer variables
nonlocal highlight_diff
if href == 'hide':
view.hide_popup()
elif href == 'copy':
del_text = '\n'.join(del_lines)
sublime.set_clipboard(del_text)
sublime.status_message(
'Copied: {0} characters'.format(len(del_text)))
elif href == 'revert':
# hide the popup and update the view
view.hide_popup()
revert.revert_change_impl(view, diff_info)
elif href == 'disable_hl_diff':
# show a diff popup with the same diff info (previous revision)
highlight_diff = False
_show_diff_popup_impl(
git_gutter, line, highlight_diff, flags, diff_info)
elif href == 'enable_hl_diff':
# show a diff popup with the same diff info (highlight diff)
highlight_diff = True
_show_diff_popup_impl(
git_gutter, line, highlight_diff, flags, diff_info)
elif href in ('first_change', 'next_change', 'prev_change'):
next_line = meta.get(href, line)
point = view.text_point(next_line - 1, 0)
def show_new_popup():
# wait until scrolling has completed
if not view.visible_region().contains(point):
return sublime.set_timeout_async(show_new_popup, 20)
# show a diff popup with new diff info
_show_diff_popup_impl(
git_gutter, next_line, highlight_diff, 0,
git_gutter.git_handler.diff_line_change(next_line))
view.hide_popup()
view.show_at_center(point)
show_new_popup()