Programlisting or screens are tags used to show something you would see on a computer screen (in the case of screen) and/or show some code. Much of this document was written using <screen> tags. Here's an example of a programlisting:
<programlisting> #include <stdio.h> main() { printf("Hello world\n"); } </programlisting> |
One thing you should note about <programlisting> is that you can have markup included inside the tags and it will get rendered. Here, to get the desired effect of producing a "<" and ">" I need to use the character entities (in this case that is the < and the >) in the above code. Otherwise the parser will think that <stdio.h> is an SGML tag and try to render it. We'll cover character entities later but for now just realize that you have be careful. Another thing to notice is the formatted version below has line numbers. This is something which will only appear if you used the newbiedoc custom stylesheets. If you're using the custom stylesheets make sure you only use <programlisting> when you want to explain something using line numbers. Otherwise, use the <screen> tag. If you would like to use the custom stylesheets see the Using the custom stylesheets section. The final thing to notice is that the position of the text does matter. For instance, The above programlisting was indented one tab from the left edge of the screen in the SGML source file. Here's what it'll look like formatted:
1 #include <stdio.h> 2 main() { 3 printf("Hello world\n"); 4 } 5 |
It's difficult to illustrate this so I will show an extreme example. Here's the same code indented 5 tabs from the left edge of the screen in the SGML source file:
<programlisting> #include <stdio.h> main() { printf("Hello world\n"); } </programlisting> |
And here is what that looks like rendered:
1 #include <stdio.h> 2 main() { 3 printf("Hello world\n"); 4 } 5 |
Do you see how that made a difference? The effect is the same with <screen> tags.
As far as <screen> tags go consider them to be the same as <programlisting>. The only difference being the line numbers if you're using the custom stylesheets as mentioned earlier.