in the color scheme you can:
<key>popupCss</key>
<string><![CDATA[
html {
background-color: #404238; // your color here
but it will affect all popups, not just phantoms.
in the color scheme you can:
<key>popupCss</key>
<string><![CDATA[
html {
background-color: #404238; // your color here
but it will affect all popups, not just phantoms.
it worked for me after running the build system again. But a lot of color scheme changes sometimes need a complete ST restart to take effect.
phantomCss (in the .tmTheme file) can be used to style phantoms. If it’s not present, popupCss will be used instead.
@gwenzek that’s a function of the regex specified in the build system. The file_regex in the .sublime-build can specify 4 capture groups, for file, line, column and message respectively. If the file_regex provides less than 4 captures, then the whole line is used as the message. Take a look at Makefile/Make.sublime-build for an example.
Edit: Actually, on further reading, file_regex isn’t flexible enough for this, as it requires everything to fit on one line. file_regex+line_regex can be used if file names and line numbers are on separate lines (e.g., similar to Find in Files results), but there’s no combination that will properly support error messages in the above format
Nice. I can’t test anything at the moment, so I need to ask.
How often is this method called? Once per view or whenever view settings change? Can viewlisteners unsubscribe from events that way?
Since we cannot subscribe to on_new (not sure why?), is it safe to assume that init is called whenever a view is opened or created, assuming the class method returned true? What are other supposedly window-level events?
(also, some image or video with phantom views would be cool )
Currently, CSS is generated for the background and foreground color, along with a link color and class names error
, deleted
, success
, inserted
, warning
and modified
. The background is modified by lightening it slightly to help distinguish from the text area background. The link and various class colors are pulled from the color scheme by looking through the various colors in the scheme and then setting the color:
rule to the closest match to:
a
tags: #0000FF
.error, .deleted
classes: #FF0000
.success, .inserted
classes: #00FF00
.warning, .modified
classes: #FFD900
It’s called when views are created and when settings change. For example, if is_applicable returns True iff the syntax of a view is set to Python, then the listener will be created or destroyed as required when the user changes the syntax of the file.
More question time!
Is there an event/method that is called if a view is unsubscribed from? The classmethod that does unsubscribing doesn’t have access to the particular instance and __del__
is not approproate for situations like these. If no, I’d like to request this.
In the changelog there was a mention of a cancel
key. Is that supposed to be a command name or a shell command (I assume the former)?
What does View.is_primary()
tell? If a view is a phantom view? So far, I only managed to get it return True
on the several views I tried.
Currently relying on __del__
is the only option.
cancel
may be either a command name (a Sublime Text one, not a shell command), or a map of args that to pass to the target
command.
If a buffer has multiple views (e.g., New View into File has been used), then is_primary() will only return True for one of them. Note that a view can start as non-primary, but become primary if the previous primary view is closed. By default, ViewEventListeners only get created for primary views.
Amazing API additions in the new dev builds!!
It would be great to use this to preview the best completion inserted by insert_best_completion
(tab
key by default) particularly when the completion popup is not visible. However, I don’t think there is an API method to get the best completion (maybe I am wrong) and ST adds a small gap for LAYOUT_INLINE
. Would be pretty neat.
body = """\n <style>\n body {\n background-color: #f1f1f1;\n}\n span {\n color: #aaaaaa;\n }\n </style>\n <span>ball</span> """
view.add_phantom("test", view.sel()[0], body, sublime.LAYOUT_INLINE)
They are not saved to disk anywhere, just stored in memory. They are not generated if the color scheme defines its own popupCss
.
Small bug.
In symbol.py, this line:
symbol_begin_pt = view.text_point(l[2][0] - 1, l[2][1])
must be:
symbol_begin_pt = view.text_point(l[2][0] - 1, l[2][1] - 1)
In addition, this is a Gist with a modified symbol.py to propose active file items first and an other item than the current one by default.
Maybe this can be integrated in standard ST3 (only tested on Windows).
when i define the settings they always use the same default colors (white bg and blue links) so maybe u can save the generated colors to the scheme file ,this way it could be edited easily
First off, thanks for the new build!
I’ve found https://github.com/lord/slate to be great for documentation, compare https://lord.github.io/slate for output of the gh-pages
branch. Docs could be included and opened via default brower from Sublime Text when offline, as well as linked to from the website when hosted on github and opened from Sublime Text when online.
@alkuzad Dash and/or Zeal would require those to be installed, browsers come with the OS. Using Slate here would reduce third-party dependencies.
- Build errors are now shown inline at the location where they occurred. This is controlled with the show_errors_inline setting.
As much as I welcome this feature in general, I think the way it’s currently implemented looks terrible. Would be nice if error messages can by customized by themes, so they stand out visually, rather than looking like a line of text inserted in the editor – I find that very confusing.
Really excited about the new API’s. This opens many possibilities related to additional information about the code on screen. One thing I would like to see added is the ability to set an icon for a phantom region to be displayed only when there is no existing icon on the line (for inline display) or always display when displaying as a block region. I can see this being very effective for quickly identifying lines with build errors. To avoid the issue of trying to render multiple icons to the gutter I would say existing icons from normal regions that have been added to the code should take priority over phantom icons.
Thank you for the new build devs, keep up the amazing work!
I’ve been working on some enhancements to minihtml that will make it easier to tweak the various popups. I’m also planning on making some visual tweaks. Keep your eyes peeled for further improvements.
I was trying out your example ViewCalculator plugin and I noticed that if I open a new file tab that the is_applicable()
class method gets called on every character I type into that view until the file is saved. Is that expected behavior?