Insure transpose-characters works with UTF8.

This commit is contained in:
Renaud 2016-05-20 20:42:37 +08:00
parent 92078e5595
commit f11dea468f
4 changed files with 28 additions and 23 deletions

View File

@ -73,7 +73,7 @@ struct key_tab keytab[NBINDS] = {
, ,
{CONTROL | 'S', forwsearch} {CONTROL | 'S', forwsearch}
, ,
{CONTROL | 'T', twiddle} {CONTROL | 'T', (fn_t) twiddle}
, ,
{CONTROL | 'U', unarg} {CONTROL | 'U', unarg}
, ,

View File

@ -217,7 +217,7 @@ struct name_bind names[] = {
#if BSD | __hpux | SVR4 #if BSD | __hpux | SVR4
{"suspend-emacs", bktoshell}, {"suspend-emacs", bktoshell},
#endif #endif
{"transpose-characters", twiddle}, {"transpose-characters", (fn_t) twiddle},
#if AEDIT #if AEDIT
{"trim-line", trim}, {"trim-line", trim},
#endif #endif

View File

@ -230,27 +230,32 @@ int setccol(int pos)
* work. This fixes up a very common typo with a single stroke. Normally bound * work. This fixes up a very common typo with a single stroke. Normally bound
* to "C-T". This always works within a line, so "WFEDIT" is good enough. * to "C-T". This always works within a line, so "WFEDIT" is good enough.
*/ */
int twiddle(int f, int n) boolean twiddle( int f, int n) {
{ unicode_t c ;
struct line *dotp; int len ;
int doto; boolean eof_f = FALSE ;
int cl;
int cr;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if( curbp->b_mode & MDVIEW) /* don't allow this command if */
return rdonly(); /* we are in read only mode */ return rdonly() ; /* we are in read only mode */
dotp = curwp->w_dotp;
doto = curwp->w_doto; len = llength( curwp->w_dotp) ;
if (doto == llength(dotp) && --doto < 0) if( len < 2 || curwp->w_doto == 0) /* at least 2 chars & not bol */
return FALSE; return FALSE ;
cr = lgetc(dotp, doto);
if (--doto < 0) if( curwp->w_doto == len) { /* at end of line */
return FALSE; backchar( FALSE, 1) ;
cl = lgetc(dotp, doto); eof_f = TRUE ;
lputc(dotp, doto + 0, cr); }
lputc(dotp, doto + 1, cl);
lchange(WFEDIT); lgetchar( &c) ;
return TRUE; ldelchar( 1, FALSE) ;
backchar( FALSE, 1) ;
linsert( 1, c) ;
if( eof_f == TRUE)
forwchar( FALSE, 1) ;
lchange( WFEDIT) ;
return TRUE ;
} }
/* /*

View File

@ -24,7 +24,7 @@ int showcpos( int f, int n) ;
int getcline( void) ; int getcline( void) ;
int getccol( int bflg) ; int getccol( int bflg) ;
int setccol( int pos) ; int setccol( int pos) ;
int twiddle( int f, int n) ; boolean twiddle( int f, int n) ;
int quote( int f, int n) ; int quote( int f, int n) ;
int insert_tab( int f, int n) ; int insert_tab( int f, int n) ;
#if AEDIT #if AEDIT