mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-20 16:22:38 -05:00
Review list-buffers to handle file and buffer names including UTF-8 characters.
This commit is contained in:
parent
0f6de2f3b4
commit
d18cfd2925
31
buffer.c
31
buffer.c
@ -21,6 +21,7 @@
|
|||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "mlout.h"
|
#include "mlout.h"
|
||||||
|
#include "utf8.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@ -332,6 +333,19 @@ static void do_layout( char *line, int mode) {
|
|||||||
line[ 4 + i] = '.' ;
|
line[ 4 + i] = '.' ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int utf8_disp_len( const char *s) {
|
||||||
|
unsigned int len = 0 ;
|
||||||
|
|
||||||
|
while( *s) {
|
||||||
|
unicode_t c ;
|
||||||
|
|
||||||
|
s += utf8_to_unicode( s, 0, 4, &c) ;
|
||||||
|
len += 1 ; /* single width unicode for now */
|
||||||
|
}
|
||||||
|
|
||||||
|
return len ;
|
||||||
|
}
|
||||||
|
|
||||||
static int makelist( int iflag)
|
static int makelist( int iflag)
|
||||||
{
|
{
|
||||||
struct buffer *bp;
|
struct buffer *bp;
|
||||||
@ -391,17 +405,22 @@ static int makelist( int iflag)
|
|||||||
l_to_a( &line[ 13], 10 + 1, nbytes) ; /* "%10d" formatted numbers */
|
l_to_a( &line[ 13], 10 + 1, nbytes) ; /* "%10d" formatted numbers */
|
||||||
cp1 = &line[ 23] ;
|
cp1 = &line[ 23] ;
|
||||||
*cp1++ = ' ' ;
|
*cp1++ = ' ' ;
|
||||||
cp2 = &bp->b_bname[0]; /* Buffer name */
|
|
||||||
|
/* Display buffer name */
|
||||||
|
cp2 = &bp->b_bname[ 0] ;
|
||||||
while ((c = *cp2++) != 0)
|
while ((c = *cp2++) != 0)
|
||||||
*cp1++ = c;
|
*cp1++ = c;
|
||||||
|
|
||||||
if( bp->b_fname[ 0] != 0) {
|
/* Pad with spaces to max buffer name length */
|
||||||
while( cp1 < &line[ FNAMSTART])
|
int len = sizeof bp->b_bname ;
|
||||||
|
len -= utf8_disp_len( bp->b_bname) ;
|
||||||
|
while( len--)
|
||||||
*cp1++ = ' ' ;
|
*cp1++ = ' ' ;
|
||||||
|
|
||||||
strncpy( cp1, bp->b_fname, &line[ sizeof line - 1] - cp1) ;
|
/* Display filename if any */
|
||||||
line[ sizeof line - 1] = 0 ;
|
if( bp->b_fname[ 0] != 0)
|
||||||
} else
|
mystrscpy( cp1, bp->b_fname, &line[ sizeof line] - cp1) ;
|
||||||
|
else
|
||||||
*cp1 = 0 ; /* Terminate string */
|
*cp1 = 0 ; /* Terminate string */
|
||||||
|
|
||||||
if( addline( line) == FALSE) /* Add to the buffer. */
|
if( addline( line) == FALSE) /* Add to the buffer. */
|
||||||
|
Loading…
Reference in New Issue
Block a user