From 1b2307e056e845630189ddfc8f1e489f6b799f1f Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sat, 9 Apr 2016 11:46:40 +0800 Subject: [PATCH] Partial fix of issues when using unicode sequence with describe-key, search-forward, query-replace-string. --- Makefile | 12 ++++++------ defines.h | 8 ++++---- display.c | 10 ++++++---- display.h | 3 ++- input.c | 4 ++-- posix.c | 3 +-- tcap.c | 2 +- terminal.h | 3 ++- termio.c | 2 +- termio.h | 4 +++- 10 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index d8b5582..8080651 100644 --- a/Makefile +++ b/Makefile @@ -139,7 +139,7 @@ bindable.o: bindable.c bindable.h defines.h buffer.h line.h retcode.h \ terminal.h buffer.o: buffer.c buffer.h line.h retcode.h utf8.h defines.h estruct.h \ file.h input.h bind.h mlout.h window.h -display.o: display.c display.h estruct.h buffer.h line.h retcode.h utf8.h \ +display.o: display.c display.h estruct.h utf8.h buffer.h line.h retcode.h \ input.h bind.h termio.h terminal.h defines.h version.h wrapper.h \ window.h ebind.o: ebind.c ebind.h basic.h bind.h estruct.h bindable.h buffer.h \ @@ -151,15 +151,15 @@ eval.o: eval.c eval.h basic.h bind.h buffer.h line.h retcode.h utf8.h \ exec.o: exec.c exec.h retcode.h buffer.h line.h utf8.h bind.h display.h \ estruct.h eval.h file.h flook.h input.h random.h window.h defines.h execute.o: execute.c execute.h estruct.h bind.h random.h retcode.h \ - display.h file.h buffer.h line.h utf8.h input.h mlout.h search.h \ + display.h utf8.h file.h buffer.h line.h input.h mlout.h search.h \ terminal.h defines.h window.h file.o: file.c file.h buffer.h line.h retcode.h utf8.h defines.h \ display.h estruct.h execute.h fileio.h input.h bind.h lock.h mlout.h \ window.h fileio.o: fileio.c fileio.h defines.h retcode.h utf8.h flook.o: flook.c flook.h retcode.h defines.h fileio.h -input.o: input.c input.h bind.h estruct.h bindable.h display.h exec.h \ - retcode.h names.h terminal.h defines.h utf8.h wrapper.h +input.o: input.c input.h bind.h estruct.h bindable.h display.h utf8.h \ + exec.h retcode.h names.h terminal.h defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h line.h retcode.h utf8.h \ display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \ window.h @@ -186,9 +186,9 @@ search.o: search.c search.h line.h retcode.h utf8.h basic.h buffer.h \ spawn.o: spawn.c spawn.h defines.h buffer.h line.h retcode.h utf8.h \ display.h estruct.h exec.h file.h flook.h input.h bind.h terminal.h \ window.h -tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \ +tcap.o: tcap.c terminal.h defines.h retcode.h utf8.h display.h estruct.h \ termio.h -termio.o: termio.c termio.h estruct.h retcode.h utf8.h +termio.o: termio.c termio.h utf8.h estruct.h retcode.h utf8.o: utf8.c utf8.h window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \ basic.h display.h estruct.h execute.h terminal.h wrapper.h diff --git a/defines.h b/defines.h index 22a28d0..6327efe 100644 --- a/defines.h +++ b/defines.h @@ -15,10 +15,10 @@ #define NSTRING 128 /* # of bytes, string buffers */ -#define CONTROL 0x10000000 /* Control flag, or'ed in */ -#define META 0x20000000 /* Meta flag, or'ed in */ -#define CTLX 0x40000000 /* ^X flag, or'ed in */ -#define SPEC 0x80000000 /* special key (function keys) */ +#define CONTROL 0x01000000 /* Control flag, or'ed in */ +#define META 0x02000000 /* Meta flag, or'ed in */ +#define CTLX 0x04000000 /* ^X flag, or'ed in */ +#define SPEC 0x08000000 /* special key (function keys) */ /* Actual 380x134 on a 1920x1080 screen in landscape, if smaller font or portrait orientation limit to 400x150 */ diff --git a/display.c b/display.c index f57f6b1..c676856 100644 --- a/display.c +++ b/display.c @@ -1284,7 +1284,7 @@ void mlerase( void) { TTflush() ; } -static void mlputc( char c) { +static void mlputc( unicode_t c) { if( ttcol < term.t_ncol) { TTputc( c) ; ++ttcol ; @@ -1297,9 +1297,11 @@ static void mlputc( char c) { * char *s; string to output */ void ostring( char *s) { + unsigned char c ; + if( discmd) - while( *s) - mlputc( *s++ & 0xFF) ; + while( (c = *s++) != 0) + mlputc( c) ; } @@ -1552,7 +1554,7 @@ static int newscreensize(int h, int w) * * char c ; character to output */ -void echoc( char c) { +void echoc( unicode_t c) { if( disinp) TTputc( c) ; } diff --git a/display.h b/display.h index 6b91ab2..2710328 100644 --- a/display.h +++ b/display.h @@ -4,6 +4,7 @@ #include #include "estruct.h" +#include "utf8.h" extern int mpresf ; /* Stuff in message line */ extern int scrollcount ; /* number of lines to scroll */ @@ -28,7 +29,7 @@ void mlerase( void) ; void vmlwrite( const char *fmt, va_list ap) ; void mlwrite( const char *fmt, ...) ; void ostring( char *s) ; -void echoc( char c) ; +void echoc( unicode_t c) ; void echos( char *s) ; void getscreensize( int *widthp, int *heightp) ; diff --git a/input.c b/input.c index dab1382..b56c836 100644 --- a/input.c +++ b/input.c @@ -724,7 +724,7 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar) for (n = 0; n < cpos; n++) { c = buf[n]; if ((c < ' ') && (c != '\n')) { - echos("^"); + echoc( '^') ; ++ttcol; c ^= 0x40; } @@ -751,7 +751,7 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar) buf[cpos++] = c; if ((c < ' ') && (c != '\n')) { - echos("^"); + echoc( '^') ; ++ttcol; c ^= 0x40; } diff --git a/posix.c b/posix.c index e75d84b..7339adc 100644 --- a/posix.c +++ b/posix.c @@ -119,8 +119,7 @@ void ttclose(void) * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on * MS-DOS (use the very very raw console output routine). */ -int ttputc(int c) -{ +int ttputc( unicode_t c) { char utf8[6]; int bytes; diff --git a/tcap.c b/tcap.c index 0ddf872..5d25e52 100644 --- a/tcap.c +++ b/tcap.c @@ -370,6 +370,6 @@ static void tcapbeep(void) static void putpad(char *str) { - tputs(str, 1, ttputc); + tputs( str, 1, (int (*)( int)) ttputc) ; } #endif /* TERMCAP */ diff --git a/terminal.h b/terminal.h index df4e9e8..9346df6 100644 --- a/terminal.h +++ b/terminal.h @@ -4,6 +4,7 @@ #include "defines.h" /* COLOR, SCROLLCODE */ #include "retcode.h" +#include "utf8.h" /* * The editor communicates with the display using a high level interface. A @@ -27,7 +28,7 @@ struct terminal { void (*t_kopen)(void); /* Open keyboard */ void (*t_kclose)(void); /* close keyboard */ int (*t_getchar)(void); /* Get character from keyboard. */ - int (*t_putchar)(int); /* Put character to display. */ + int (*t_putchar)( unicode_t) ; /* Put character to display. */ void (*t_flush) (void); /* Flush output buffers. */ void (*t_move)(int, int);/* Move the cursor, origin 0. */ void (*t_eeol)(void); /* Erase to end of line. */ diff --git a/termio.c b/termio.c index dfeef3f..fb6d243 100644 --- a/termio.c +++ b/termio.c @@ -281,7 +281,7 @@ void ttclose(void) * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on * MS-DOS (use the very very raw console output routine). */ -int ttputc( int c) { +int ttputc( unicode_t c) { #if VMS if (nobuf >= NOBUF) ttflush(); diff --git a/termio.h b/termio.h index 5a3382c..5f96f25 100644 --- a/termio.h +++ b/termio.h @@ -1,6 +1,8 @@ #ifndef _TERMIO_H_ #define _TERMIO_H_ +#include "utf8.h" + #define TYPEAH 1 /* type ahead causes update to be skipped */ #define HUGE 1000 /* Huge number (for row/col) */ @@ -10,7 +12,7 @@ extern int ttcol ; /* Column location of HW cursor */ void ttopen( void) ; void ttclose( void) ; -int ttputc( int c) ; +int ttputc( unicode_t c) ; void ttflush( void) ; int ttgetc( void) ; int typahead( void) ;