Coder Social home page Coder Social logo

styledpopup's Introduction

StyledPopup

This plugin provides a standardized way to style view popups based on the view's color scheme.

The plugin will parse the active color scheme and generate a style sheet which can be used to style the html displayed in the popup.

The classes generated are based on the scopes available within the color scheme. Since all color schemes are based on common scopes, this provides an ideal method to style html elements.

Usage

How to use StyledPopup as a dependencey

The StyledPopup module needs to be installed as a dependency through package control in order to be able to import the new python module. Simply create a dependencies.json file within your plugin and add the following content.

{
	"*": {
		"*": [
			"StyledPopup"
		]
	}
}

Once the file has been added to your plugin, simply run the ** Package Control: Satisfy Dependencies ** command to tell Package Control to install your dependencies. You could also restart Sublime Text and Package Control should notify you that a new dependency has been install.

Once installed you can simply call the styled popup

Calling the Styled Popup.

Import the module using:

import styled_popup

Then call the styled_popup.show_popup function passing the view associated with the popup and any arguments to be passed to the view's show_popup function. The html will have the style sheet appended automatically and any css styles that match a given scope will be styled.

styled_popup.show_popup(view, html)

HTML Markup

To style specific elements in the html, simply assign the element a class that matches the scope you would like to use.

<span class="keyword">This should be styled like a keyword</span>

Each nested scope selector should be applied as a seperate css class:

<span class="entity name function"> This should be styled similar to a function within the color scheme</span>

alt text

The css classes will all be based on the basic supported scopes.

  • string.quoted.double
  • entity.name.function
  • invalid.illegal
  • keyword.control
  • storage.type

For a complete list of supported scopes please visit the Textmate language grammer documentation

Example Command

Create a new python file within the "User" directory of packages. Paste the following code into the new file and save.

import sublime
import sublime_plugin
import styled_popup

class PopupTestCommand(sublime_plugin.WindowCommand):
    def run(self):

        html = """Each <span class="keyword">element</span> within
                  the <span class="entity name class">html</span> can be styled
                  individually using common <span class="string quoted">scope</span> names.
                  Simply wrap each element to be styled in a span and apply the
                  <span class="comment line">css classes</span> for each scope."""

        styled_popup.show_popup(self.window.active_view(), html)

Open the Sublime Text Console("ctrl+`") and enter "window.run_command('popup_test')" into the input field at the bottom of the console and press "Enter". You should see a popup window appear which follows the styling for the active view.

Package Settings

popup_style_cache_limit

An integer setting that controls the number of parsed color scheme to cache. Default: 5

Future Tasks

  1. Implement styled code blocks with language based syntax coloring.

styledpopup's People

Contributors

huot25 avatar

Watchers

James Cloos avatar YDP avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.