Re: OT What does RET (Enter) do and how does it do it ??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2007-08-24 at 17:42 -0400, William Case wrote:
> Hi;
> 
> This question is meant as a Friday afternoon to a Sunday evening
> discussion. It is not rush; but I have been unable to discover an answer
> to what seems to me a basic question on how my computer works.
> 
> I have asked on my local LUG mailing list (which is usually quite good);
> searched the following text books; "Modern Operating Systems", 2nd ed,
> Andrew S. Tanenbaum; "Computer Organization & Architecture", 6th ed,
> William Stallings; "The Linux Kernel Primer", Rodriguez, Fischer,
> Smolski.  I have done the usual google and Wikipedia.  I mention the
> above to indicate I am am willing to dig quite deeply for an answer.  
> 
> Since I have been unable to find an answer, I might be able to conclude
> I have mis-posed the question.  That is why I am asking for your help,
> pointing me to the correct answer or offering me enough of an
> explanation, that I can begin to look in the right places.
> 
> Put simply:  
> 1) If I am in any kind of text application, from emacs, vim to OOo
> Writer, whenever I push RET the line of characters I have just typed
> gets saved as a string literal the, "\n", new line character gets added
> to the string array, and the cursor gets moved down to the beginning of
> the next line. Of course, in the right circumstances within an
> application (i.e. menu selection) push RET to get a sub-program or a
> program module to run.  (More questions in a moment)
> 
> 2) If I am in a terminal at the command prompt and I type in a command,
> whenever I push RET the command name I just typed gets executed.  When
> it is finished being executed I get a new command line prompt.  Of
> course, a executed program can take a string as an argument.
> 
> For 1) How does the context (i.e. that I am in a text program) get
> established?  Is there a context line at the start of the application?
> Is it through main(argc, argv) or some such, depending on the
> programming language of the application?  How does it know to move one
> line down on the screen i.e. is there a system call, a special
> function ?
> 
> For 2) Again, how does the context (i.e. that I am in a terminal with a
> command prompt) get established?  Is there an exec() call or system call
> to execute the program on pushing RET? How can stdin tell the
> difference? Why does exec(), or its brethren (fork() etc), act one way
> in one instance and another in the next instance?  What is the command
> that RET issues that starts, forks, calls or whatever a process or
> program?
> 
> I suppose there is a simple answer; there should be.  But I have been
> having difficulty even explaining what I am asking.  I usually get
> answers of the kind "Of course it executes the command.  You pushed RET"
> 
> As I said, maybe I am mis-posing the question.  Maybe someone could help
> me straighten the question out.  Maybe someone can point me to an
> answer.  It can't be a new question. 

Well, it's simple.  The intent of text editors, word processors and the
like is that whatever you type in gets saved in the file.  In *nix-ish
operating systems (Linux, Unix, MacOS, etc.), the RETURN or ENTER key is
denoted by a single character in the file.  We call this the "newline"
character, which is the hexadecimal value 0x0a.  In ASCII parlance,
that's the "LF" or "linefeed" character.  The LF character can also
be entered by holding down the "CTRL" key and pressing "j" (also
sometimes called "control-J").

In Windows-type stuff (DOS, Windows, CP/M, etc.), the ENTER key is
denoted by a two character sequence, the hex value 0x0d (ASCII "CR" or
"carriage return"), followed by the hex value 0x0a (ASCII "LF" or
"linefeed" again).  We call this sequence the "CRLF" sequence.  Note
that the "CR" character can also be entered by holding down the "CTRL"
key and pressing "m", which is why it's sometimes called "control-M".

(ADDITIONAL INFO: The hex value of "m" is "0x4d" and that of "j" is
0x4a.  Holding down the CTRL key inhibits the generation of bit 6 or
the value of 0x40, so CTRL-M generates 0x0d instead of 0x4d.  Easy.)

So much for text editors, word processors and the like.  Now, when
you're at a command prompt or other program requesting input (remember
that the command prompt is the shell program asking for input), the
RETURN (or ENTER) key signals the end of user input and the program then
processes that according to whatever the program is supposed to do.

Does that clarify things?

----------------------------------------------------------------------
- Rick Stevens, Principal Engineer             rstevens@xxxxxxxxxxxx -
- CDN Systems, Internap, Inc.                http://www.internap.com -
-                                                                    -
-      Do you know how to save five drowning lawyers?  No?  GOOD!    -
----------------------------------------------------------------------

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux