Skip to main content



      Home
Home » Archived » Orion (Archived) » Editor Font Size(How to change orion's font size dynamically)
Editor Font Size [message #839692] Mon, 09 April 2012 00:10 Go to next message
Eclipse UserFriend
I am aware font size can be changed by modifying its value from "textviewContainer" CSS class. What I am interested in is changing font-size dynamically from JavaScript.

Is there any method for that?
Re: Editor Font Size [message #840056 is a reply to message #839692] Mon, 09 April 2012 12:04 Go to previous messageGo to next message
Eclipse UserFriend
Hi Joe,

The short answer is that you can use JavaScript, although there is no API specific for setting the font at the moment. A JavaScript call would modify the style sheet and alter the settings for that class.

If you check the settings page, you can use a user interface to change the size and color of the font. The programming behind that is in textStylerOptions.js

[ org.eclipse.orion.client >> bundles >> org.eclipse.orion.client.editor >> web >> examples >> textview >> textStylerOptions.js ]

Anton
Re: Editor Font Size [message #840231 is a reply to message #840056] Mon, 09 April 2012 16:59 Go to previous message
Eclipse UserFriend
Hi Anton,

Thanks for your reply.

Here is my snippet for those who may need change each setting separately.

var setSetting = (function(){
    var indexArray = [];
    var styleSheet = function (path) {
        for(var i = 0; i < doc.styleSheets.length; i++) {
            var sheet = doc.styleSheets[i];
            if(path.test(sheet.href)) 
                return sheet;
        }
        return null;
    }(/textview\.css/);
    if (!styleSheet) return false;

    const css = ".textviewContainer{%s}";
    return function(type, value) {
        if (indexArray[type])
            styleSheet.deleteRule(indexArray[type]);
        else
            indexArray[type] = styleSheet.cssRules.length;
            
        styleSheet.insertRule(css.replace("%s",  type + ": " + value + " !important"), indexArray[type]);
        textView.update(true);
        
        return true;
    }
})();

setSetting("font-family", "monospace");
setSetting("background-color", "white");
setSetting("font-size", "12pt");


"doc" and "textView" must be set before execution.

P.S:
The code has been just tested in Firefox browser.

[Updated on: Mon, 09 April 2012 17:05] by Moderator

Previous Topic:Editor problem with FF10.0.2
Next Topic:Key words auto suggestion
Goto Forum:
  


Current Time: Sat May 17 01:54:29 EDT 2025

Powered by FUDForum. Page generated in 0.03408 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top