Sponsored Content
Top Forums Programming curses & window resize issues Post 95983 by kwaz on Monday 16th of January 2006 03:49:22 PM
Old 01-16-2006
curses & window resize issues

I am writing a program to display a database to the screen(xterm) and want to allow the window resize signal to increase/decrease the amount data that is displayed. I have a signal handler function for catching the SIGWINCH event and calling a function to reallocate the space for the windows (stdscr and curscr) an reallocate the space for the windows.

The resize function looks something like:

Code:
//GLOBAL CONSTANTS, initialized elsewhere to the correct values
WINDOW* display;
int maxX;
int maxY;

// resize event function
void resizeHandler() {
   WINDOW*curscrOld = curscr;
   WINDOW*stdscrOld = stdscr;

   delwin(curscrOld);
   delwin(stdscrOld);
   endwin();

   display = initscr();
   getmaxyx(display, maxY, maxX);

   signal(SIGWINCH, resizeHandler);
}

The problem with the reallocation function seems to be that I put in another call to initscr(). Not every time, but frequently enough to be annoying, the program will have a segmentation fault during the call to initscr() when a resize event occurs. The reason I put in another call to initscr() was getmaxyx() was not updating the size of the windows on a resize event, I tried to just use the endwin() then a call to refresh() to reinitialize the values with no luck. Is there someplace else I can get the xterm's window size and the use some calls to newwin() to create new stdscr and curscr variables on my own? I am running on Solaris 8, thanks in advance for any help.
 

10 More Discussions You Might Find Interesting

1. IP Networking

UNIX & WINDOW

Is there any way that I could invoke a Win NT application in a UNIX environment? Needed to do this to direct the output of an Win NT application to a UNIX program, and then back again. Furthermore, because there's a large amount of processing to be done, it will be great if I could do this... (1 Reply)
Discussion started by: Norman N
1 Replies

2. Solaris

CDE loging window resize?

I was asked to display a banner on the CDE login window and I have successfully accomplished that task. This is what I did: 1) made the directory /etc/dt/config/C 2) cp /usr/dt/config/C/Xresources /etc/dt/config/C 3) I edited /etc/dt/config/C/Xresources and ensured the following lines were... (0 Replies)
Discussion started by: rtoba
0 Replies

3. UNIX for Advanced & Expert Users

CDE loging window resize?

I was asked to display a banner on the CDE login window and I have successfully accomplished that task. This is what I did: 1) made the directory /etc/dt/config/C 2) cp /usr/dt/config/C/Xresources /etc/dt/config/C 3) I edited /etc/dt/config/C/Xresources and ensured the following lines were... (0 Replies)
Discussion started by: rtoba
0 Replies

4. UNIX Desktop Questions & Answers

Resize the default window size

Hi, How can I resize the terminal window's default size in CDE (Solaris)? Regards, Sharif. (1 Reply)
Discussion started by: sharif
1 Replies

5. UNIX for Dummies Questions & Answers

Question on x-window & which Linux to go with

Hi, Currently in my company, we are using Windows 2003 server and Exceed. Team from India can connect to the Windows 2003 server and start Exceed to run their UNIX application. The application is GUI based. As you know, Windows 2003 only allows two connection at any time. so I want to... (3 Replies)
Discussion started by: samnyc
3 Replies

6. UNIX for Dummies Questions & Answers

Preventing the terminal window to resize

I am running Terminal (xterm) on FreeBSD and XFCE. When opening a new terminal window so that an additional tab appears, the window resizes to become taller and partially hiding behind the task bar. I noticed that Xubuntu has fixed this feature and the window does not resize when opening a second... (0 Replies)
Discussion started by: figaro
0 Replies

7. Programming

Resize current window with Curses

Hi. I am beginning with Unix C Curses Library and i would like to know if it's possible to resize my current window. In other words, i am working with a Putty Client over my Windows system and with a telnet/ssh connection to linux. I want to build a small linux application using C Curses... (10 Replies)
Discussion started by: pogdorica
10 Replies

8. Shell Programming and Scripting

Synchronize pictures & resize at the same time

Hi, I"m trying to achieve the following: I have a NAS which holds all my pictures, and have it mounted on my xbmc as a network share. I want to automatically synchronize my pictures (NAS -> xbmc, one direction). But, during the synchronization I want to resize the pictures to make them... (7 Replies)
Discussion started by: Joeba
7 Replies

9. Shell Programming and Scripting

How to find & auto resize images?

I need a command or mini scripts that can find certain type of images file recursively from the current dir with files of minimum 736 width and resize them by "736 max width, relative height" and replace the source files. I currently have GD installed but can also install Imagemagick if needed, I'm... (5 Replies)
Discussion started by: Frozen77
5 Replies

10. UNIX and Linux Applications

Xalan & Xerces issues for Oracle Linux 6.6 & Solarisstudio12.3 C++ compiler for Linux

Hi Team, I am facing issue while using Xalan & Xerces for my application. Below are my environment details i am using :- Platform:- Oracle Linux 6.6 Compiler :- solarisstudio12.3 C++ compiler for Linux Below are the versions of Xalan & Xerces source code used to build the shared object... (0 Replies)
Discussion started by: agrachirag
0 Replies
CURSES_SCREEN(3)					   BSD Library Functions Manual 					  CURSES_SCREEN(3)

NAME
curses_screen, newterm, set_term, delscreen, endwin, initscr, isendwin, resizeterm, setterm -- curses terminal and screen routines LIBRARY
Curses Library (libcurses, -lcurses) SYNOPSIS
#include <curses.h> SCREEN * newterm(char *type, FILE *outfd, FILE *infd); SCREEN * set_term(SCREEN *screen); void delscreen(SCREEN *screen); int endwin(void); WINDOW * initscr(void); bool isendwin(void); int resizeterm(int lines, int cols); int setterm(char *name); extern int LINES; extern int COLS; DESCRIPTION
These functions initialize terminals and screens. The newterm() function initialises the curses data structures and pointers ready for use by curses. The type argument points to a termcap(5) capability name, or it may be NULL in which case the TERM environment variable is used. The outfd and infd are the output and input file descriptors for the terminal. The newterm() function must only be called once per terminal. The set_term() function can be used to switch between the screens defined by calling newterm(), a pointer to the previous screen structure that was in use will be returned on success. Calling delscreen() will destroy the given screen and free all allocated resources. Calling endwin() will end the curses session and restore the saved terminal settings. The curses session must be initialised by calling initscr() which saves the current terminal state and sets up the terminal and internal data structures to support the curses application. This function call must be, with few exceptions, the first Curses library call made. The exception to this rule is the newterm() call which may be called prior to initscr(). The size of the curses screen is determined by checking the tty(4) size and then the termcap(5) entries for the terminal type. If the environment variables LINES or COLS are set, then these will be used instead. When either newterm() or initscr() are called, the Curses library sets up signal handlers for SIGTSTP and SIGWINCH. If a signal handler is already installed for SIGWINCH, this will also be called when the Curses library handler is called. The isendwin() function can be used to determine whether or not a refresh of the screen has occurred since the last call to endwin(). The size of the screen may be changed by calling resizeterm() with the updated number of lines and columns. This will resize the curses internal data structures to accommodate the changed terminal geometry. The curscr and stdscr windows and any of their subwindows will be resized to fit the new screen size. The application must redraw the screen after a call to resizeterm(). The setterm() function sets the terminal type for the current screen to the one passed, initialising all the curses internal data structures with information related to the named terminal. The name argument must be a valid name or alias in the termcap(5) database for this function to succeed. RETURN VALUES
Functions returning pointers will return NULL if an error is detected. The functions that return an int will return one of the following values: OK The function completed successfully. ERR An error occurred in the function. SEE ALSO
curses_window(3), tty(4), termcap(5), signal(7) STANDARDS
The NetBSD Curses library complies with the X/Open Curses specification, part of the Single Unix Specification. HISTORY
The Curses package appeared in 4.0BSD. The resizeterm() function is a ncurses extension to the Curses library and was added in NetBSD 1.6. BSD
October 24, 2007 BSD
All times are GMT -4. The time now is 05:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy