update drag-move to v1.5-beta
[nedit-bw.git] / strip_hostname.patch
blob6839ed77de45425849b62c21aad041edebf91649
1 Subject: strip trailing components from hostname in window title
3 The %h format takes an optional digit argument: %nh
5 ---
7 doc/help.etx | 3 ++-
8 source/windowTitle.c | 23 ++++++++++++++++++++++-
9 2 files changed, 24 insertions(+), 2 deletions(-)
11 diff --quilt old/source/windowTitle.c new/source/windowTitle.c
12 --- old/source/windowTitle.c
13 +++ new/source/windowTitle.c
14 @@ -246,7 +246,8 @@ static void compressWindowTitle(char *ti
15 ** of trailing directory components to display. Skipped components are
16 ** replaced by an ellipsis (...).
17 ** %f : file name
18 -** %h : host name
19 +** %[n]h : host name, with one optional digit specifying the max number
20 + of leading hosts components to dispaly.
21 ** %S : file status
22 ** %u : user name
24 @@ -349,6 +350,26 @@ char *FormatWindowTitle(const char* file
26 titlePtr = safeStrCpy(titlePtr, titleEnd, trailingPath);
28 + } else if (*titleFormat == 'h') {
29 + int comps = c - '0';
30 + char* hostname = strdup(GetNameOfHost());
31 + char *p, *n;
32 + hostNamePresent = True;
33 + titleFormat++; /* delete the argument */
34 + n = p = hostname;
35 + while (comps) {
36 + if ((n = strchr(n, '.'))) {
37 + comps--;
38 + p = n;
39 + while (*n && *n == '.')
40 + n++;
41 + } else
42 + break;
43 + }
44 + if (*p == '.')
45 + *p = '\0';
46 + titlePtr = safeStrCpy(titlePtr, titleEnd, hostname);
47 + free(hostname);
49 break;
51 diff --quilt old/doc/help.etx new/doc/help.etx
52 --- old/doc/help.etx
53 +++ new/doc/help.etx
54 @@ -1078,7 +1078,8 @@ Tabs/Emulated Tabs
55 .. components to display. Skipped components are
56 .. replaced by an ellipsis (...).
57 .. %f file name, without the path name
58 -.. %h host name
59 +.. %[n]h host name, with one optional digit specifying the max number
60 +.. of leading hosts components to dispaly.
61 .. %s NEdit server name (server mode only)
62 .. %[*]S file status, either verbose (%S) or brief (%*S).
63 .. In verbose mode the file status is spelled out: