EmEditor (text editor) Forum Index
   Questions and Answers about Macros
     Toggling Line Number via Macro?
Register To Post

Threaded | Oldest First Previous Topic | Next Topic | Bottom
Poster Thread
ToadLoadin
Posted on: 3/23/2011 12:03 am
Just can't stay away
Joined: 7/4/2008
From: China
Posts: 119
Re: Toggling Line Number via Macro?
Yes, it works! Thank you!

Quote:

Yutaka wrote:
Hi ToadLoadin,

You should write like this:

function toggleLineNum() {
    var cfg = document.Config;
    var isLineNumOn = cfg.General.ShowLineNumbers;
    cfg.General.ShowLineNumbers = !isLineNumOn;
    cfg.Save();
}

Yutaka
Posted on: 3/22/2011 9:39 pm
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2404
Re: Toggling Line Number via Macro?
Hi ToadLoadin,

You should write like this:

function toggleLineNum() {
    var cfg = document.Config;
    var isLineNumOn = cfg.General.ShowLineNumbers;
    cfg.General.ShowLineNumbers = !isLineNumOn;
    cfg.Save();
}


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

ToadLoadin
Posted on: 3/22/2011 9:06 pm
Just can't stay away
Joined: 7/4/2008
From: China
Posts: 119
Re: Toggling Line Number via Macro?
Hi Yutaka,

I rewrote my function to this:
function toggleLineNum() {
    var cfg = document.Config;
    var isLineNumOn = document.Config.General.ShowLineNumbers;
    document.Config.General.ShowLineNumbers = !isLineNumOn;
    cfg.Save();
}


but it still does not work...

Quote:

Yutaka wrote:
Hi ToadLoadin,

This is a frequently asked question. Please use Save() when you finished settings:


cfg = document.Config;
/// do something
cfg.Save();


Of course, you can use the EmEditor command "Line Number", and there is a toolbar button for this command.
ToadLoadin
Posted on: 3/22/2011 12:57 am
Just can't stay away
Joined: 7/4/2008
From: China
Posts: 119
Re: Toggling Line Number via Macro?
Thank you webern and Yutaka!
Yutaka
Posted on: 3/21/2011 7:57 am
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2404
Re: Toggling Line Number via Macro?
Hi ToadLoadin,

This is a frequently asked question. Please use Save() when you finished settings:


cfg = document.Config;
/// do something
cfg.Save();


Of course, you can use the EmEditor command "Line Number", and there is a toolbar button for this command.


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

webern
Posted on: 3/21/2011 7:07 am
Not too shy to talk
Joined: 11/23/2006
From: Moscow, Russia
Posts: 38
Re: Toggling Line Number via Macro?
To toggle Line Numbers via a macro you can use just this command alone:
editor.ExecuteCommandByID(4530);

ToadLoadin
Posted on: 3/21/2011 5:09 am
Just can't stay away
Joined: 7/4/2008
From: China
Posts: 119
Toggling Line Number via Macro?
Hi,

I want to toggle line number on/off via macro, so I wrote this function:

function toggleLineNum() {
    var isLineNumOn = document.Config.General.ShowLineNumbers;
    document.Config.General.ShowLineNumbers = !isLineNumOn;
}


But nothing chages while invoking this function, any advice?
Threaded | Oldest First Previous Topic | Next Topic | Top


Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文