I have my own macros for this. You can probably play with the code below if it's not exactly what you want.
If you call the command select_char on the command line, then move the cursor with right-arrow or ctrl-right-arrow etc, you find that it creates a selection, then extends it as the cursor moves.
I have some cursor moving macros that are slightly different to next-word prev-word - the "stop-on-all" macros step from token to token rather than word to word.
cursor-to-next-token
cursor-to-prev-token
cursor_to_next_token_stop_on_all
cursor_to_prev_token_stop_on_all
So then I have select_cursor_to_next_token() which starts a selection if there isn't one already and calls cursor_to_next_token().
_command void select_cursor_to_next_token() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
if ( !select_active() ) {
select_char();
}
cursor_to_next_token();
}
If you want to try it, add the code below to something.e in your configuration folder and load using the load module command in the macro menu. Unload with the unload module command.
BTW - I suspect that cua-select is consistent - default ctrl-right-arrow is the same as default ctrl-shift-right-arrow but the second one selects text. cua-select is 492 lines of fairly complex looking code - would you believe.
#include "slick.sh"
#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)
//#import "window.e"
#include "se/ui/toolwindow.sh"
static boolean is_wordchar(_str s1)
{
//return isalnum(s1) || (s1=='_');
return pos('['p_word_chars']',s1,1,'R') > 0;
}
static boolean is_whitespace(_str s1)
{
return (s1==' ') || (s1==\n) || (s1==\t) || (s1==\r) ;
}
/* cursor_to_next_token_stop_on_all
- skips whitespace,
- stops at start and end of a word,
- stops on any other non whitespace char
*/
_command void cursor_to_next_token_stop_on_all() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
int lim = 0;
if ( is_wordchar(get_text()) ) {
while ( is_wordchar(get_text()) ) {
if (++lim > 2000)
return;
cursor_right();
}
} else {
cursor_right();
}
lim = 0;
_str s1 = get_text();
while ( is_whitespace(s1) ) {
if (++lim > 2000)
return;
if ((s1==\n) || (s1==\r)) {
begin_line();
cursor_down();
} else {
cursor_right();
}
s1 = get_text();
}
}
/* cursor_to_prev_token_stop_on_all
- skips whitespace,
- stops at start and end of a word,
- stops on any other non whitespace char
*/
_command void cursor_to_prev_token_stop_on_all() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
int lim = 0;
cursor_left();
while ( is_whitespace(get_text()) ) {
if (++lim > 2000)
return;
cursor_left();
if (get_text()==\r) {
return;
}
}
lim = 0;
if ( is_wordchar(get_text()) ) {
while ( is_wordchar(get_text()) ) {
if (++lim > 2000)
return;
cursor_left();
}
cursor_right();
}
}
_command select_to_next_token() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
_select_char();
cursor_to_next_token_stop_on_all();
_select_char();
}
_command void select_to_prev_token() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
_select_char();
cursor_to_prev_token_stop_on_all();
_select_char();
}
/* cursor_to_next_token
- stops at start and end of a word
*/
_command void cursor_to_next_token() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
int lim = 0;
if ( is_wordchar(get_text()) ) {
while ( is_wordchar(get_text()) ) {
if (++lim > 2000)
return;
cursor_right();
}
return;
} else {
while ( !is_wordchar(get_text()) ) {
if (++lim > 2000)
return;
cursor_right();
}
return;
}
}
_command void select_cursor_to_next_token() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
if ( !select_active() ) {
select_char();
}
cursor_to_next_token();
}
/* cursor_to_prev_token
- stops at start and end of a word
*/
_command void cursor_to_prev_token() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
int lim = 0;
cursor_left();
if ( is_wordchar(get_text()) ) {
while ( is_wordchar(get_text()) ) {
if (++lim > 2000)
return;
cursor_left();
}
cursor_right();
return;
} else {
while ( !is_wordchar(get_text()) ) {
if (++lim > 2000)
return;
cursor_left();
}
cursor_right();
return;
}
}
_command void select_cursor_to_prev_token() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
if ( !select_active() ) {
select_char();
}
cursor_to_prev_token();
}