On Mon, Dec 03, 2012 at 11:59:00AM +0100, Jasper Lievisse Adriaanse wrote:
> Hi,
> 
> Some weeks ago the column number display was removed from the modeline; while
> it's totally understandable this is a horror on slower displays, it's still
> usefull on faster displays.
> 
> mg has a line-number-mode, but not a column-number-mode like Emacs has. This
> diff adds the column-number-mode, and thus partly reverting the previous 
> change.
> Column numbers are still disabled by default.
> 
> I've also removed the unconditional LINENOMODE define which is unused 
> elsewhere,
> but the linenos handling could use some more cleanup; which is for a later 
> diff.
> 
> OK?
> 

Yes, please, I was actually missing the column number. OK reyk.

> Index: def.h
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/def.h,v
> retrieving revision 1.131
> diff -p -u -r1.131 def.h
> --- def.h     27 Nov 2012 19:46:46 -0000      1.131
> +++ def.h     3 Dec 2012 10:53:14 -0000
> @@ -424,6 +424,7 @@ void              vtinit(void);
>  void         vttidy(void);
>  void         update(void);
>  int          linenotoggle(int, int);
> +int          colnotoggle(int, int);
>  
>  /* echo.c X */
>  void          eerase(void);
> Index: display.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/display.c,v
> retrieving revision 1.38
> diff -p -u -r1.38 display.c
> --- display.c 11 Nov 2012 20:40:49 -0000      1.38
> +++ display.c 3 Dec 2012 10:53:14 -0000
> @@ -101,10 +101,8 @@ struct video       blanks;               /* Blank line im
>   */
>  struct score *score;                 /* [NROW * NROW] */
>  
> -#ifndef LINENOMODE
> -#define LINENOMODE TRUE
> -#endif /* !LINENOMODE */
> -static int    linenos = LINENOMODE;
> +static int    linenos = TRUE;
> +static int    colnos  = FALSE;
>  
>  /* Is macro recording enabled? */
>  extern int macrodef;
> @@ -129,6 +127,19 @@ linenotoggle(int f, int n)
>       return (TRUE);
>  }
>  
> +int
> +colnotoggle(int f, int n)
> +{
> +     if (f & FFARG)
> +             colnos = n > 0;
> +     else
> +             colnos = !colnos;
> +
> +     sgarbf = TRUE;
> +
> +     return (TRUE);
> +}
> +
>  /*
>   * Reinit the display data structures, this is called when the terminal
>   * size changes.
> @@ -835,7 +846,12 @@ modeline(struct mgwin *wp)
>       ++n;
>  
>       if (linenos) {
> -             len = snprintf(sl, sizeof(sl), "--L%d", wp->w_dotline);
> +             if (colnos)
> +                     len = snprintf(sl, sizeof(sl), "--L%d--C%d", 
> wp->w_dotline,
> +                         getcolpos());
> +             else
> +                     len = snprintf(sl, sizeof(sl), "--L%d", wp->w_dotline);
> +
>               if (len < sizeof(sl) && len != -1)
>                       n += vtputs(sl);
>       }
> Index: funmap.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/funmap.c,v
> retrieving revision 1.43
> diff -p -u -r1.43 funmap.c
> --- funmap.c  27 Nov 2012 19:46:46 -0000      1.43
> +++ funmap.c  3 Dec 2012 10:53:14 -0000
> @@ -40,6 +40,7 @@ static struct funmap functnames[] = {
>       {capword, "capitalize-word",},
>       {changedir, "cd",},
>       {clearmark, "clear-mark",},
> +     {colnotoggle, "column-number-mode",},
>       {copyregion, "copy-region-as-kill",},
>  #ifdef       REGEX
>       {cntmatchlines, "count-matches",},
> Index: mg.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/mg.1,v
> retrieving revision 1.72
> diff -p -u -r1.72 mg.1
> --- mg.1      27 Nov 2012 19:46:46 -0000      1.72
> +++ mg.1      3 Dec 2012 10:53:14 -0000
> @@ -414,6 +414,8 @@ upper case, and subsequent letters to lo
>  .It cd
>  Change the global working directory.
>  See also global-wd-mode.
> +.It column-number-mode
> +Show the current column number in the mode line.
>  .It copy-region-as-kill
>  Copy all of the characters in the region to the kill buffer,
>  clearing the mark afterwards.
> 
> -- 
> Cheers,
> Jasper
> 
> "Stay Hungry. Stay Foolish"

Reply via email to