Revision: 3487 http://vexi.svn.sourceforge.net/vexi/?rev=3487&view=rev Author: clrg Date: 2009-04-24 17:29:20 +0000 (Fri, 24 Apr 2009)
Log Message: ----------- More improvements to copy/paste (still a few issues with cursor placement remaining) Modified Paths: -------------- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2009-04-24 15:54:56 UTC (rev 3486) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2009-04-24 17:29:20 UTC (rev 3487) @@ -475,10 +475,10 @@ var cwi = cWord ? cBlock.indexof(cWord) : 0; var cwt = cWord ? cWord.text : ""; var cbi = thisbox.indexof(cBlock); - var cps = cPos; - var head; - var tail; var coff = cwt.length; + var type = cWord.chartype; + var head, tail, tmpb; + if (cWord) { if (cwi>0 or cPos>0) { head = static.getTextUpToWord(cBlock, cwi) + cwt.substring(0, cPos); @@ -493,44 +493,54 @@ // single line of text if (blocks.length == 1) { if (cWord) { - cBlock.text = head + blocks[0]; - cWord = cBlock[cBlock.numchildren-1]; - cwi = cBlock.indexof(cWord); - cwt = cWord.text; - cps = cWord.text.length; - cBlock.text = cBlock.text + tail; - if (cBlock[cwi].text == cwt and cwi == cBlock.numchildren-1) { - cWord = cBlock[cwi]; - cPos = cps; - } else { - cWord = cBlock[cwi+1]; - cPos = 0; - } + head = head ? head + blocks[0] : blocks[0]; + cBlock.text = head; + cwi = cBlock.numchildren-1; + cwt = cBlock[cwi].text; + // TODO: make this more efficient + if (tail) cBlock.text = head + tail; + cWord = cBlock[cwi]; } else { cBlock.text = blocks[0]; cWord = cBlock[cBlock.numchildren-1]; - cPos = cWord.text.length; + cPos = cWord ? cWord.text.length : 0; + return; } } else { // first part of cBlock - cBlock.text = head + blocks[0]; + cBlock.text = head ? head + blocks[0] : blocks[0]; // intervening portion of blocks - var tmpb, i; - for (i=1; blocks.length>i+1; i++) { + var tmpb; + var l = blocks.length; + for (var i=1; l>i+1; i++) { tmpb = .block(vexi.box, blockargs); tmpb.text = blocks[i]; thisbox[cbi+i] = tmpb; } // second part of cBlock + // TODO: make this more efficent as it currently + // doubles up on block formation by putting the + // same text twice to a block with the addition + // of the 'tail' text the second time tmpb = .block(vexi.box, blockargs); - tmpb.text = blocks[blocks.length-1]; + tmpb.text = blocks[l-1]; cwi = tmpb.numchildren ? tmpb.numchildren-1 : 0; - tmpb.text = blocks[blocks.length-1] + tail; + if (tail) tmpb.text = blocks[l-1] + tail; cwt = tmpb[cwi]; cwt = cwt ? cwt.text : ""; thisbox[cbi+i] = tmpb; cBlock = tmpb; cWord = tmpb[cwi]; + } + + // set correct cursor position + if (cWord==null) cPos = 0; + else if (type and cWord.chartype==type) cPos = cWord ? cwt.length-coff : 0; + else if (cwi == cBlock.numchildren-1) + cPos = cwt.length; + else { + cWord = tmpb[cwi+1]; + cPos = 0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn