Yet another lame program -- ncurses problem

This is a discussion on Yet another lame program -- ncurses problem within the C Programming forums, part of the General Programming Boards category; Ok, i'm working on another simple ncurses program for a few friends and I. It's supposed to do this, in ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    52

    Yet another lame program -- ncurses problem

    Ok, i'm working on another simple ncurses program for a few friends and I. It's supposed to do this, in it's present state of being just a GUI-test (well, not exactly a GUI):

    1) Show title at top -- it does this.
    2) Create another window, below that, with a border. that window fills up the rest of the screen. --- this doens't work.

    Here's the source.
    Code:
    #include <ncurses.h>
    #include <stdarg.h>
    #include <string.h>
    #include <stdlib.h>
    #include <time.h>
    #include <ctype.h>
    
    int main(int argc, char *argv[]) {
      WINDOW *win;
      int curchar;
      int height = (LINES - 5);
      int width = (COLS - 3);
      
      initscr();
      cbreak();
      keypad(stdscr, TRUE);
      noecho();
      start_color();
      
      init_pair(1, COLOR_GREEN, COLOR_BLACK);
      init_pair(2, COLOR_BLUE, COLOR_BLACK);
      init_pair(3, COLOR_RED, COLOR_BLACK);
      init_pair(4, COLOR_WHITE, COLOR_BLACK);
      
      bkgdset(COLOR_BLACK);
      attron(A_BOLD | COLOR_PAIR(1));
      mvprintw(0, (COLS / 2) - (0.5 * strlen("SCSCO Communicator")), "SCSCO Communicator");
      attroff(A_BOLD);
      mvprintw(1, (COLS / 2) - (0.5 * strlen("By Cam Tenny")), "By Cam Tenny");
      attroff(COLOR_PAIR(1));
      win = newwin(height, width, 4, 1);
      wborder(win, '|', '|', '-', '-', '*', '*', '*', '*');
      wrefresh(stdscr);
      wrefresh(win);
      getch();
      delwin(win);
      endwin();
      return 0;
    }
    compile with -lncurses, if you actually try to run it.

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Don't understand why but it shows the border if you create the window like this
    Code:
      win = newwin(LINES - 5, COLS - 3, 4, 1);
    and that should be just the same as your code. ?????
    Kurt

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    52
    EDIT: Nevermind about the first part of my question (the colors), i just had to use wattron instead of attron.

    hmm. very interesting.
    but thanks!

    one last thing on this:

    Code:
      attron(COLOR_PAIR(2) | A_BOLD);
      wborder(win, ACS_CKBOARD, ACS_CKBOARD, ACS_CKBOARD, ACS_CKBOARD, ACS_CKBOARD, ACS_CKBOARD, ACS_CKBOARD, ACS_CKBOARD);
      attroff(COLOR_PAIR(2));
    (and color pair 2 is blue on black)
    it still shows the border as being in gray............
    any way around that?

    also, i heard that with ncurses and multiple windows you have to refresh them from the bottom up, or at least that you have to refresh them in some strange order..... can anybody tell me how (and how often) I should be refreshing these?
    Last edited by w00tw00tkab00t; 01-08-2006 at 03:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem w/ doubles in friend's program
    By mkylman in forum C Programming
    Replies: 16
    Last Post: 11-22-2008, 10:45 AM
  2. Problem with my program i cant figure out...
    By youareafever in forum C Programming
    Replies: 7
    Last Post: 11-02-2008, 12:56 AM
  3. I have finished my program, one problem
    By sloopy in forum C Programming
    Replies: 4
    Last Post: 11-29-2005, 02:10 AM
  4. Program problem
    By Birdhaus in forum C++ Programming
    Replies: 6
    Last Post: 11-21-2005, 10:37 PM
  5. Replies: 2
    Last Post: 04-25-2005, 12:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21