Thread: Scrolling text in a DOS CONSOLE box

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Scrolling text in a DOS CONSOLE box

    Im writing a FakeOS in Win32 DOS CONSOLE, and its got its own text file format(with color control). well, heres my problem:

    I want a cin input (cin >> 1 == page up, cin >> 2 == page down)
    to scroll through lists of files, when i list the files, and of text files. the Directory listing scrolling isn't at the top of my list, but the text file scrolling most certainly is. How can i do this in an external declaration?
    Thanks in advnace
    This war, like the next war, is a war to end war.

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    By describing what you want in terms of what you've actually done and what you want instead of ambiguous terms. IOW I have no idea what you're talking about
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    OKay, let me reword that.

    have you ever played DOOM?

    If you have, you've seen the dos help file.

    Using Page Up and Page Down, you can scroll through the help file, in dos.

    I want to do that, but using a cin >> integer input.

    I dont know how to do it with page up/page down at all, so i have no idea how to do it in cin input either.

    I'll make an ascii picture of it here:

    ----------------------------------------------------------
    Exe
    ================================




    text is down here
    >scroll down
    -------------------------------------------------------------



    -----------------------------------------------------------
    Exe
    =================================
    Text is up here





    >
    -------------------------------------------------------------

    I hope that looks like a console box....

    OH BTW, you can get a copy of ion at my website,
    http://blizzarddog.tk/
    If you want to see a better example.

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    OK, got it. You want a little viewer for text files.

    Are you reading the file completely into memory and displaying only a few lines or reading only enough to display? The former will be easier to deal with.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  5. #5
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    heres my code for the part:

    Code:
    int read_text_file()
    {
    	char file[100];
    	cout << "File: ";
    	cin.getline(file, 100);
    	clrscr();
    	ifstream fin(file);
    	char ch;
    	while(fin.get(ch))
    	{
    		if (ch == '^')
    		{
    			char ch2;
    			fin >> ch2;
    			switch (ch2)
    			{
    				case 'R' : textcolor(RED);
    				break;
    				case 'G' : textcolor(GREEN);
    				break;
    				case 'W' : textcolor(WHITE);
    				break;
    				case 'B' : textcolor(BLUE);
    				break;
    				case 'C' : textcolor(CYAN);
    				break;
    				case 'M' : textcolor(MAGENTA);
    				break;
    				case 'Y' : textcolor(YELLOW);
    				break;
    				case 'b' : textcolor(LIGHTBLUE);
    				break;
    				case 'U' : textcolor(DARKGRAY);
    				break;
    				case 'g' : textcolor(LIGHTGRAY);
    				break;
    				case 'r' : textcolor(LIGHTRED);
    				break;
    				case 'E' : textcolor(BROWN);
    				break;
    				case 'c' : textcolor(LIGHTCYAN);
    				break;
    			}
    		}
    		else
    		{
    			cout << ch;
    			Sleep(8);
    		}
    	}
    	getche();
    	textcolor(WHITE);
    	clrscr();
    }
    I dont want to lose the color functions, thats what makes this thing unique.


    I figured i could do it with a string, but i dont knwo how i will make it work exactly like this. but once i get the scrolling, i can take out the sleep(8);

    Er.. i just confused myself with that bit...
    Last edited by Blizzarddog; 04-06-2004 at 02:30 PM. Reason: [code] not working

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Obtaining a value from a text box
    By thetinman in forum Windows Programming
    Replies: 1
    Last Post: 11-23-2006, 05:50 PM
  3. edit box affecting displaying of text?
    By algi in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2005, 03:28 PM
  4. String from a text box
    By Garfield in forum Windows Programming
    Replies: 4
    Last Post: 09-16-2001, 03:20 PM