Changeset 24377

Show
Ignore:
Timestamp:
11/20/08 04:05:19 (7 weeks ago)
Author:
anekos
Message:

for 2.0pre

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/multi_requester.js

    r24371 r24377  
    1111 * 
    1212 * Usage: 
    13  *   command[!] subcommand [ANY_TEXT | -s] 
     13 *   command[!] subcommand [ANY_TEXT] 
    1414 * 
    1515 *     !                create new tab. 
    1616 *     ANY_TEXT         your input text 
    17  *     FLAGS: 
    18  *       -s             use selected text 
    19  * 
    20  *   :mr  alc ANY_TEXT  -> request by the input text, and display to the buffer. 
    21  *   :mr! goo -s        -> request by the selected text, and display to the new tab. 
     17 * 
     18 *   :mr  alc ANY_TEXT           -> request by the input text, and display to the buffer. 
     19 *   :mr! goo {window.selection} -> request by the selected text, and display to the new tab. 
    2220 * 
    2321 * 
     
    5452 *       [',ml', 'ex'],                  // == :mr  ex 
    5553 *       [',mg', 'goo', '!'],            // == :mr! goo 
    56  *       [',ma', 'alc',    , 'args'],    // == :mr  alc args (however, it uses a selected_text with precedence.) 
     54 *       [',ma', 'alc',    , 'args'],    // == :mr  alc args 
    5755 *   ]; 
    5856 *   EOM 
     
    190188                "user defined mapping", 
    191189                function() { 
    192                     var str = $U.getSelectedString() || args || ''; 
    193                     if (str.length) { 
    194                         liberator.execute(cmd + str); 
     190                    if (args) { 
     191                        liberator.execute(cmd + args); 
    195192                    } else { 
    196                         commandline.open(':', cmd, modes.EX); 
     193                        let sel = $U.getSelectedString(); 
     194                        if (sel.length) { 
     195                            liberator.execute(cmd + sel); 
     196                        } else { 
     197                            commandline.open(':', cmd, modes.EX); 
     198                        } 
    197199                    } 
    198200                }, 
     
    465467    name: DataAccess.getCommand(), 
    466468    description: 'request, and display to the buffer', 
    467     cmdOptions: [ 
    468         [['-s'], liberator.OPTION_NOARG] 
    469     ], 
    470469    cmdAction: function(args, special, count) { 
    471470 
     471        args = args.string; 
    472472        var parsedArgs = this.parseArgs(args); 
    473473        if (!parsedArgs || !parsedArgs.siteinfo || !parsedArgs.str) { return; } // do nothing 
     
    510510        if (!args) return null; 
    511511 
    512         var isOptS = args.hasOwnProperty('-s'); 
    513         if ((isOptS && args.arguments.length < 1) || (!isOptS && args.arguments.length < 2)) return null; 
    514  
    515         var siteName = args.arguments.shift(); 
    516         var str = (isOptS ? $U.getSelectedString() : args.arguments.join()).replace(/[\n\r]+/g, ''); 
     512        var arguments = args.split(/ +/); 
     513        var sel = $U.getSelectedString(); 
     514 
     515        if ((sel && arguments.length < 1) || (!sel && arguments.length < 2)) return null; 
     516 
     517        var siteName = arguments.shift(); 
     518        var str = (arguments.length < 1 ? sel : arguments.join()).replace(/[\n\r]+/g, ''); 
    517519        var siteinfo = this.getSite(siteName); 
    518520