In all our previous examples, we only used a single line to display data, even though the XOSD window was big enough to display two lines. In this section we will display text and percentage bars on multiple lines, and scroll the window.
The number of lines that can be displayed in an XOSD window is set when the window is created by xosd_create and the the line to use is specified by xosd_display. The lines are numbered from the topmost line (line 0), so to display two lines of text in a two-line window we would use the following code.
xosd_display(osd, 0, XOSD_string, "You have been R00t3d"); xosd_display(osd, 1, XOSD_string, "By an l33t h4x0r");
We could also display a percentage bar on the bottom line (line 1) as the XMMS plugin does when the volume changes. The following code fragment combines the progress bar example with a single line of text, which is then replaced when bar reaches 100%.
Rather than simply replacing what is displayed on each line, as we did in the previous example, we can scroll the window, using xosd_scroll. This is useful when you have a large amount of data to display but do not want to create a large window or use a small font. The following example extends the previous example by scrolling the window to blank the display.
Example 3.5. Scrolling in XOSD
xosd_display(osd, 0, XOSD_string, "Being R00t3d"); for (i = 0; i <= 100; i += 5) { xosd_display (osd, 1, XOSD_percentage, i);sleep(1); } xosd_scroll(osd, 1); sleep(1); xosd_scroll(osd, 1); sleep(1);
xosd_display(osd, 1, XOSD_string, "You have been R00t3d"); sleep(1); xosd_scroll(osd, 1); sleep(1); xosd_display(osd, 1, XOSD_string, "By an l33t h4x0r"); sleep(1);
xosd_scroll(osd, 1); sleep(1); xosd_scroll(osd, 1); sleep(1); xosd_display(osd, 1, XOSD_string, "Long live script k1dd3z"); sleep(1); xosd_scroll(osd, 1); sleep(1); xosd_scroll(osd, 1); sleep(1);