From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Martin Pool Newsgroups: gmane.emacs.devel Subject: Re: suggested feature -- console-mode frame title sets Xterm title Date: Mon, 29 Sep 2003 15:17:30 +1000 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20030929051617.GB7359@vexed.ozlabs.hp.com> References: <87r8j9n6v4.fsf@blarg.net> <200206152147.g5FLlUB10968@aztec.santafe.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0640150388==" X-Trace: sea.gmane.org 1064812982 15195 80.91.224.253 (29 Sep 2003 05:23:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Sep 2003 05:23:02 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Sep 29 07:23:00 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A3qUu-0005jI-00 for ; Mon, 29 Sep 2003 07:23:00 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1A3qUt-0000jF-00 for ; Mon, 29 Sep 2003 07:22:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A3qRM-0000Y7-HS for emacs-devel@quimby.gnus.org; Mon, 29 Sep 2003 01:19:20 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.22) id 1A3qQp-0000W0-Bz for emacs-devel@gnu.org; Mon, 29 Sep 2003 01:18:47 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.22) id 1A3qQm-0000UK-QC for emacs-devel@gnu.org; Mon, 29 Sep 2003 01:18:46 -0400 Original-Received: from [192.6.86.210] (helo=sngrel5.hp.com) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A3qQk-0000T7-Gi for emacs-devel@gnu.org; Mon, 29 Sep 2003 01:18:42 -0400 Original-Received: from XAUBRG2.AUS.HP.COM (xaubrg2.aus.hp.com [15.23.69.43]) by sngrel5.hp.com (Postfix) with SMTP id 5C10D1C9 for ; Mon, 29 Sep 2003 13:18:37 +0800 (SGP) Original-Received: from 15.23.69.43 by XAUBRG2.AUS.HP.COM (InterScan E-Mail VirusWall NT); Mon, 29 Sep 2003 15:18:36 +1000 Original-Received: from XAUBRG2.AUS.HP.COM (localhost [127.0.0.1]) by XAUBRG2.AUS.HP.COM with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2656.59) id TTGLLHBK; Mon, 29 Sep 2003 15:18:36 +1000 Original-Received: from 16.176.65.141 by XAUBRG2.AUS.HP.COM (InterScan E-Mail VirusWall NT); Mon, 29 Sep 2003 15:18:35 +1000 Original-Received: from mbp by vexed with local (Exim 3.36 #1 (Debian)) id 1A3qPa-00031i-00 for ; Mon, 29 Sep 2003 15:17:30 +1000 Original-To: emacs-devel@gnu.org In-Reply-To: X-GPG: 1024D/A0B3E88B: AFAC578F 1841EE6B FD95E143 3C63CA3F A0B3E88B User-Agent: Mutt/1.5.4i X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:16755 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:16755 --===============0640150388== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 26 Sep 2003, Richard Stallman wrote: > Your patch looks good, except that there is no way to turn it on and > off. Can you make xterm_title_start and xterm_title_end into Lisp > variables, and enable this feature if their values are strings? After a bit more study, I think that a better way to do this is to get the values from termcap for the terminal's status line. This new patch does so. On systems which are using Eric Raymond's termcap distribution the xterm title line is not represented as a status line. (I don't really understand why, since the absence just encourages programs to hardcode escape sequences as I originally did.) So on Debian, to make this patch do anything, you have to set for example TERM=3Dxterm+sl before running emacs. This ought to be explained in the NEWS file if this feature is accepted. Perhaps this patch ought to add Lisp variables to set the escape codes, but there is already a (slightly obscure) way to set them through the termcap file or $TERMCAP. I think it would be better to do that, and hope people fix their termcaps, rather than putting in a redundant mechanism. If people disagree I can add the variables. Incidentally, there is a bit of duplicated code in the implementations of x_explicitly_set_name and x_set_name for different window systems. It might be good to factor that out to a higher level, and then perhaps just make the actual work of setting the title go through a window system specific hook. This patch causes trouble with mode-line-frame-identification: the whole title is displayed on the modeline and it takes up a lot of space. Normally terminal frames have a little "F%d" identifier, which is set into f->name by make_terminal_frame(). =20 The problem is that the usage of the f->name field is a bit inconsistent between window system and termcap frames. On termcap frames it really is the name of the frame, and usually something brief like 'F0'. But x_set_name and x_consider_frame_title expect it to be the title of the frame, as produced from the frame-title-format. I'm not sure of the best way to resolve this, but resolving it might remove the kludge of clearing mode-line-frame-identification on non-termcap frames. I renamed x_consider_frame_title because it is no longer X-specific. diff -rud emacs-21.3/src/dispextern.h emacs-21.3-title/src/dispextern.h --- emacs-21.3/src/dispextern.h 2002-11-15 00:15:46.000000000 +1100 +++ emacs-21.3-title/src/dispextern.h 2003-09-29 13:02:51.000000000 +1000 @@ -2365,6 +2365,7 @@ /* Defined in term.c */ =20 extern void ring_bell P_ ((void)); +extern void terminal_set_frame_title P_ ((char *, int)); extern void set_terminal_modes P_ ((void)); extern void reset_terminal_modes P_ ((void)); extern void update_begin P_ ((struct frame *)); diff -rud emacs-21.3/src/term.c emacs-21.3-title/src/term.c --- emacs-21.3/src/term.c 2001-05-31 18:56:32.000000000 +1000 +++ emacs-21.3-title/src/term.c 2003-09-29 13:51:44.000000000 +1000 @@ -285,6 +285,9 @@ char *TS_set_window; /* "wi" (4 params, start and end of window, each as vpos and hpos) */ =20 +char *TS_to_status; /* "ts", go to status line */ +char *TS_from_status; /* "fs", go back from status line */ + /* Value of the "NC" (no_color_video) capability, or 0 if not present. */ =20 @@ -369,9 +372,13 @@ TN_standout_width =3D=3D 0, it means don't bother to write any end-standout cookies. */ =20 +int TF_status; /* termcap hs flag: has a status line + (title for xterms) */ + int TN_standout_width; /* termcap sg number: width occupied by standout markers */ =20 + static int RPov; /* # chars to start a TS_repeat */ =20 static int delete_in_insert_mode; /* delete mode =3D=3D insert mode */ @@ -472,6 +479,22 @@ } =20 void +terminal_set_frame_title (line, len) + char *line; + int len; +{ + if (!TF_status || !TS_to_status || !TS_from_status) + return; /* no status line */ + + /* XXX: Are there any terminals where we need to explicitly clear + the status line after jumping to it? */ + + OUTPUT1 (TS_to_status); + fwrite (line, 1, len, stdout); + OUTPUT1 (TS_from_status); +} + +void set_terminal_modes () { if (FRAME_TERMCAP_P (XFRAME (selected_frame))) @@ -2334,6 +2357,9 @@ TS_cursor_visible =3D tgetstr ("vs", address); TS_cursor_invisible =3D tgetstr ("vi", address); TS_set_window =3D tgetstr ("wi", address); + TS_to_status =3D tgetstr ("ts", address); + TS_from_status =3D tgetstr ("fs", address); + TF_status =3D tgetflag ("hs"); =20 TS_enter_underline_mode =3D tgetstr ("us", address); TS_exit_underline_mode =3D tgetstr ("ue", address); diff -rud emacs-21.3/src/xdisp.c emacs-21.3-title/src/xdisp.c --- emacs-21.3/src/xdisp.c 2003-01-18 00:45:13.000000000 +1100 +++ emacs-21.3-title/src/xdisp.c 2003-09-29 14:50:09.000000000 +1000 @@ -523,6 +523,11 @@ =20 int cursor_in_non_selected_windows; =20 +/* Non-nil means to try to show frame titles on tty frames. Whether + we can actually do so depends on whether the termcap definition has + hardstatus capabilities. */ +Lisp_Object Vtty_frame_title_on_status; + /* A scratch glyph row with contents used for generating truncation glyphs. Also used in direct_output_for_insert. */ =20 @@ -688,7 +693,7 @@ static int text_outside_line_unchanged_p P_ ((struct window *, int, int)); static void store_frame_title_char P_ ((char)); static int store_frame_title P_ ((unsigned char *, int, int)); -static void x_consider_frame_title P_ ((Lisp_Object)); +static void consider_frame_title P_ ((Lisp_Object)); static void handle_stop P_ ((struct it *)); static int tool_bar_lines_needed P_ ((struct frame *)); static int single_display_prop_intangible_p P_ ((Lisp_Object)); @@ -7142,7 +7147,6 @@ ***********************************************************************/ =20 =20 -#ifdef HAVE_WINDOW_SYSTEM =20 /* A buffer for constructing frame titles in it; allocated from the heap in init_xdisp and resized as needed in store_frame_title_char. */ @@ -7211,17 +7215,19 @@ } =20 =20 + /* Set the title of FRAME, if it has changed. The title format is Vicon_title_format if FRAME is iconified, otherwise it is frame_title_format. */ =20 static void -x_consider_frame_title (frame) +consider_frame_title (frame) Lisp_Object frame; { struct frame *f =3D XFRAME (frame); =20 if (FRAME_WINDOW_P (f) + || FRAME_TERMCAP_P (f) || FRAME_MINIBUF_ONLY_P (f) || f->explicit_name) { @@ -7266,18 +7272,31 @@ display_mode_element, then we might need to optimize at a higher level than this.) */ if (! STRINGP (f->name)=20 - || STRING_BYTES (XSTRING (f->name)) !=3D len - || bcmp (frame_title_buf, XSTRING (f->name)->data, len) !=3D 0) - x_implicitly_set_name (f, make_string (frame_title_buf, len), Qnil); + || STRING_BYTES (XSTRING (f->name)) !=3D len + || bcmp (frame_title_buf, XSTRING (f->name)->data, len) !=3D 0) + { +#ifdef HAVE_WINDOW_SYSTEM + /* Even if we're compiled with a window system, we might not be + using it for this frame... */ + /* TODO: There is some common logic across all terminal + types that could be factored out of + x_implicitly_set_name() */ + if (FRAME_WINDOW_P (f)) + x_implicitly_set_name (f, make_string (frame_title_buf, len), = Qnil); +#endif + if (FRAME_TERMCAP_P (f) + && !NILP (Vtty_frame_title_on_status)) + { + terminal_set_frame_title (frame_title_buf, len); + f->name =3D make_string (frame_title_buf, len); + } + + /* There are other possibilities, e.g. a nongraphical window + on Windows NT. We don't handle that at the moment. */ + } } } =20 -#else /* not HAVE_WINDOW_SYSTEM */ - -#define frame_title_ptr ((char *)0) -#define store_frame_title(str, mincol, maxcol) 0 - -#endif /* not HAVE_WINDOW_SYSTEM */ =20 =20 =20 @@ -7307,7 +7326,6 @@ /* Update all frame titles based on their buffer names, etc. We do this before the menu bars so that the buffer-menu will show the up-to-date frame titles. */ -#ifdef HAVE_WINDOW_SYSTEM if (windows_or_buffers_changed || update_mode_lines) { Lisp_Object tail, frame; @@ -7317,10 +7335,9 @@ f =3D XFRAME (frame); if (!EQ (frame, tooltip_frame) && (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f))) - x_consider_frame_title (frame); + consider_frame_title (frame); } } -#endif /* HAVE_WINDOW_SYSTEM */ =20 /* Update the menu bar item lists, if appropriate. This has to be done before any actual redisplay or generation of display lines. */ @@ -14955,6 +14972,14 @@ Qnil)))), Qnil))); =20 + DEFVAR_BOOL ("tty-frame-title-on-status", &Vtty_frame_title_on_status, +"Non-nil means that the title of a text terminal frame is shown in the\n\ +terminal's \"hard status\" line or a terminal emulator's title bar, if\n\ +the terminal has that capability.\n\ +The terminal must have the \"hs\", \"ts\" and \"fs\" termcap capabilies\n\ +for this to work."); + Vtty_frame_title_on_status =3D Qt; + DEFVAR_LISP ("message-log-max", &Vmessage_log_max, "Maximum number of lines to keep in the message log buffer.\n\ If nil, disable message logging. If t, log messages but don't truncate\n\ @@ -15120,7 +15145,6 @@ default_invis_vector[i] =3D make_number ('.'); } =20 -#ifdef HAVE_WINDOW_SYSTEM { /* Allocate the buffer for frame titles. */ int size =3D 100; @@ -15128,7 +15152,6 @@ frame_title_buf_end =3D frame_title_buf + size; frame_title_ptr =3D NULL; } -#endif /* HAVE_WINDOW_SYSTEM */ =20 help_echo_showing_p =3D 0; } --=20 Martin=20 --YiEDa0DAkWCtVeE4 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/d8AhPGPKP6Cz6IsRAjxRAJ0QmI++9a6v86c96sxEiN57Or+xogCgiZxY WRwGn9tuBgW9rTjMDvxcPFo= =uYDl -----END PGP SIGNATURE----- --YiEDa0DAkWCtVeE4-- --===============0640150388== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel --===============0640150388==--