bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Not getting colours in Ubuntu gnome terminal with ncurses


From: srepuac
Subject: Not getting colours in Ubuntu gnome terminal with ncurses
Date: Sat, 21 Jun 2008 03:30:29 -0700 (PDT)



     Hi everyone, I just started learning a bit of c++ and ncurses and I'm
also pretty new to Linux...

My gnome terminal, that has colours when I query him with ls, suddenly
doesn't want to change colours when I am using ncurses :( here is an example
program...

#include <string>   //Length
#include <curses.h>
using namespace std;
string menuarray[20];

void cursesinit()
{

    initscr();
    cbreak(); //no newline needed for getch()
    keypad(stdscr, TRUE);
    noecho();
    start_color();

}

unsigned short makearray(string menusentence)
{

    string temp = menusentence + ", ";
    menusentence += ", ";
    int c = 0; //To store how many words
    int d;
    int wherearewe;

    while (temp.find(", ") != temp.npos)
    {//Counts the number of words

        wherearewe = temp.find(", ");
        temp = temp.substr(wherearewe + 2, temp.length());
        c += 1;

    };


    for (d = 0; d < c; d++)
    {

        wherearewe = menusentence.find(", ");
        menuarray[d] = menusentence.substr(0, wherearewe);
        menusentence = menusentence.substr(wherearewe + 2,
menusentence.length());


    }

    return c;


}

void printmenu()
{

    int x, y;

    getmaxyx(stdscr,y,x);

    string menusentence = "Choice 1, Choice 2, Choice 3, Choice 4, Choice
5";
    string menutitle = "Welcome to the menu!";
    int choices = makearray(menusentence);
    string aos[50];

    for (int ze = 1; ze < 50; ze++)
    {
        aos[ze] = "  ";
    };

    aos[0] = " >";


    mvprintw(0, ((x/2) - menutitle.length()/2), "%s",menutitle.c_str());
    printw("%s","\n\n");

    for (int e = 0; e < choices; e++)
    {

        printw("%s",aos[e].c_str());
        printw("%s"," ");
        printw("%s",menuarray[e].c_str());
        printw("%s","\n\n");

    };

    init_pair(1, COLOR_RED, COLOR_WHITE);
    mvchgat((+2), 0, menuarray[0].length(), COLOR_PAIR(1), 0, NULL);

}

int main()
{
    cursesinit();

    printmenu();

    getch();

    endwin();
}


Any ideas what might be wrong?

Thanks in advance,

Srepuac
-- 
View this message in context: 
http://www.nabble.com/Not-getting-colours-in-Ubuntu-gnome-terminal-with-ncurses-tp18042981p18042981.html
Sent from the Gnu - Ncurses mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]