Exemplo n.º 1
0
/*--------------------------------------------------------------------------*/
void pasteClipBoard(void)
{
    HGLOBAL hGMem = NULL;
    LPSTR lpMem; /* Ptr on clipboard */

    int typeClipboard = CF_TEXT;

    OpenClipboard(NULL);

    hGMem = GetClipboardData (typeClipboard);
    if (hGMem)
    {

        char *CurrentLine = getCurrentLine();

        lpMem = (LPSTR)GlobalLock( hGMem );
        if (lpMem)
        {
            char *newline = (char*)MALLOC(sizeof(char) * (strlen(CurrentLine) + strlen(lpMem) + 1));
            memset(newline, 0x00, strlen(CurrentLine) + strlen(lpMem) + 1);
            strncpy(newline, CurrentLine, cur_pos);
            strcat(newline, lpMem);

            clearCurrentLine();
            copyLine(newline);
            FREE(newline);
        }
        GlobalUnlock (hGMem);
        FREE(CurrentLine);
    }

    CloseClipboard ();
}
Exemplo n.º 2
0
/*--------------------------------------------------------------------------*/
void putLineSearchedHistory(void)
{
    char *line = NULL;
    char *token = getCurrentLine();

    if (token)
    {
        if ( (int)strlen(token) > 1 )
        {
            setSearchedTokenInScilabHistory(&token[1]);
            line = getNextLineInScilabHistory();
        }
        FREE(token);
        token = NULL;
    }

    clearCurrentLine();

    if (line)
    {
        copyLine(line);
        FREE(line);
        line = NULL;
    }
}
Exemplo n.º 3
0
/*--------------------------------------------------------------------------*/
void moveForwardHistory(void)
{
    char *newline = NULL;

    reallocLineBuffer();

    cur_line[max_pos + 1] = '\0';
    if (cur_line[0] == '\0')
    {
        resetSearchedTokenInScilabHistory();
        setSearchedTokenInScilabHistory(NULL);
    }

    newline = getNextLineInScilabHistory();

    if (newline)
    {
        clearCurrentLine();
        copyLine(newline);
        FREE(newline);
        newline = NULL;
    }
}
Exemplo n.º 4
0
/*--------------------------------------------------------------------------*/
static void TermCompletionOnFiles(char **dictionaryFiles, int sizedictionaryFiles,
                                  char *lineBeforeCaret, char *lineAfterCaret, char *filePattern, char *defaultPattern)
{
    if (dictionaryFiles)
    {
        if (sizedictionaryFiles == 1)
        {
            char *newline = completeLine(lineBeforeCaret, dictionaryFiles[0], filePattern, defaultPattern, TRUE, lineAfterCaret);
            if (newline)
            {
                clearCurrentLine();
                copyLine(newline);
                FREE(newline);
                return;
            }
        }
        else
        {
            char *common = getCommonPart(dictionaryFiles, sizedictionaryFiles);

            displayCompletionDictionary(dictionaryFiles,
                                        sizedictionaryFiles, gettext("File or Directory"));

            displayPrompt();
            newLine();

            if (defaultPattern[0] == 0)
            {
                int lennewline = (int)strlen(lineBeforeCaret) + (int)strlen(lineAfterCaret);
                char *newline = (char*)MALLOC(sizeof(char) * (lennewline + 1));

                clearCurrentLine();
                if (newline)
                {
                    strcpy(newline, lineBeforeCaret);
                    strcat(newline, lineAfterCaret);
                    copyLine(newline);
                    FREE(newline);
                    newline = NULL;
                }
            }
            else if (common)
            {
                char *newline = completeLine(lineBeforeCaret, common, filePattern, defaultPattern, TRUE, lineAfterCaret);
                if (newline)
                {
                    clearCurrentLine();
                    copyLine(newline);
                    FREE(newline);
                    return;
                }
                else
                {
                    int lennewline = (int)strlen(lineBeforeCaret) + (int)strlen(lineAfterCaret);
                    newline = (char*)MALLOC(sizeof(char) * (lennewline + 1));

                    clearCurrentLine();
                    if (newline)
                    {
                        strcpy(newline, lineBeforeCaret);
                        strcat(newline, lineAfterCaret);
                        copyLine(newline);
                        FREE(newline);
                        newline = NULL;
                    }
                }
                FREE(common);
                common = NULL;
            }
        }
    }
}
Exemplo n.º 5
0
/*--------------------------------------------------------------------------*/
static void TermCompletionOnAll(char *lineBeforeCaret, char *lineAfterCaret, char *defaultPattern)
{
    if (defaultPattern)
    {
        int numberWordFound = 0;
        char **completionDictionaryFunctions = NULL;
        int sizecompletionDictionaryFunctions = 0;

        char **completionDictionaryCommandWords = NULL;
        int sizecompletionDictionaryCommandWords = 0;

        char **completionDictionaryMacros = NULL;
        int sizecompletionDictionaryMacros = 0;

        char **completionDictionaryVariables = NULL;
        int sizecompletionDictionaryVariables = 0;

        char **completionDictionaryHandleGraphicsProperties = NULL;
        int sizecompletionDictionaryHandleGraphicsProperties = 0;

        char **completionDictionaryFields = NULL;
        int sizecompletionDictionaryFields = 0;

        completionDictionaryFields = completionOnFields(lineBeforeCaret, defaultPattern, &sizecompletionDictionaryFields);

        if ((completionDictionaryFields == NULL) && strcmp(defaultPattern, ""))
        {
            completionDictionaryFunctions = completionOnFunctions(defaultPattern, &sizecompletionDictionaryFunctions);
            completionDictionaryCommandWords = completionOnCommandWords(defaultPattern, &sizecompletionDictionaryCommandWords);
            completionDictionaryMacros = completionOnMacros(defaultPattern, &sizecompletionDictionaryMacros);
            completionDictionaryVariables = completionOnVariablesWithoutMacros(defaultPattern, &sizecompletionDictionaryVariables);
            completionDictionaryHandleGraphicsProperties = completionOnHandleGraphicsProperties(defaultPattern, &sizecompletionDictionaryHandleGraphicsProperties);
        }
        numberWordFound = sizecompletionDictionaryFunctions + sizecompletionDictionaryCommandWords +
                          sizecompletionDictionaryMacros + sizecompletionDictionaryVariables +
                          sizecompletionDictionaryHandleGraphicsProperties + sizecompletionDictionaryFields;

        if (numberWordFound > 0)
        {
            if (numberWordFound == 1)
            {
                char **completionDictionary = NULL;
                char *new_line = NULL;

                if (completionDictionaryFields)
                {
                    completionDictionary = completionDictionaryFields;
                }
                if (completionDictionaryFunctions)
                {
                    completionDictionary = completionDictionaryFunctions;
                }
                if (completionDictionaryCommandWords)
                {
                    completionDictionary = completionDictionaryCommandWords;
                }
                if (completionDictionaryMacros)
                {
                    completionDictionary = completionDictionaryMacros;
                }
                if (completionDictionaryVariables)
                {
                    completionDictionary = completionDictionaryVariables;
                }
                if (completionDictionaryHandleGraphicsProperties)
                {
                    completionDictionary = completionDictionaryHandleGraphicsProperties;
                }

                new_line = completeLine(lineBeforeCaret, completionDictionary[0], NULL, defaultPattern, FALSE, lineAfterCaret);
                if (new_line)
                {
                    clearCurrentLine();
                    copyLine(new_line);
                    FREE(new_line);
                }
            }
            else
            {
                char *commonAll = NULL;
                if (completionDictionaryFields)
                {
                    commonAll = getCommonPart(completionDictionaryFields, sizecompletionDictionaryFields);
                    displayCompletionDictionary(completionDictionaryFields, sizecompletionDictionaryFields, (char *)_("Scilab Fields"));
                    freeArrayOfString(completionDictionaryFields, sizecompletionDictionaryFields);
                }
                else
                {
                    char *commonFunctions = getCommonPart(completionDictionaryFunctions, sizecompletionDictionaryFunctions);
                    char *commonCommandWords = getCommonPart(completionDictionaryCommandWords, sizecompletionDictionaryCommandWords);
                    char *commonMacros = getCommonPart(completionDictionaryMacros, sizecompletionDictionaryMacros);
                    char *commonVariables = getCommonPart(completionDictionaryVariables, sizecompletionDictionaryVariables);
                    char *commonHandleGraphicsProperties = getCommonPart(completionDictionaryHandleGraphicsProperties, sizecompletionDictionaryHandleGraphicsProperties);

                    int sizecommonsDictionary = 0;
                    char **commonsDictionary = concatenateStrings(&sizecommonsDictionary, commonFunctions,
                                               commonMacros, commonCommandWords, commonVariables, commonHandleGraphicsProperties);

                    if (sizecommonsDictionary > 0)
                    {
                        if (sizecommonsDictionary == 1)
                        {
                            commonAll = strdup(commonsDictionary[0]);
                        }
                        else
                        {
                            commonAll = getCommonPart(commonsDictionary, sizecommonsDictionary);
                        }
                        freeArrayOfString(commonsDictionary, sizecommonsDictionary);
                    }

                    displayCompletionDictionary(completionDictionaryFunctions, sizecompletionDictionaryFunctions, (char *)_("Scilab Function"));
                    displayCompletionDictionary(completionDictionaryCommandWords, sizecompletionDictionaryCommandWords, (char *)_("Scilab Command"));
                    displayCompletionDictionary(completionDictionaryMacros, sizecompletionDictionaryMacros, (char *)_("Scilab Macro"));
                    displayCompletionDictionary(completionDictionaryVariables, sizecompletionDictionaryVariables, (char *)_("Scilab Variable"));
                    displayCompletionDictionary(completionDictionaryHandleGraphicsProperties, sizecompletionDictionaryHandleGraphicsProperties, (char *)_("Graphics handle field"));
                    freeArrayOfString(completionDictionaryFunctions, sizecompletionDictionaryFunctions);
                    freeArrayOfString(completionDictionaryCommandWords, sizecompletionDictionaryCommandWords);
                    freeArrayOfString(completionDictionaryMacros, sizecompletionDictionaryMacros);
                    freeArrayOfString(completionDictionaryVariables, sizecompletionDictionaryVariables);
                    freeArrayOfString(completionDictionaryHandleGraphicsProperties, sizecompletionDictionaryHandleGraphicsProperties);
                }

                displayPrompt();
                newLine();

                if (commonAll)
                {
                    char *newline = NULL;

                    newline = completeLine(lineBeforeCaret, commonAll, NULL, defaultPattern, FALSE, lineAfterCaret);

                    if (newline)
                    {
                        clearCurrentLine();
                        copyLine(newline);
                        FREE(newline);
                    }
                    FREE(commonAll);
                    commonAll = NULL;
                }
            }
        }
    }
}
Exemplo n.º 6
0
/*--------------------------------------------------------------------------*/
static char actionControlKey(void)
{
    if ( isCTRL_VKEY('X') || isCTRL_VKEY('C') )
    {
        ControlC_Command();
        return '\n';
    }
    else if (isCTRL_VKEY('A')) /* moves to the beginning of the line */
    {
        moveBeginningLine();
    }
    else if (isCTRL_VKEY('B')) /* moves back a single character */
    {
        moveBackSingleChar();
    }
    else if (isCTRL_VKEY('D')) /* deletes the current character */
    {
        deleteCurrentChar();
    }
    else if (isCTRL_VKEY('E')) /* moves to the end of the line */
    {
        moveEndLine();
    }
    else if (isCTRL_VKEY('F')) /* moves forward a single character */
    {
        moveForwardSingleChar();
    }
    else if (isCTRL_VKEY('H')) /* delete the previous character */
    {
        deletePreviousChar();
    }
    else if (isCTRL_VKEY('K')) /* kills from current position to the end of line */
    {
        killCurrentPositionToEndLine();
    }
    else if (isCTRL_VKEY('N')) /* moves forward through history */
    {
        moveForwardHistory();
    }
    else if (isCTRL_VKEY('P')) /* moves back through history */
    {
        moveBackHistory();
    }
    else if ( isCTRL_VKEY('R') || isCTRL_VKEY('L') ) /* redraw line in case it gets trashed */
    {
        redrawLine();
    }
    else if (isCTRL_VKEY('U')) /* kills the entire line */
    {
        clearCurrentLine();
    }
    else if (isCTRL_VKEY('V'))
    {
        pasteClipBoard();
    }
    else if (isCTRL_VKEY('W')) /* kills last word */
    {
        killLastWord();
    }
    else if (isCTRL_VKEY(VK_TAB) || isCTRL_VKEY(VK_SPACE)) /* Completion */
    {
        TermCompletion();
    }
    else if (isCTRL_VKEY(VK_LEFT)) /* */
    {
        moveBackSingleWord();
    }
    else if (isCTRL_VKEY(VK_RIGHT)) /* */
    {
        moveForwardSingleWord();
    }
    return 0;
}