Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have an application running on Linux and has it's own CLI. The CLI uses editline library. At the command prompt when I type more than 80 characters and press backspace then the first 80 characters gets repeated. This line will repeat everytime till I delete the 80th character. The line will not repeat when the deletion is from 79th character.
For example, if there are 85 characters entered at the command prompt then backspace is pressed 5 times then the first 80 characters gets repeated 5 times and then the backspace deletion is normal.
Has anybody come across this kind of problem. Please suggest a solution how editline can be modified to overcome this issue.
Click here to see the post LQ members have rated as the most helpful post in this thread.
I'm not familiar with the editline library; most text-mode applications use the readline library. Is it an option to modify the code to use that?
Have you tried something like
Code:
# Use a value that matches your terminal settings
stty cols 120
What happens if you resize the window in which the application is running?
On a side note to what Rod said, I remember a while back helping someone out with a similar issue. Could you post the code that controls the functions for the columns? I haven't really worked with the editline library myself, but I just started reading into it a bit.
I'm not familiar with the editline library; most text-mode applications use the readline library. Is it an option to modify the code to use that?
Have you tried something like
Code:
# Use a value that matches your terminal settings
stty cols 120
What happens if you resize the window in which the application is running?
--- rod.
Thanks rod for replying.
If i resize the window to full screen(132 characters)then the above problem repeats if the command entered is more than 132 characters. E.g., if the command length is 135 and backspace is entered then the first 132 characters repeats 3 times then normal backspace deletion happens.
If i resize the window to full screen(132 characters)then the above problem repeats if the command entered is more than 132 characters. E.g., if the command length is 135 and backspace is entered then the first 132 characters repeats 3 times then normal backspace deletion happens.
when backspace is pressed it calls a function reposition() in editline.c
00926 case CSmove:
00927 reposition();
00937 case CSmove:
00938 reposition();
00284 STATIC void
00285 reposition()
00286 {
00287 int i;
00288 CHAR *p;
00289
00290 TTYput('\r');
00291 TTYputs((CONST CHAR *)Prompt);
00292 for (i = Point, p = Line; --i >= 0; p++)
00293 TTYshow(*p);
00294 }
For every backspace that is pressed the CLI repositions itself on the same line by putting the command prompt and also all the characters. Now, if the terminal size is of 80 characters but the command is more than 80 (say 84) then the first 80 characters gets repeated 4 times.
Hard to interpret the code snippet without a lot more context, but my hunch is that this is a problem with the console/terminal configuration, and/or a misuse of your application's use of the termcap configuration. I've experienced similar problems, and never found a good solution. There are some terminal emulations that have problems with writing to the last character cell on the screen, and the use of scrolling when that cell is written. Does the problem occur only when the output is at the last line of the terminal? What kind of terminal is in use? Does the behavior change if you use a different type (say, xterm vs. Konsole or some other terminal). Is there a valid setting for the $TERM variable in the shell from which your application is launched?
Hard to interpret the code snippet without a lot more context, but my hunch is that this is a problem with the console/terminal configuration, and/or a misuse of your application's use of the termcap configuration. I've experienced similar problems, and never found a good solution. There are some terminal emulations that have problems with writing to the last character cell on the screen, and the use of scrolling when that cell is written. Does the problem occur only when the output is at the last line of the terminal? What kind of terminal is in use? Does the behavior change if you use a different type (say, xterm vs. Konsole or some other terminal). Is there a valid setting for the $TERM variable in the shell from which your application is launched?
--- rod.
Hi Rod,
The TERM variable is set to xterm. The problem doesn't happen in the last line of the terminal though. Tried setting the $TERM variable to VT102 and konsole but the problem persists.
Well, then I'm going to call that a bug in your editline library. If that is an actively maintained package, perhaps submit a bug report, after making sure your existing library is up to date.
--- rod.
Guys, sometime back I had a chance to investigate this issue and this is what I found.
reposition()
{
int i;
CHAR *p;
TTYput('\r');
TTYputs((CONST CHAR *)Prompt);
for (i = Point, p = Line; --i >= 0; p++)
TTYshow(*p);
}
The problem is with the reposition logic and the offending line is TTYput(“/r”), which basically takes the cursor the beginning of line. So lets take the above reposition logic and see how it interprets any line > 80 chars and < 80 chars.
Case-1: Command input Line/buffer > 80 chars and < 160.
This implies the line occupies 2 lines on the terminal. So upon hitting TTYput('/r') the cursor postions/points itself points to beginning of the second line instead of actual location(begining of first line) where the cmd actually originated and thereafter it repaints the entire line( NOTE: buffer still conatins all chars > 80) which gives the impression the cmd repeats untill we reach 79/80th char.
Case-2: buffer/input line < 80 chars.
This implies the line occupies only one line length on the terminal. So upon hitting TTYput('/r') the cursor postions/points itself points to beginning of the first line where the cmd actually originated and thereafter it repaints the same line(re writes the first line) which gives the impression that the line didn't repeat.
Hope this is gives an insight in to the problem. Now the question is how make the cursor to point to begining of line where cmd originated if the input line is > 80 chars?
"/r" escape sequence cannot be used.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.