Search code examples
emeditor

Macro to Toggle Alternate Colour Rows


The ability to set different colour rows is great, but would it be possible to set this temporarily on/off any file (so it can then potentially be assigned to a button that could be toggled on the menu bar)? The ability to do something similar to the Hide Quotes Temporarily button would be great.


Solution

  • You can run the following macro.

    r = 255;   // red of even number background
    g = 255;   // green of even number background
    b = 128;    // blue of even number background
    rgbCustom = r + (g << 8) + (b << 16);
    cfg = document.Config;
    mode = cfg.Display.ColorList.Item( 100 ).BackMode;   // get Background Mode of 100th color (even lines)
    if( mode == 2 ) {   // 2 : Transparent
        cfg.Display.ColorList.Item( 100 ).BackMode = 0;  // set Background Mode as Custom
        cfg.Display.ColorList.Item( 100 ).BackColor = rgbCustom;  // set Background color
    }
    else {
        cfg.Display.ColorList.Item( 100 ).BackMode = 2;  // set Background Mode as Transparent, don't care Background color
    }
    cfg.Save();
    

    To run this, save this code as, for instance, ToggleAlternateColour.jsee, and then select this file from Select... in the Macros menu. Finally, select Run ToggleAlternateColour.jsee in the Macros menu.

    To assign this macro as a button in the basic toolbar, you can double-click the basic toolbar (or select Customize Toolbars on the Tools menu, select Untitled (Toolbar 1) in the Basic Toolbars list, and click Customize). In the Customize Toolbar dialog box, find ToggleAlternateColour.jsee from the left list box, and click Add.