Resize current window with Curses


 
Thread Tools Search this Thread
Top Forums Programming Resize current window with Curses
# 8  
Old 02-09-2010
How about:

Code:
printf("\x1b[8;%d;%dt", rows, cols);

to avoid the extra process.
# 9  
Old 02-09-2010
Ohhhh, itīs very good !!! It works very fine, but ..... i donīt undestand it. Never i have used 'printf' with that format.

May you explain me ? where could i find that documentation about that sequence?

But ..... unfortunately ... i would like to save the initial status, so, when program exits, restore it. Now, i execute 'resize' to get current values and then i execute 'resize' to change the window to the size i want. Finally, the program restore those values.
# 10  
Old 02-09-2010
Quote:
Originally Posted by pogdorica
Ohhhh, itīs very good !!! It works very fine, but ..... i donīt undestand it. Never i have used 'printf' with that format.
printf's only doing what you'd expect it to, converting %d into digits and printing the rest literally: ESC[8;25;80t where ESC is an ASCII 0x1b -- or as you'd do that in a C string, \x1b. xterm-compatible terminals understand that sequence as 'resize to 80 columns 25 rows'.

There's an equivalent command for 'report the number of columns and rows': ESC[18t. This will cause the terminal itself to print ESC[8;24;80t back to you(assuming your term's 80x24 that is). These escape sequences are how the 'resize' command works.

Of course, in hardcoding them you're abandoning all pretenses of portability. But then, you already did so when you insisted the terminal had to be able to resize itself Smilie

There's a gigantic list of the escape sequences xterm understands here. The VT100 DEC-based sequences are going to be portable to most terminal programs, but only the xterm ones can do things like move and resize the window.
# 11  
Old 02-10-2010
Ok, again, itīs very good, i 'll have a look at this link, it seems very interesting.

To get initial values of the screen size, i can use 'getmaxyx' to obtain them, and finally execute printf sentence to change size or restore initial status.

Code:
   void init ()
   {
      getmaxyx(stdscr, nRows, nColumns);
   }

   void draw (int nRows, int nColumns)
   {
      printf("\x1b[8;%d;%dt", nRows, nColumns);
   }

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Toggle between xterm window and standard terminal window

Is it possible to toggle back and forth between an xterm invoked from one tty, and a shell invoked from a different tty? I am running Centos 7 with KDE and booting in non-graphic mode. After logging in on the default window (/dev/tty1) , I can then use ALT-F2 to access a new window (/dev/tty2),... (1 Reply)
Discussion started by: rhgscty
1 Replies

2. 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

3. 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

4. UNIX for Advanced & Expert Users

send characters to current window

Before I re-invent the wheel... I have written an on-screen keyboard & handwriting input client in Java (spare me please, I get paid to write Java and it will take some time to get back up to speed in C & X11). In order to concentrate on the other bits, I took advantage of a hack... (0 Replies)
Discussion started by: bcw
0 Replies

5. Programming

curses.h

hi all i get a segmentation fault error in the following program. couldn't understand why it happens. can anyone explain what is really happening. s1.c #include<curses.h> main(){ int c; noecho(); cbreak(); c=getch(); printf("%c",(char)c); } I compiled this program as cc s1.c... (2 Replies)
Discussion started by: bankpro
2 Replies

6. 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

7. 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

8. Programming

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... (0 Replies)
Discussion started by: kwaz
0 Replies

9. Windows & DOS: Issues & Discussions

window 2000 professional not pinging my window 98 system.

Hello, We someone help me resolve this problem. I have window 2000 professional, windows 98 and Unixware 7.0.1 on the network. I was able to establish connection with all. However, l was unable to ping window 98 from window 2000 professional. I was able to ping the window 2000 from the window... (10 Replies)
Discussion started by: kayode
10 Replies

10. UNIX for Dummies Questions & Answers

curses.h

hi i'd like to know how to draw a rectangle using the curses.h library, you know with all the WINDOW *newwin stuff and all thanx!:) (1 Reply)
Discussion started by: chomano
1 Replies
Login or Register to Ask a Question