Revision: 3628
http://vexi.svn.sourceforge.net/vexi/?rev=3628&view=rev
Author: clrg
Date: 2009-08-27 16:26:26 +0000 (Thu, 27 Aug 2009)
Log Message:
-----------
Support wraptext=false
Modified Paths:
--------------
trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/block.t
trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t
trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t
Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/block.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/block.t
2009-08-27 14:07:13 UTC (rev 3627)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/block.t
2009-08-27 16:26:26 UTC (rev 3628)
@@ -27,7 +27,7 @@
edit = arguments[1];
font = arg0.font;
fontsize = arg0.fontsize;
- multiline = arg0.multiline;
+ multiline = arg0.multiline and arg0.wraptext;
wrapwidth = arg0.wrapwidth;
}
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-08-27
14:07:13 UTC (rev 3627)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2009-08-27
16:26:26 UTC (rev 3628)
@@ -1528,12 +1528,14 @@
for (var i=0; blockInd>=i; i++) {
var b = thisbox[i];
if (i==blockInd) {
- for (var j=0; wordInd>j; j++)
+ for (var j=0; wordInd>j; j++) {
cindex += b[j].length;
+ }
} else {
var n = b.numchildren;
- for (var j=0; n>j; j++)
+ for (var j=0; n>j; j++) {
cindex += b[j].length;
+ }
}
}
return cWord ? cindex+cPos : cindex;
@@ -1571,15 +1573,20 @@
// special case for first line
var b = thisbox[0];
var n = b.numchildren;
- for (var j=0; n>j; j++) ret[++k] = b[j].text;
+ for (var j=0; n>j; j++) {
+ ret[++k] = b[j].text;
+ }
// build up with newlines for multiline
if (multiline) {
- for (var i=1; numchildren>i; i++) {
+ var numblocks = numchildren;
+ for (var i=1; numblocks>i; i++) {
ret[++k] = "\n";
b = thisbox[i];
n = b.numchildren;
- for (var j=0; n>j; j++) ret[++k] = b[j].text;
+ for (var j=0; n>j; j++) {
+ ret[++k] = b[j].text;
+ }
}
}
// return result
@@ -1591,7 +1598,7 @@
// special case "" and null
if (t == null or t == "") {
cascade = null;
- while (thisbox[0]) thisbox[0] = null;
+ clear();
thisbox[0] = .block(vexi.box, blockargs);
select = false;
// normal text put
@@ -1605,8 +1612,11 @@
var blocks = static.getBlocksFromString(t);
var numblocks = blocks.length;
for (var i=0; numblocks>i; i++) {
- if (!thisbox[i]) thisbox[i] = .block(vexi.box,
blockargs);
var b = thisbox[i];
+ if (b == null) {
+ b = .block(vexi.box, blockargs);
+ thisbox[i] = b;
+ }
b.text = blocks[i];
b.wrapwidth = wrapwidth;
if (b.font != font) b.font = font;
@@ -1666,7 +1676,9 @@
static.wraptextWrite = function(v) {
cascade = v;
var n = numchildren;
- for (var i=0; n>i; i++) thisbox[i].multiline = v;
+ for (var i=0; n>i; i++) {
+ thisbox[i].multiline = v;
+ }
}
/** generate a set of text blocks from a string by splitting it at
newlines */
@@ -1675,9 +1687,9 @@
var bn = t.split('\n');
var bl = bn.length;
for (var i=0; bl>i; i++) {
- if (bn[i] == "")
+ if (bn[i] == "") {
blocks[blocks.length] = "";
- else {
+ } else {
var br = bn[i].split('\r');
for (var j=0; br.length>j; j++)
blocks[blocks.length] = br[j];
Modified: trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t 2009-08-27
14:07:13 UTC (rev 3627)
+++ trunk/widgets/org.vexi.widgets/src_dev/visualtest/text.t 2009-08-27
16:26:26 UTC (rev 3628)
@@ -1,12 +1,23 @@
<vexi xmlns:ui="vexi://ui" xmlns:w="vexi.widget">
<w:surface />
<ui:box orient="vertical">
- <w:textarea id="edit">
- text = "Apples and oranges,\npears and mangos.\n\nPotatoes and
sprouts,\ncelery and leak.\n\n"
- + "All that kind of stuff is healthy for you but doesn't
taste as nice as chocolate!\n\n"
- + "123 12345 1.23 123.45";
- </w:textarea>
+ <ui:box vshrink="true">
+ <ui:box text="Wrapping" />
+ <ui:box text="No wrap" />
+ </ui:box>
<ui:box>
+ <w:textarea id="edit">
+ text = "Apples and oranges,\npears and mangos.\n\nPotatoes and
sprouts,\ncelery and leak.\n\n"
+ + "All that kind of stuff is healthy for you but doesn't
taste as nice as chocolate!\n\n"
+ + "123 12345 1.23 123.45";
+ </w:textarea>
+ <w:textarea id="edit2" wraptext="false">
+ text = "Apples and oranges, pears and mangos. Potatoes and
sprouts, celery and leak.\n\n"
+ + "All that kind of stuff is healthy for you but doesn't
taste as nice as chocolate!\n\n"
+ + "123 12345 1.23 123.45";
+ </w:textarea>
+ </ui:box>
+ <ui:box>
<w:button id="set" text="Set Focused" />
<w:button id="get" text="Get Cursor Index" />
<ui:box id="output" />
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn