I would like to create a program that reads a TXT file (say, a poem or a song) and then it outputs it on the terminal screen in a scrolling way, like at the bottom of the window, making it to appear from the bottom right, scrolling to the left and disappearing.
Here's a small program I threw together, that displays a section of a sentence at a time, till the whole sentence scrolls across the bottom of the screen. This should give you ideas on you can add it to your program..
#include <iostream>
#include <string>
#include <Windows.h>
usingnamespace std;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
void gotoXY(int x, int y);
int main()
{
string rotating_string = "This is a moving marquee, that shows an IMPORTANT
message... It could also be a poem, or short story : ";
string partial_string="";
int len = rotating_string.length();
char letter_holder;
do
{
gotoXY(38, 28);
partial_string = "";
for(int y=0;y<30;y++)
partial_string+= rotating_string[y];
cout << partial_string;
Sleep(100);
letter_holder = rotating_string[0];
for (int x = 1; x<len; x++)
{
rotating_string[x-1] = rotating_string[x];
}
rotating_string[len-1] = letter_holder;
} while (true);
return 0;
}
void gotoXY(int x, int y)
{
CursorPosition.X = x;
CursorPosition.Y = y;
SetConsoleCursorPosition(console, CursorPosition);
}
I don't know/use a Mac, but I'm thinking you can find a library that lets you use the gotoXY function, of placing text at a specified location. That's all the Windows.h library is used for my program.
Sorry. I've never used the #ifdef functions in my program, so when I saw the #include <Windows.h>, I figured it would be used. I too, hope it helps VonNeumann.