LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Reply
 
Search this Thread
Old 11-28-2011, 06:11 AM   #1
sameeruj
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Rep: Reputation: 0
Command Line Interface


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.
Old 11-28-2011, 06:42 AM   #2
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
What application are you using? The more information you give us, the merrier
 
Old 11-28-2011, 03:05 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.

Last edited by theNbomr; 11-28-2011 at 03:07 PM.
 
2 members found this post helpful.
Old 11-28-2011, 06:07 PM   #4
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
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.
 
1 members found this post helpful.
Old 11-28-2011, 11:35 PM   #5
sameeruj
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by theNbomr View Post
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.
 
Old 11-28-2011, 11:39 PM   #6
sameeruj
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by corp769 View Post
What application are you using? The more information you give us, the merrier
I am using HP Virtual Connect Manager CLI.

Thanks,
Sameer
 
Old 11-28-2011, 11:54 PM   #7
sameeruj
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sameeruj View Post
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.
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.
 
Old 11-29-2011, 09:40 AM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 12-05-2011, 02:29 AM   #9
sameeruj
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by theNbomr View Post
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.
 
Old 12-05-2011, 10:05 AM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 12-14-2011, 04:06 PM   #11
ravitm
LQ Newbie
 
Registered: Nov 2008
Posts: 2

Rep: Reputation: 0
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.

Last edited by ravitm; 12-14-2011 at 04:08 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Line Interface sj061 Linux - Newbie 4 02-22-2007 01:48 AM
Replace Command Line Interface sekelsenmat Mandriva 3 11-01-2006 09:20 AM
Can only use command line interface! The helpless one Linux - Newbie 6 03-12-2006 03:42 PM
How to get back into command line interface bonniehandi Linux - Newbie 1 11-19-2005 12:07 AM
cdrecord - command line interface satimis Linux - General 5 05-24-2005 07:15 PM


All times are GMT -5. The time now is 10:57 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration