1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Version 4.2

Consistent display of µEMACS as program name among
- ue --version
- on status bar
- insert-string $progname
- write-message $progname (FIX).
This commit is contained in:
Renaud 2015-02-12 13:15:45 +08:00
parent b2306e379d
commit e13bc9ca7e
5 changed files with 44 additions and 11 deletions

View File

@ -87,7 +87,7 @@ static void modeline(struct window *wp);
static void mlputi(int i, int r); static void mlputi(int i, int r);
static void mlputli(long l, int r); static void mlputli(long l, int r);
static void mlputf(int s); static void mlputf(int s);
static void mlputs( char *s) ; static void mlputs( unsigned char *s) ;
#if SIGWINCH #if SIGWINCH
static int newscreensize(int h, int w); static int newscreensize(int h, int w);
#endif #endif
@ -1154,7 +1154,7 @@ static void modeline(struct window *wp)
vtputc( ' ') ; vtputc( ' ') ;
n = 3 ; n = 3 ;
cp = &PROGRAM_NAME_LONG " " VERSION ": " [ 1] ; /* Start past utf8 mark */ cp = PROGRAM_NAME_LONG " " VERSION ": " ;
while ((c = *cp++) != 0) { while ((c = *cp++) != 0) {
vtputc(c); vtputc(c);
++n; ++n;
@ -1394,7 +1394,7 @@ void mlwrite(const char *fmt, ...)
break; break;
case 's': case 's':
mlputs(va_arg(ap, char *)); mlputs( (unsigned char *) va_arg( ap, char *)) ;
break; break;
case 'f': case 'f':
@ -1441,10 +1441,28 @@ void mlforce( char *s) {
* the characters in the string all have width "1"; if this is not the case * the characters in the string all have width "1"; if this is not the case
* things will get screwed up a little. * things will get screwed up a little.
*/ */
static void mlputs( char *s) { static void mlputs( unsigned char *s) {
int c ; unicode_t c ;
while( ((c = *s++) != 0) && (ttcol < term.t_ncol)) { while( ((c = *s++) != 0) && (ttcol < term.t_ncol)) {
/* Accept UTF-8 sequence */
if( c > 0xC1 && c <= 0xF4) {
char utf[ 4] ;
char cc ;
int bytes ;
utf[ 0] = c ;
utf[ 1] = cc = *s ;
if( (c & 0x20) && ((cc & 0xC0) == 0x80)) { /* at least 3 bytes and a valid encoded char */
utf[ 2] = cc = s[ 1] ;
if( (c & 0x10) && ((cc & 0xC0) == 0x80)) /* at least 4 bytes and a valid encoded char */
utf[ 3] = s[ 2] ;
}
bytes = utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) &c) ;
s += bytes - 1 ;
}
TTputc( c) ; TTputc( c) ;
++ttcol ; ++ttcol ;
} }

2
eval.c
View File

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

14
main.c
View File

@ -4,7 +4,11 @@
/* /*
* main.c * main.c
*
* µEMACS 4.2
*
* Based on:
*
* uEmacs/PK 4.0 * uEmacs/PK 4.0
* *
* Based on: * Based on:
@ -53,10 +57,14 @@
* *
* 4.0 Petri Kutvonen, 1-Sep-91 * 4.0 Petri Kutvonen, 1-Sep-91
* *
* This modified version is now called uEmacs/rf. * This modified version is now called uEMACS.
* *
* 4.1 Renaud Fivet, 1-May-13 * 4.1 Renaud Fivet, 1-May-13
* *
* Renamed as µEMACS to emphasize UTF-8 support.
*
* 4.2 Renaud Fivet, 2015-02-12
*
*/ */
#include <stdio.h> #include <stdio.h>
@ -106,7 +114,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_LONG " version " VERSION "\n", stdout) ; fputs( PROGRAM_NAME_PFX PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ;
} }

6
utf8.c
View File

@ -88,6 +88,12 @@ unsigned unicode_to_utf8( unicode_t c, char *utf8) {
int bytes = 1 ; int bytes = 1 ;
assert( c <= 0x10FFFF) ; assert( c <= 0x10FFFF) ;
#ifdef NDEBUG
if( c > 0x10FFFF) /* Let's assume this is due to sign extension */
c &= 0xFF ;
#endif
*utf8 = c ; *utf8 = c ;
if (c > 0x7f) { if (c > 0x7f) {
int prefix = 0x40; int prefix = 0x40;

View File

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