Find the answer to your Linux question:
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 28 of 28
Originally Posted by sharonenoch but anyway i have to manipulate the cursor positions so i guess i still have to go with ncurses since i need to do editing of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #21
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578

    Quote Originally Posted by sharonenoch
    but anyway i have to manipulate the cursor positions so i guess i still have to go with ncurses since i need to do editing of the command line
    Do you really need to implement command-line editing yourself, though? Wouldn't readline be OK? If you really cannot use readline for one reason or another, then yes, ncurses is most likely the best thing to use.

  2. #22
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Quote Originally Posted by sharonenoch
    I had printed them using %d instead of %i that was why
    What's the difference between %d and %i ?

  3. #23
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    None, AFAIK. I was wondering about that too...

  4. #24
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141
    Dolda

    I am trying to use readline

    but inspite of adding the .h files at the beginning i am getting an undefined refernce when i link it. what option should i use along with gcc to link it???

    If this works out then i will not use ncurses.

    I also dont know the difference between %i and %d
    but when i changed it to %i as i saw from ur program i got the following values

  5. #25
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141
    Dolda

    but inspite of adding the .h files at the beginning i am getting an undefined refernce when i link it. what option should i use along with gcc to link it???
    i got that i used -lreadline and -lcurses and solved the problem

  6. #26
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Quote Originally Posted by sharonenoch
    I also dont know the difference between %i and %d
    but when i changed it to %i as i saw from you program i got the following values
    Which values ?

  7. #27
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141
    Santa's little helper

    Which values ?
    Those values where the ones dolda has printed earlier. The sequence which comes for the arrow keys. i.e 27 91 67 etc...

    If we print only with %d we get only 27 but with %i we get the whole sequence if an extended key is pressed.

    Dolda

    Thanks for the readline() logic. I impplemented it today and it works fine just that i had to allocate memory for the string i write on the command line as by default it allocates only malloc(3)
    so i had to allocate atleast 1024
    and then freeing of that string also was to be taken care by me
    Anyway i got the whole thing to work along with the history, editing etc..
    using readline
    Thanks

  8. #28
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    I think I see your point now that you mention capturing
    individual presses of even the modifier keys. However,
    it's certainly not without problems. First of all, if you
    have to open a file, then it won't be transparent. Consider,
    for example, using this terminal emulator to ssh to another
    machine. Then the processes running on that other machine
    won't able to access the extended key information.
    If the other machine doesn't have access to the same file
    system I guess so.My suggestion isn't meant to be perfect ,
    just an extra option.
    The most prevalent problem is, of course, that only your
    terminal emulator will be able to do this, and thus programs
    that rely on that functionality, will also implicitly be
    relying on X. Therefore, such programs may just as well be
    written using Xlib to begin with
    Relying on something is very different from knowing and directly
    using something.Shell scripts for example rely on C libraries but
    one can write shell scripts without knowing anything about C.
    The basic reason why TTYs don't support this to begin
    with is, of course, because the TTY "protocol" sends ASCII,
    not human interface data.
    ASCII *is* human inerface.
    Sending ASCII is much more independant of platform and
    input method than sending human interface data is.
    What I'm proposing is also based on printable characters which
    can be represented with ASCII.So no difference there.
    That's what terminfo and ncurses are good for,
    though
    You need a lot of extra info to use those.With terminfo in
    particular I have yet to see a good tutorial which explains
    how to decrypt it.
    And, to be honest, I don't think it should be very
    hard to come up with that kind of script. Apart from all
    the fanciness of presentation, the only non-obvious parts is
    turning off echo and canonical input with stty, and reading a
    character at a time with the `-n' switch to read. It doesn't
    seem all that hard to me.
    You already have a lot of knowledge.I think most people here
    wouldn't be able to write it.By the way what does the "$c"
    != $'\004'
    part do ?
    Then again, using your method, one has to learn that
    (not how) one has to open a special file. That's probably
    about as obvious as putting the terminal in raw mode.
    That got me thinking.Instead of the emulator putting key
    presses in some file there could be an alternative raw
    mode.In that mode the programme would still read from stdin
    to know which keys were pressed.But the emulator would send
    a sequence of printable characters which would allow the
    programme to determine exactly which combination of keys gets
    pressed.Something like the information xev returns. (Thanks for
    that by the way ; I didn't know about it.) Or something more
    terse perhaps.I don't know what the exact format should be but
    my main point is that one shouldn't have to learn a new set of
    libraries and perhaps an appropriate programming language just
    to be able to get arbitrary key combinations from the emulator.
    This method would also work over a network.

Page 3 of 3 FirstFirst 1 2 3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •