Sublime Forum

How do I create phantoms with a close button (like a build system's errors)?

#1

I’m writing a small code processor that exploits sublime’s parsing to transform CFML code to CFScript. I expect that there will be a number of transformation failures on a typical file, and I would like to display error messages inline like a build system would – in particular, I want the close button. I’m already creating phantoms, but of course they don’t go away on their own, so I’m removing them when the view is modified, which is less than ideal.

Is this somehow accomplished in minihtml, or is there some option or argument I’ve missed?

0 Likes

#2

You can add a function on_navigate, which will be called if you click a link.
A minimalistic example to past into the ST console:

view.add_phantom("test", view.sel()[0], 'Hello World<a href=hide>' + chr(0x00D7) + '</a>', 0, on_navigate=lambda href: view.erase_phantoms("test"))
4 Likes

#3

You might want to take a look at the GitGutter plugin which has several buttons on its popups.
It uses mdpopup a library to show rich popups in Sublime

https://github.com/jisaacks/GitGutter/blob/master/git_gutter_popup.py

0 Likes