- AuthorPosts
- January 7, 2008 at 1:22 am #5268tranglosMember
Very often I need to ensure that a string does not exceed a particular length.
To this end it would be very helpful if EmEditor would display current selection length in the status bar, next to the cursor position field. I hoped this option would already be available in Customize -> Status, but it isn’t. Could this be added, please?
January 7, 2008 at 4:42 am #5269Yutaka EmuraKeymastertranglos wrote:
Very often I need to ensure that a string does not exceed a particular length.To this end it would be very helpful if EmEditor would display current selection length in the status bar, next to the cursor position field. I hoped this option would already be available in Customize -> Status, but it isn’t. Could this be added, please?
Use the following macro:
SelLength.jsee:
status = "Selection: " + document.selection.Text.length + " characters.";
and run this macro when you want to find the selection length. Or, even better, set this macro run at the event of selection changed. To do this, select Customize on the Macros menu, in the My Macros tab, select this macro (SelLength.jsee) in the list, check Runs at Events, click Events button, and check Selection Changed.
January 7, 2008 at 2:26 pm #5273tranglosMemberThis works great, thank you kindly!
(Now, about that “replace in all open documents” request od mine… :)
February 16, 2008 at 12:41 am #5451DeipotentParticipantI set the delay time to 0.0 seconds, and there is still a delay before the status bar is updated. Is this a bug ?
I would also like it to show the number of lines in the selection. Is this possible ?
BTW, the documentation does not mention about the length property. Where can I find an up-to-date reference for all objects and properties ?
February 16, 2008 at 7:35 am #5452PeterParticipantIt would be better if it can be put in a field on the right side of the status bar. So that it will not block other status messages.
February 18, 2008 at 7:58 pm #5467Yutaka EmuraKeymasterDeipotent wrote:
I set the delay time to 0.0 seconds, and there is still a delay before the status bar is updated. Is this a bug ?I would also like it to show the number of lines in the selection. Is this possible ?
BTW, the documentation does not mention about the length property. Where can I find an up-to-date reference for all objects and properties ?
The status bar is updated when EmEditor becomes idle, so it is not a bug. You can certainly include the number of lines in the selection. I will write the code if you would like me to. length property is not a property of EmEditor objects, rather it is a property of string object in JavaScript. JavaScript is a popular script language, and so you can find the reference in Web sites or in many books. Search for “JavaScript string length” in Google.
February 18, 2008 at 8:00 pm #5468Yutaka EmuraKeymasterwhileloop wrote:
It would be better if it can be put in a field on the right side of the status bar. So that it will not block other status messages.Unfortunately, it is not possible to put in a field on the right side of the status bar with the current version of EmEditor.
February 18, 2008 at 8:15 pm #5473DeipotentParticipantIs there no way of making it update immediately ?
If not, can you consider adding this ability, or have a separate option to display the number of bytes and lines in a selection on the status bar.
February 19, 2008 at 2:44 am #5477lutzMemberI am not sure if I fully understand the discussion.
But a display of the size of the current selection in the status bar would surely be really nice !! :-)February 19, 2008 at 7:47 am #5480Yutaka EmuraKeymasterDeipotent wrote:
Is there no way of making it update immediately ?If not, can you consider adding this ability, or have a separate option to display the number of bytes and lines in a selection on the status bar.
How many seconds do you have to wait until the status bar is updated with the correct number of bytes? It should be within a few seconds. If not, there might be something wrong with EmEditor.
February 23, 2008 at 1:58 pm #5496shaohaoMemberI just wrote a more complex Macro for the selected text status.
anchorX = document.selection.GetAnchorPointX(eePosLogical);
anchorY = document.selection.GetAnchorPointY(eePosLogical);
activeX = document.selection.GetActivePointX(eePosLogical);
activeY = document.selection.GetActivePointY(eePosLogical);
lines = 0;
chars = document.selection.text.length;
if ( chars != 0) { // really select something
if ( activeY > anchorY) {
lines = activeY - anchorY + 1;
if ( activeX == 1) lines--;
} else if ( activeY < anchorY) {
lines = anchorY - activeY + 1;
if ( anchorX == 1) lines--;
} else /* activeY == anchorY */ {
lines = 1;
}
}
status = "Selected: " + lines + "lines, " + chars + " chars";
February 23, 2008 at 7:53 pm #5498Yutaka EmuraKeymasterGood job! :-)
- AuthorPosts
- You must be logged in to reply to this topic.