Thread: nCurses

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    nCurses

    Hi

    Hopefully someone here as dealt with nCurses before. For a project I have to implement nCurses for the UI. My plan is to have a button, or text to move back and forth between pages for entering text.

    How should I go about doing this? Is it all possible?

    Thanks
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  2. #2
    Registered User Fredd's Avatar
    Join Date
    Oct 2002
    Posts
    69
    you could read through this: http://en.tldp.org/HOWTO/NCURSES-Programming-HOWTO/

    not sure of what you mean though.
    "Writing software is more fun than working."

    got slack?
    http://www.slackware.com/

  3. #3
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    Ill try to textually draw what I mean

    Window 1

    Code:
    *-----------*
    |           |
    | TEXT      |
    |         > |
    *-----------*
    Window 1 above
    Now when I select the > or any piece of text in the first window, I would like to move to a new window, ontop of that window, and do this numerous times.

    So if there is a series of lets say 5 windows, I would still like to be able to get to the first window after I am at the fifth.
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  4. #4
    Registered User Fredd's Avatar
    Join Date
    Oct 2002
    Posts
    69
    Like a menu you mean?
    I still recommend reading thru http://en.tldp.org/HOWTO/NCURSES-Programming-HOWTO/

    check out the parts about windows ( /windows.html ) and perhaps keyboard/ mouse handling.
    "Writing software is more fun than working."

    got slack?
    http://www.slackware.com/

  5. #5
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    I actually was already looking at the site, but I am still un sure as how to switch between windows when some has their cursor over a piece of text like <FORWARD> and then opens that window.
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  6. #6
    phooey
    Guest

    Information

    Hmm .. this may be alot to absorb, and alot of it IS found in the tutorial previously posted, but maybe it will help you.


    Ncurses views your entire screen as one, overlapping layout. The overlaps, obviously, being windows.
    Ncurses allows you to do some keyboard mapping, create windows, colors, etc. A good example is the Linux kernel config utility (ie: make menuconfig). I am not sure if that was written in curses or not, but it is very 'curses'ish. If you know what I mean.

    As far as how to write text on windows, Ncurses has a standard (of sorts), where you can prefix/suffix (not sure which .. been awhile) any command with 'w', which specificies to operate on a window, or 'mv', which moves the location of the cursor, and a few others.

    If you need more, try peeking at a google search, 'ncurses tutorials'. There's a few out there I am sure of.

  7. #7
    Registered User
    Join Date
    Dec 2002
    Posts
    19
    hi,
    i'm also working now with ncurses, and i'm also a beginner. i tried to figure out your problem, and i've tested it with this little program. i hope this will solve your problem!

    Code:
    #include <ncurses.h>
    
    int main() {
      WINDOW* one, *two, *three;
    
      initscr();
      cbreak();
      keypad(stdscr, TRUE);
      start_color();
    
      one = newwin(20, 20, 0, 0);
      two = newwin(20, 20, 0, 0);
      three = newwin(20, 20, 0, 0);
      init_pair(2, COLOR_MAGENTA, COLOR_BLACK);
      init_pair(3, COLOR_YELLOW, COLOR_BLACK);
      init_pair(4, COLOR_CYAN, COLOR_BLACK);
    
    
      wbkgdset(one, COLOR_PAIR(2));
      wbkgdset(two, COLOR_PAIR(3));
      wbkgdset(three, COLOR_PAIR(4));
    
      box(three, 0, 0);
      wrefresh(three);
      sleep(1);
      box(two, 0, 0);
      wrefresh(two);
      sleep(1);
      box(one, 0, 0);
      refresh();
      wrefresh(one);
    
      getch();
    
      endwin();
      return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-26-2009, 02:47 PM
  2. Ncurses or not?
    By Zarniwoop in forum C Programming
    Replies: 4
    Last Post: 05-04-2008, 11:19 AM
  3. Why I only get 8 colors out of ncurses?
    By Nazgulled in forum C Programming
    Replies: 3
    Last Post: 05-08-2007, 06:06 PM
  4. Ncurses and Standard Functions
    By gsoft in forum C Programming
    Replies: 2
    Last Post: 02-07-2005, 08:18 PM
  5. using the mouse with ncurses
    By dsharp in forum Linux Programming
    Replies: 2
    Last Post: 12-24-2003, 05:35 PM