[Pkg-mc-devel] Bug#504105: may be suitable this patch?
Хурамшин
Хурамшин
Tue Jan 20 07:23:15 UTC 2009
--- ./src/main.c 2008-11-01 15:09:54.000000000 +0500
+++ ./src/main.c 2008-11-01 15:27:34.000000000 +0500
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -278,6 +279,9 @@
/* The user's shell */
const char *shell = NULL;
+/* The xterm title */
+char *xterm_title_str = NULL;
+
/* Is the LANG UTF-8 ? */
gboolean is_utf8 = FALSE;
@@ -1621,9 +1625,23 @@
update_xterm_title_path (void)
{
char *p, *s;
+ char h[64];
+ struct passwd *pw;
if (xterm_flag && xterm_title) {
+ if ( xterm_title_str ) g_free (xterm_title_str);
p = s = g_strdup (strip_home_and_password (current_panel->cwd));
+ if ( !gethostname (h, 64) ) {
+ h[63] = '\0'; /* Be sure the hostname is NUL terminated */
+ s = g_strdup_printf ("%s:%s", h, s);
+ g_free (p);
+ p = s;
+ }
+ if ( (pw = getpwuid(getuid())) ) {
+ s = g_strdup_printf ("%s@%s", pw->pw_name, s);
+ g_free (p);
+ p = s;
+ }
do {
#ifndef UTF8
if (!is_printable ((unsigned char) *s))
@@ -1634,7 +1652,7 @@
} while (*++s);
fprintf (stdout, "\33]0;mc - %s\7", p);
fflush (stdout);
- g_free (p);
+ xterm_title_str = p;
}
}
--- ./src/main.h 2008-11-01 15:09:54.000000000 +0500
+++ ./src/main.h 2008-11-01 15:28:32.000000000 +0500
@@ -70,6 +70,7 @@
extern int output_starts_shell;
extern int midnight_shutdown;
extern gboolean is_utf8;
+extern char *xterm_title_str;
extern char cmd_buf [512];
extern const char *shell;
--- ./src/view.c 2008-11-01 15:09:54.000000000 +0500
+++ ./src/view.c 2008-11-01 15:31:11.000000000 +0500
@@ -3368,6 +3368,11 @@
WButtonBar *bar;
Dlg_head *view_dlg;
+ if (xterm_flag && xterm_title && xterm_title_str) {
+ fprintf (stdout, "\33]0;mc - %s/%s\7", xterm_title_str, file);
+ fflush(stdout);
+ }
+
/* Create dialog and widgets, put them on the dialog */
view_dlg =
create_dlg (0, 0, LINES, COLS, NULL, view_dialog_callback,
@@ -3391,6 +3396,8 @@
}
destroy_dlg (view_dlg);
+ update_xterm_title_path();
+
return succeeded;
}
More information about the Pkg-mc-devel
mailing list