User: Password:
|
|
Subscribe / Log in / New account

Terminals crap on greater than 80 columns

Terminals crap on greater than 80 columns

Posted Jun 5, 2004 2:01 UTC (Sat) by jwb (guest, #15467)
In reply to: Terminals crap on greater than 80 columns by smoogen
Parent article: The Grumpy Editor's guide to terminal emulators

Ah, after using UNIX and variants for over a decade I finally discovered the source of this utterly baffling problem. And now I will share my hard-gained wisdom with you, gentle readers:

The problem is SIGWINCH. Let's say you call up an xterm in your favorite 80x25 or 80x40 or 120x40 etc. Then you invoke your favorite pager on some really wide file. The lines are wrapped, so you make the xterm wider. This works fine. Afterwards, you go back to the shell, but your long command lines are all screwed up! Egads!

What's happened is SIGWINCH, the signal sent to programs when the size of the controlling terminal changes, we delivered to your pager (less, more, whatever). It was NOT delivered to your shell. So the shell, which is probably using readline for command editing, has no idea the terminal is now 281 characters across. This causes major problems inside the readline library, and is why editing long command lines often barfs.

The workaround: just resize the terminal a bit when you see the problem. This will deliver the SIGWINCH to the program you are currently using, and make everything look correct again.

A real solution would be for the shell (or readline, or some other bit of code) to check the size of the controlling terminal whenever it resumes control of it, when children exit, or whenever it might have changed unnoticed.


(Log in to post comments)

Terminals crap on greater than 80 columns

Posted Jun 5, 2004 7:56 UTC (Sat) by glettieri (subscriber, #15705) [Link]

In bash, just do:

shopt -s checkwinsize

Don't think this is the problem smoogen was having, though...

Terminals crap on greater than 80 columns

Posted Jun 5, 2004 14:43 UTC (Sat) by tzafrir (subscriber, #11501) [Link]

another option: maximize the window, and restore (pressing alt-F10 twice, in default icewm settings).

Terminals crap on greater than 80 columns

Posted Jun 5, 2004 15:06 UTC (Sat) by glettieri (subscriber, #15705) [Link]

I guess my previous post was a little bit cryptic :)
You don't have to type that command each time readline goes out of sync with the window size. If you turn the 'checkwinsize' option on, bash will chech the window size after each command. Put the 'shopt -s ...' in your rc file and the problem is gone forever...

Terminals crap on greater than 80 columns

Posted Jun 5, 2004 15:05 UTC (Sat) by vivek (guest, #6962) [Link]

kill -WINCH $$ usually does the trick when the window size has
been changed behind the emulator's back.

Terminals crap on greater than 80 columns

Posted Jun 7, 2004 19:10 UTC (Mon) by Ross (guest, #4065) [Link]

But why does this work in xterm by default but not in kterm? In any case
I'm able to fix it by running the "resize" program but I shouldn't have to.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds