Need way to add content to stylesheet
I need a way to add additional selectors to the style sheet for structural formatting (margin, padding, font-size, etc.).
I've forked the repository and can add the functionality, but was wondering which would be the best approach.
- Add an additional keyword argument to
show_popupcalledadditional_stylesthat will be appended to the end of the generated stylesheet. - Provide a second function called
get_stylesheetthat just returns the stylesheet. Other developers could then use or modify the stylesheet directly and callview.show_popupdirectly.
Either approach is fine for my needs, but I guess option 2 provides a bit more flexibility.
You could add a new style element as part of the html content that you are passing in which would override/add to the default styling. If you know the element you want to add padding to then you could do something like this. If this doesn't allow you to do what you please let me know and we can explore the option of adding additional stylesheets.
class TestPopupCommand(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
html = "<style> .entity.name.tag { color: #F00; padding:30px; } </style>"
html += """<p class="entity name tag">Testing Type</p>"""
print (html)
styled_popup.show_popup(view, html)
The following I think would suffice for item 2, but please let me know if you need anything different:
class TestPopup2Command(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
manager = styled_popup.StyleSheetManager()
stylesheet = manager.get_stylesheet(view.settings().get("color_scheme"))["content"]
stylesheet += """
.entity.name.tag{
padding: 45px;
color: #00F;
}
"""
html = "<style>%s</style>" % (stylesheet)
html += """<p class="entity name tag">Testing Type</p>"""
view.show_popup(html)