Thanks, I didn’t realise we could submit pull requests; I’ll keep that in mind for the future
Dev Build 3118
@jps while you’re on these definition related functionality, please take a look at this issue:
Long story short, if you have same method defined in multiple files, go to definition should display current file first in the dropdown.
Thanks!
Color Schemes: popupCss will be generated automatically if not present
Can anyone clarify this? what CSS is generated exactly? just background and foreground is used? what are the generated classnames
The phantoms are pretty awesome. 3 remarks though:
- It’s a bit unexpected that hitting [x] on a phantom closes all of them in all files, with no (apparent) way to bring them back.
- The [x] it a bit rough visually, couldn’t we get a nice icon in there? I think you could even get away with having no [x] at all and just close on click.
- Is there a css selector I can use in my theme to set a phantom off from the source code (like tweak the background)?
It looks like Christmas is earlier than usual this year !
Phantoms are pretty cool, but that raises other feature requests
In python the error-message phantom looks like:
do = da + 2
di = do + 3
File "~/foo.py", line 2 [X]
The thing is I don’t really care about the file name and the line because the phantom is already in the good place.
I’m much more interested in the error message and the details:
di = do + 3
^
IndentationError: unexpected indent
I made a more detailed post in the “API suggestion thread”: API Suggestions
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
Build system regex captures
Help with build system for Crystal specs
Inline build errors for Python do not show useful information
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
Minihtml best practises to work alongside theme developers
How to achieve default style for phantom_css if popup_css is defined in color scheme?
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).