Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Oct 2006 11:30:45 +1030
From:      Malcolm Kay <malcolm.kay@internode.on.net>
To:        freebsd-questions@freebsd.org
Cc:        Jerry McAllister <jerrymc@msu.edu>, "Peter A. Giessel" <pgiessel@mac.com>, Noah <admin2@enabled.com>
Subject:   Re: replacing ^M with emacs
Message-ID:  <200610291130.46023.malcolm.kay@internode.on.net>
In-Reply-To: <4542C704.70309@enabled.com>
References:  <45425D61.6030209@enabled.com> <20061028003929.GA99333@gizmo.acns.msu.edu> <4542C704.70309@enabled.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 28 Oct 2006 12:27 pm, Noah wrote:
> well I am pressing control-J for return not control-M so I
> dont understand your rationale.
>

There seems to be considerable confusion in this thread between 
keystrokes and the codes they produce.

Most modern keyboards report some form of scan code for each key 
pressed whether or not it is one of the modifier or special 
keys. At this stage there is no connection between the key or
key combination pressed and an ASCII code.

What an application sees in terms of codes depends on the OS and 
anything else that may get in between. We mostly think of keys 
and key combinations as being connected to the the codes seen by
an ordinary console application, but this can vary according to 
the OS.

With a standard setup running X applications with a graphics 
interface are able to see all keys translated to some form of 
symbol code (some sort of a super set of ASCII including codes
for special keys) which can be customised with xmodmap.
 
Character mode programs under X through some terminal emulation
window will see codes (usually ASCII) as further translated by
that terminal emulator. I find that by default xterm reports ^M
on pressing the "enter/return" key but this can further 
customised through XTerm or .Xdefaults. A basic key is generally
combined with the currently active modifier keys(shift,ctrl,alt,
etc) to produce the code reported to the application. Other keys 
such as function keys might be reported as a sequence of codes.

Utilities and applications may manage codes differently when they 
recognise the source as the keyboard so for example Ctrl-J, 
Ctrl-M and "enter" from the keyboard are all reported by "cat" 
as ^J.

Malcolm


> Jerry McAllister wrote:
> >> Thanks Peter,
> >>
> >> where is the logic here?  What is control-q for and what is
> >> control-j for?  I am trying to figure out how I could have
> >> figured that out.
> >
> > They are ASCII characters.   For example, the ^M you wanted
> > to get rid of is CTRL-M.    There are ASCII tables in
> > various places. A quick search should turn up a few.   The
> > assignment of the characters are ancient and traditional and
> > somewhat weird by how things are currently used, but will
> > probably continue to stay that way.
> >
> > Line-Feed, for example - which is that character that marks
> > the end of a line in text files, means it causes the printer
> > to move the paper up one line - in old line printers and
> > teletypes.  CTRL-M or ^M is a RETURN (also ENTER nowdays)
> > and that caused the print head to return to the beginning of
> > the line.  By the time UNIX came along, it wasn't necessary
> > to use both characters to move the paper and print head
> > because those were virtual.  So, they just used one
> > character - the line feed.   But, MS-DOS and some others
> > continued to use the pair to mean a new line for some reason
> > - maybe the original association with IBM, although they
> > didn't use ASCII, but EBCDIC - another animal.
> >
> > So, look up an ASCII chart with explanations and you can
> > make an educated guess on the meanings.
> >
> > ////jerry
> >
> >> also is there a better page than the one I am using below
> >> to figure all these keystrokes out?
> >>
> >> http://www.math.uh.edu/~bgb/emacs_keys.html
> >>
> >> Cheers,
> >>
> >> Noah
> >>
> >> Peter A. Giessel wrote:
> >>> On 2006/10/27 15:20, Noah seems to have typed:
> >>>> this is the best answer.  Hits it right on the head of
> >>>> what I want. What if I want the character to replace the
> >>>> ^M with a new line what do I enter in the replace field?
> >>>
> >>> control-q control-j
> >>
> >> _______________________________________________
> >> freebsd-questions@freebsd.org mailing list
> >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> >> To unsubscribe, send any mail to
> >> "freebsd-questions-unsubscribe@freebsd.org"
>
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610291130.46023.malcolm.kay>