Thread: console scrolling

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    102

    console scrolling

    hello,
    what i am trying to do, is have the user type at the bottom of the console, and print the text at the top example:

    Code:
    #include <iostream>
    #include <string>
    #include <windows.h>
    using namespace std;
    
    
    void gotoxy ( int x, int y )
    {
    	COORD dwCursorPosition = { x, y };
    	SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), dwCursorPosition );
    }
    
    
    
    int main()
    {
    	int loc=0;
    	string test;
    	while(true){
    		gotoxy(0,23);
    		cout << "type: ";
    		getline(cin, test);
    		gotoxy(0,23);
    		for(int x = test.length()+6; x>0; x--)
    		{
    			cout << ' ';
    		}
    		gotoxy(0,loc);
    		cout << test;
    		loc++;
    	}
    	
    	return 0;
    }
    now this does exactly what i want it to do, untill you have inputted so many times that, it begins to display the text below where your acctually typing.
    so basically when int loc reaches 22 i want to move all the text up one line..?

    if you compile the code, my question may be easier to understand.

    windows,
    MSVC++6

  2. #2
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    sorry to bump this, but i am really stuck, does nobody have any ideas as to a solution?

  3. #3
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119
    Unfortunaley my friend no there is no way out

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    so theres absolutly no solution?

  5. #5
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    Code:
    #include <iostream>
    #include <string>
    #include <windows.h>
    using namespace std;
    
    
    void gotoxy ( int x, int y )
    {
    	COORD dwCursorPosition = { x, y };
    	SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), dwCursorPosition );
    }
    
    
    
    int main()
    {
    	int loc=0;
    	int y = 23;
    	string test;
    	while(true){
    		if (loc == y-1){
    			y++;
    		}
    		gotoxy(0,y);
    		cout << "type: ";
    		getline(cin, test);
    		gotoxy(0,y);
    		for(int x = test.length()+6; x>0; x--)
    		{
    			cout << ' ';
    		}
    		gotoxy(0,loc);
    		cout << test;
    		loc++;
    	}
    	
    	return 0;
    }
    i just fugured it out..
    it now works perfectly
    thanks me, bye
    Last edited by b00l34n; 04-26-2004 at 03:25 AM.

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    I cover scrolling horizontally, vertically and even diagonally in my console tutorials, this topic is in part 6, but I recommend you start from the beginning, here.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    i never realized that was your site, its very good, i already have it all saved to my harddrive, but i have never read part 6, i will read it now.

  8. #8
    Registered User cfrost's Avatar
    Join Date
    Apr 2004
    Posts
    119

    Arrow Well Nice coverage

    Greetings My friend and thanx for your help : )

  9. #9
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You can implement text windows in your code to create scrolling in separate portions of the screen. Use adrian's code for scrolling but place the code into your window class. That way each window on screen can scroll vertically, horizontall, and even diagonally.

  10. #10
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    just read part 6 of your tutorial, i don't think that is the kind of scrolling i am talking about

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 09:59 PM
  2. Scrolling text in a DOS CONSOLE box
    By Blizzarddog in forum C++ Programming
    Replies: 4
    Last Post: 04-06-2004, 02:27 PM
  3. scrolling map terrain for console
    By Leeman_s in forum Game Programming
    Replies: 2
    Last Post: 06-07-2002, 08:18 PM
  4. Console Text Scrolling Help!!
    By frgmstr in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2002, 02:37 PM
  5. My Console RPG with scrolling terrain ver 4!
    By Jeremy G in forum Game Programming
    Replies: 4
    Last Post: 11-25-2001, 04:39 PM