5.1. Text output

There are many ways of dealing and producing text in Anableps, each one with its different levels of sophistication, color and graphics.

This chapter deals with text output to consoles or documents, in addition and independently of the graphics produced. To include text in your drawings see xxxxxxx: to include text on your scenes , see xxxx for decals or xxxx for solid letters.

5.1.1. Standard plain text output

The simple:

print "this a a text"

prints a text in the console. By default, it directs the text to the std output stdout. To print in std.error, use its evil counterpart:

print.err "asdfsadfasdf"

That directs the output to the stderr stream.

You can collect text in other virtual streams using the .to parameter:

print "asdfasfd" .to mystream

This just collects all you want in an ouput stream in memory. Later you can print it or whatever. As an example:

print "some text" .to mystream
print "even more text" .to mystream
print .from myStream
print.myStream

In the same way, you can set which stream is the default stream for printing:

print.defaultStream = stdout

5.1.1.1. Logging

Anableps brings a powerful logging system, designed t

You can use the functions debug info warning error and fatal to log you application.

There are collected by the object logger that resides by default on the namespace. This logger is a screen logger: prints the output to the screen depending on the level assigned. Level can be changed:

warning "this is a warning"  ## appears on stderr
debug "some msg"  ## this doesn't appear on screen, as by default,
                  ## logge has minimum level of "info".

logger.setLevel debug
debug "asdf"  ## now the logger prints 'asdf'

The user can set up its own logger:

logger = fileLogger:  .filename mylog.txt

5.1.1.1.1. Logger kinds

  • screenLogger : a logger that outputs
  • fileLogger: sends data to a file log
  • remoteLogger: sends data to a remote computer?

5.1.1.1.2. text format

text sent to a logger can be formatted: bold, italic, colors, indent and dedent

5.1.1.1.3. colors

example:

print "this is a {red:coloured} string"

numbers can be colorized:

print "the numbers are highlighted: 2.32cm" -n green

print can colorize numbers according with their value:

print "answer is {number}" -numbers:{green if <0.3;
       yellow if < 40; else blue}

print can colorize some words, just the same:

print "answer is {1}" -1:{green if t<0.3; else reed}

Here we color a word depending on the value of OTHER

5.1.1.1.4. Effects

sdsdfds

blink:blinking text
underscored:underscored text
bold:bold
reverse:reverse text

5.1.1.1.5. List of colors

Text output is limited by the std console (protocol??XXXXX). Below is a list of allowed colors, much more limited that the color palette for anableps

red:red
green:green
blue:blue
bkred:background red
bkgreen:background green
blink:blinking

It is possible to combine, using the “+” sign: for example red+bkgree +blink. If two colors are combined, the later prevails red+green is green

5.1.2. A fancier console

For more complex output (say formulas, shapes), you can open an special console to print. This allows formulas, graphs and scenes. It works as a console:

console.print "text"
f = fn1v x^2 + 3
console.plot(f, 10 30)   ## plots f, so we check that it's ok

Console is mostly used as a debug

Console can present several tabs or channels:

console.addTab("tab1")
console.tab1.print "text"

or:

console.addTab "tab1"
console.select "tab1"
console.print "text"

In this fancy console, we can dump any object. 3D objects will be rendered (as usual) soy they are printable too.

formulas:example console.print {2^x + 3}
tables:
canvases:

5.1.3. Logging and verbosity

Actions do log in different levels:

  • trace:
  • debug:
  • task:
  • info:
  • warning:
  • error:
  • fatal:

Logging is hierarchical. You can indent and dedent. There exists onScopeExit that allows letting actions to when the scope exits.

For any operands and functions, there is always a “verbosity” parameter that can be set. This makes that function debug its process with the wanted verbosity