You can use libtecla, which is avalable on Solaris. This library provides command line editting and auto-completion function. It's homepage:
http://www.astro.caltech.edu/~mcs/tecla/ To use this library for command line editting, basically what you need do is to replace your original input function(say, fgets()) with gl_get_line(). This function sits between user and application code, it intercept user's input, perform command line editting, and pass the final input to application. As a result, command line editting is totally transparent to application and thus simple and clear code. As for auto-completion function, libtecla's default behavior is to look for files under current work directory. If that's not what you want, you can customize this behavior. To do that, you need write your own auto-compete handler and call gl_customize_completion() to register it. See more details on this in its manual. Thanks, Raymond On 05/08/08, wenxing zheng wrote: > Hi all, > > Just imagine that i have the following commands: > execCmd start startop1/startop2/startop3 > execCmd stop stopop1/stopop2/stopop3 > > And when the user enters the execCmd and then presses the TAB key, how > can i display the start/stop? and If the user has reached at the execCmd > start and then presses the TAB, how can i display the > startop1/startop2/startop3? > > The function is like the TAB key in the BASH, which is very smartable > and loveable. > > Thanks for your help. > > > This message posted from opensolaris.org > _______________________________________________ > opensolaris-code mailing list > [email protected] > http://mail.opensolaris.org/mailman/listinfo/opensolaris-code -- Regards, Raymond _______________________________________________ opensolaris-code mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
