Forum Replies Created

Viewing 22 posts - 1 through 22 (of 22 total)
  • Author
    Posts
  • in reply to: snippets indentation bug and question #7824
    dreftymac
    Participant

    The bugs do seem to be fixed in the latest version. Thanks.

    Is there a way to get snippets triggers to work without the snippets sidebar open?

    dreftymac
    Participant

    You can do this with HTMLTidy. It has a clean-up mode that works specifically for xml. To attach HTMLTidy into emeditor, just run it like a regular scripting tool against the file you are currently editing.

    in reply to: save files with a custom name #6792
    dreftymac
    Participant

    Save the following example to h1_rename.jsee in your macro directory. Then open an html file that you want to rename. Run h1_rename.jsee while that file is open and the output file will be saved (copied) with the new name in the same directory.


    // helper function that we use to put the entire text of a file in a string
    // **************************************************
    function string_fromfile(sUrl){
    var ForReading = 1, ForWriting = 2, ForAppending = 8;
    var fso, fob;
    try{
    fso = new ActiveXObject("Scripting.FileSystemObject");
    fob = fso.OpenTextFile(sUrl, ForReading);
    var strRead = fob.ReadAll();
    fob.Close();
    fso = null;
    return strRead;
    }
    catch(e){
    if(000){}
    else if(e.message == 'Input past end of file'){return '';} // blank file
    else if(e.message == 'File not found'){return ''} // not found
    else if(e.message != ''){return ''} // other problem
    };
    }

    // main code
    // **************************************************
    stext = (string_fromfile(document.FullName));
    smatch = '';

    // look inside the raw text and see if we can find something inside the h1 tag
    try{
    amatch = stext.match(/<h1>([^<]+)<.h1>/);
    smatch = amatch[1];
    }catch(ex){ smatch = '';}

    // did we actually find something inside the h1 tag?
    if(smatch != ''){
    // fix what we found so that unwanted characters get changed into a dash
    smatch = smatch.split(/[W]+/).join('-');
    // extract the parent directory and combine it with what we found to form a new filename
    newname = (document.FullName.split(/x5c/).slice(0,-1).join("x5c") + "x5c" + smatch + '.htm');
    // save a copy of the document with its new name
    document.Save( newname );
    }

    NOTE: Using this script could be cumbersome and annoying. The reason is because it would be tedious to open 100 files, one at a time, and then run this macro against the file. Therefore, you may want to modify this macro to loop through the directory, grab all the names and save the files. Another problem, however, is it may be annoying and cumbersome to have a script open EmEditor to do this.

    Therefore, the easiest way to accomplish this task may be simply to write a WSH script file and have it process the files in a without using EmEditor to do it. That’s probably how I would do it anyway.

    Nevertheless, you asked for an example and there it is!

    in reply to: FYAT… Find-As-You-Type for "Core" feature? #6790
    dreftymac
    Participant

    Greetings cjkawe,

    Here are some quick points:

    1) Generally, you do not have to duplicate a post in multiple parts of the forum. The EmEditor home page shows all recent posts regardless of the specific forum sub-area. One post should be enough for someone to catch your question eventually.

    2) EmEditor has the Highlight all feature, and there is also a “FindBar” plugin. I tried the FindBar plugin only once and then never tried it again, therefore I don’t have any details but you can try it yourself and see if it meets your requirements. For more details on the feature that works similar to Firefox CTRL+F, search for the following items in EmEditor help:

    — “highlight previously searched strings”
    — “HighlightFind Property”
    — “Erase Find Highlight command”

    If you include the double-quotes, the CHM help file will know you are searching for these exact phrases.

    in reply to: Request: Code Hinting #6774
    dreftymac
    Participant

    There are already a few options available in EmEditor:

    1) have you had a chance to look at the autocomplete plugin?

    2) have you had a chance to look at the wordcomplete plugin?

    One or both of these may come close enough to what you are looking for. If not, you might still be able to design something like this yourself using regular EmEditor macros, specifically with the “popup” menu feature therein.

    3) have you had a chance to see if macros can do this for you?

    I’ve already implemented a version of “dynamic snippets” that pretty much does exactly what you describe (unless I misunderstood you). The user types in a word and then presses tab key (or other shortcut key), and a snippet comes up based on that trigger word. If there is more than one snippet that has that trigger word as a substring, a menu appears to let the user pick which one they want to insert.

    For more details of what it looks like, watch the videos at:

    http://www.emeditor.com/modules/newbb/viewtopic.php?topic_id=965&forum=2

    in reply to: Feature request: Outlining/highlighting nested blocks #6768
    dreftymac
    Participant

    This is a pretty interesting idea. Have you ever seen something like this actually implemented in a text editor before? The closest I have seen is “outlining” and “folding” which EmEditor already has.

    http://en.wikipedia.org/wiki/Code_folding

    in reply to: Can we insert the content of a jsee file in a jsee file? #6765
    dreftymac
    Participant

    You can still do what you want if you make sure that standard.jsee encloses its code in a javascript function or a javascript class definition.

    For example:

    function say_hello(name){
    return “hello world from ” + name + ” ! ” ;
    }
    // filename = say_hello.jsee

    #include “say_hello.jsee”

    var name = ’emeditor’;
    alert(say_hello(name));

    name = ’emacs??’;
    alert(say_hello(name));

    name = ‘vim??’;
    alert(say_hello(name));

    The #include feature of EmEditor is powerful enough to allow you to ‘insert’ code wherever you want as long as the code you are ‘inserting’ is correctly enclosed in a function or class, then you use the function or class to invoke the code you want to run at the exact place where you want to run it.

    in reply to: Customizable configuration order #6681
    dreftymac
    Participant

    Greetings wdscxsj,

    In case you had not already considered it, or in case anyone else reading this would like to know, another alternative would be to write a macro that you assign to a shortcut key, and the macro could contain only those configurations that you use on a regular basis.

    If you use the CreatePopupMenu Method, you can pretty easily create a list that contains only those configurations that you use regularly, and just have that menu create the new document. The nice thing about this is that you can edit the macro any time you like if you want to change the contents or the ordering of the list.

    in reply to: Code auto format (pretty-print) plugin #6680
    dreftymac
    Participant

    Greetings Maxim,

    This can be done very easily with a macro if you have a parser or processor that can be run from the Windows command line against a file via your own custom function.

    For example, you can pass the currently selected text to a function that cleans up the code for whatever default syntax you are using.


    mysyntax = document.ConfigName;
    mycode = document.selection.Text;
    myresult = MyCleanupSyntax(mysyntax,mycode);
    document.selection.Text = myresult;

    The hard part will be finding a code-formatter that you can plug into your MyCleanupSyntax function. I am sure there are plenty available for Java-style syntax.

    in reply to: Are there onKeyPress, onMouseClick or somethike like those ? #6656
    dreftymac
    Participant

    I don’t know if there is a way to trigger a macro with a mouse click, but you can trigger a macro using a keyboard shortcut. You can also use a single keyboard shortcut to trigger multiple choices for the user, so you do not have to restrict your macro to doing just one “action”.

    The following example uses the document.selection and the CreatePopupMenu function inside a jsee macro. The popup menu gives the user multiple choices before displaying the result.


    var vtext = document.selection.Text;
    var result = '';
    var menu = CreatePopupMenu();
    menu.Add( "look north", 1 );
    menu.Add( "look south", 2 );
    menu.Add( "look east", 3 );
    result = menu.Track( 0 );
    if( result != 0 ) {
    result = ( menu.GetText( result ) );
    }
    Window.alert([result,vtext].join(' '));
    in reply to: EmEditor window redraw and "jittery" text and phantom scrollbar #6638
    dreftymac
    Participant

    Ok, the issue is resolved. The issue was apparently caused by the Outline plugin.

    The plugin was enabled with the option to display outline when the outline pane is closed. The problem can be solved by turning off the outline plugin or enabling outline only when the side pane is open.

    Thanks for your help.

    in reply to: macro to convert content to html? #6625
    dreftymac
    Participant

    Although this is not an example of converting html, it is an introduction to the “Run” feature of the windows scripting host:

    var shell = new ActiveXObject(“WScript.Shell”);
    shell.Run(“”C:Program FilesInternet ExplorerIExplore.exe”http://www.emeditor.com&#8221;);

    This example will work on most systems to open MSIE. You can paste this into an EmEditor macro file and run it. The important point is that all macros in EmEditor are also scripts that you can run in regular Windows. This is useful because it means anything you can do from Windows, you can do it from inside EmEditor also.

    An example for converting html could be to create a macro that runs HTMLTidy against the currently-focused document in EmEditor, where you just pass the path to HTMLTidy and the path of the current document to EmEditor.

    For those who are not programmers, but willing to learn a little bit about Windows Scripting in order to get more out of EmEditor macros, a good thing to try is a search on your favorite search engine:

    “What is WSH”

    or

    “What is Windows Scripting Host”

    If you are familiar with EmEditor macros, you are already familiar with WSH, so you may want to take a moment to read some of the tutorials and the reference from Microsoft.

    http://cwashington.netreach.net/
    http://msdn.microsoft.com/en-us/library/98591fh7.aspx

    dreftymac
    Participant

    For this feature to be useful (to me anyway), all that would be needed is for EmEditor to check the “program root” directory for the file:

    C:\%root_directory_of_emeditor_exe\%eeCommon.ini

    and if the file is not found there, EmEditor could check:

    C:\%root_directory_of_emeditor_exe\%settingseeCommon.ini

    If the file is found in either of these two locations, EmEditor can assume the ini files are being used. If the file is *not* found in either of these two locations, EmEditor can assume the Registry. Using this approach would require only the small change to EmEditor that it checks in two places instead of just one.

    Of course, some windows applications also check in the “Documents and Settings” folder of the currently-logged-in user for windows, but I don’t need anything that fancy. All that’s needed (for me) is just a way to save the ini files in some directory besides the EmEditor program root without breaking the “use INI files” feature. If this directory is “hard coded” into EmEditor, that’s not a problem, just as long as its documented somewhere so I will know where I can put the ini files.

    Thanks for your reply and for considering this idea, best regards.

    in reply to: macro to convert content to html? #6615
    dreftymac
    Participant

    That makes sense. Just as a reminder (to others who may read this, in case you already know) EmEditor allows you to create a macro that runs an external script as well. This is a built-in feature of windows scripting host.

    You can mix EmEditor macro code with the code that someone else has written so that you never have to leave the editor to do anything you want. This means you never actually have to write custom code (ulness you prefer to do so of course).

    This aspect of EmEditor (direct support for windows scripting host) is really powerful, and as far as I have seen, unique for windows editors. Even editors that support macro scripting don’t usually integrate with the windows scripting host.

    It does get a little tricky if you try to use Ruby or Python ActiveScript engines, but the built-in javascript and vbscript support seems to work very well.

    in reply to: macro to convert content to html? #6612
    dreftymac
    Participant

    You might want to try a script that is designed for this purpose. One example is txt2tags.

    http://en.wikipedia.org/wiki/Txt2tags

    in reply to: ExtractLinesContain.jsee question #6524
    dreftymac
    Participant

    Hello nickb,

    Try taking the line that says:

    re = new RegExp( “.*” + sFind + “.*” );

    … and change it to this …

    re = new RegExp( “.*” + sFind + “.*” , “i”);

    This should tell the regular expression matcher to ignore case.

    For more details see :
    http://www.regular-expressions.info/javascript.html
    or search microsoft.com for “jscript reference” “regexp”

    HTH

    in reply to: screen resolution problems with output bar #6489
    dreftymac
    Participant

    Greetings Yutaka,

    Here are the screen resolutions:
    screen one: 1280 by 1024
    screen two: 1024 by 768

    Here is a step by step description to explain the issue:

    – start up your computer and open up EmEditor
    – resize EmEditor so it takes up the entire screen

    – create a script file that outputs a long list of results
    (e.g., try a ruby script –> 500.times{ puts “hello world” })
    – run the script file in EmEditor, and make the output go to the
    output bar.
    – notice how EmEditor looks when you get the results, if you have
    enough space, you will be able to see the output bar and resize
    it using the mouse.

    – now, close the output bar and resize EmEditor window so it only takes
    up 10\% of the screen. Then, run the same ruby script again, sending
    the output to the output bar again.

    – notice: this time, the top of the output bar is not visible. All that
    can be seen is the output itself (the buffer tabs are now hidden
    beneath).

    – It is possible to close the output bar using the ESCAPE key, but it
    is now not possible to resize the output bar to make the buffer
    tabs visible. The only way to deal with this is to resize the
    EmEditor window.

    The problem is, you cannot resize the EmEditor window if you have
    changed to a screen with a smaller resolution. (e.g, you started the
    document on your work computer, but you change to a different
    machine with a smaller screen or a laptop).

    Thank you for taking a moment to respond at this time, best wishes to you.

    dreftymac
    Participant
    You can use QueryStringByID Method to figure out which plug-in corresponds to which ID

    Yes, thank you for this, but that was not actually the question. The question is not how to run any plugin, but the question was how to run any specific *command* inside of any specific plugin.

    For example:


    /// we know we can do this for any plugin ...
    var idd = 5637; /// QueryStringByID found this for us
    editor.ExecuteCommandByID(idd); /// activate the "outline" plugin

    /// but can you do *this* for any plugin ...
    /*
    var oPlugin = editor.GetPluginByID(idd); /// <-- how can you do this?
    oPlugin.doCommand('CollapseAll'); /// <-- or this?
    oPlugin.doCommand('ExpandAll'); /// <-- or this?
    oAnyPlugin.doCommand('AnyCommandYouWant'); /// <-- or even this?
    */
    in reply to: Add a few more items to make EmEditor pure genius #6380
    dreftymac
    Participant

    Hi Stefan,

    The Snippets “grid” control requires a snippet with
    “fill in the blank” parameters. If you define one, you
    will see the GUI.

    Here are the steps to reproduce:

    * Open the Snippets plugin window on the side
    * Create a new snippet using “New Text” as usual
    * Type in the following text for your new snippet:

    Hello {fname} {lname}! You are {age} years old!

    * Now insert the snippet into your text as usual, when
    you do you will see a special surprise! :-D This is
    described in better detail under the snippets plugin
    help screen.

    What would be nice is if you could call this from a Macro
    and have the macro get its arguments from this little GUI.

    in reply to: Add a few more items to make EmEditor pure genius #6352
    dreftymac
    Participant

    Yes, the Snippets Grid control would be great if you could instantiate it from a macro, just like the built-in “prompt” control.

    That way, a macro could prompt for more than one variable from the user, without requiring the use of multiple prompt dialogs, one per variable.

    in reply to: How to use "Object"? #6349
    dreftymac
    Participant

    In Java_script:


    var myobject = document.Config.General;
    Window.alert(myobject.WrapMode);

    This is not documented very well, but if you do a little digging, you will see in

    EmEditor Home – EmEditor Help – History – Version 7

    “The Config property was added to the Document Object. “

    further down you will see that Configs is attached to the Editor Object.

    The *General* corresponds to the *GeneralProp* Object. It appears to be a naming convention used by the developer.

    *FoobarProp* Object in the docs => just *Foobar* in your code

    The developer also uses “object” as a general convention in the documentation without always spelling out what the specific object actually is. That’s fine if your goal is to get the documentation done quicker, but not so great if you’re trying to learn from the docs :)

    in reply to: How to use "Object"? #6347
    dreftymac
    Participant

    Greetings Stefan,

    This could be documented a little better, because the “object” designation is a little vague. Please take a look at the documentation for

    “Config Object”

    In EmEditor help. This explains a little bit more to help you do what you are trying to do. There is an example in the documentation that shows how to loop through editor.Configs, you can modify that example slightly as shown below:

    cfgs = new Enumerator( editor.Configs );
    for( ; !cfgs.atEnd(); cfgs.moveNext() ){
    cfg = cfgs.item();
    alert( cfg.Name );
    alert( cfg.General.WrapMode ); /// <— this uses the GeneralProp object
    }

    This is in Javascript, but there is a VB example in the documentation as well. The documentation could use some improvements, but since this is a closed-source software I don’t know if users are allowed to make updates, or whether there is a wiki or something like that. If there is hopefully someone will link to it, as that would help a lot.

    Cheers,

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