Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4253

    BSI
    Member

    I downloaded tagger.zip and extracted files to the Plugins folder. The result is a set of plugins in the Tools->Plugins area. I assigned some of them to keyboard shortcuts. When I run them as keyboard shortcuts, they do tag the selected text (for instance, as selected text. However, after the plugin is run, the cursor bounces up several lines. Is that common? Is there a way to avoid it?

    #4254

    Yutaka Emura
    Keymaster

    I reproduced this issue. It works fine when “No Wrap” is selected for “Wrap by” (you can select on the toolbar, or on the General tab of the Properties for Current Configuration). However, I am not the author of these plug-ins, and so I cannot fix them.

    You can probably do the same thing by writing a macro, and you can assign the macro to any keyboard shortcut.

    #4255

    BSI
    Member

    You’re so right! Thank you for demystifying the use of the plugin. I just downloaded emeditor, so I’m not sure how to accomplish a macro that sees the beginning/end of a selection and inserts characters at each end.

    #4257

    Yutaka Emura
    Keymaster

    Try this:

    document.selection.Text = "<b>" + document.selection.Text + "</b>";

    You can save this one line macro as something like “bold.jsee”. Then while this file is still active, click “Select This” on the Macros menu. When you open an HTML file, select text and click “Run Macro” on the toolbar or press F4. If you have multiple macros, you can assign keyboard shortcut from Keyboard Map on the Help menu.

    #4260

    Vlad
    Member

    We can do better than installing a dozen plugins or macros. The Execute Extension plugin can be configured to insert tags, but configuring it is a pain. Here is a script version of tagger, it generates popup menu with tags to insert:


    // TAGGER.JSEE -- tagger and clip library, inserts strings around selected text or at the cursor.
    // Usage: modify tables of tags at the start of file as you see fit.
    // To add tags for other configurations: add new tables of tags and edit switch statement at the end.

    // format: [string to insert before selection, string to insert after selection, optional menu label]
    ////////////////////////////////
    HTML_TAGS = [
    ['<br>', '', ''],
    ['<p>', '</p>', ''],
    [' ', '', 'space'],
    ['', '<hr>', ''],
    ['<!-- ', ' -->', 'comment'],
    ['', '', '-----------'], //menu separator
    ['<b>', '</b>', 'bold'],
    ['<i>', '</i>', 'italic'],
    ['<u>', '</u>', 'underline'],
    ['<pre>', '</pre>', ''],
    ['<blockquote>', '</blockquote>', 'blockquote'],
    ['<big>', '</big>', 'big'],
    ['<small>', '</small>', 'small'],
    ['<sup>', '</sup>', 'superscript'],
    ['<sub>', '</sub>', 'subscript'],
    ['<center>', '</center>', 'center'],
    ['', '', '-----------------'],
    ['<a href=#>', '</a>', 'Link'],
    ['<a name=>', '</a>', 'Mark'],
    ['<img src="" alt="" width="" height=>', '', 'Image'],
    ['', '', '--------------'],
    ['<table>', '</table>', 'table'],
    ['<tr>', '</tr>', ''],
    ['<td>', '</td>', ''],
    ['<ul>n', 'n</ul>', 'unorderd list'],
    ['<ol>n', 'n</ol>', 'orderd list'],
    ['<li>', '', ''],
    ['<dl>n', 'n<dl>', 'definition list'],
    ['<dt>', '', ''],
    ['<dd>', '', ''],
    ['', '', ''], //these are ignored
    ['', '', ''],
    ['', '', ''],
    ['', '', '']
    ];
    ////////////////////////////////
    TEXT_TAGS = [
    ['Dear Collector:', '', ''],
    ['I would like to sell my kidney.', '', ''],
    ['Which way is to the soup kitchen?', '', ''],
    ['', '', ''],
    ['', '', '']
    ];
    ////////////////////////////////
    UNIVERSAL_TAGS = [ //these should always be available
    ['', '', '--------------------'],
    ['/*', '*/', '/**/'],
    ['u03B2', '', 'beta'],
    ['', '', '']
    ];
    /////////////////////////////////////////////////////////////////
    function createMenu(tags) {
    tags = tags.concat(UNIVERSAL_TAGS);
    menu = CreatePopupMenu();
    //populate menu
    L = tags.length;
    for (i=0; i<L; i++) {
    if (tags[i].length!=3 || (tags[i][0]=="" && tags[i][1]=="" && tags[i][2]=="")) continue;
    if (tags[i][2].slice(0,6)=="------")
    menu.Add( '', 0, eeMenuSeparator );
    else
    menu.Add( tags[i][2] || tags[i][0] || tags[i][1], i+1 );
    }
    //display menu
    result = menu.Track(0);
    //insert tags
    if (result!=0) insertTags(tags[result-1][0], tags[result-1][1]);
    }

    function insertTags(text_before, text_after) {
    document.selection.Text = text_before + document.selection.Text + text_after;
    // to do: restore selection
    }

    switch( document.ConfigName ) {
    case("HTML"):
    createMenu(HTML_TAGS);
    break;
    case("Text"):
    createMenu(TEXT_TAGS);
    break;
    default:
    createMenu(HTML_TAGS);
    }
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.