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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-10-2006, 01:15 AM
|
#1
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Rep: 
|
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
|
|
|
|
12-11-2006, 05:20 AM
|
#2
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Original Poster
Rep: 
|
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.
|
|
|
|
12-11-2006, 11:59 AM
|
#3
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
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
|
|
|
|
12-11-2006, 08:58 PM
|
#4
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Original Poster
Rep: 
|
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.
|
|
|
|
12-12-2006, 02:24 AM
|
#5
|
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,595
|
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.
|
|
|
|
12-12-2006, 02:43 AM
|
#6
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Original Poster
Rep: 
|
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.
|
|
|
|
12-13-2006, 01:10 AM
|
#7
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Original Poster
Rep: 
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:46 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|