473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to quit

Hi,
I'm pretty new to programming and i need a bit help from you, the
experienced programmers.
Well the thing is I'm making a small program on C. I want that
whenever user presses the key combination of ctrl+F3, he exits from
the program. how could I code this thing?

Mar 28 '07 #1
31 2222
At about the time of 3/27/2007 9:29 PM, my********************@gmail.com
stated the following:
Hi,
I'm pretty new to programming and i need a bit help from you, the
experienced programmers.
Well the thing is I'm making a small program on C. I want that
whenever user presses the key combination of ctrl+F3, he exits from
the program. how could I code this thing?
Well, to exit, you do exit(EXIT_SUCCESS) or exit(EXIT_FAILURE). As for
control key sequences, you will need to find out what characters are
generated when a user hits CTRL-F3, then have your program look for that
key sequence.
--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
Mar 28 '07 #2
On Mar 27, 9:29 pm, mynameisthomasander...@gmail.com wrote:
Hi,
I'm pretty new to programming and i need a bit help from you, the
experienced programmers.
Well the thing is I'm making a small program on C. I want that
whenever user presses the key combination of ctrl+F3, he exits from
the program. how could I code this thing?
>From the C-FAQ:
19.5: How do I read the arrow keys? What about function keys?

A: Terminfo, some versions of termcap, and some versions of curses
have support for these non-ASCII keys. Typically, a special key
sends a multicharacter sequence (usually beginning with ESC,
'\033'); parsing these can be tricky. (curses will do the
parsing for you, if you call keypad() first.)

Under MS-DOS, if you receive a character with value 0 (*not*
'0'!) while reading the keyboard, it's a flag indicating that
the next character read will be a code indicating a special key.
See any DOS programming guide for lists of keyboard scan codes.
(Very briefly: the up, left, right, and down arrow keys are 72,
75, 77, and 80, and the function keys are 59 through 68.)

References: PCS Sec. 5.1.4 pp. 56-7.

Mar 28 '07 #3
my********************@gmail.com wrote:
>
I'm pretty new to programming and i need a bit help from you, the
experienced programmers. Well the thing is I'm making a small
program on C. I want that whenever user presses the key combination
of ctrl+F3, he exits from the program. how could I code this thing?
Probably easier to have him hit CTL-C. You will probably not have
to do anything.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Mar 28 '07 #4
my********************@gmail.com wrote:
# Hi,
# I'm pretty new to programming and i need a bit help from you, the
# experienced programmers.
# Well the thing is I'm making a small program on C. I want that
# whenever user presses the key combination of ctrl+F3, he exits from
# the program. how could I code this thing?

Whether you want to poll for keypress or arrange some kind of
interrupt handler, you'll need a system specific function. What you're
going to get from ANSI C by itself is to stop the program until
input is available and then check the input characters. So it's going
to depend on the operating system and/or the windowing system.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
I have no respect for people with no shopping agenda.
Mar 28 '07 #5
user923005 <dc*****@connx.comwrote:
On Mar 27, 9:29 pm, mynameisthomasander...@gmail.com wrote:
>Hi,
I'm pretty new to programming and i need a bit help from you, the
experienced programmers.
Well the thing is I'm making a small program on C. I want that
whenever user presses the key combination of ctrl+F3, he exits from
the program. how could I code this thing?
>>From the C-FAQ:
19.5: How do I read the arrow keys? What about function keys?
A: Terminfo, some versions of termcap, and some versions of curses
oh. "some versions of termcap" is a little odd (can anyone point
to a version of termcap that does not?).

most versions of curses as well - but this isn't the first inaccuracy
we've seen in the FAQ.

regards.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 28 '07 #6
On Mar 28, 9:01 am, Thomas Dickey <dic...@saltmine.radix.netwrote:
user923005 <dcor...@connx.comwrote:
On Mar 27, 9:29 pm, mynameisthomasander...@gmail.com wrote:
Hi,
I'm pretty new to programming and i need a bit help from you, the
experienced programmers.
Well the thing is I'm making a small program on C. I want that
whenever user presses the key combination of ctrl+F3, he exits from
the program. how could I code this thing?
From the C-FAQ:
19.5: How do I read the arrow keys? What about function keys?
A: Terminfo, some versions of termcap, and some versions of curses

oh. "some versions of termcap" is a little odd (can anyone point
to a version of termcap that does not?).

most versions of curses as well - but this isn't the first inaccuracy
we've seen in the FAQ.
If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.
I guess that there is at least one exception in either case.
Of course, both statements are mathematically true, because 'some' is
a subset of 'all'.
In any case, it's a nit.

Mar 28 '07 #7
user923005 <dc*****@connx.comwrote:
If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.
He said he would the last time I pointed out an error.
He didn't correct it.
I guess that there is at least one exception in either case.
Of course, both statements are mathematically true, because 'some' is
a subset of 'all'.
In any case, it's a nit.
hmm - no. It's incorrect, and (even given the old information that he
used), was never correct since the FAQ was written.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 28 '07 #8
Thomas Dickey <di****@saltmine.radix.netwrote:
user923005 <dc*****@connx.comwrote:
>If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.
btw, his copyright precludes any extensive discussion.

http://c-faq.com/copyright.html

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 28 '07 #9
In article <13*************@corp.supernews.com>,
Thomas Dickey <di****@saltmine.radix.netwrote:
>>If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.
>btw, his copyright precludes any extensive discussion.

http://c-faq.com/copyright.html
How can copyright preclude discussion?

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Mar 28 '07 #10
Richard Tobin <ri*****@cogsci.ed.ac.ukwrote:
In article <13*************@corp.supernews.com>,
Thomas Dickey <di****@saltmine.radix.netwrote:
>>>If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.
>>btw, his copyright precludes any extensive discussion.

http://c-faq.com/copyright.html
How can copyright preclude discussion?
Read the page (obviously you either did not, or the implication of
extensive discussion was too elusive ;-).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 28 '07 #11
Thomas Dickey <di****@saltmine.radix.netwrites:
user923005 <dc*****@connx.comwrote:
>If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.

He said he would the last time I pointed out an error.
He didn't correct it.
[...]

He is but human. Consider trying again.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 28 '07 #12
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote:
>Thomas Dickey <di****@saltmine.radix.netwrites:
>user923005 <dc*****@connx.comwrote:
>>If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.

He said he would the last time I pointed out an error.
He didn't correct it.
[...]

He is but human. Consider trying again.
The implication is that this was not a one time occurrence.

My reading of Thomas's text is that he has pointed out several errors
over the years, and that, on at least one occasion, Steve explicitly
said that it would be fixed, but nothing happened. Hence the loss of
faith.

Mar 28 '07 #13
Thomas Dickey wrote:
Richard Tobin <ri*****@cogsci.ed.ac.ukwrote:
In article <13*************@corp.supernews.com>,
Thomas Dickey <di****@saltmine.radix.netwrote:
>>If you have proof that there are no exceptions, then send an
email to >>>Steve and he will correct it, I imagine.
btw, his copyright precludes any extensive discussion.
>
http://c-faq.com/copyright.html
How can copyright preclude discussion?

Read the page (obviously you either did not, or the implication of
extensive discussion was too elusive ;-).

Yeah, so? Besides not seeing anything in there relevant to what you
say, the copyright holder can't make it more restrictive than the law
allows.


Brian
Mar 28 '07 #14
Thomas Dickey <di****@saltmine.radix.netwrites:
Thomas Dickey <di****@saltmine.radix.netwrote:
>user923005 <dc*****@connx.comwrote:
>>If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.

btw, his copyright precludes any extensive discussion.

http://c-faq.com/copyright.html
Here's what that page currently says (I'm going to assume that quoting
it is covered under fair use):

This collection of hypertext pages is Copyright 1995-2005 by Steve
Summit. Content from the book "C Programming FAQs: Frequently
Asked Questions" (Addison-Wesley, 1995, ISBN 0-201-84519-9) is
made available here by permission of the author and the publisher
as a service to the community. It is intended to complement the
use of the published text and is protected by international
copyright laws. The on-line content may be accessed freely for
personal use but may not be published or retransmitted without
explicit permission.

I see nothing there that precludes discussion, unless you assume that
discussion requires quoting substantial parts of the FAQ. Since the
FAQ is well indexed, a great deal of discussion can take place using
question numbers or hyperlinks.

I Am Not A Lawyer.

Re-posting the entire FAQ would fairly clearly be a copyright
violation. Citing individual questions presumably would not. Quoting
portions of it might or might not fall under fair use, depending on
the size of the quotation and on other factors about which, not being
a lawyer, I won't speculate.

Steve has tended to be reasonably generous in allowing use of the FAQ,
at least as generous as his publisher allows him to be. People have
occasionally quoted entire pages here, with no complaint from Steve.
(Personally, I prefer just to cite question numbers, not just to avoid
copyright infringement, but because it encourages readers to browse
nearby portions of the document.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 29 '07 #15
Thomas Dickey wrote:
>
user923005 <dc*****@connx.comwrote:
If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.

He said he would the last time I pointed out an error.
He didn't correct it.
I guess that there is at least one exception in either case.
Of course, both statements are mathematically true, because 'some' is
a subset of 'all'.
In any case, it's a nit.

hmm - no. It's incorrect, and (even given the old information that he
used), was never correct since the FAQ was written.
I, presonally, have used versions of termcap that had no concept
as "function keys" (ie: F1, F2, and so on). Of course, that was
some 20 years ago, and the modern implementations that I have seen
have entries for such keys. Whether any versions still exist that
do not support them, I cannot say.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Mar 29 '07 #16
Kenneth Brody <ke******@spamcop.netwrote:
Thomas Dickey wrote:
>hmm - no. It's incorrect, and (even given the old information that he
used), was never correct since the FAQ was written.
I, presonally, have used versions of termcap that had no concept
as "function keys" (ie: F1, F2, and so on). Of course, that was
some 20 years ago, and the modern implementations that I have seen
have entries for such keys. Whether any versions still exist that
do not support them, I cannot say.
hmm. termcap stores the whole entry as a string. Function keys and
other capabilities are string-capabilities with conventional (not
standardized) names. So any termcap file can represent function keys.

That is, unless you were using some highly advanced technology which
deduced that some capability names referred to function keys and
prevented you from using them.

If that's the case, you should elaborate on it.

More likely, you simply did not know.

termcap, when I first encountered it in the early 80's was certainly
capable of representing function keys. It was taken for granted that
termcap could represent anything that an application needed from a
terminal.

Curses did not necessarily have a parser for those (as I recall writing
one in late 1983/early 1984 to make BSD 4.3's curses more palatable with
a couple of terminals for some applications that used both cursor-keys
and function-keys).

Here's one -

http://vt100.net/annarbor/aaa-ug/section4.html#S4.1

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 29 '07 #17
Thomas Dickey wrote:
>
Kenneth Brody <ke******@spamcop.netwrote:
Thomas Dickey wrote:
hmm - no. It's incorrect, and (even given the old information that he
used), was never correct since the FAQ was written.
I, presonally, have used versions of termcap that had no concept
as "function keys" (ie: F1, F2, and so on). Of course, that was
some 20 years ago, and the modern implementations that I have seen
have entries for such keys. Whether any versions still exist that
do not support them, I cannot say.

hmm. termcap stores the whole entry as a string. Function keys and
other capabilities are string-capabilities with conventional (not
standardized) names. So any termcap file can represent function keys.
Okay, let me clarify...

What I meant was that there were no standardized entries for such
keys. So, unless you wanted to write custom termcap entries for
every terminal you wanted to support, you were stuck with the
standard, defined entries. Current versions appear to have
defined a standard set of entries for these keys.

On the other hand, current versions of termcap are often simply
wrappers to terminfo routines, and terminfo is not extensible. If
the entry wasn't defined by the implementor of the library, you
cannot add it.

Now, we defined our own entries for the functionality we wanted to
support, and wrote a wrapper around the termcap routines that could
use both the /etc/termcap file (or $TERMCAP), plus our application-
specific termcap file stored elsewhere. This allowed us to simply
enhance the existing termcap file, rather than replace it.

Of course, all of this is OT for clc. On the other hand, writing
a termcap library would probably be topical for clc, as you could
implement it in ANSI C, AFAIK. After all, it's just some functions
which read and parse a text file, and then use that info to send
things to stdout.

[...]

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Mar 29 '07 #18
Kenneth Brody <ke******@spamcop.netwrote:
Thomas Dickey wrote:
>Kenneth Brody <ke******@spamcop.netwrote:
I, presonally, have used versions of termcap that had no concept
as "function keys" (ie: F1, F2, and so on). Of course, that was
some 20 years ago, and the modern implementations that I have seen
have entries for such keys. Whether any versions still exist that
do not support them, I cannot say.
hmm. termcap stores the whole entry as a string. Function keys and
other capabilities are string-capabilities with conventional (not
standardized) names. So any termcap file can represent function keys.
Okay, let me clarify...
You didn't have to (the time would have been better spent by checking).

BSD 4.2 (I see the file's date July 1, 1983 - more than 20 years)
distributed a termcap with k1, k2, etc., in its entries. A quick check
shows 35 entries with _that_ much use of function keys.

That convention is still in use. You may not have used or even been
aware of it (there were manpages...), but other people used it, and
assumed it.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 29 '07 #19
Kenneth Brody <ke******@spamcop.netwrote:
Of course, all of this is OT for clc. On the other hand, writing
I'm afraid not:
discussing inaccuracies in a newsgroup's faq is always on topic.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 29 '07 #20
On Mar 28, 1:51 pm, Thomas Dickey <dic...@saltmine.radix.netwrote:
user923005 <dcor...@connx.comwrote:
If you have proof that there are no exceptions, then send an email to
Steve and he will correct it, I imagine.
">
He said he would the last time I pointed out an error.
He didn't correct it.
I guess that there is at least one exception in either case.
Of course, both statements are mathematically true, because 'some' is
a subset of 'all'.
In any case, it's a nit.

hmm - no. It's incorrect, and (even given the old information that he
used), was never correct since the FAQ was written.

--
Thomas E. Dickeyhttp://invisible-island.netftp://invisible-island.net
From:
http://www.delorie.com/gnu/docs/termcap/termcap_37.html
We have this:
The Termcap Library

[ < ] [ ] [ << ] [ Up ] [ >] [Top] [Contents]
[Index] [ ? ]
3.14 Keypad and Function Keys

Many terminals have arrow and function keys that transmit specific
character sequences to the computer. Since the precise sequences used
depend on the terminal, termcap defines capabilities used to say what
the sequences are. Unlike most termcap string-valued capabilities,
these are not strings of commands to be sent to the terminal, rather
strings that are received from the terminal.

Note the sentence: "Many terminals have arrow and function keys that
transmit specific character sequences to the computer." indicating
that {at least potentially} some do not.

The GNU entry reads the same:
http://www.gnu.org/software/termutil...p_4.html#SEC37

Same from University of Utah:
http://www.cs.utah.edu/dept/old/texi...cap.html#SEC35

The BSD docummentation:
http://www.freebsd.org/cgi/man.cgi?q...mcap&sektion=5
says:
"Keypad
If the terminal has a keypad that transmits codes when the keys
are
pressed, this information can be given. Note that it is not
possible to
handle terminals where the keypad only works in local mode (this
applies,
for example, to the unshifted Hewlett-Packard 2621 keys). If the
keypad
can be set to transmit or not transmit, give these codes as ks
and ke.
Otherwise the keypad is assumed to always transmit. The codes
sent by
the left-arrow, right-arrow, up-arrow, down-arrow, and home keys
can be
given as kl, kr, ku, kd, and kh, respectively. If there are
function
keys such as f0, f1, ..., f9, the codes they send can be given as
k0, k1,
..., k9. If these keys have labels other than the default f0
through f9,
the labels can be given as l0, l1, ..., l9."

I think we can infer that all credible sources of documentation agree
with Steve's interpretation.

IMO-YMMV.

Mar 30 '07 #21
user923005 <dc*****@connx.comwrote:
Many terminals have arrow and function keys that transmit specific
terminals are a different type of entity than termcap entries.

(If you have this much time to waste,
you should use some of it to learn the terminology).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 30 '07 #22
On Mar 29, 5:32 pm, Thomas Dickey <dic...@saltmine.radix.netwrote:
user923005 <dcor...@connx.comwrote:
Many terminals have arrow and function keys that transmit specific

terminals are a different type of entity than termcap entries.

(If you have this much time to waste,
you should use some of it to learn the terminology).
If the terminals do not have function keys, then termcap can hardly
map them, n'est ce pas?

Mar 30 '07 #23
user923005 <dc*****@connx.comwrote:
On Mar 29, 5:32 pm, Thomas Dickey <dic...@saltmine.radix.netwrote:
>user923005 <dcor...@connx.comwrote:
Many terminals have arrow and function keys that transmit specific

terminals are a different type of entity than termcap entries.

(If you have this much time to waste,
you should use some of it to learn the terminology).
If the terminals do not have function keys, then termcap can hardly
map them, n'est ce pas?
hmm. In your first response, you did the equivalent of stating that
gray is a shade of black.

Then you followed up with two secondary references (claiming they were
three primary ones ;-), confusing the terminal's capabilities with the
programmatic interface for controlling it.

Now you're moving on to confuse a program (which is the point of the FAQ's
comment - otherwise it's only saying something completely absurd) with its
data.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 30 '07 #24
Thomas Dickey wrote:
>
Kenneth Brody <ke******@spamcop.netwrote:
Thomas Dickey wrote:
Kenneth Brody <ke******@spamcop.netwrote:
I, presonally, have used versions of termcap that had no concept
as "function keys" (ie: F1, F2, and so on). Of course, that was
some 20 years ago, and the modern implementations that I have seen
have entries for such keys. Whether any versions still exist that
do not support them, I cannot say.
hmm. termcap stores the whole entry as a string. Function keys and
other capabilities are string-capabilities with conventional (not
standardized) names. So any termcap file can represent function keys.
Okay, let me clarify...

You didn't have to (the time would have been better spent by checking).

BSD 4.2 (I see the file's date July 1, 1983 - more than 20 years)
distributed a termcap with k1, k2, etc., in its entries. A quick check
shows 35 entries with _that_ much use of function keys.

That convention is still in use. You may not have used or even been
aware of it (there were manpages...), but other people used it, and
assumed it.
I wasn't using BSD. The system in question was Xenix, and its
termcap did not have k1, k2, and so on. As I recall, it also did
not have any entries defined for "page up", "page down", and so on.

Just because BSD's termcap defined them, doesn't mean that all
implementations used them.

Of course, the manuals are long gone.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Mar 30 '07 #25
Thomas Dickey wrote:
>
user923005 <dc*****@connx.comwrote:
[...]
If the terminals do not have function keys, then termcap can hardly
map them, n'est ce pas?

hmm. In your first response, you did the equivalent of stating that
gray is a shade of black.
Hmm... I have seen documentation on some computers which have a
video attribute of "bright black", to correspond to the others
along the line of "bright red" or "bright yellow". (Others call
the same value "dark gray".)

:-)

[...]

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Mar 30 '07 #26
Thomas Dickey wrote:
>
Kenneth Brody <ke******@spamcop.netwrote:
Of course, all of this is OT for clc. On the other hand, writing

I'm afraid not:
discussing inaccuracies in a newsgroup's faq is always on topic.
True. I forgot that the "real" discussion here was whether or not
the FAQ had an error saying "some termcap" implementations, implying
that not all, had this in it.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Mar 30 '07 #27
On Mar 30, 4:18 am, Thomas Dickey <dic...@saltmine.radix.netwrote:
user923005 <dcor...@connx.comwrote:
On Mar 29, 5:32 pm, Thomas Dickey <dic...@saltmine.radix.netwrote:
user923005 <dcor...@connx.comwrote:
Many terminals have arrow and function keys that transmit specific
terminals are a different type of entity than termcap entries.
(If you have this much time to waste,
you should use some of it to learn the terminology).
If the terminals do not have function keys, then termcap can hardly
map them, n'est ce pas?

hmm. In your first response, you did the equivalent of stating that
gray is a shade of black.
That's because grey is a shade of black. Or, perhaps, black is a
shade of grey. The only thing in the universe that is truly black is
a black hole (and even those emit something, according to prevailing
theory).
Then you followed up with two secondary references (claiming they were
three primary ones ;-), confusing the terminal's capabilities with the
programmatic interface for controlling it.
I understand what termcap does.
Now you're moving on to confuse a program (which is the point of the FAQ's
comment - otherwise it's only saying something completely absurd) with its
data.
The point is that termcap may or may not re-map function keys.

The FAQ was saying that termcap may or may not remap your function
keys. It is possible that to make it work correctly, you will simply
need to add some entries into the termcap database, but it is also
possible that the terminals do not support function keys, in which
case the entries will be useless.

The upshot is that you may or may not be able to define function keys
with termcap (which is pretty much obsolete anyway).

Here is an entry from a vi release notes file:

If the lhs of a macro is "#0" through "#9", this maps the particular
function key instead of the 2 char # sequence, if the terminal has
function keys. This only works if termcap has function key entries
for the particular terminal. For terminals without function keys,
the sequence #x means function key x, as typed. As a special case,
on terminals without function keys, the #x sequence need not be
typed within one second. The character # can be changed by using
a macro in the usual way:
map ^V^I #
to use tab, for example. (This won't affect the map command, which
still uses #, but just the invocation from visual mode.)
The undo command will undo an entire macro call as a unit.

Perhaps the FAQ entry should say something like:
"If you are using termcap, and your terminal supports function keys,
then you might be able to use termcap to collect function key
information."
How would you word it?

Mar 30 '07 #28
Kenneth Brody <ke******@spamcop.netwrote:
I wasn't using BSD. The system in question was Xenix, and its
termcap did not have k1, k2, and so on. As I recall, it also did
not have any entries defined for "page up", "page down", and so on.
Just because BSD's termcap defined them, doesn't mean that all
implementations used them.
Of course, the manuals are long gone.
It's easier to discuss things when they're documented.

The only references I can see offhand to Xenix (which I also used around
the same time - including porting my termcap applications) remind one
that some function-key combinations were intercepted by the keyboard
driver to switch virtual screens. But the same references state that
k0-k9 were available for application use (and vendor's suggested
termcaps, e.g., from Wyse) agree with that.

Xenix (like a few others which linger on - Ingres for example) had
extensions to termcap to provide support for line-drawing characters
which do not agree with the usual termcap convention.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 30 '07 #29
user923005 <dc*****@connx.comwrote:
Perhaps the FAQ entry should say something like:
"If you are using termcap, and your terminal supports function keys,
then you might be able to use termcap to collect function key
information."
How would you word it?
By making it clearer how the pieces are related.

The paragraph quoted does not make it apparent that these are programmatic
interfaces, with varying capabilities (except for "some versions of curses")
and that they rely upon knowing the terminal's capabilities (or lack):

A: Terminfo, some versions of termcap, and some versions of curses
have support for these non-ASCII keys. Typically, a special key
sends a multicharacter sequence (usually beginning with ESC,
'\033'); parsing these can be tricky. (curses will do the
parsing for you, if you call keypad() first.)

It's the first sentence which is the problem. Start by providing a clue
to the answer:

This addresses only the most common case, where the keys send
characters to your application, running in a terminal.

Arrow keys and function keys (special keys) are not ASCII
values. Typically, a special key sends a multicharacter
sequence (usually beginning with ESC, '\033'). Parsing these
can be tricky.

The multicharacter sequences sent may differ from one terminal
type to another. Different terminals have different numbers of
special keys - even none in rare instances. There are system
dependent programmatic interfaces which provide the ability to
retrieve this information for different terminal types. These
interfaces include the low-level terminfo and termcap (named for
their respective databases) as well as curses (alluding to the
higher level optimization of cursor movement).

Most implementations of curses are built on either terminfo or
termcap, and as part of their interface include these
lower-level interfaces. Most versions of curses also provide
functions which can parse the multicharacter sequences to return
a code denoting which special key was sent. You must call the
keypad() function to use this feature, as well as use the curses
getch() function for reading the keys from the terminal.

btw - I chose to ignore the reference to MS-DOS, since (a) it's
tecnically obsolete, and (b) more than a mention of the more commonly
used interfaces with Windows would require greater detail than is in the
FAQ for any entry. Note however, that far more people are looking for
analogous information about Windows than MS-DOS (the FAQ is long out
of date as well).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Mar 31 '07 #30
mynameisthomasanderson wrote:
I'm pretty new to programming and i need a bit help from you, the
experienced programmers.
Well the thing is I'm making a small program on C. I want that
whenever user presses the key combination of ctrl+F3, he exits from
the program. how could I code this thing?
I'm afraid I can't contribute anything about termcap, copyright law, the
quality of the FAQ, or what constitutes on topicness.

But if the OP is still around, perhaps here is something he could adapt.
This uses ^c as an attention interrupt. Note that the process in control
continues, and that the user response waits for an Enter key stroke. No
error handling for scanf is provided, I expect it would be removed in the
adaptation the OP makes, I used it for testing. This is only intended to
work once per program execution, which as I understand it, is sufficient.

#include <stdio.h>
#include <signal.h>

void piddle();
int stop = 0;

// f is the user supplied interrupt hander for the SIGINT interrupt
// modify per your needs
void f(int n/* argument not used */)
{
printf("f called\n");
printf("Quit? y n\n");
char ch;
scanf("%c", &ch);
printf("\n%c\n", ch);
if(ch == 'y')
exit(0); // success
else
{
printf("Still alive\n");
fflush(NULL);
stop = 1;
}
}
//--------------
void set_up_interrupt()
{
// SIGINT (interactive attention) produced by ^c
signal(SIGINT, f);
}
//---------------
// prints a message once a second
void piddle()
{
time_t t = time(NULL);
while(!stop)
if(t != time(NULL) )
{
t = time(NULL);
printf("Tick\n");
}
}
//==============
int main()
{
// function used for clarity
set_up_interrupt();
piddle();
// next only to retain sanity while debugging with MingW
while(1)
getchar();
}
Mar 31 '07 #31
osmium <r1********@comcast.netwrote:
But if the OP is still around, perhaps here is something he could adapt.
This uses ^c as an attention interrupt. Note that the process in control
continues, and that the user response waits for an Enter key stroke. No
error handling for scanf is provided, I expect it would be removed in the
adaptation the OP makes, I used it for testing. This is only intended to
work once per program execution, which as I understand it, is sufficient.
hmm - if this were almost any other newsgroup, e.g., comp.unix.programmer,
I'd point out that the signal handler may dump core. But this is comp.lang.c
which is unconstrained by that sort of consideration.

OP may find it useful though.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Apr 1 '07 #32

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David Conorozzo | last post by:
I create a new Access.Application instance. As soon as I refernce the property "References", I am unable to issue a truly successful quit on that instance. By that I mean the call to quit is fine...
2
by: Lauren Quantrell | last post by:
Running Access2000 ADP Project/MSDE on Windows XP... - I Open my Access ADP project. In the Windows Task Manager Processes window MSACCESS.EXE shows up. - I don't do anything else in Access. - I...
3
by: downwitch | last post by:
Greetings, I have an application which has recently gone from being one big piece of front-end code to being three, i.e. an mdb A that references an mda B and an mda C. (For what it's worth, in...
6
by: Max | last post by:
I have the following code on a form that launches Microsoft Outlook and creates a new email message for the user: Outlook.Application oApp = new Outlook.Application(); Outlook.MailItem oMail...
5
by: mzdude | last post by:
I've just started playing with Python. Installed 2.5 on Windows XP system. I'm working through some of the examples in Programming Python 3ed by Mark Lutz. Given the following example when the Quit...
2
by: Alan T | last post by:
private Interop.Word.Application _wordApp; What is the differences betwenn _wordApp.Quit(...) and _wordApp.Application.Quit(...) ?
5
by: Mubs | last post by:
i have the following script.. but i cant get the quit command working... can some1 help quit = n host="$(hostname)" todaysdate="$(date)" lastboot="$(last reboot)" licensinginfo="$(uname...
0
by: Greg Donald | last post by:
When using starttls(), calling quit() throws an exception: -server.quit() (Pdb) n send: 'quit\r\n' sslerror: (8, 'EOF occurred in violation of protocol') For the moment I and catching it...
0
by: Roger | last post by:
I am having a problem sending email through smtp.gmail.com using smtplib. Everything works and the mail is sent and received, except quit. The following shows the problem (without bothering to...
9
by: Andy | last post by:
Just noticed something interesting in the above. If you have your program file set to "Compact on Close" in access 2007 (which is desirable when you have a larger program that frequently needs...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.