HTML commands in echo

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

HTML commands in echo

Ronaldo
I guess I have found a small glitch in echo with HTML commands when the commands are not properly closed. For instance,

text = "Test";
echo(str( "<h4><p style='background-color:lightblue;'>", text ));

instead of:

text = "Test";
echo(str( "<h4><p style='background-color:lightblue;'>", text,"</p></h4>"));

will paint the console background with blue. The new background color will extend beyond the echo text and will be kept even in the following code previews. To reestablish the white background, some echo like bellow might be needed:

echo("<p style='background-color:white;'></p>");

I think that echo should force a close of all open HTML commands before ending.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

tp3
On 20.12.19 21:19, Ronaldo Persiano wrote:
> I guess I have found a small glitch in echo with HTML
> commands when the commands are not properly closed.

HTML will not be supported in echo(). It already is disabled
for most cases that output to console but it seems there's
still some places not fixed.

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

Ronaldo
All my fancy echo's will be garbage after all the hard work to make them. ☹️

A sexta, 20/12/2019, 20:33, Torsten Paul <[hidden email]> escreveu:
On 20.12.19 21:19, Ronaldo Persiano wrote:
> I guess I have found a small glitch in echo with HTML
> commands when the commands are not properly closed.

HTML will not be supported in echo(). It already is disabled
for most cases that output to console but it seems there's
still some places not fixed.

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

tp3
On 20.12.19 23:23, Ronaldo Persiano wrote:
> All my fancy echo's will be garbage after all the
> hard work to make them. ☹️

What are the formatting features used? The current HTML
support was an accidental feature leaking the internals
of the GUI control used as console window. That's also
the reason why it changed behavior some time ago causing
all sorts of issues and different behavior depending on
the OpenSCAD version.

The only way for providing a stable way of generating
output (with string formatting, no ECHO prefix, ...)
would be having a dedicated output window.

Collecting ideas for that would help a lot.

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

Ronaldo


A sexta, 20/12/2019, 23:16, Torsten Paul 
What are the formatting features used? 

Nothing more then colouring text and it's background and add some line breaks. But, for instance, I was unable to add an extra line break at the end of my formatted  text. I must admit I am less than a beginner in HTML.

My intention is to visually distinguish error, warning and info messages issued by a library. 

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

thehans
We could theoretically add support back in for html-specific output as a separate module without much effort I think,  Call it something like "html()", "html_echo()", or "echo_html()".

The current formatting code is in mainwin.cc:consoleOutput function ( https://github.com/openscad/openscad/blob/2a943a57f9d23511c0021b228dee6b6eb9ae440d/src/mainwin.cc#L2923-L2946 ) , and it works by checking if the message starts with "WARNING:", or "ERROR:" etc to highlight those messages in different colors.  In the most recent builds, since Dec. 11, the echo appends plain text only to the console, and those specific formatting options can't be invoked directly by the user(they couldn't before either) because echo() statements always start with "ECHO:"

So another option which could be useful is if scripts were able to apply some of those builtin formats to highlight their own warnings (and maybe errors?) without requiring html either.  So for example echo() could take an optional "message_type" parameter that would alter its prefix from "ECHO:" to some other from a list of pre-defined options.  If we did something like that we might also want to differentiate between messages coming from the application, vs those coming from a script.  Maybe prefix "SCRIPT-WARNING:" instead of "WARNING:" etc. 

One last note which doesn't directly help but might be some consolation for library writing:
(version_num()-20191211 >= 0)
Should return true if the build has had echo html support removed, based on the merge date.

-Hans


On Fri, Dec 20, 2019 at 6:13 PM Ronaldo Persiano <[hidden email]> wrote:


A sexta, 20/12/2019, 23:16, Torsten Paul 
What are the formatting features used? 

Nothing more then colouring text and it's background and add some line breaks. But, for instance, I was unable to add an extra line break at the end of my formatted  text. I must admit I am less than a beginner in HTML.

My intention is to visually distinguish error, warning and info messages issued by a library. 
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

runsun
In reply to this post by Ronaldo
I have lots of code (A LOT!!!) using the HTML style to structure/color text
for complicate code. If the HTML feature is disabled, all those hard work
will be wasted. I haven't have a chance to try newer release to check how
devastating it is.

Btw happy new year, guys.



-----

$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

egburr
In reply to this post by thehans
On that note about adding the ability to issue "WARNING" and "ERROR" messages
that are highlited, how about also a "NOTICE" message that is also highlited
but for things that aren't necessarily a problem.

Alternatively, I'd probably prefer "color=" and "bgcolor=" parameters added
to echo, so we can just specify colors for our messages and lead off with
whatever capitalized text we want to (after the "ECHO:" bit, of course) if
we want any at all.

Just use the same color options as already available for the "color"
command.

Too bad this:
*color("red") echo("This should be red text.");*
doesn't work. :)


thehans wrote

> The current formatting code is in mainwin.cc:consoleOutput function (
> https://github.com/openscad/openscad/blob/2a943a57f9d23511c0021b228dee6b6eb9ae440d/src/mainwin.cc#L2923-L2946
> ) , and it works by checking if the message starts with "WARNING:", or
> "ERROR:" etc to highlight those messages in different colors.  In the most
> recent builds, since Dec. 11, the echo appends plain text only to the
> console, and those specific formatting options can't be invoked directly
> by
> the user(they couldn't before either) because echo() statements always
> start with "ECHO:"
>
> So another option which could be useful is if scripts were able to apply
> some of those builtin formats to highlight their own warnings (and maybe
> errors?) without requiring html either.  So for example echo() could take
> an optional "message_type" parameter that would alter its prefix from
> "ECHO:" to some other from a list of pre-defined options.  If we did
> something like that we might also want to differentiate between messages
> coming from the application, vs those coming from a script.  Maybe prefix
> "SCRIPT-WARNING:" instead of "WARNING:" etc.





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

JordanBrown
On 1/5/2020 11:02 PM, egburr wrote:
Too bad this:
*color("red") echo("This should be red text.");*
doesn't work. :)

Or

scale(1.1) echo("Big text");


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

nophead
What would these do when run from the command line?

On Mon, 6 Jan 2020 at 18:27, Jordan Brown <[hidden email]> wrote:
On 1/5/2020 11:02 PM, egburr wrote:
Too bad this:
*color("red") echo("This should be red text.");*
doesn't work. :)

Or

scale(1.1) echo("Big text");

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

egburr
Probably depends on the terminal you're on, at least for the color option.
There is some way for a program to determine if the terminal it's
interacting with supports color or not, isn't there?

Scaling might have to be just ignored altogether for command-line.


nophead wrote
> What would these do when run from the command line?
>
> On Mon, 6 Jan 2020 at 18:27, Jordan Brown &lt;

> openscad@.maileater

> &gt;
> wrote:
>
>> On 1/5/2020 11:02 PM, egburr wrote:
>>
>> Too bad this:
>> *color("red") echo("This should be red text.");*
>> doesn't work. :)
>>
>>
>> Or
>>
>> scale(1.1) echo("Big text");
>>





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

egburr
In reply to this post by nophead
What happens on command-line with current "ERROR" and "WARNING" messages that
are currently colored/highlited in the OpenSCAD console? I'm guessing they
come out as just plain uncolored text?


nophead wrote
> What would these do when run from the command line?
>
> On Mon, 6 Jan 2020 at 18:27, Jordan Brown &lt;

> openscad@.maileater

> &gt;
> wrote:
>
>> On 1/5/2020 11:02 PM, egburr wrote:
>>
>> Too bad this:
>> *color("red") echo("This should be red text.");*
>> doesn't work. :)
>>
>>
>> Or
>>
>> scale(1.1) echo("Big text");
>>





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

nophead
Yes they need to be plain text for my usage.

On Mon, 6 Jan 2020 at 18:44, egburr <[hidden email]> wrote:
What happens on command-line with current "ERROR" and "WARNING" messages that
are currently colored/highlited in the OpenSCAD console? I'm guessing they
come out as just plain uncolored text?


nophead wrote
> What would these do when run from the command line?
>
> On Mon, 6 Jan 2020 at 18:27, Jordan Brown &lt;

> openscad@.maileater

> &gt;
> wrote:
>
>> On 1/5/2020 11:02 PM, egburr wrote:
>>
>> Too bad this:
>> *color("red") echo("This should be red text.");*
>> doesn't work. :)
>>
>>
>> Or
>>
>> scale(1.1) echo("Big text");
>>





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

JordanBrown
In reply to this post by nophead
On 1/6/2020 10:30 AM, nop head wrote:
On Mon, 6 Jan 2020 at 18:27, Jordan Brown <[hidden email]> wrote:
On 1/5/2020 11:02 PM, egburr wrote:
Too bad this:
*color("red") echo("This should be red text.");*
doesn't work. :)
Or

scale(1.1) echo("Big text");

What would these do when run from the command line?

I guess it was unclear that I was 97% kidding.

Semi-seriously...

You *could* use ANSI x3.64 escape sequences for color.  Addenda bring in 24-bit color support.  However, I don't see any size support.

That would mess up any postprocessor, but you'd use the same strategy that was used for (e.g.) ls and its color-coding of file types:  have OpenSCAD automatically disable colors if stdout isn't a terminal.

Tempting and cute as this scheme might be, I don't think you'd actually want to have the same operators affecting your console output and your geometry.  Just because a particular component is scaled or colored doesn't mean that you want its diagnostic output to be scaled or colored.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

QuackingPlums
In reply to this post by tp3
I also use some simple HTML formatting in my output window.

I have a rudimentary library that creates documentation for my other
libraries, so that I can quickly remind myself of function/module syntax
without loading up the library source directly.

I don't use colours as much but I do use text formatting - for example:
<http://forum.openscad.org/file/t311/Screenshot_2020-01-11_at_16.png>

Will this be lost?



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

runsun
In reply to this post by nophead
This is not a direct answer to your question, but some of my programs has a
switch to output either HTML-encoded text or plain text.
 

nophead wrote
> What would these do when run from the command line?





-----

$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: HTML commands in echo

nophead
So perhaps we need a variable to indicate command line mode.


On Sat, 18 Jan 2020, 18:31 runsun, <[hidden email]> wrote:
This is not a direct answer to your question, but some of my programs has a
switch to output either HTML-encoded text or plain text.


nophead wrote
> What would these do when run from the command line?





-----

$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org