Review buffer list and mode line printing.

Increase version number as two buffer modes have been removed (Spell and Crypt).
This commit is contained in:
Renaud 2016-03-24 15:25:48 +08:00
parent 645a0d734b
commit 9669fea1ce
4 changed files with 44 additions and 64 deletions

View File

@ -316,7 +316,12 @@ int listbuffers(int f, int n)
* *
* int iflag; list hidden buffer flag * int iflag; list hidden buffer flag
*/ */
#define MAXLINE MAXCOL /* Layout: "ACT MODES Size Buffer File"
AAA MMMMMMMMMSSSSSSSSSS BBBBBBBBBBBBBBB FFF...
FNAMSTART ---------------------------------------^
*/
#define FNAMSTART (3 + 1 + NUMMODES + 10 + 1 + (sizeof( bname_t) - 1) + 1)
static int makelist( int iflag) static int makelist( int iflag)
{ {
char *cp1; char *cp1;
@ -328,24 +333,21 @@ static int makelist( int iflag)
int i; int i;
long nbytes; /* # of bytes in current buffer */ long nbytes; /* # of bytes in current buffer */
long nlines ; /* # of lines in current buffer */ long nlines ; /* # of lines in current buffer */
char b[ 10 + 1] ; char line[ FNAMSTART + sizeof( fname_t)] ;
char line[MAXLINE];
blistp->b_flag &= ~BFCHG; /* Don't complain! */ blistp->b_flag &= ~BFCHG; /* Don't complain! */
if ((s = bclear(blistp)) != TRUE) /* Blow old text away */ if ((s = bclear(blistp)) != TRUE) /* Blow old text away */
return s; return s;
strcpy(blistp->b_fname, "");
blistp->b_fname[ 0] = 0 ;
if( addline("ACT MODES Size Buffer File") == FALSE if( addline("ACT MODES Size Buffer File") == FALSE
|| addline("‾‾‾ ‾‾‾‾‾ ‾‾‾‾ ‾‾‾‾‾‾ ‾‾‾‾") == FALSE) || addline("‾‾‾ ‾‾‾‾‾ ‾‾‾‾ ‾‾‾‾‾‾ ‾‾‾‾") == FALSE)
return FALSE; return FALSE;
bp = bheadp; /* For all buffers */
/* build line to report global mode settings */ /* build line to report global mode settings */
cp1 = &line[0]; strcpy( line, " ") ;
*cp1++ = ' '; cp1 = &line[ 4] ;
*cp1++ = ' ';
*cp1++ = ' ';
*cp1++ = ' ';
/* output the mode codes */ /* output the mode codes */
for (i = 0; i < NUMMODES; i++) for (i = 0; i < NUMMODES; i++)
@ -353,36 +355,27 @@ static int makelist( int iflag)
*cp1++ = modecode[i]; *cp1++ = modecode[i];
else else
*cp1++ = '.'; *cp1++ = '.';
strcpy(cp1, " Global Modes"); strcpy(cp1, " Global Modes");
if (addline(line) == FALSE) if (addline(line) == FALSE)
return FALSE; return FALSE;
/* output the list of buffers */ /* output the list of buffers */
while (bp != NULL) { for( bp = bheadp ; bp != NULL ; bp = bp->b_bufp) { /* For all buffers */
/* skip invisable buffers if iflag is false */ /* skip invisible buffers if iflag is false */
if (((bp->b_flag & BFINVS) != 0) && (iflag != TRUE)) { if (((bp->b_flag & BFINVS) != 0) && (iflag != TRUE))
bp = bp->b_bufp;
continue; continue;
}
cp1 = &line[0]; /* Start at left edge */ cp1 = &line[0]; /* Start at left edge */
/* output status of ACTIVE flag (has the file been read in? */ /* output status of ACTIVE flag ('@' when the file has been read in) */
if (bp->b_active == TRUE) /* "@" if activated */ *cp1++ = (bp->b_active == TRUE) ? '@' : ' ' ;
*cp1++ = '@';
else
*cp1++ = ' ';
/* output status of changed flag */
if ((bp->b_flag & BFCHG) != 0) /* "*" if changed */
*cp1++ = '*';
else
*cp1++ = ' ';
/* report if the file is truncated */ /* report if the file is truncated */
if ((bp->b_flag & BFTRUNC) != 0) *cp1++ = ((bp->b_flag & BFTRUNC) != 0) ? '#' : ' ' ;
*cp1++ = '#';
else /* output status of changed flag ('*' when the buffer is changed) */
*cp1++ = ' '; *cp1++ = ((bp->b_flag & BFCHG) != 0) ? '*' : ' ' ;
*cp1++ = ' '; /* space */ *cp1++ = ' '; /* space */
@ -394,8 +387,8 @@ static int makelist( int iflag)
*cp1++ = '.'; *cp1++ = '.';
} }
/* No gap as buffer size if left padded with space */ /* No gap as buffer size is left-padded with space */
/* Buffer size */ /* Buffer size */
nbytes = 0L; /* Count bytes in buf. */ nbytes = 0L; /* Count bytes in buf. */
nlines = 0 ; nlines = 0 ;
@ -409,30 +402,28 @@ static int makelist( int iflag)
if( bp->b_mode & MDDOS) if( bp->b_mode & MDDOS)
nbytes += nlines ; nbytes += nlines ;
l_to_a( b, sizeof b, nbytes) ; /* 10 digits string buffer size. */ l_to_a( cp1, 10 + 1, nbytes) ; /* "%10d" formatted numbers */
cp2 = &b[0]; cp1 += 10 ;
while ((c = *cp2++) != 0)
*cp1++ = c;
*cp1++ = ' '; /* Gap. */ *cp1++ = ' '; /* Gap. */
cp2 = &bp->b_bname[0]; /* Buffer name */ cp2 = &bp->b_bname[0]; /* Buffer name */
while ((c = *cp2++) != 0) while ((c = *cp2++) != 0)
*cp1++ = c; *cp1++ = c;
cp2 = &bp->b_fname[0]; /* File name */
if (*cp2 != 0) { if( bp->b_fname[ 0] != 0) {
while( cp1 < &line[ 3 + 1 + NUMMODES + 8 + 1 + (NBUFN-1) + 1]) while( cp1 < &line[ FNAMSTART])
*cp1++ = ' '; *cp1++ = ' ' ;
while ((c = *cp2++) != 0) {
if (cp1 < &line[MAXLINE - 1]) strncpy( cp1, bp->b_fname, &line[ sizeof line - 1] - cp1) ;
*cp1++ = c; line[ sizeof line - 1] = 0 ;
} } else
} *cp1 = 0 ; /* Terminate string */
*cp1 = 0; /* Add to the buffer. */
if (addline(line) == FALSE) if( addline( line) == FALSE) /* Add to the buffer. */
return FALSE; return FALSE ;
bp = bp->b_bufp;
} }
return TRUE; /* All done */
return TRUE ; /* All done */
} }
static void l_to_a(char *buf, int width, long num) static void l_to_a(char *buf, int width, long num)

View File

@ -5,7 +5,6 @@
typedef char fname_t[ 256] ; /* file name type */ typedef char fname_t[ 256] ; /* file name type */
typedef char bname_t[ 16] ; /* buffer name type */ typedef char bname_t[ 16] ; /* buffer name type */
#define NBUFN sizeof( bname_t)
/* /*
* Text is kept in buffers. A buffer header, described below, exists for every * Text is kept in buffers. A buffer header, described below, exists for every

View File

@ -1118,18 +1118,8 @@ static void modeline(struct window *wp)
lchar = '-'; lchar = '-';
bp = wp->w_bufp; bp = wp->w_bufp;
#if PKCODE == 0 vtputc( ((bp->b_flag & BFTRUNC) != 0) ? '#' : lchar) ; /* truncated? */
if ((bp->b_flag & BFTRUNC) != 0) vtputc( ((bp->b_flag & BFCHG) != 0) ? '*' : lchar) ; /* changed? */
vtputc('#');
else
#endif
vtputc(lchar);
if ((bp->b_flag & BFCHG) != 0) /* "*" if changed. */
vtputc('*');
else
vtputc(lchar);
vtputc( ' ') ; vtputc( ' ') ;
if( n == term.t_nrow - 1) if( n == term.t_nrow - 1)

View File

@ -12,6 +12,6 @@
# define PROGRAM_NAME_PFX "\xC2" # define PROGRAM_NAME_PFX "\xC2"
# define PROGRAM_NAME_LONG "\xB5""EMACS" /* UTF-8 µEMACS */ # define PROGRAM_NAME_LONG "\xB5""EMACS" /* UTF-8 µEMACS */
# define VERSION "4.2.1" # define VERSION "4.2.2"
#endif /* VERSION_H_ */ #endif /* VERSION_H_ */