hankejh: -------------------------------------------------------------------------------- Hi Chuckf,
I updated ingkcpos.js, adding CTRL+ALT+W to select the word under cursor. The updated script can be obtained here: http://ingk.com/pspad/ingkcpos_v0.7.zip -------------------------------------------------------------------------------- Thanks, hankejh I wrote my own very similar to yours. Too bad the formatting is lost here... chuckf //****************************************************************************** * // filename : copy_word.js // description: Copy word under cursor to clipboard - based on Select Word // by Serge Balance // created : 12/16/09 // author : updated Chuck Fossen // // You may distribute this script freely, but please keep this header intact. //****************************************************************************** * module_name = "copy_word"; module_ver = "1.0"; menu_name = "Utilities"; function Init() { addMenuItem("Copy Word", menu_name, "copy_word", "Ctrl+W"); } // select a word even if the cursor is one character after the word function cw_select(ed) { var line = new String(ed.lineText()); var curx = ed.caretX(); var cury = ed.caretY(); var i, pos, begPos, endPos; var len = line.length; // positions in line begin from 1 not from 0 pos = curx - 1; // check if the current location does not contain a char if (!line.charAt(pos).match(/\w/)) { //echo("no \\w " + line.charAt(pos)); // check one char to the left if (line.charAt(pos-1).match(/\w/)) { pos--; curx--; //echo("starting at " + line.charAt(pos)); } else { //echo("no word"); return false; } } // find end of word while ((line.charAt(pos).match(/\w/)) && (pos<len)) { pos++; } // loop ended when pointing to position after the end of the word endPos = pos - 1; pos = curx - 1; // find beginning of word while ((line.charAt(pos).match(/\w/)) && (pos>=0)) { pos--; } // loop ended when pointing to position before the beginning of the word begPos = pos + 1; // move cursor to beginning of word (1 based) ed.caretX(begPos + 1); // include to end char as well len = endPos - begPos + 1; // select word for (i=0; i<len; i++) { ed.command("ecSelRight"); } //echo("returning true"); return true; } function copy_word() { var ed = neweditor(); ed.assignActiveEditor(); ret = cw_select(ed); if (ret) { // copy to clipboard ed.command("ecCopy"); // remove selection ed.command("ecLeft"); } } -- <http://forum.pspad.com/read.php?2,51903,52102> PSPad freeware editor http://www.pspad.com
