Resize current window with Curses | Unix Linux Forums | Programming

  Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Resize current window with Curses

Programming


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-04-2010
pogdorica's Avatar
pogdorica pogdorica is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 30 August 2012, 4:32 AM EDT
Location: Madrid
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
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 library and i want to fix the size (rows and columns) of my current Putty window.

Is it possible?

First of all, thanks for your help
Sponsored Links
    #2  
Old 02-04-2010
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 30 September 2014, 7:25 PM EDT
Location: Saskatchewan
Posts: 19,479
Thanks: 795
Thanked 3,286 Times in 3,081 Posts
A little googling found me this. You may or may not need to tweak your terminal types, etc. for curses to realize putty's terminal supports resizing, but it definitely does.
Sponsored Links
    #3  
Old 02-04-2010
pogdorica's Avatar
pogdorica pogdorica is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 30 August 2012, 4:32 AM EDT
Location: Madrid
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, thanks Corona.

I had been looking for that this morning and i had found 'resize_term' but my first tests didn't make it.

I 'll read more about this and i 'll do more tests.

I 'll report about any advances.

---------- Post updated at 04:59 PM ---------- Previous update was at 04:26 PM ----------

Oh !!! I just find this post:

terminal Width/height change

    #4  
Old 02-04-2010
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 30 September 2014, 7:25 PM EDT
Location: Saskatchewan
Posts: 19,479
Thanks: 795
Thanked 3,286 Times in 3,081 Posts
Quote:
Originally Posted by pogdorica View Post
---------- Post updated at 04:59 PM ---------- Previous update was at 04:26 PM ----------

[/COLOR]Oh !!! I just find this post:

terminal Width/height change

No, I really think you need to call resizeterm(). The ioctl only changes what size is reported, not what size the window is, so isn't very useful. How the terminal is actually resized from the user end is terminal-specific and nothing to do with the kernel, hence part of curses.

What value is resizeterm returning? It may not think your terminal's resizable. Curses also provides the function is_term_resized() to tell if curses thinks the terminal is even capable of resizing. What does 'env | grep TERM' show? If TERM is not xterm it probably won't try to resize it even if the terminal supports it.

---------- Post updated at 10:50 AM ---------- Previous update was at 10:09 AM ----------

(posted from PM with permission)
Quote:
Originally Posted by pogdorica
Hi Corona.

I'm grateful for your time and support. I'm from Madrid-Spain and I'm really sorry if my english isnīt very good. I hope you understand all my post.
Even if it's not as easy as Spanish for you, your english is quite good.
Quote:
Today, itīs the first time that i try to do something with 'curses' library and i would want to know what it is possible to do and not to do with this library. I am studying your link; sure it 's very good.
I really don't know curses. I'm just using google, reading documentation, and suggesting things I do by habit. It certainly seems possible to resize terminals with curses -- both PuTTY and curses support it.

Whenever a function doesn't work, first check its return value. Whether curses believes its succeeded or not will help you figure out what's gone wrong. curses might not even be trying to resize the terminal if it doesn't believe its resizable.

Another thing to check is the manual page, see 'man resizeterm'. That's where I found that resizeterm and resize_term are different functions -- you should be calling resizeterm -- and where I found the mention of is_term_resized.

You might also find Writing Programs with NCURSES useful.
Sponsored Links
    #5  
Old 02-04-2010
pogdorica's Avatar
pogdorica pogdorica is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 30 August 2012, 4:32 AM EDT
Location: Madrid
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
I have found this Linux Redhat command "resize -s Rows Columns" and it works in my PuTTY terminal, so,... Curses should work too, i hope so.
Sponsored Links
    #6  
Old 02-04-2010
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 30 September 2014, 7:25 PM EDT
Location: Saskatchewan
Posts: 19,479
Thanks: 795
Thanked 3,286 Times in 3,081 Posts
I've been toying with curses a little and have found that it believes it has resized it when in fact it has not. When the program exits Putty has spammed "PuTTYPuTTYPuTTYPuTTYPuTTYPuTTY" messages to console no matter what I do, meaning curses is sending it some weird ^e control codes instead of the esc-codes one would expect of an xterm!

Looking up the actual esc codes, I made this shell function:

Code:
function resize # call resize x y
{
        echo -e "\x1b[8;${2};${1}t"
}

it acts as expected, so curses seems to be giving bananas resize codes for this for some reason.

---------- Post updated at 12:36 PM ---------- Previous update was at 12:04 PM ----------

On further testing my code was messed up. But whether the call succeeds or not, it seems that it doesn't actually send any codes to resize the window! This may be another one of those strange curses things where it's "supposed to do that" until you do the right voodoo. Or it may be a bug. With curses it's sometimes hard to tell the difference...
Sponsored Links
    #7  
Old 02-09-2010
pogdorica's Avatar
pogdorica pogdorica is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 30 August 2012, 4:32 AM EDT
Location: Madrid
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Hi.

Well, i finally havenīt got to resize my xterm terminal with C library Curses, so i have had to do it with "resize command" such as:

Code:
sprintf (vx_sttorden, "resize -s %d %d >/dev/null", 
         p_nuRows, p_nuColumns);

ret = system (vx_sttorden);

Thanks for all.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Preventing the terminal window to resize figaro UNIX for Dummies Questions & Answers 0 10-07-2009 06:45 AM
Resize the default window size sharif UNIX Desktop for Dummies Questions & Answers 1 07-14-2008 03:05 PM
CDE loging window resize? rtoba UNIX for Advanced & Expert Users 0 02-28-2006 06:18 PM
CDE loging window resize? rtoba Solaris 0 02-16-2006 02:00 PM
curses & window resize issues kwaz Programming 0 01-16-2006 03:49 PM



All times are GMT -4. The time now is 11:58 PM.