Is there a way to add syntax highlighting to a popup(created via show_popup())? Right now, I am adding it manually which isnt very practical, and doesnt follow the current color scheme.
Syntax highlighting in popup
If you are developing your own plugin, I’ve create a dependency which will parse the view’s color scheme and generate css. The css classes are based on the scopes so you could do something like My Function Name and it should style that span element similar to how your function names are styled with you scheme. It’s only version 1.0, and I have not been able to get back to it for a bit, but you can certainly download the file and give it a try if you wanted.
https://github.com/huot25/StyledPopup
Let me know what you think!
That is really cool! I am just contributing to another person’s plugin, so i’d better ask what the auther thinks about dependencies.
E:Oh, and can you explain how to use dependencies in ST2? From what I understand you just have to “leave a big NOTICE in your readme file”, rather than making sublime download it for you.
E2:Nevermind the edit, I forgot popups are ST3 only.
If you would like to try it before adding the dependency, you can download the .py file and import the show_popup function from the module:
import styled_popup import show_popup
Then you can just execute the method:
show_popup(view, content , other_args])
I am using it now for an internal plugin I’ve developed for my employer. If you have any questions or run into any problems, please let me know. I am going to try to get back to developing this once my workload lightens up a little.
I would recommend sticking with the common scopes outlined in the Textmate grammars documentation. That should be a pretty safe to assume the styling will be converted. I am sure there are some color schemes that are using some complex scopes, but I have not run into any myself yet to determine a best approach of handling those.
I was asking about installing it. I dont understand how I tell package control what dependencies a package is using.
packagecontrol.io/docs/dependencies
@huot25: you should add instructions for how to use your dependency like I did with github.com/packagecontrol/requests.
Also, your example in the readme is outdated, the module is named styled_popup
now.
Okay, I got it working but it seems a bit weird - sometimes the popup doesnt get removed and it stays, even when I change the view; sometimes even 2-3 at a time. Somethings arent styled for some color schemes. For example, “string quoted” is styled for the Eiffel color scheme but not for Dawn (I guess that is what you meant).
I believe you have to manually hide the view on deactivate if you are not doing so already. It might have been fixed in the latest dev build, but at one point the tooltip remained visible after changing tabs.
Also try something more specific for the string quoted class. Try “string quoted double” or something like that. I think what might be happening is one color scheme has “string.quoted” as a defined scope with styling where the other has “string.quoted.double” styling defined. Even if you use the more specific class in your html any less specific classes, such as string of string quoted, will be applied first and then the more specific styles are applied on top. Sorry, not doing the best job of explaining.
let me know if that doesn’t help. I’ll take a look as well when I have a second to see if I can find a solution.
I looked at Dawn and Cobalt, it looks like there are some characters defined in the scopes that I was not accounting for and they were breaking the generated CSS styles. I will need to update the module. I should have something over the weekend. I am only going to support the main scopes defined in the grammar docs to make it a little easier to work with. This will inevitably reduce the number of options a developer has to choose from for styles, but it should make sure that the generated style sheets from each scheme are more consistent.
Good catch, and thank you for giving this a try. I think you’re the first developer to implement this besides me, but hopefully not the last!
I just pushed out version 1.0.1 which addresses the issue for some of the color schemes not being styled correctly. There were invalid characters in the css class names which were causing the styling to fail. Please let me know if the updated version is still not working for you.