Console Help.

closed account (967L1hU5)
I am making a console program, that displays multiple bits of information on multiple rows and columns. I want to not have the terminal make more lines to give more information, but rather update the old bits. I have pd/n curses and am using refresh(), but it is not giving any effect. So I searched for alternate ways, and found that \r will bring it to the beginning of the line. Going via the \r route would solve my problem, but I didn't find a way to go up lines. If anybody could explain refresh() or any way to move the cursor up lines, it would be a huge help and greatly appreciated.
Doesn't curses have a function to move the cursor to any point on the screen? Check the documentation.
closed account (967L1hU5)
I'll check it out now, thanks! Completely unrelated however, I remember your name and figure that you are a top contributor, but what does the number next to usernames represent? Random thought, sorry if off topic.
Post count.
closed account (967L1hU5)
Ahh. Well, while doing my research, I stumbled upon some code, and put it into a compilable format:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <curses.h>
#include <iostream>

using namespace std;

main()
{
    cout << "Sample";
    int i;
    cin >> i;
    int move(int y, int x);
    refresh();
    int wmove(WINDOW *win, int y, int x);
    return 0;
}
(The only parts I didn't add are from int move to int wmove)
While this compiles, it doesn't do anything, but this is expected. So I change int x and y to 2, at move, than wmove, than both, with about the same error:
C:\Users\Dallas\Documents\Code Blocks\PD Curses\main.cpp|11|error: initializer expression list treated as compound expression|
C:\Users\Dallas\Documents\Code Blocks\PD Curses\main.cpp|11|warning: left-hand operand of comma has no effect|

I am at the end of what to do, as most websites gave info similar to this ones:
http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=wmove
wmove() requires a WINDOW pointer, which you haven't obtained from the library. move() doesn't.
http://pdcurses.sourceforge.net/doc/PDCurses.txt
closed account (967L1hU5)
Sorry for noobish question, but I Ctrl-F'd the document, and couldn't find what a window pointer is. Sorry, I am new to programming (5 months), and newer to curses (a week). Could you explain what a window pointer is?
One screen from the BOF:
DATA TYPES

The following data types are declared:

	WINDOW *	pointer to screen representation
closed account (967L1hU5)
Oh, well I feel ignorant on two accounts now. So a windows pointer is what the terminal shows?
It's a pointer to an object that represents the screen.
closed account (967L1hU5)
Oh, well back to the question, how would I than get the terminal updated?
I wrote:
wmove() requires a WINDOW pointer, which you haven't obtained from the library. move() doesn't [require a WINDOW pointer].
I realize you are an absolute beginner, so I'll be nice.

Things like int wmove(WINDOW *win, int y, int x); are function prototypes. Read up on using functions here: http://www.cplusplus.com/doc/tutorial/functions/
closed account (967L1hU5)
I've used functions before, but not to return integers. Yes, I am pretty much an absolute beginner, so how'd I use int wmove(WINDOW *win, int y, int x);? If you could give an example, it would be great. I am more of a learn-by-doing person.
Use the tutorial, luke.
closed account (967L1hU5)
Excuse my vulgar, but shit. I have google'd the hell out of pd/n curses tutorials.
Why should I help you if you want to become vulgar?

Your problem isn't with the console libraries, it is with language basics -- functions -- as I have already told you. I've even given you a direct link to the stuff that will help you.
closed account (967L1hU5)
I apologize for my vulgar, I had become exasperated. But I do understand the concepts of functions, while it may not seem like it. I hit rough patches in learning sometimes.
Everyone does.

A function prototype tells the computer what a function looks like: the number and kinds of arguments it takes, and what kind of thing it returns. An example:

    int wmove(WINDOW *win, int y, int x);

This tells you that the function wmove() takes three arguments (a pointer to a WINDOW and two integers) and it returns an integer.

To call the function (or use it), you simply give it values for the arguments (either literals or a valid value identifier), and if the function returns a value you may assign it to a variable.

When you prototype a function, it tells the compiler that the function exists, even though the compiler knows nothing else about it at the moment. Hence, you'll see code like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

int main( int argc, char* argv )
  {
  void greet( const char* name );  // this is a prototype -- this function must exist somewhere

  if (argc == 2)
    greet( argv[ 1 ] );  // here we use the function

  else
    greet( "world" );  // and here also

  return 0;
  }

void greet( const char* name )  // this is the function definition
  {
  cout << "Hello " << name << "!\n";
  }

The NCurses functions are already defined in the library (which you use when you compile with the -lcurses option). They are also already prototyped (you get the prototypes when you #include <ncurses.h>). Hence, all you need to do is call, or use, the functions.

Here are some example programs, both of which make use of the wmove() function to position the cursor:
http://www.cplusplus.com/forum/beginner/4520/#msg19965
http://www.cplusplus.com/forum/general/497/#msg1734

Hope this helps.
Topic archived. No new replies allowed.