Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Hello, I have a question regarding terminal apps., I usually use gnome-terminal but it's missing one very important function. When I run a program that asks for the user's input ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    5

    Terminal Question


    Hello, I have a question regarding terminal apps.,
    I usually use gnome-terminal but it's missing one very important function. When I run a program that asks for the user's input (for instance: cin >> something; in c++) I can't cycle through the command history with the point keys. This function is provided in DOS on the windows command prompt but not in any of linux terminals that I have seen. I was wondering if anyone knows of any terminal apps that has this function provided. It would be incredibly helpful.

    Thanks,
    -Alphonse

  2. #2
    Linux Engineer b2bwild's Avatar
    Join Date
    Jul 2008
    Location
    Behind You!
    Posts
    1,108

    Arrow

    Its not the feature you get in DOS (May be a bug), as far as I know for "cin"
    When you press "Point keys" it should grab the ASCII value of Pointer key.
    (i.e ^[[A ^[[B ^[[C and ^[[D )
    I think that's the correct behavior.
    Never make any misteaks.

    Read my Blog at --> Penguin Inside Subscribe Feed

  3. #3
    Just Joined!
    Join Date
    Apr 2009
    Posts
    5
    See, that's just what I mean: In gnome-terminal, or konsole, when I press the up or down pointER keys it types out the ASCII codes (eg ^[[A,^[[B,etc). On my windows XP pro workstation, in a DOS command prompt when you hit either the up or down pointer key, it cycles through the previous commands that were typed in to that program since it was last compiled (If you don't believe me try it out). That feature in DOS would be very convenient in linux, especial when you need to type in long file path names.

    Know of any linux terminal apps that have this feature?

    -Alphonse

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    What shell are you running? The bash shell has this (up/down arrows to cycle thru the command history) as well as filename completion. Check your user entry in /etc/passwd, which is the shell you get when you login. If it isn't bash, then you won't get this capability.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    Apr 2009
    Posts
    5
    I guess this would be more of a shell question than a terminal app question.

    Code:
    $ echo $0
    bash
    $ ps -p $$
      PID TTY          TIME CMD
     6785 pts/3    00:00:00 bash
    $
    bash does allow you to cycle through the command history stack, but not within a program. DOS allows for this.

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    Quote Originally Posted by Alphonse23 View Post
    bash does allow you to cycle through the command history stack, but not within a program. DOS allows for this.
    True. In the Linux/Unix world, this would be a function of the application. I agree that it would be convenient, but... In any case, this is a good example of how thoroughly the Windows OS is in control of your applications. IMO, this is not necessarily a good thing. It is also one of the reasons why Windows security vulnerabilities are so deadly to applications that otherwise would be secure themselves.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Linux Engineer b2bwild's Avatar
    Join Date
    Jul 2008
    Location
    Behind You!
    Posts
    1,108
    Its nothing to do with the shell because when you execute the program..
    you are in new non-login shell made by your compiler. noting to do with terminal.
    program and teminal both are working fine in this case.
    Never make any misteaks.

    Read my Blog at --> Penguin Inside Subscribe Feed

  8. #8
    Just Joined!
    Join Date
    Apr 2009
    Posts
    5
    So its the compiler that has this feature...
    On windows I use mingw to compile c++ files. I tried downloading mingw32 on fedora10 to see if a compiled program would remember the command history, but It doesn't work. Pressing the pointer keys still results in the ASCII codes.

    Does mingw only provide this feature for the windows version. Or am I missing something.

  9. #9
    Linux Engineer b2bwild's Avatar
    Join Date
    Jul 2008
    Location
    Behind You!
    Posts
    1,108
    compiling on different platforms is whole different thing, even if you use same compiler.
    Never make any misteaks.

    Read my Blog at --> Penguin Inside Subscribe Feed

  10. #10
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    Quote Originally Posted by Alphonse23 View Post
    So its the compiler that has this feature...
    On windows I use mingw to compile c++ files. I tried downloading mingw32 on fedora10 to see if a compiled program would remember the command history, but It doesn't work. Pressing the pointer keys still results in the ASCII codes.

    Does mingw only provide this feature for the windows version. Or am I missing something.
    It's not a compiler thing. It's a device-driver, OS thing. In Windows, the kernel interprets an up-arrow key press in such a way as to present the previous input line to the applications input buffer. Other operating systems could do this, but don't. This would be more difficult in Linux since the X-server does all the keyboard input processing before passing it to the application. So, there is a layer between the OS and the application when you are running a GUI. Even if this input-line recall was supported in the text interface (I don't know for sure), the standard system libraries would have to be modified to support the feature.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 1 of 2 1 2 LastLast

Posting Permissions

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