Selection Functions

SlickEditŪ supports multiple selections; however, only one selection can be active or visible. Selections are specified by handles. Most selection functions accept a selection handle. A handle of '' specifies the active selection or selection showing, that is always available.

The table below describes some common selection functions.

Function

Description

_alloc_selection

Returns a handle to a selection.

_free_selection

Frees a selection associated with the selection handle given. Note that it cannot free the active selection. To free the active selection, use _show_selection first.

_show_selection

Used to make another selection the active selection.

_duplicate_selection()

Returns the actual handle number of the active selection.

Example:

    //  Duplicate the current line.
    mark_id=_alloc_selection();
    // 
    if (mark_id<0) {
       message(get_message(mark_id));
       return(rc);
    }
    _select_line(mark_id);
    _copy_to_cursor(mark_id);
    // This selection can be freed because it is not the active selection. 
    _free_selection(mark_id);
    
    // This code copies selected text and keeps the resulting selection on the // source text instead of 
    the destination text. if (_select_type()==""){ 
       message(get_message(TEXT_NOT_SELECTED_RC)); return(1); 
    } mark_id=_duplicate_selection()   // Make a copy of the active selection. 
    _copy_to_cursor(); // Save the selection id. 
    old_active_mark_id= duplicate_selection(); 
    // Must make another mark active before the old active mark can be freed. show(selection(mark_id)); 
    // Make copy of visible mark active. free(selection(old_active_mark_id));

For more information about selection functions, from the main menu, select Help → Macro Functions by Category, then click Selection Functions.