model_server/gra/src/graSymbol.h.cxx
// Handler for text input.
// returns 1 if text is handled, 0 otherwise.
Handler for text input.
returns 1 if text is handled, 0 otherwise.
Handler for text input . returns 1 if text is handled 0 otherwise .
int graParametricSymbol::handle_text_input (
    unsigned char* string, int len, int, int, int, int)
{
    Initialize (graParametricSymbol::handle_text_input);
    if (text_focus == 0 || modified_token == NULL || len == 0)
	return 0;
    if (editbuffer)
    {
	unhilite_all ();
	OPTYPE opcode = get_operation (string, len);
	switch (opcode)
	{
	  case DELETE_PREVIOUS:
	    if (char_marker <= 0)
		break;
	    set_modified_token ();
	    if (char_marker == modification_start && modified_token)
	    {
		if (report_text_update())
		    return 1;
		char_marker--;
		set_modified_token();
		char_marker++;
	    }
	    if (editbuffer->Delete(char_marker, -1) == -1)
	    {
		modification_end--;
		shift_cursor_left ();
	    }
	    break;
	  case DELETE_NEXT:
	    if (char_marker >= strlen(buffer))
		break;
	    set_modified_token ();
	    if (modified_token && char_marker == modification_end)
	    {
		if (report_text_update())
		    return 1;
		char_marker++;
		set_modified_token();
		char_marker--;
	    }
	    if (editbuffer->Delete(char_marker, 1) == 1)
		modification_end--;
	    break;
	  case PREVIOUS_LINE:
	    break;
	  case NEXT_LINE:
	    break;
	  case FORWARD_CHAR:
	    if (char_marker >= strlen(buffer))
		break;
	    if (modified_token && char_marker == modification_end)
	    {
		if (report_text_update())
		    return 1;
	    }
	    shift_cursor_right();
	    set_modified_token();
	    break;
	  case BACKWARD_CHAR:
	    if (char_marker <= 0)
		break;
	    if (modified_token && char_marker == modification_start)
	    {
		if (report_text_update())
		    return 1;
	    }
	    shift_cursor_left();
	    set_modified_token();
	    break;
	  case REPORT:		
	    report_text_update ();
	    return 1;
	  case INSERT:
	  default:
	    set_modified_token();
	    len = editbuffer->Insert (char_marker, (char*)string, len);
	    while (len--)
	    {
                modification_end++;
		shift_cursor_right();
	    }
	    break;
	}
	replace_text ((char*) editbuffer->Text());
    }
    return 1;
}
int graParametricSymbol :: handle_text_input ( unsigned char * string , int len , int , int , int , int ) { Initialize ( graParametricSymbol :: handle_text_input ) ; if ( text_focus == 0 || modified_token == NULL || len == 0 ) return 0 ; if ( editbuffer ) { unhilite_all ( ) ; OPTYPE opcode = get_operation ( string , len ) ; switch ( opcode ) { case DELETE_PREVIOUS : if ( char_marker <= 0 ) break ; set_modified_token ( ) ; if ( char_marker == modification_start && modified_token ) { if ( report_text_update ( ) ) return 1 ; char_marker -- ; set_modified_token ( ) ; char_marker ++ ; } if ( editbuffer -> Delete ( char_marker , -1 ) == -1 ) { modification_end -- ; shift_cursor_left ( ) ; } break ; case DELETE_NEXT : if ( char_marker >= strlen ( buffer ) ) break ; set_modified_token ( ) ; if ( modified_token && char_marker == modification_end ) { if ( report_text_update ( ) ) return 1 ; char_marker ++ ; set_modified_token ( ) ; char_marker -- ; } if ( editbuffer -> Delete ( char_marker , 1 ) == 1 ) modification_end -- ; break ; case PREVIOUS_LINE : break ; case NEXT_LINE : break ; case FORWARD_CHAR : if ( char_marker >= strlen ( buffer ) ) break ; if ( modified_token && char_marker == modification_end ) { if ( report_text_update ( ) ) return 1 ; } shift_cursor_right ( ) ; set_modified_token ( ) ; break ; case BACKWARD_CHAR : if ( char_marker <= 0 ) break ; if ( modified_token && char_marker == modification_start ) { if ( report_text_update ( ) ) return 1 ; } shift_cursor_left ( ) ; set_modified_token ( ) ; break ; case REPORT : report_text_update ( ) ; return 1 ; case INSERT : default : set_modified_token ( ) ; len = editbuffer -> Insert ( char_marker , ( char * ) string , len ) ; while ( len -- ) { modification_end ++ ; shift_cursor_right ( ) ; } break ; } replace_text ( ( char * ) editbuffer -> Text ( ) ) ; } return 1 ; }
Handler for text input.
Handler for text input .
// unhilite everything // Get operation to perform // operate on it // Set token to be previous token // Set token to be next token // Report new text to application // display it fresh