Thread: How to handle long lines using GNU readline?

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    5

    Question How to handle long lines using GNU readline?

    Hey there. I implemented a small command line interpreter using the GNU readline library. This works really nice except for lines having much text input. As soon as the user reaches the console width the readline command prompt within the same line gets overwritten. What I want is the line to wrap around automatically. For example:

    Code:
    cli> this is some very long line which should wrap around
     to the next line
    instead of
    Code:
     to the next line very long line which should wrap around

    Is there a way to do that? Thanks in advance.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Perhaps you can post your code?

    As far as I can see, readline SHOULD cope with long lines.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    5
    You are right. This only happens when using a colored command line:

    Code:
    //input = readline("cli> ");			// Works
    input = readline("\033[1;37mcli>\033[0m ");	// Works not
    Hrm.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    133
    I can't tell for sure, but I know color prompts caused trouble in terminals with long lines from day 0 (at least for me). Maybe the problem is in "\033[0m" which resets stuff. Try replacing it with ansi code to change color to previous one, not to reset anything.

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    5
    Thanks, but I already tried that before. Even a fully colored prompt misbehaves.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. error: double free or corruption
    By dsc in forum C Programming
    Replies: 3
    Last Post: 04-03-2008, 09:26 AM
  3. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  4. need help
    By emperor in forum C Programming
    Replies: 1
    Last Post: 03-04-2002, 12:26 PM
  5. can someone check this out and let me know ?
    By javaz in forum C Programming
    Replies: 5
    Last Post: 01-21-2002, 02:13 PM

Tags for this Thread