Home Download Buy Blog Forum Support

Color Scheme Builder

Re: Color Scheme Builder

Postby facelessuser on Thu Jun 21, 2012 1:37 am

agibsonsw wrote:@facelessuser Thank you.

For my own interest, what technology/extension can be used to directly edit, insert into, an XML file? I believe it's possible but haven't quite stumbled upon the technology that can do this. That is, without having to parse/load the whole file and then re-output it?

Andy.


Nothing special is needed. Maybe it wouldn't be so bad working directly with the XML.

You could just write the XML as string in the JavaScript and then just convert it:
 1456             var xml, parser;
1457 if (window.ActiveXObject){
1458 xml = new window.ActiveXObject('Microsoft.XMLDOM');
1459 xml.async = 'false';
1460 if (!xml.loadXML(str)) xml = null;
1461 } else {
1462 parser = new window.DOMParser();
1463 xml = parser.parseFromString(str, 'text/xml');
1464 }
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: Color Scheme Builder

Postby Francisc on Thu Jun 21, 2012 8:05 pm

Didn't know about studiostyl.es, looks pretty good.
The creation interface looks like it will take a bit of time to create in exactly the same manner, but I'd be happy with something like a table:

Code: Select all
Lang: default
   variable:#colour
   function:#colour
   etc

Lang: PHP
   variable:#colour
   "<?php","<?=":#colour
   //Function is not defined so it gets inherited from Lang: default

Lang: JavaScript
   variable:#colour
   variable(this):#colour //Maybe allow different colours for special vars

etc


So that's not the final theme file but the interface a simple "label: input" like UI.
That should be a lot faster than the studiostyl.es UI.
Francisc
 
Posts: 55
Joined: Thu Sep 22, 2011 7:14 pm

Re: Color Scheme Builder

Postby agibsonsw on Thu Jun 21, 2012 8:31 pm

@facelessuser. Thank you but I don't quite follow - I'm a bit under the weather :cry: so maybe my brains' not firing on all cylinders..

What I'm looking at is injecting a node such as

Code: Select all
      <dict>
         <key>name</key>
         <string>Magic Functions (Python)</string>
         <key>scope</key>
         <string>support.function.magic.python</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#00F5FF</string>
         </dict>
      </dict>

directly into a theme-file, at a suitable location, without having to parse or load the whole XML? I think your example demonstrates building the XML node, but how do I "inject" it..? Ta, Andy.

@Francisc. Sorry to side-step your post :) . But isn't it better to see some sample code - like studiostyl.es - so that you can see precisely how your colour will impact the code? It will also be easier for someone to create, as they can (effectively) copy some sample code, stick it in ST, and read the scope at each character/word position.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Color Scheme Builder

Postby C0D312 on Thu Jun 21, 2012 8:43 pm

C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Color Scheme Builder

Postby facelessuser on Thu Jun 21, 2012 8:43 pm

agibsonsw wrote:@facelessuser. Thank you but I don't quite follow - I'm a bit under the weather :cry: so maybe my brains' not firing on all cylinders..

What I'm looking at is injecting a node such as

Code: Select all
      <dict>
         <key>name</key>
         <string>Magic Functions (Python)</string>
         <key>scope</key>
         <string>support.function.magic.python</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#00F5FF</string>
         </dict>
      </dict>

directly into a theme-file, at a suitable location, without having to parse or load the whole XML? I think your example demonstrates building the XML node, but how do I "inject" it..? Ta, Andy.

@Francisc. Sorry to side-step your post :) . But isn't it better to see some sample code - like studiostyl.es - so that you can see precisely how your colour will impact the code? It will also be easier for someone to create, as they can (effectively) copy some sample code, stick it in ST, and read the scope at each character/word position.


You always have to parse an entire file. You can never just insert something into a file on disk, you have to rewrite the file with the node inserted in. The code I provided takes the text content of the XML and creates an XML object that you can use to insert a node. When you are done inserting nodes you can extract the content from the object. The XML object has methods for inserting new nodes etc. I don't really have time right now to go through the XML methods but here is showing how you can create a node http://www.w3schools.com/dom/dom_nodes_create.asp, but it is pretty well documented online.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: Color Scheme Builder

Postby agibsonsw on Thu Jun 21, 2012 9:54 pm

@facelessuser. Thank you.

You can never just insert something into a file on disk, you have to rewrite the file with the node inserted in


That's the detail I was looking for :D . Thanks for the link (.. although, I don't really need it ;) )

An interesting, or debatable, read - depending on your point of view: w3fools
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Color Scheme Builder

Postby facelessuser on Thu Jun 21, 2012 10:39 pm

agibsonsw wrote:@facelessuser. Thank you.

You can never just insert something into a file on disk, you have to rewrite the file with the node inserted in


That's the detail I was looking for :D . Thanks for the link (.. although, I don't really need it ;) )

An interesting, or debatable, read - depending on your point of view: w3fools


Interesting link. Though I only provided a link to them because it was one of the first to show up in google ;). Wasn't exactly sure what you were asking, so I was trying to cover all the bases.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: Color Scheme Builder

Postby agibsonsw on Thu Jun 21, 2012 10:53 pm

@facelessuser

I still refer to w3schools because it always appears earliest from a Google search, and it's a familiar site to navigate. But I also try to dig a little deeper as well - I have myself occasionally noticed incomplete or out-of-date information on that site.

Regards, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Color Scheme Builder

Postby quodlibet on Sat Jun 23, 2012 11:20 am

Sorry if I'm being OT.

As far as I can tell the biggest difficulty with editing sublime colour schemes has to do with finding out how to write it out so that it cascades properly for the various language (rather than defining everything with very specific scopes) and that as the file grows, fiddling with hex values becomes rather infuriating*.

This issue would not be greately helped by a UI. On the other hand, it would be great if one were able to define and reuse values and, closely related to this, the ability to define colors programatically. For example, in LESS one might write something like:

Code: Select all
@blue-color: #0066cc;

some.div {
   background:@blue-color;
   border:1px solid darken(@blue-color, 10);
}

@other-color: desaturate(spin(@blue-color, 30), 10);


Now that I'm thinking about it, it would also be nice to be able to nest scopes:

Code: Select all
string {
   foreground: @orange;
   punctuation {
      foreground: lighten(@orange, 15);
   }
}


* The "solution" I currently use, is to create very dense scope definitions:

Code: Select all
{
    "name": "Green",
    "scope": "entity.name.class, entity.other.inherited-class, entity.name.function, entity.other.attribute-name, markup.inserted",
    "settings": {
        "foreground": "#A6E22E"
    }
}
quodlibet
 
Posts: 498
Joined: Sat Jun 18, 2011 5:53 pm

Re: Color Scheme Builder

Postby agibsonsw on Sat Jun 23, 2012 2:46 pm

Doesn't a theme file already, effectively, use a cascade? If you colour "entity.other" and also colour "entity.other.class" then this creates a cascade?
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

PreviousNext

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 8 guests