Updated definiton of move_word, more intuitive behaviour when a token consists only of non-alphanumerics

darcs-hash:20060831004525-ac50b-aa6675809f0f17fa266982374700a8a4ce6b2f5a.gz
This commit is contained in:
axel 2006-08-31 10:45:25 +10:00
parent 7df536023b
commit b1439075c6

View file

@ -1984,11 +1984,25 @@ static void handle_token_history( int forward, int reset )
static void move_word( int dir, int erase ) static void move_word( int dir, int erase )
{ {
int end_buff_pos=data->buff_pos; int end_buff_pos=data->buff_pos;
int mode=0;
int step = dir?1:-1; int step = dir?1:-1;
while( mode < 2 ) /*
If we are beyond the last character and moving left, start by
moving one step, since otehrwise we'll start on the \0, which
should be ignored.
*/
if( !dir && (end_buff_pos == data->buff_len) )
{ {
if( !end_buff_pos )
return;
end_buff_pos--;
}
while( 1 )
{
wchar_t c;
if( !dir ) if( !dir )
{ {
if( end_buff_pos == 0 ) if( end_buff_pos == 0 )
@ -1999,41 +2013,46 @@ static void move_word( int dir, int erase )
if( end_buff_pos == data->buff_len ) if( end_buff_pos == data->buff_len )
break; break;
} }
c = data->buff[end_buff_pos];
if( !iswspace( c ) )
{
break;
}
end_buff_pos+=step; end_buff_pos+=step;
if( end_buff_pos < data->buff_len )
{
switch( mode )
{
case 0:
if( iswalnum(data->buff[end_buff_pos] ) )
mode++;
break;
case 1:
if( !iswalnum(data->buff[end_buff_pos] ) )
{
if( !dir )
end_buff_pos -= step;
mode++;
} }
while( 1 )
{
wchar_t c;
if( !dir )
{
if( end_buff_pos == 0 )
break; break;
}
else
{
if( end_buff_pos == data->buff_len )
break;
}
c = data->buff[end_buff_pos];
if( !iswalnum( c ) )
{
/* /*
case 2: Don't gobble the boundary character if it was a
if( !iswspace(data->buff[end_buff_pos] ) ) whitespace, but do for all other non-alphabetic
{ characters
mode++;
if( !dir )
end_buff_pos-=step;
}
break;
*/ */
} if( iswspace( c ) )
} end_buff_pos -= step;
if( mode==2)
break; break;
}
end_buff_pos+=step;
} }
if( erase ) if( erase )