From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike Gran Newsgroups: gmane.lisp.guile.devel Subject: Re: Set debug output width in REPL Date: Thu, 24 Feb 2011 17:43:00 -0800 (PST) Message-ID: <21720.11103.qm@web37908.mail.mud.yahoo.com> Reply-To: Mike Gran NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1298598197 15660 80.91.229.12 (25 Feb 2011 01:43:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 Feb 2011 01:43:17 +0000 (UTC) To: =?utf-8?B?THVkb3ZpYyBDb3VydMOocw==?= , "guile-devel@gnu.org" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Feb 25 02:43:12 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Psmi7-0002aR-M7 for guile-devel@m.gmane.org; Fri, 25 Feb 2011 02:43:11 +0100 Original-Received: from localhost ([127.0.0.1]:54695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Psmi7-0000EU-8u for guile-devel@m.gmane.org; Thu, 24 Feb 2011 20:43:11 -0500 Original-Received: from [140.186.70.92] (port=41423 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Psmhz-0000BA-9g for guile-devel@gnu.org; Thu, 24 Feb 2011 20:43:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Psmhy-0004K4-Ao for guile-devel@gnu.org; Thu, 24 Feb 2011 20:43:03 -0500 Original-Received: from web37908.mail.mud.yahoo.com ([209.191.91.170]:25220) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Psmhy-0004Jy-2H for guile-devel@gnu.org; Thu, 24 Feb 2011 20:43:02 -0500 Original-Received: (qmail 11574 invoked by uid 60001); 25 Feb 2011 01:43:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1298598181; bh=TSNt9cRDKuSyYlOTEh8b/YJ05hBmVhvAliPQUH8GfqI=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=VCK4VyRuPOHEH+1t7ODml9QJ7sr4DTzI5f66WSIi2A6zn2bKm/VrYz7LgCYgioHneuhdQ2iHdH/JljXcFLI+hH57HwyE6aWEjN4VHvKLNBJiz1+wMghmPbZi1ieZGsa983XbWaUppq1NneNIpem5zNAH5j7kZhj3gfeUyxjqu/w= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=MP3skaAEbaeJJIL+iE4Oj+PX8hfR84utNGn8+Lt/I+3AVIT5+p4AdSbkiRaC8sH08aXM9eiBH3IhyYXFZiBkCEDe3ycdz79lCfV2azv494OMJCN3pVc43JSiP+32bVg22D71TEZi2//HYwpQcCGZjEp4dhGV9lvYhmSVgMdnPpo=; X-YMail-OSG: RJNxAPEVM1lU2bmpTS6_h2CfQzE0qII58Drg4FXeiD0sChQ uDY6keaiQ2LAaFoa9HvC8jQyQ1tm2X8M2Omv42Ac2Q.u17BAZ1SaUI.gPs7I MwlVoKjfGjWsgnuEmYGVav6AokaurJF_jUX7FK7Q1RKPlzs5KDHfa8rF6sCo dd9Eg5eOTExyYc1TIJNYhjKdPM9lRPdih.Zz_6fual.e91Glclq1NsTzsZ_E 0tiMhwIzSSfKHSVi6JpZ5FfToHhRCMSJDNDx5AbDFl8UTD9EdmuWm0Yhu.fM g6vveHgHQfxbLwaYv98HRB1TSzYDa.nhkTLfx3sS3I8B0sQ-- Original-Received: from [71.140.66.20] by web37908.mail.mud.yahoo.com via HTTP; Thu, 24 Feb 2011 17:43:00 PST X-Mailer: YahooMailWebService/0.8.109.292656 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) X-Received-From: 209.191.91.170 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11711 Archived-At: > From:Ludovic Court=C3=A8s =0A> How about having a per-REPL = setting that=E2=80=99s automatically set to the=0A> terminal=E2=80=99s widt= h by default?=0A> =0A> What=E2=80=99s the exact call to get the width?=0A= =0AThe lightweight way is to just check for the COLUMNS environment variabl= e.=0AMost of the xterm-like terminals set COLUMNS when a program is execute= d.=0AThat will cover most situations when running in X.=0A=0ABeyond that, y= ou'd need to look at the TERM variable and guess columns=0Afrom that.=C2=A0= For this you'd usually query the terminfo database, which means=0Athat you= probably end up with curses as a dependency.=C2=A0 It usually already=0Ais= , since readline depends on it.=0A=0ABelow please find a program that uses = curses to find the terminal's=0Awidth.=C2=A0 It needs to be linked -lcurses= .=0A=0AAlternately you could=C2=A0execute=C2=A0"tput cols".=0A=0AThanks,=0A= =0A-Mike=0A=0A#include =0A#include =0A#include = =0A#define STDOUT_FILENO 1=0A#define DEFAULT_COLUMNS (80)=0Aint main (int a= rgc, char ** argv)=0A{=0A=C2=A0 int ret, err, cols;=0A=C2=A0 setupterm ((ch= ar *) 0, STDOUT_FILENO, &err);=0A=C2=A0 if (ret =3D=3D OK || err =3D=3D 1)= =0A=C2=A0=C2=A0=C2=A0 {=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cols =3D tigetnum = ("cols");=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (cols < 0)=0A=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 cols =3D DEFAULT_COLUMNS;=0A=C2=A0=C2=A0=C2=A0 = }=0A=C2=A0 else=0A=C2=A0=C2=A0=C2=A0 cols =3D DEFAULT_COLUMNS;=0A=C2=A0 pri= ntf("columns %d\n", cols);=0A=C2=A0 return 0;=0A}=0A