ActiveState Powered by ActiveState

ActiveState Community


Fold margin colors

Posted by airdrik on 2008-05-14 10:08
OS: Windows

Is there a way to customize the fold margin colors (in komodo 4.3 on winXP 64)?

ToddW | Wed, 2008-05-14 10:43

There is no UI preference for setting the fold margin colors, but there is a way to do this through the Komodo JavaScript API. Create a new JavaScript macro in Komodo's toolbox named "set margin color" with the following code contents:

// Note that the color value is BGR, not RGB!
ko.views.manager.currentView.scimoz.setFoldMarginColour(1, 0x0000FF);
// Note that the color value is BGR, not RGB!
ko.views.manager.currentView.scimoz.setFoldMarginColour(1, 0x0000FF);

Triggering this macro will change the color of the margin. You can find out more Scintilla (scimoz) api methods here:
http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_SETFOLDMARGINCOLO...

Cheers,
Todd

airdrik | Wed, 2008-05-14 12:18

That works for the background of the folds (which you need the following to produce a solid color, for the record:

ko.views.manager.currentView.scimoz.setFoldMarginColour(1, 0x400000)
ko.views.manager.currentView.scimoz.setFoldMarginHiColour(1, 0x400000)

)

I would also like to be able to change the colors of the fold markers (the lines on the fold margin indicating collapsible areas) as well. Any ideas?

ToddW | Wed, 2008-05-14 13:55

These are actual images (in xpm format), so you'll need to create your own images for this purpose, see:
http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_MARKERDEFINE
http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_MARKERDEFINEPIXMA...

The existing fold markers can be selected in the Komodo UI through Komodo's "Editor->Smart Editing->Folding" preferences.

Cheers,
Todd

airdrik | Thu, 2008-05-15 07:10

Thanks for the quick responses. I'll take a look.

Where can I find the current set of images? Would I be correct in assuming they are in one of the jars or archives somewhere?
I would like something to base my images off of.

ToddW | Thu, 2008-05-15 08:59

After examing marker the code "LineMarker::Draw" in:
http://svn.openkomodo.com/openkomodo/view/openkomodo/trunk/contrib/scint...

These fold markers are just drawn in directory as blocks/glyphs and as such do not have an xpm image.

It seems you should be then able to set the marker color using the following API methods:
http://scintilla.sourceforge.net/ScintillaDoc.html#SCI_MARKERSETFORE

/**
 * @type {Components.interfaces.ISciMoz}
 */

var scimoz = ko.views.manager.currentView.scimoz;
// Note that the color value is BGR, not RGB!
scimoz.markerSetBack(scimoz.SC_MARKNUM_FOLDER, 0xFFFFFF);
scimoz.markerSetFore(scimoz.SC_MARKNUM_FOLDER, 0x000000);
// Or you may want to just set all the marker types in one go:
for (var i=0; i <= scimoz.MARKER_MAX; i++) {
  scimoz.markerSetBack(i, 0xFFFFFF);
  scimoz.markerSetFore(i, 0x000000);
}
/**
 * @type {Components.interfaces.ISciMoz}
 */
var scimoz = ko.views.manager.currentView.scimoz;
// Note that the color value is BGR, not RGB!
scimoz.markerSetBack(scimoz.SC_MARKNUM_FOLDER, 0xFFFFFF);
scimoz.markerSetFore(scimoz.SC_MARKNUM_FOLDER, 0x000000);
// Or you may want to just set all the marker types in one go:
for (var i=0; i <= scimoz.MARKER_MAX; i++) {
  scimoz.markerSetBack(i, 0xFFFFFF);
  scimoz.markerSetFore(i, 0x000000);
}

Is that working for you?

Cheers,
Todd

airdrik | Thu, 2008-05-15 13:45

Perfect, thanks.

On _FOLDER, _FOLEROPEN, _FOLDEROPENMID, and _FOLDEREND, the setting the foreground sets the fill color.
Setting the background on all of them will set the (out)line color.

-->