LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-10-2006, 01:15 AM   #1
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Rep: Reputation: 121Reputation: 121
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
 
Old 12-11-2006, 05:20 AM   #2
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Original Poster
Rep: Reputation: 121Reputation: 121
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.
 
Old 12-11-2006, 11:59 AM   #3
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 12-11-2006, 08:58 PM   #4
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Original Poster
Rep: Reputation: 121Reputation: 121
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.
 
Old 12-12-2006, 02:24 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,763

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
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.
 
Old 12-12-2006, 02:43 AM   #6
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Original Poster
Rep: Reputation: 121Reputation: 121
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:

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.

Last edited by vharishankar; 12-12-2006 at 02:44 AM.
 
Old 12-13-2006, 01:10 AM   #7
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Original Poster
Rep: Reputation: 121Reputation: 121
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.
 
  


Reply

Tags
framebuffer, laptop, mode, ncurses, rendering


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming with NCurses indienick Programming 7 07-11-2006 02:56 PM
C programming HELP, ncurses window functions naomi Programming 3 02-06-2005 05:54 AM
framebuffer video mode problems mundri Linux - Hardware 5 11-23-2004 10:31 PM
Ncurses windows and sockets in asynch mode (?) krajzega Programming 4 04-03-2004 01:31 PM
Parallel programming with ncurses problem StressedLemming Programming 4 02-26-2004 11:54 AM


All times are GMT -5. The time now is 06:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration