Yet another tweak to the move_word function

darcs-hash:20061012161317-ac50b-3b374e2b6c4c22f82c1cf018bf83298c8216fcb1.gz
This commit is contained in:
axel 2006-10-13 02:13:17 +10:00
parent a620a1e5ed
commit 92446bda80

View file

@ -1531,6 +1531,19 @@ static void move_word( int dir, int erase )
int end_buff_pos=data->buff_pos;
int step = dir?1:-1;
/*
Return if we are already at the edge
*/
if( !dir && data->buff_pos == 0 )
{
return;
}
if( dir && data->buff_pos == data->buff_len )
{
return;
}
/*
If we are beyond the last character and moving left, start by
moving one step, since otehrwise we'll start on the \0, which
@ -1544,6 +1557,14 @@ static void move_word( int dir, int erase )
end_buff_pos--;
}
/*
When moving left, ignore the character under the cursor
*/
if( !dir )
{
end_buff_pos+=2*step;
}
/*
Remove all whitespace characters before finding a word
*/
@ -1578,7 +1599,6 @@ static void move_word( int dir, int erase )
end_buff_pos+=step;
}
/*
@ -1604,17 +1624,25 @@ static void move_word( int dir, int erase )
if( !iswalnum( c ) )
{
/*
Don't gobble the boundary character if it was a
whitespace, but do for all other non-alphabetic
characters
Don't gobble the boundary character when moving to the
right
*/
if( iswspace( c ) /* && ( abs( end_buff_pos-data->buff_pos ) > 1 ) */ && (step < 0))
if( !dir )
end_buff_pos -= step;
break;
}
end_buff_pos+=step;
}
/*
Make sure we move at least one character
*/
if( end_buff_pos==data->buff_pos )
{
end_buff_pos+=step;
}
if( erase )
{
int remove_count = abs(data->buff_pos - end_buff_pos);