Sublime Forum

Dev Build 3118

#11

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)?
3 Likes

#12

It looks like Christmas is earlier than usual this year !

Phantoms are pretty cool, but that raises other feature requests :slightly_smiling:

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

6 Likes

#13

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.

0 Likes

#14

I tried that, but it didn’t seem to affect the phantoms. I’ll try again :slight_smile:

0 Likes

#15

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.

0 Likes

#16

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

5 Likes

Build system regex captures
Help with build system for Crystal specs
Inline build errors for Python do not show useful information
#17

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 :+1:)

0 Likes

#18

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
4 Likes

Minihtml best practises to work alongside theme developers
How to achieve default style for phantom_css if popup_css is defined in color scheme?
#19

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.

5 Likes

#20

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.

2 Likes

#21

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.

4 Likes

#22

where the generated settings gets saved ??, i cant find it in the active scheme

0 Likes

#23

I would expect them not to get saved at all but rather generated on the fly.

0 Likes

#24

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)
1 Like

#25

They are not saved to disk anywhere, just stored in memory. They are not generated if the color scheme defines its own popupCss.

0 Likes

#26

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).

1 Like

#27

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 :wink:

0 Likes

#28

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.

0 Likes

#29
  • 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.

1 Like

#30

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!

1 Like