THE TERMINAL

When you run a satellite program, it runs inside a terminal: the window around the text. That might be the terminal program you use every day, or the console window satl opens by itself. In satellite, that window is satellite.terminal.

It is a different thing from satellite.console. The console is the stream of lines your program writes and reads. The terminal is the window they appear in. So satellite.console.foreground colours your program’s lines, and satellite.terminal.foreground colours the terminal itself.

Changing the terminal’s colours

satellite.terminal.foreground(c) and satellite.terminal.background(c) change the terminal’s own colours. That means everything drawn in its default colour, and the empty rows too, not only the lines written after them. A colour is six hex digits, like x101010, or a satellite.variable.color held by name.

night_mode.satlSATELLITE 004 Download
Green text on near-black, for the whole window
satellite.include(satellite)

satellite.capsule satellite.main()
{
    satellite.terminal.background(x101010)
    satellite.terminal.foreground(x33FF33)
    satellite.console.display("green on near-black, the whole terminal")
    satellite.console.display("and your own colours come back when this ends")
    satellite.return(satellite)
}
OUTPUT
green on near-black, the whole terminal
and your own colours come back when this ends

The output box shows only the words. The colours are a change to the terminal, not to the text, so they never appear in what your program prints.

Putting the colours back

Write the same words with empty brackets, satellite.terminal.foreground() and satellite.terminal.background(), and the terminal’s own colours come back straight away. Here the colours live in names, so they are easy to change in one place:

reading_lamp.satlSATELLITE 004 Download
Set the colours from names, then put them back
satellite.include(satellite)

satellite.capsule satellite.main()
{
    satellite.variable.color paper = xFFF8E7
    satellite.variable.color ink = x3B2F2F
    satellite.terminal.background(paper)
    satellite.terminal.foreground(ink)
    satellite.console.display("dark ink on warm paper")
    satellite.terminal.foreground()
    satellite.terminal.background()
    satellite.console.display("your own colours again")
    satellite.return(satellite)
}
OUTPUT
dark ink on warm paper
your own colours again

You do not have to remember to do this. satl puts back whatever it changed when the program ends, however it ends: when it finishes, when it stops on an error, when you press Ctrl-C, or when it crashes. A program never leaves your shell orange.

One thing to know: “back” means the colours from your terminal’s own settings. If your shell had already changed the terminal’s colours in the same way, satl does not remember that change, and you get the terminal’s settings instead.

When nothing changes

The terminal is only touched when there is one to touch:

  • When your program’s output goes into a pipe or a file, satl does not change any colours. That is why the examples on this page could be checked without a terminal at all.
  • When the NO_COLOR setting is on, satl leaves the terminal’s colours alone.

A colour that is not a colour

A colour must be six hex digits or a colour held by name. Text is refused before the program starts, so nothing is half changed:

orange_words.satlSATELLITE 004 Download
A colour's name in words is not a colour
satellite.include(satellite)

satellite.capsule satellite.main()
{
    satellite.terminal.foreground("orange")
    satellite.return(satellite)
}
OUTPUT
--------------------------------------------------------------------------------
SATELLITE CRITICAL ERROR REPORT
--------------------------------------------------------------------------------
S301: TYPES_DO_NOT_MEET
satl(check): in satellite.main, satellite.terminal.foreground takes a colour --
six hex digits like xFF8800, or a satellite.variable.color -- and was given text

directory: orange_words.satl:5
syntax: satellite.terminal.foreground("orange")
        /\

this operator has no scenario for the two kinds it was given. Nothing was
guessed at, because a guess here is an answer that is wrong and does not say so.
machine code 27 types_do_not_meet -- satl exits with this.

--------------------------------------------------------------------------------

satl’s own console

If you start a program without a terminal, for example from a desktop launcher, satl opens a console window of its own to run it in. You can also ask for one:

BASH Download
satl --console night_mode.satl

That console is a terminal like any other, so satellite.terminal colours it the same way. Your program’s input and output are that window, and when the program finishes, the window closes. If a program stops on an error, the window stays open and says so, so you can read the report, and closes when you press a key. Setting SATL_NO_WINDOW stops satl from opening a console by itself.

Where next

Every terminal and console word is in the FULL REFERENCE. To colour single lines and words instead of the whole window, read COLOR ON THE CONSOLE, and for everything the satl command can do, THE SATL COMMAND.

You may also like...

1 Response

  1. tsouqjnfop says:

    kqsfwqzpoyvlmjsywhnuyiqgpizhge

Leave a Reply

Your email address will not be published. Required fields are marked *