-   Programming (
-   -   ncurses programming -- problems in Framebuffer mode? (

vharishankar 12-10-2006 02:15 AM

ncurses programming -- problems in Framebuffer mode?
I am writing a simple ncurses program in C and it displays perfectly in the X terminal (Konsole and xterm).

However, since I boot in the framebuffer mode (to display splash screen using splashy) the program doesn't display properly in the terminal mode. In particular it doesn't seem to calculate the correct screen parameters as returned by the getmaxyx() function.

Anybody else noticed this behaviour? Is this an ncurses limitation?

ncurses version 5.5

vharishankar 12-11-2006 06:20 AM

I don't get it. It doesn't work in normal terminal mode as well (no framebuffer) but it displays correctly with an X terminal.

Any ideas where I'm going wrong? I've done ncurses programming before and didn't have this problem on my desktop.

paulsm4 12-11-2006 12:59 PM

Beats me.

I thought Suse's "Yast2" was a pretty good example of an ncurses-based application ... and Yast2 works fine for me when the system is in text mode (init 3, framebuffer-only).

Could the problem lie in the particular framebuffer and/or particular ncurses implementation in your distro? Does the program exhibit the same problem when you try other distros?

Sorry I can't be of more help .. PSM

vharishankar 12-11-2006 09:58 PM

Well, in the same laptop it doesn't work properly in pure text mode either, but in an X terminal it displays the border and the text in the correct location.

gnashley 12-12-2006 03:24 AM

Perhaps the problem is with the particular version of ncurses you are using. You might test that by trying the compile on one of your other distros.

vharishankar 12-12-2006 03:43 AM

I have the same version of ncurses on the same distro (Debian) on my desktop. And that program worked fine in the pure terminal mode as well as in an X terminal on my desktop system.

Is there a problem with the pure text mode in laptops which cause this issue. Or is the code the problem? Here's the code:


#include <curses.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>

/* Finishing up the ncurses proram */
static void finish (int sig)
        endwin ();
        exit (0);

/* Do some initializing for ncurses terminal mode */
void initialize ()
        signal (SIGINT, finish);
        initscr ();
        cbreak ();
        noecho ();
        if (has_colors ())
                start_color ();
                init_pair (1, COLOR_WHITE, COLOR_BLACK);
                init_pair (2, COLOR_WHITE, COLOR_BLUE);
                bkgd (COLOR_PAIR(2));       

/* Main program loop */
void main_loop ()
        char* window_title = " poorty - not fortune ";
        int x, y;
        while (1)
                getmaxyx (stdscr, y, x);
                clear ();
                box (stdscr, 0, 0);
                mvaddstr (0, x/2 - strlen(window_title)/2, window_title);
                refresh ();

                int ch = getch ();
                switch (ch)
                        case 'q':
                        case 'Q':
                                finish (0);


int main ()
        // Initialize the curses terminal
        initialize ();
        // Main program loop
        main_loop ();
        // Clean up on terminate
        finish (0);

In pure text mode, this program doesn't draw the border correct around the whole terminal and the text is displayed in the wrong location (not at the centre of the first line).

NOTE: the program is not yet complete. It's supposed to display a random quote.

vharishankar 12-13-2006 02:10 AM

I found out what was causing this issue. The 915resolution program. I removed it and now it works properly in the terminal mode also.

Strange problem... but I suspected it was something to do with the laptop.

All times are GMT -5. The time now is 01:40 AM.