문제

I'm trying to do add an advanced feature to my command line program that when you press the 'Tab' button it suggests what word you might mean (In the context of files, bash has this feature when you press tab it prints matching filenames on the next line).

Below is a snippet of what I have. I've replace the '\n' with the ASCII for tab (to see if it works) but i sill need to press the enter key for data to be directed to Standard In.

Any help is appreciated. Thanks.

    while (1){
        c = getchar() ;
        if (isspace(c)){
            curLine[pos]='\0';
            buffer[w_count] = curLine ;
            ++w_count;
            pos=0;
            curLine = calloc(10, sizeof(char));
            if (c == '\n')
                break;
            }
            curLine[pos]=c;
             ++pos;
        }
    }
도움이 되었습니까?

해결책

Use gnu readline library and refer sample example of readline library at http://www.delorie.com/gnu/docs/readline/rlman_48.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top