poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Styled output in Poke programs!


From: Jose E. Marchesi
Subject: Styled output in Poke programs!
Date: Sun, 20 Oct 2019 22:36:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi people!

I just committed support for styling in printf.  Basically, it uses the
libtextstyle approach of having styling classes that the user can
customize in a .css file.

The support is implemented as follows.  There are two new %- tags
recognized in the format strings passed to printf:

%<NAME:
   begins a styling class.
%>
   ends the last opened styling class.

Where NAME is some name identifying the class. Note that NAME cannot be
empty.  Styling classes can be nested.  All classes should be ended by
the end of the format string.

If you use a NAME class, you can define how to style it in the .css file
(poke installs and uses poke-default.css but you can set the POKE_STYLE
environment variable to point to another css) like this:

.NAME { text-decoration: blink; color : pink; }

Examples:
printf "This is a foo: %<foo:xxx%>"
printf "Name: %<string:%s%> Age: %<integer:%i32d%>", "Joe", 39

I already stylized the `dump' command (you can take a look at
src/pk-dump.pk) which is itself written in Poke.  For this purpose I
added three new classes to poke-default.css:

.dump-ruler { text-decoration: underline; }
.dump-address { color : green; }
.dump-ascii { color : brown; }

(Yes I know you _will_ find my styling ugly :P)

Ah, and for testing it I pass --color=html to poke to get strings I can
match.  Example of a test:

/* { dg-do run } */
/* { dg-options "--color=html" } */

/* { dg-command {printf "xxx%<foo:%i32dyyy%<bar:%i32d%>%>zzz", 10, 20} } */
/* { dg-output "xxx<span class=\"foo\">10yyy<span 
class=\"bar\">20</span></span>zzz" } */

Happy styling! :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]