Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #5268

    tranglos
    Member

    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?

    #5269

    Yutaka Emura
    Keymaster

    tranglos 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.

    #5273

    tranglos
    Member

    This works great, thank you kindly!

    (Now, about that “replace in all open documents” request od mine… 🙂

    #5451

    Deipotent
    Participant

    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 ?

    #5452

    Peter
    Participant

    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.

    #5467

    Yutaka Emura
    Keymaster

    Deipotent 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.

    #5468

    Yutaka Emura
    Keymaster

    whileloop 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.

    #5473

    Deipotent
    Participant

    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.

    #5477

    lutz
    Member

    I 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 !! 🙂

    #5480

    Yutaka Emura
    Keymaster

    Deipotent 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.

    #5496

    shaohao
    Member

    I 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";
    #5498

    Yutaka Emura
    Keymaster

    Good job! 🙂

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

Share with friends... Tweet about this on TwitterShare on FacebookShare on Google+Email this to someone