Nicholas Marriott wrote (2015/04/14):
> Don't see a problem with this, can you add a line to the manpage too?

Yes:

--- tmux.1.orig 2015-04-15 17:19:32.000000000 +0200
+++ tmux.1      2015-04-15 17:24:56.000000000 +0200
@@ -3080,7 +3080,8 @@
 A limit may be placed on the length of the resultant string by prefixing it
 by an
 .Ql = ,
-a number and a colon, so
+a number and a colon, where positive number means left part of the string
+and negative number right part. For example,
 .Ql #{=10:pane_title}
 will include at most the first 10 characters of the pane title.
 .Pp

However, I have found a problem in manpage and sources: On another place
in manpage, there is in status-left section: "Where appropriate, special
character sequences may be prefixed with a number to specify the maximum
length, for example `#24T'.". But I think that this short form is broken.
In status.c in status_replace(), there is a loop with status_replace1(),
which does something that I could not understand: "#24T" is replaced to
"#T" and "#1T" to "#"? Why? And only then format_expand() is called, so
string length limit in short form seems to be effectively removed?

> On Fri, Apr 10, 2015 at 07:00:03PM +0200, Cejka Rudolf wrote:
> > Hello,
> >   would it be possible to allow negative length limit in format
> > specification? For example, #{=10:pane_title} include first 10
> > characters, while #{=-10:pane_title} would include last 10 characters?
> > 
> > Maybe something like this? (tmux-1.9a)
> > 
> > --- format.c.orig   2015-04-10 17:42:31.000000000 +0200
> > +++ format.c        2015-04-10 18:34:26.000000000 +0200
> > @@ -197,7 +197,7 @@
> >     char            *copy, *copy0, *endptr, *ptr, *saved;
> >     const char      *value;
> >     size_t           valuelen;
> > -   u_long           limit = ULONG_MAX;
> > +   long             limit = LONG_MAX;
> >  
> >     /* Make a copy of the key. */
> >     copy0 = copy = xmalloc(keylen + 1);
> > @@ -210,8 +210,8 @@
> >                     switch (*copy) {
> >                     case '=':
> >                             errno = 0;
> > -                           limit = strtoul(copy + 1, &endptr, 10);
> > -                           if (errno == ERANGE && limit == ULONG_MAX)
> > +                           limit = strtol(copy + 1, &endptr, 10);
> > +                           if (errno == ERANGE && (limit == LONG_MAX || 
> > limit == LONG_MIN))
> >                                     goto fail;
> >                             copy = endptr;
> >                             break;
> > @@ -259,7 +259,11 @@
> >     valuelen = strlen(value);
> >  
> >     /* Truncate the value if needed. */
> > -   if (valuelen > limit)
> > +   if (limit < 0 && valuelen > -limit) {
> > +           value += valuelen + limit;
> > +           valuelen = -limit;
> > +   }
> > +   if (limit >= 0 && valuelen > limit)
> >             valuelen = limit;
> >  
> >     /* Expand the buffer and copy in the value. */
> > 
> > -- 
> > Rudolf Cejka <cejkar at fit.vutbr.cz> http://www.fit.vutbr.cz/~cejkar
> > Brno University of Technology, Faculty of Information Technology
> > Bozetechova 2, 612 66  Brno, Czech Republic
> > 
> > ------------------------------------------------------------------------------
> > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> > Develop your own process in accordance with the BPMN 2 standard
> > Learn Process modeling best practices with Bonita BPM through live exercises
> > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
> > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> > _______________________________________________
> > tmux-users mailing list
> > tmux-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/tmux-users

-- 
Rudolf Cejka <cejkar at fit.vutbr.cz> http://www.fit.vutbr.cz/~cejkar
Brno University of Technology, Faculty of Information Technology
Bozetechova 2, 612 66  Brno, Czech Republic

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to