Example #1
0
/***********************************************************************
 * line editor
 **********************************************************************/
static void getCommandLine(void)
{
    tmpPrompt = GetTemporaryPrompt();
    GetCurrentPrompt(Sci_Prompt);

    if (__CommandLine)
    {
        FREE(__CommandLine);
        __CommandLine = NULL;
    }

    if (getScilabMode() == SCILAB_STD)
    {
        /* Send new prompt to Java Console, do not display it */
        if (tmpPrompt != NULL)
        {
            SetConsolePrompt(tmpPrompt);
        }
        else
        {
            SetConsolePrompt(Sci_Prompt);
        }
        setSearchedTokenInScilabHistory(NULL);
        /* Call Java Console to get a string */
        __CommandLine = strdup(ConsoleRead());
    }
    else
    {
        /* Call Term Management for NW and NWNI to get a string */
        __CommandLine = getCmdLine();

    }
}
/*--------------------------------------------------------------------------*/
char * getCmdLine(void)
{
    char *line = NULL;
    static char save_prompt[PROMPT_SIZE_MAX];

    if (GetTemporaryPrompt() != NULL) /* Input function is used */
    {
        line = TerminalGetString(GetTemporaryPrompt());
    }
    else
    {
        GetCurrentPrompt(save_prompt);
        line = TerminalGetString(save_prompt);
    }
    strcpy(save_prompt, "");
    return line;
}