how to implement automatic completion in c

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhumathikv
    New Member
    • Aug 2007
    • 11

    how to implement automatic completion in c

    Hi all,
    How to implement automatic completion i.e, suppose
    Assume that there are commands like

    show
    show version
    show ip
    show arp

    As soon as you press "s" and tab it should display "show ".

    Please any one help..
    Thanks in advance.
  • arnaudk
    Contributor
    • Sep 2007
    • 425

    #2
    First of all, you'll need to detect when the TAB key which means you'll have to capture individual keyboard key presses. This is implementation-dependent. In Windows, use kbhit() or (for VC++) _kbhit(). In Linux, check out the ncurses library.
    The way I see it, you'll have to make a loop which handles alphanumeric key presses by displaying them on the screen and storing them in a buffer (like the normal line input functions of C++ do), and detects TAB key presses, responding accordingly by completing the word on the screen and in the buffer. The loop should also detect when the Enter/Return key is pressed then exit.

    Arnaud

    Comment

    • shabinesh
      New Member
      • Jan 2007
      • 61

      #3
      Hey,
      check out the bioskey(),first note the values for each key press and proceed

      Comment

      • arnaudk
        Contributor
        • Sep 2007
        • 425

        #4
        The bioskey() function is largely obsolete, it only works in older versions of Borland's Turbo C I think.

        Arnaud

        Comment

        Working...