Yes, it's possible.
To help you get started, here is some code that spell checks one word, and highlights it if misspelled. It can also clear existing spelling highlights. It's lifted out of one of my macro files, and it probably won't compile as-is, you'll need to do some tweaking etc.
/*
* Spell checking.
*/
static int s_timer = -1;
static int s_markerType = -1;
definit()
{
s_timer = -1;
s_markerType = _MarkerTypeAlloc();
}
static void ClearSpellHighlights()
{
if ( s_timer >= 0 )
_kill_timer( s_timer );
s_timer = -1;
_StreamMarkerRemoveAllType( s_markerType );
refresh();
}
static void SpellTimerCallback()
{
ClearSpellHighlights();
}
_command void SpellCheckWord() name_info(','VSARG2_EDITORCTL|VSARG2_READ_ONLY)
{
typeless p;
save_pos( p );
_str old_mark;
save_selection( old_mark );
_str mark=_duplicate_selection( '' );
_deselect( mark );
_str old_word_chars = p_word_chars;
p_word_chars = "A-Za-z'";
int start_col;
//$ todo: (chrisant) Should check the word under the cursor, or immediately
// left of the cursor. Should not check "foo" in this case: "foo \c", for
// example (where cursor is at \c).
prev_word();
_str check_word = cur_word2( start_col, VSCURWORD_AT_END_USE_PREV );
start_col = _text_colc( start_col, 'I' );
p_word_chars = old_word_chars;
if ( check_word != '' )
{
int len = _rawLength( check_word );
p_col = start_col;
long start_ofs = _QROffset();
_select_char( mark );
p_col += len;
_select_char( mark );
p_col -= len; // Put cursor at beginning of word so undo works properly.
_show_selection( mark );
_str word;
_str replace_word;
int col;
int status = _spell_check( word, replace_word, col, check_word );
boolean fOk = ( status == SPELL_NO_MORE_WORDS_RC );
int style = VSMARKERTYPEFLAG_DRAW_SQUIGGLY;
int color = fOk ? _rgb( 0, 255, 0 ) : _rgb( 255, 0, 0 );
int timeout = fOk ? 1 : 5;
ClearSpellHighlights();
if ( !fOk )
{
_MarkerTypeSetFlags( s_markerType, style|VSMARKERTYPEFLAG_AUTO_REMOVE );
int pos_marker = _StreamMarkerAdd(
p_window_id, start_ofs, len, true, 0, s_markerType, '' );
_StreamMarkerSetStyleColor( pos_marker, color );
s_timer = _set_timer( timeout * 1000, SpellTimerCallback );
}
end_select(); // Put cursor just after word checked.
_deselect( mark );
}
restore_selection( old_mark );
restore_pos( p );
}