discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Feature request: recognize the line break in multi line string

GW
G. Wade Johnson
Tue, Sep 15, 2015 12:20 PM

On Mon, 14 Sep 2015 21:00:14 -0700 (MST)
runsun runsun@gmail.com wrote:

G. Wade Johnson wrote

The problem comes when you get files from a different system...

Some tools can handle the variations, and we are talking about
adding that feature to OpenSCAD. It isn't really as much of a
problem in the whitespace, but when a newline occur in a string,
more thought is needed.

Python has much larger user space and a lot more fields of
application. If python can handle files from different systems, then
this cross-platform issue shouldn't become a problem for openscad.

I'm not saying it's impossible, or that OpenSCAD shouldn't do it.

The point is that this is actually not an automatic feature of any OS
I'm aware of. OpenSCAD will need to change to handle it explicitly.
That includes making such decisions as how to handle a 'line end
character sequence' when it is inside a double quoted string.

  1. Keep it literal

    • surprise effects when the file is used on another system and the
      string is printed
  2. Convert it to current system's line ending

    • surprise effects when the file is used on another system and we
      depend on the length of the string or the exact character values.
  3. Convert it to a canonical line ending

    • similar issue to 2, above. But at least it's consistent.

All of the decisions are a trade-off. Many tools have followed the 'C'
tradition of treating text line endings as "\n" no matter how they
exist on disk (option 3). That doesn't require a lot of work, but there
is a little bit.

Sorry for ranting a bit. I've had to solve this problem before (for
small values of the term "solve").

G. Wade


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD
2015.03.15/2015.04.01.nightly

--
View this message in context:
http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13838.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
Indirection should add meaning, not hide it.        -- Jessica Kerr

On Mon, 14 Sep 2015 21:00:14 -0700 (MST) runsun <runsun@gmail.com> wrote: > G. Wade Johnson wrote > > The problem comes when you get files from a different system... > > > > Some tools can handle the variations, and we are talking about > > adding that feature to OpenSCAD. It isn't really as much of a > > problem in the whitespace, but when a newline occur in a string, > > more thought is needed. > > Python has much larger user space and a lot more fields of > application. If python can handle files from different systems, then > this cross-platform issue shouldn't become a problem for openscad. I'm not saying it's impossible, or that OpenSCAD shouldn't do it. The point is that this is actually not an automatic feature of any OS I'm aware of. OpenSCAD will need to change to handle it explicitly. That includes making such decisions as how to handle a 'line end character sequence' when it is inside a double quoted string. 1. Keep it literal - surprise effects when the file is used on another system and the string is printed 2. Convert it to current system's line ending - surprise effects when the file is used on another system and we depend on the length of the string or the exact character values. 3. Convert it to a canonical line ending - similar issue to 2, above. But at least it's consistent. All of the decisions are a trade-off. Many tools have followed the 'C' tradition of treating text line endings as "\n" no matter how they exist on disk (option 3). That doesn't require a lot of work, but there is a little bit. Sorry for ranting a bit. I've had to _solve_ this problem before (for small values of the term "solve"). G. Wade > ----- > > $ Runsun Pan, PhD > > $ -- libs: doctest , faces ( git ), offliner ( git ); > > tips: hash( 1 , 2 ), sweep , var > > $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD > 2015.03.15/2015.04.01.nightly > > > > > -- > View this message in context: > http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13838.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- Indirection should add meaning, not hide it. -- Jessica Kerr
R
runsun
Tue, Sep 15, 2015 1:17 PM

I see what you mean.

This thread from the beginning is a feature request, so yes, it means a
change to openscad.

Like Tosten said, how to is not an issue, but "if we want to do it" is. With
the relatively small discussions (comparing to vast openscad users out
there), I don't see many positive voices.

But this is somehow expected, after all, handling long or multiline string
is not in most users' mind.

I personally do have the need, but I supposed it's just 0.00001% or less.

G. Wade Johnson wrote

I'm not saying it's impossible, or that OpenSCAD shouldn't do it.

The point is that this is actually not an automatic feature of any OS
I'm aware of. OpenSCAD will need to change to handle it explicitly.
That includes making such decisions as how to handle a 'line end
character sequence' when it is inside a double quoted string.

  1. Keep it literal

    • surprise effects when the file is used on another system and the
      string is printed
  2. Convert it to current system's line ending

    • surprise effects when the file is used on another system and we
      depend on the length of the string or the exact character values.
  3. Convert it to a canonical line ending

    • similar issue to 2, above. But at least it's consistent.

All of the decisions are a trade-off. Many tools have followed the 'C'
tradition of treating text line endings as "\n" no matter how they
exist on disk (option 3). That doesn't require a lot of work, but there
is a little bit.

Sorry for ranting a bit. I've had to solve this problem before (for
small values of the term "solve").

G. Wade


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD
2015.03.15/2015.04.01.nightly

--
View this message in context:
http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13838.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list

Discuss@.openscad

--
Indirection should add meaning, not hide it.        -- Jessica Kerr


OpenSCAD mailing list

Discuss@.openscad


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

--
View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13845.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I see what you mean. This thread from the beginning is a feature request, so yes, it means a change to openscad. Like Tosten said, how to is not an issue, but "if we want to do it" is. With the relatively small discussions (comparing to vast openscad users out there), I don't see many positive voices. But this is somehow expected, after all, handling long or multiline string is not in most users' mind. I personally do have the need, but I supposed it's just 0.00001% or less. G. Wade Johnson wrote > I'm not saying it's impossible, or that OpenSCAD shouldn't do it. > > The point is that this is actually not an automatic feature of any OS > I'm aware of. OpenSCAD will need to change to handle it explicitly. > That includes making such decisions as how to handle a 'line end > character sequence' when it is inside a double quoted string. > > 1. Keep it literal > - surprise effects when the file is used on another system and the > string is printed > > 2. Convert it to current system's line ending > - surprise effects when the file is used on another system and we > depend on the length of the string or the exact character values. > > 3. Convert it to a canonical line ending > - similar issue to 2, above. But at least it's consistent. > > All of the decisions are a trade-off. Many tools have followed the 'C' > tradition of treating text line endings as "\n" no matter how they > exist on disk (option 3). That doesn't require a lot of work, but there > is a little bit. > > Sorry for ranting a bit. I've had to _solve_ this problem before (for > small values of the term "solve"). > > G. Wade > >> ----- >> >> $ Runsun Pan, PhD >> >> $ -- libs: doctest , faces ( git ), offliner ( git ); >> >> tips: hash( 1 , 2 ), sweep , var >> >> $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD >> 2015.03.15/2015.04.01.nightly >> >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13838.html >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> > Discuss@.openscad >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > -- > Indirection should add meaning, not hide it. -- Jessica Kerr > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org ----- $ Runsun Pan, PhD $ -- libs: doctest , faces ( git ), offliner ( git ); tips: hash( 1 , 2 ), sweep , var $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13845.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TV
Tim V. Shaporev
Tue, Sep 15, 2015 1:22 PM

"It is\n
so easy\n
to add explicit\n
newlines.";

Just my $0.02

On 15.09.2015 16:17, runsun wrote:

I see what you mean.

This thread from the beginning is a feature request, so yes, it means a
change to openscad.

Like Tosten said, how to is not an issue, but "if we want to do it" is. With
the relatively small discussions (comparing to vast openscad users out
there), I don't see many positive voices.

But this is somehow expected, after all, handling long or multiline string
is not in most users' mind.

I personally do have the need, but I supposed it's just 0.00001% or less.

G. Wade Johnson wrote

I'm not saying it's impossible, or that OpenSCAD shouldn't do it.

The point is that this is actually not an automatic feature of any OS
I'm aware of. OpenSCAD will need to change to handle it explicitly.
That includes making such decisions as how to handle a 'line end
character sequence' when it is inside a double quoted string.

1. Keep it literal
   - surprise effects when the file is used on another system and the
     string is printed

2. Convert it to current system's line ending
   - surprise effects when the file is used on another system and we
     depend on the length of the string or the exact character values.

3. Convert it to a canonical line ending
   - similar issue to 2, above. But at least it's consistent.

All of the decisions are a trade-off. Many tools have followed the 'C'
tradition of treating text line endings as "\n" no matter how they
exist on disk (option 3). That doesn't require a lot of work, but there
is a little bit.

Sorry for ranting a bit. I've had to solve this problem before (for
small values of the term "solve").

G. Wade


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD
2015.03.15/2015.04.01.nightly

--
View this message in context:
http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13838.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list

Discuss@.openscad

--
Indirection should add meaning, not hide it.        -- Jessica Kerr


OpenSCAD mailing list

Discuss@.openscad


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

--
View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13845.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
.

"It is\n so easy\n to add explicit\n newlines."; Just my $0.02 On 15.09.2015 16:17, runsun wrote: > I see what you mean. > > This thread from the beginning is a feature request, so yes, it means a > change to openscad. > > Like Tosten said, how to is not an issue, but "if we want to do it" is. With > the relatively small discussions (comparing to vast openscad users out > there), I don't see many positive voices. > > But this is somehow expected, after all, handling long or multiline string > is not in most users' mind. > > I personally do have the need, but I supposed it's just 0.00001% or less. > > > G. Wade Johnson wrote >> I'm not saying it's impossible, or that OpenSCAD shouldn't do it. >> >> The point is that this is actually not an automatic feature of any OS >> I'm aware of. OpenSCAD will need to change to handle it explicitly. >> That includes making such decisions as how to handle a 'line end >> character sequence' when it is inside a double quoted string. >> >> 1. Keep it literal >> - surprise effects when the file is used on another system and the >> string is printed >> >> 2. Convert it to current system's line ending >> - surprise effects when the file is used on another system and we >> depend on the length of the string or the exact character values. >> >> 3. Convert it to a canonical line ending >> - similar issue to 2, above. But at least it's consistent. >> >> All of the decisions are a trade-off. Many tools have followed the 'C' >> tradition of treating text line endings as "\n" no matter how they >> exist on disk (option 3). That doesn't require a lot of work, but there >> is a little bit. >> >> Sorry for ranting a bit. I've had to _solve_ this problem before (for >> small values of the term "solve"). >> >> G. Wade >> >>> ----- >>> >>> $ Runsun Pan, PhD >>> >>> $ -- libs: doctest , faces ( git ), offliner ( git ); >>> >>> tips: hash( 1 , 2 ), sweep , var >>> >>> $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD >>> 2015.03.15/2015.04.01.nightly >>> >>> >>> >>> >>> -- >>> View this message in context: >>> http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13838.html >>> Sent from the OpenSCAD mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> > >> Discuss@.openscad > >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >> -- >> Indirection should add meaning, not hide it. -- Jessica Kerr >> >> _______________________________________________ >> OpenSCAD mailing list > >> Discuss@.openscad > >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > > ----- > > $ Runsun Pan, PhD > > $ -- libs: doctest , faces ( git ), offliner ( git ); > > tips: hash( 1 , 2 ), sweep , var > > $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly > > > > > -- > View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13845.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > . >
R
runsun
Tue, Sep 15, 2015 1:48 PM

bobc wrote

MichaelAtOz wrote

The OP wishes the CR character to be a continuation (not a token) when
within the scope of a text string, ie between two string tokens ("), as
default behaviour.

Really? I thought he was asking for the opposite.

Yes,  I am asking CR in a sting to be treated as a line break, but not line
continuation. Openscad ignores CR, so in effect it's the same as handling it
as line continuation already.

One of the issues I have with it is that the following string, for example :

" Given a 3-pointer (pqr), return the angle of P-Q-R.

2015.3.3: new arg Rf : a point given to decide the sign of
angle. If the Rf is on the same side of normalPt, the angle
is positive. Otherwise, negative.

2015.3.8:

Allows for angle( [line1,line2]).
"

is echoed to the console as a long winding line without paragraphs. Even I
have a split(...) function, I can't manage to show the text in console as it
is.

It'd be worse if I want to doc my code with a figure:

           N
       .:'`|`':.
     :`    |    `:
    :_____Q|______:____M
    :     /|`.    :
     '_  / |  `._'
       '/._|_.-'`. 
       /          R
      P

My current solution is to put something in the beginning of line for my
split() function to catch, and I don't want to use \n because it is much
harder to type:

" Given a 3-pointer (pqr), return the angle of P-Q-R.
;;
;; 2015.3.3: new arg Rf : a point given to decide the sign of
;;  angle. If the Rf is on the same side of normalPt, the angle
;;  is positive. Otherwise, negative.
;;
;; 2015.3.8:
;;
;;  Allows for angle( [line1,line2]).
;;
"

But it'd be more convinient if openscad can see CR as line break.


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

--
View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13847.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

bobc wrote > > MichaelAtOz wrote >> The OP wishes the CR character to be a continuation (not a token) when >> within the scope of a text string, ie between two string tokens ("), as >> default behaviour. > Really? I thought he was asking for the opposite. Yes, I am asking CR in a sting to be treated as a line break, but not line continuation. Openscad ignores CR, so in effect it's the same as handling it as line continuation already. One of the issues I have with it is that the following string, for example : > " Given a 3-pointer (pqr), return the angle of P-Q-R. > > 2015.3.3: new arg *Rf* : a point given to decide the sign of > angle. If the Rf is on the same side of normalPt, the angle > is positive. Otherwise, negative. > > 2015.3.8: > > Allows for angle( [line1,line2]). > " is echoed to the console as a long winding line without paragraphs. Even I have a split(...) function, I can't manage to show the text in console as it is. It'd be worse if I want to doc my code with a figure: > N > .:'`|`':. > :` | `: > :_____Q|______:____M > : /|`. : > '_ / | `._' > '/._|_.-'`. > / R > P My current solution is to put something in the beginning of line for my split() function to catch, and I don't want to use \n because it is much harder to type: > " Given a 3-pointer (pqr), return the angle of P-Q-R. > ;; > ;; 2015.3.3: new arg *Rf* : a point given to decide the sign of > ;; angle. If the Rf is on the same side of normalPt, the angle > ;; is positive. Otherwise, negative. > ;; > ;; 2015.3.8: > ;; > ;; Allows for angle( [line1,line2]). > ;; > " But it'd be more convinient if openscad can see CR as line break. ----- $ Runsun Pan, PhD $ -- libs: doctest , faces ( git ), offliner ( git ); tips: hash( 1 , 2 ), sweep , var $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13847.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Tue, Sep 15, 2015 11:33 PM

runsun wrote

I don't want to use \n because it is much harder to type:

Humm, possibly break existing programs, or type '\n'...

I just copied/pasted the console text into Notepadd++ (windows) and it
contains CRLF at EOL.

So the console output is still going to be platform dependent.

Unfortunately we don't know how many programs out in the wild use multiline
strings in the current method.

I vote for no change.


BTW in case this is useful to anyone

s="1
\n
2
\r
3
4 5\n
\u20AC10 \u263A
6";

for(i=[0:len(s)-1]) {
echo(encode(asc((s[i]))));
}

function asc(c, n = 0) = c == chr(n) ? n : asc(c, n + 1); // by nophead

function encode(n) =
( n < 0 ) ? "[error negative]"
: ( n < asc("!") ) ? str("[",code0020[n],"]")
: ( n <= asc("~") ) ? str(""",chr(n),""")
: ( n < asc("¡") ) ? str("[",code7FA0[n],"]")
: str("[unicode:",n,"=",chr(n));

code0020= [
"NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL"
,"BS","HT","LF","VT","FF","CR","SO","SI"
,"DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB"
,"CAN","EM","SUB","ESC","FS","GS","RS","US"
,"SP"
];

code7FA0= [
"DEL"
,"PAD","HOP","BPH","NBH","IND","NEL","SSA","ESA"
,"HTS","HTJ","VTS","PLD","PLU","RI","SS2","SS3"
,"DCS","PU1","PU2","STS","CCH","MW","SPA","EPA"
,"SOS","SGCI","SCI","CSI","ST","OSC","PM","APC"
,"NBSP"
];


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13854.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

runsun wrote > I don't want to use \n because it is much harder to type: Humm, possibly break existing programs, or type '\n'... I just copied/pasted the console text into Notepadd++ (windows) and it contains CRLF at EOL. So the console output is still going to be platform dependent. Unfortunately we don't know how many programs out in the wild use multiline strings in the current method. I vote for no change. ------------------------------------------------ BTW in case this is useful to anyone s="1 \n 2 \r 3 4 5\n \u20AC10 \u263A 6"; for(i=[0:len(s)-1]) { echo(encode(asc((s[i])))); } function asc(c, n = 0) = c == chr(n) ? n : asc(c, n + 1); // by nophead function encode(n) = ( n < 0 ) ? "[error negative]" : ( n < asc("!") ) ? str("[",code0020[n],"]") : ( n <= asc("~") ) ? str("\"",chr(n),"\"") : ( n < asc("¡") ) ? str("[",code7FA0[n],"]") : str("[unicode:",n,"=",chr(n)); code0020= [ "NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL" ,"BS","HT","LF","VT","FF","CR","SO","SI" ,"DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB" ,"CAN","EM","SUB","ESC","FS","GS","RS","US" ,"SP" ]; code7FA0= [ "DEL" ,"PAD","HOP","BPH","NBH","IND","NEL","SSA","ESA" ,"HTS","HTJ","VTS","PLD","PLU","RI","SS2","SS3" ,"DCS","PU1","PU2","STS","CCH","MW","SPA","EPA" ,"SOS","SGCI","SCI","CSI","ST","OSC","PM","APC" ,"NBSP" ]; ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13854.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Thu, Sep 17, 2015 4:21 PM

Tim V. Shaporev wrote

"It is\n
so easy\n
to add explicit\n
newlines.";

It certainly can be done this way --- if it's short and not frequent.

However, I'm writing a lib that requires users to write documentation of
functions/modules in code for later processing. Having to type \n in every
line will like discouraging users to use it.

Just imagine the situation when we are writing posts in this forum --- we
simply hit CR for a line break, and 2 CRs for a new paragraph. What if it
requires us to write \n in every line ?


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

--
View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13868.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Tim V. Shaporev wrote > "It is\n > so easy\n > to add explicit\n > newlines."; It certainly can be done this way --- if it's short and not frequent. However, I'm writing a lib that requires users to write documentation of functions/modules in code for later processing. Having to type \n in every line will like discouraging users to use it. Just imagine the situation when we are writing posts in this forum --- we simply hit CR for a line break, and 2 CRs for a new paragraph. What if it requires us to write \n in every line ? ----- $ Runsun Pan, PhD $ -- libs: doctest , faces ( git ), offliner ( git ); tips: hash( 1 , 2 ), sweep , var $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13868.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AC
Alan Cox
Thu, Sep 17, 2015 9:09 PM

On Thu, 17 Sep 2015 09:21:31 -0700 (MST)
runsun runsun@gmail.com wrote:

Tim V. Shaporev wrote

"It is\n
so easy\n
to add explicit\n
newlines.";

It certainly can be done this way --- if it's short and not frequent.

However, I'm writing a lib that requires users to write documentation of
functions/modules in code for later processing. Having to type \n in every
line will like discouraging users to use it.

Just imagine the situation when we are writing posts in this forum --- we
simply hit CR for a line break, and 2 CRs for a new paragraph. What if it
requires us to write \n in every line ?

Multiple years of back compatibility

Removal of any ambiguity.

If you are doing general text formatting in ECHO in openscad thats a bit
of an odd use already. Using newlines embedded or explicit won't work in
either case because you've got no idea how wide the window is and the
font in use.

Perhaps you'd be better off submitting a patch to mke the ECHO output
justified ?

Alan

On Thu, 17 Sep 2015 09:21:31 -0700 (MST) runsun <runsun@gmail.com> wrote: > Tim V. Shaporev wrote > > "It is\n > > so easy\n > > to add explicit\n > > newlines."; > > It certainly can be done this way --- if it's short and not frequent. > > However, I'm writing a lib that requires users to write documentation of > functions/modules in code for later processing. Having to type \n in every > line will like discouraging users to use it. > > Just imagine the situation when we are writing posts in this forum --- we > simply hit CR for a line break, and 2 CRs for a new paragraph. What if it > requires us to write \n in every line ? Multiple years of back compatibility Removal of any ambiguity. If you are doing general text formatting in ECHO in openscad thats a bit of an odd use already. Using newlines embedded or explicit won't work in either case because you've got no idea how wide the window is and the font in use. Perhaps you'd be better off submitting a patch to mke the ECHO output justified ? Alan
R
runsun
Thu, Sep 17, 2015 10:00 PM

Alan Cox wrote

If you are doing general text formatting in ECHO in openscad thats a bit
of an odd use already. Using newlines embedded or explicit won't work in
either case because you've got no idea how wide the window is and the
font in use.

Perhaps you'd be better off submitting a patch to mke the ECHO output
justified ?

"no idea how wide the window" is a valid point, especially considering that
the console output can be saved to a file and read by a browser, which is
very common now on mobile devices.

"justified output" is not good enough, 'cos many funcs in my lib use ascii
graph to explain features, which requires specific line breaks.

It's indeed an odd use. This doctest lib of mine is probably good for lib
writers only. I am making a tool that a lib writer can set a cron job to run
function tests nightly and send notification automatically when something
goes wrong. At the mean time it can produce documentation in html format.

It's understandable that the majority of openscad users have no need for
this. So I'll have to use the more inconvenient approach.

So, lets move on. Thanks too all participate in the topic.


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

--
View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13880.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Alan Cox wrote > If you are doing general text formatting in ECHO in openscad thats a bit > of an odd use already. Using newlines embedded or explicit won't work in > either case because you've got no idea how wide the window is and the > font in use. > > Perhaps you'd be better off submitting a patch to mke the ECHO output > justified ? "no idea how wide the window" is a valid point, especially considering that the console output can be saved to a file and read by a browser, which is very common now on mobile devices. "justified output" is not good enough, 'cos many funcs in my lib use ascii graph to explain features, which requires specific line breaks. It's indeed an odd use. This doctest lib of mine is probably good for lib writers only. I am making a tool that a lib writer can set a cron job to run function tests nightly and send notification automatically when something goes wrong. At the mean time it can produce documentation in html format. It's understandable that the majority of openscad users have no need for this. So I'll have to use the more inconvenient approach. So, lets move on. Thanks too all participate in the topic. ----- $ Runsun Pan, PhD $ -- libs: doctest , faces ( git ), offliner ( git ); tips: hash( 1 , 2 ), sweep , var $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13880.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AC
Alan Cox
Fri, Sep 18, 2015 7:42 PM

On Thu, 17 Sep 2015 15:00:42 -0700 (MST)
runsun runsun@gmail.com wrote:

Alan Cox wrote

If you are doing general text formatting in ECHO in openscad thats a bit
of an odd use already. Using newlines embedded or explicit won't work in
either case because you've got no idea how wide the window is and the
font in use.

Perhaps you'd be better off submitting a patch to mke the ECHO output
justified ?

"no idea how wide the window" is a valid point, especially considering that
the console output can be saved to a file and read by a browser, which is
very common now on mobile devices.

"justified output" is not good enough, 'cos many funcs in my lib use ascii
graph to explain features, which requires specific line breaks.

So you've got \n for those. Although given there is no guarantee that the
font is fixed width its already a lost cause for charts

Alan

On Thu, 17 Sep 2015 15:00:42 -0700 (MST) runsun <runsun@gmail.com> wrote: > Alan Cox wrote > > If you are doing general text formatting in ECHO in openscad thats a bit > > of an odd use already. Using newlines embedded or explicit won't work in > > either case because you've got no idea how wide the window is and the > > font in use. > > > > Perhaps you'd be better off submitting a patch to mke the ECHO output > > justified ? > > "no idea how wide the window" is a valid point, especially considering that > the console output can be saved to a file and read by a browser, which is > very common now on mobile devices. > > "justified output" is not good enough, 'cos many funcs in my lib use ascii > graph to explain features, which requires specific line breaks. So you've got \n for those. Although given there is no guarantee that the font is fixed width its already a lost cause for charts Alan
R
runsun
Fri, Sep 18, 2015 9:13 PM

Alan Cox wrote

So you've got \n for those. Although given there is no guarantee that
thefont is fixed width its already a lost cause for charts

Console output could be controlled with html. You simply wrap the string
with monospace font family and it works nicely.

I design it to output both in the console and to a html file. So I need html
markup anyway.

Here are two examples. Copy and paste it to the editor then get a preview,
it will look the same in both the editor and the console, regardless what
font the user has in the preference ( other than \n, and assuming that all
programmers use monospaing font to code ):

echo("<pre style='font-family=monospace'>\n
13-------------9\n            -|-10- -\n          -'  -| |-  -_ \n 17.'____.' -_|_____11| -6.5\n        |-_ |-- --| _-| \n        |  -_ _--22____2- _-  | \n
16||-_/_|______|%_- |7 |4\n        -_ 21| | | |1
-\n -  |  |23___3| |  _-\n -|-/
%|-`\n                20          0\n\n      N (z)\n
|\n      |
___\n      /|'-
    |\n    / |  '-_  |\n    |  |      :
|\n    |  Q------|---- M (y)\n    | / '-._/ |\n    |/_____/'.|\n    /
'-R\n  /\n  P (x)</pre>");

So my only complaint is the \n, which I believe it will discurage users from
using my lib.


$  Runsun Pan, PhD

$ -- libs: doctest , faces ( git ), offliner ( git );

tips: hash( 1 , 2 ), sweep , var

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

--
View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13889.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Alan Cox wrote > So you've got \n for those. Although given there is no guarantee that > thefont is fixed width its already a lost cause for charts Console output could be controlled with html. You simply wrap the string with monospace font family and it works nicely. I design it to output both in the console and to a html file. So I need html markup anyway. Here are two examples. Copy and paste it to the editor then get a preview, it will look the same in both the editor and the console, regardless what font the user has in the preference ( other than \n, and assuming that all programmers use monospaing font to code ): > echo("&lt;pre style='font-family=monospace'>\n > 13-------------9\n _-`|`-_______10-` `-_\n _-' _-`| > |`-_ `-_ \n 17.'____.' -_|_____11| `-6____.5\n |`-_ > |`-_-` `-_-`| _-`| \n | `-_ _-`-22____2_-` _-` | \n > 16|_____|`-_/_|______|%_-` |7__ |4\n `-_ 21| | | |1 ` > _-`\n `-_ | |23___3| | _-`\n > `-|-/________%|-`\n 20 0\n\n N (z)\n > |\n |________\n /|'-_ |\n / | '-_ |\n | | : > |\n | Q------|---- M (y)\n | / '-._/ |\n |/_____/'.|\n / > '-R\n /\n P (x)&lt;/pre>"); So my only complaint is the \n, which I believe it will discurage users from using my lib. ----- $ Runsun Pan, PhD $ -- libs: doctest , faces ( git ), offliner ( git ); tips: hash( 1 , 2 ), sweep , var $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/Feature-request-recognize-the-line-break-in-multi-line-string-tp13789p13889.html Sent from the OpenSCAD mailing list archive at Nabble.com.