EmEditor (text editor) Forum Index
   Questions and Answers about EmEditor Core
     Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
ArthurZ
Posted on: 1/10/2013 8:49 am
Just can't stay away
Joined: 1/26/2012
From:
Posts: 78
Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
I am thinking why not allowing commenting a line of code where the cursor currently is on?

Right now the Comment/Uncomment functionality becomes enabled only when line(s) are selected and this is small but un-needed limitation IMO.
Yutaka
Posted on: 1/10/2013 6:27 pm
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2397
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Hello,

Since these commands are in the "Convert Selection" sub menu of the Edit menu, I wanted to make them work same as other commands in the same sub menu. If I allowed these commands to work when unselected, I would have to allow all other commands to work when unselected.

Thanks for your inputs!


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

ArthurZ
Posted on: 1/11/2013 6:27 am
Just can't stay away
Joined: 1/26/2012
From:
Posts: 78
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
I see, but in my case I placed the Comment-Uncomment pair onto the toolbar.

Therefore IMHO, this limitation should not be in this case.

PS: This useful command (I use very often) is buried too deep in the menus, I suggest to elevate it.
Yutaka
Posted on: 1/11/2013 8:47 am
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2397
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Hello,

How about a macro like this:

[JavaScript]
if( document.selection.IsEmpty ){
	editor.ExecuteCommandByID(4154);
}
editor.ExecuteCommandByID(4371);


This macro will comment out the selection if the selections exists, or comment the current line if the selection does not exist.

Thanks!


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

ArthurZ
Posted on: 1/11/2013 9:27 am
Just can't stay away
Joined: 1/26/2012
From:
Posts: 78
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Probably you meant it will comment in either case. At least the code does this. And I think it would be nice to enhance the functionality so if the comment is already there - uncomment - thus toggling the comments on/off.
Yutaka
Posted on: 1/13/2013 8:49 am
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2397
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
You are right; the above code was to comment in all cases.

To toggle the comment, it will a little more complicated. To uncomment in all cases, here is the code:

if( document.selection.IsEmpty ){
	editor.ExecuteCommandByID(4154);
}
editor.ExecuteCommandByID(4372);


Thanks!


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

ArthurZ
Posted on: 1/13/2013 4:59 pm
Just can't stay away
Joined: 1/26/2012
From:
Posts: 78
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Not quite there, but the following variation is almost what I need, how to un-select a line?

if( document.selection.IsEmpty )
{ 	
// highlight select and comment 

editor.ExecuteCommandByID(4154); 	editor.ExecuteCommandByID(4371); 
} 
else
{     
// uncomment 	
editor.ExecuteCommandByID(4372); 
}
mguttman
Posted on: 1/14/2013 12:27 am
Just can't stay away
Joined: 11/14/2009
From: Ashdod, Israel
Posts: 76
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Hi!

IMHO this macro just UN-comments an already commented-out text. It didn't comment out any un-commented one, or am I missing something?


----------------
Regards,
Meir

ArthurZ
Posted on: 1/14/2013 5:33 am
Just can't stay away
Joined: 1/26/2012
From:
Posts: 78
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Hello Meir,

It highlights and comments out a line of code (even if it was commented out already). You need to just position the cursor within the line.

While the cursor is still on the same (just commented) line it un-comments it.
mguttman
Posted on: 1/15/2013 3:35 am
Just can't stay away
Joined: 11/14/2009
From: Ashdod, Israel
Posts: 76
Re: Why Comment/Uncomment Functionality Becomes Enabled Only When Line(s) Selected?
Dear Arthur,

I agree with you, but when one or more lines are SELECTED, nothing happens! No commenting-out!

Is this last behavior planned? If so, what should I add to have it comment out a bunch of selected lines?


----------------
Regards,
Meir

(1) 2 »
Threaded | Newest First Previous Topic | Next Topic | Top


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