1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-07-01 14:05:24 +00:00

Display UTF-8 on the modeline [buffer name, file name].

This commit is contained in:
Renaud 2019-08-13 09:14:08 +08:00
parent 78a7a3ba4e
commit e62af18798
7 changed files with 18 additions and 14 deletions

View File

@ -1,8 +1,8 @@
# Makefile for emacs, updated Tue, Jul 31, 2018 20:37:16 # Makefile for uEMACS, updated Tue, Aug 13, 2019 7:59:24 AM
SRC=basic.c bind.c bindable.c buffer.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c input.c isearch.c line.c lock.c main.c mingw32.c mlout.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c util.c window.c word.c wrapper.c wscreen.c SRC=basic.c bind.c bindable.c buffer.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c input.c isearch.c line.c lock.c main.c mingw32.c mlout.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c util.c window.c word.c wrapper.c wscreen.c
OBJ=basic.o bind.o bindable.o buffer.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o input.o isearch.o line.o lock.o main.o mingw32.o mlout.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o util.o window.o word.o wrapper.o wscreen.o OBJ=basic.o bind.o bindable.o buffer.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o input.o isearch.o line.o lock.o main.o mingw32.o mlout.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o util.o window.o word.o wrapper.o wscreen.o
HDR=basic.h bind.h bindable.h buffer.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h mlout.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h util.h version.h window.h word.h wrapper.h wscreen.h HDR=basic.h bind.h bindable.h buffer.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isa.h isearch.h line.h lock.h mlout.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h util.h version.h window.h word.h wrapper.h wscreen.h
# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them
@ -100,7 +100,7 @@ tags: ${SRC}
source: source:
@mv Makefile Makefile.bak @mv Makefile Makefile.bak
@echo "# Makefile for emacs, updated `date`" >Makefile @echo "# Makefile for uEMACS, updated `date`" >Makefile
@echo '' >>Makefile @echo '' >>Makefile
#Sorted #Sorted
@echo SRC=`ls *.c` >>Makefile @echo SRC=`ls *.c` >>Makefile
@ -111,11 +111,12 @@ source:
# @echo OBJ=$(patsubst %.c,%.o,$(wildcard *.c)) >>Makefile # @echo OBJ=$(patsubst %.c,%.o,$(wildcard *.c)) >>Makefile
# @echo HDR=$(wildcard *.h) >>Makefile # @echo HDR=$(wildcard *.h) >>Makefile
@echo '' >>Makefile @echo '' >>Makefile
@sed -n -e '/^# DO NOT ADD OR MODIFY/,$$p' <Makefile.bak >>Makefile @sed -n -e '/^# DO NOT ADD OR MODIFY/,$$p' Makefile.bak >> Makefile
depend: ${SRC} depend: ${SRC}
@mv Makefile Makefile.bak @mv Makefile Makefile.bak
@sed -n -e '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile @sed -n -e '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile
@echo "# Updated `date`" >> Makefile
@echo >> Makefile @echo >> Makefile
@for i in ${SRC}; do\ @for i in ${SRC}; do\
$(CC) ${DEFINES} -MM $$i ; done >> Makefile $(CC) ${DEFINES} -MM $$i ; done >> Makefile
@ -129,6 +130,7 @@ depend: ${SRC}
$(Q) ${CC} ${CFLAGS} ${DEFINES} -c $*.c $(Q) ${CC} ${CFLAGS} ${DEFINES} -c $*.c
# DO NOT DELETE THIS LINE -- make depend uses it # DO NOT DELETE THIS LINE -- make depend uses it
# Updated Tue, Aug 13, 2019 7:51:49 AM
basic.o: basic.c basic.h retcode.h input.h bind.h mlout.h random.h \ basic.o: basic.c basic.h retcode.h input.h bind.h mlout.h random.h \
terminal.h defines.h utf8.h window.h buffer.h line.h terminal.h defines.h utf8.h window.h buffer.h line.h

View File

@ -228,8 +228,11 @@ static int vtputs( const char *s) {
int n = 0 ; int n = 0 ;
while( *s) { while( *s) {
vtputc( *s++) ; unicode_t c ;
n += 1 ;
s += utf8_to_unicode( s, 0, 4, &c) ;
vtputc( c) ;
n += 1 ; /* Assume non wide char unicode */
} }
return n ; return n ;
@ -1103,7 +1106,7 @@ static void modeline(struct window *wp)
vtputc( ' ') ; vtputc( ' ') ;
if( n == term.t_nrow - 1) if( n == term.t_nrow - 1)
n = 3 + vtputs( PROGRAM_NAME_LONG " " VERSION ": ") ; n = 3 + vtputs( PROGRAM_NAME_UTF8 " " VERSION ": ") ;
else else
n = 3 ; n = 3 ;

2
eval.c
View File

@ -738,7 +738,7 @@ static char *gtenv( char *vname) {
case EVVERSION: case EVVERSION:
return VERSION; return VERSION;
case EVPROGNAME: case EVPROGNAME:
return PROGRAM_NAME_PFX PROGRAM_NAME_LONG ; return PROGRAM_NAME_UTF8 ;
case EVSEED: case EVSEED:
return i_to_a(seed); return i_to_a(seed);
case EVDISINP: case EVDISINP:

2
main.c
View File

@ -103,7 +103,7 @@ static void emergencyexit(int signr)
static void edinit( char *bname) ; static void edinit( char *bname) ;
static void version( void) { static void version( void) {
fputs( PROGRAM_NAME_PFX PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ; fputs( PROGRAM_NAME_UTF8 " version " VERSION "\n", stdout) ;
} }

2
utf8.c
View File

@ -17,7 +17,7 @@
* NOTE 2! This does *not* verify things like minimality. So overlong forms * NOTE 2! This does *not* verify things like minimality. So overlong forms
* are happily accepted and decoded, as are the various "invalid values". * are happily accepted and decoded, as are the various "invalid values".
*/ */
unsigned utf8_to_unicode( char *line, unsigned index, unsigned len, unsigned utf8_to_unicode( const char *line, unsigned index, unsigned len,
unicode_t *res) { unicode_t *res) {
unicode_t value ; unicode_t value ;
unsigned c ; unsigned c ;

2
utf8.h
View File

@ -3,7 +3,7 @@
typedef unsigned int unicode_t ; typedef unsigned int unicode_t ;
unsigned utf8_to_unicode( char *line, unsigned index, unsigned len, unsigned utf8_to_unicode( const char *line, unsigned index, unsigned len,
unicode_t *res) ; unicode_t *res) ;
unsigned utf8_revdelta( unsigned char *buf, unsigned pos) ; unsigned utf8_revdelta( unsigned char *buf, unsigned pos) ;
unsigned unicode_to_utf8( unicode_t c, char *utf8) ; unsigned unicode_to_utf8( unicode_t c, char *utf8) ;

View File

@ -9,9 +9,8 @@
# define PROGRAM_NAME "em" # define PROGRAM_NAME "em"
#endif #endif
# define PROGRAM_NAME_PFX "\xC2" #define PROGRAM_NAME_UTF8 "µEMACS"
# define PROGRAM_NAME_LONG "\xB5""EMACS" /* UTF-8 µEMACS */
# define VERSION "4.2.4" #define VERSION "4.2.4"
#endif /* VERSION_H_ */ #endif /* VERSION_H_ */