1term::receive(n) Terminal control term::receive(n)
2
3
4
5______________________________________________________________________________
6
8 term::receive - General input from terminals
9
11 package require Tcl 8.4
12
13 package require term::receive ?0.1?
14
15 ::term::receive::getch ?chan?
16
17 ::term::receive::listen cmd ?chan?
18
19 cmd process string
20
21 cmd eof
22
23 ::term::receive::unlisten ?chan?
24
25______________________________________________________________________________
26
28 This package provides the most primitive commands for receiving charac‐
29 ters to a terminal. They are in essence convenient wrappers around the
30 builtin commands read and fileevent.
31
32 ::term::receive::getch ?chan?
33 This command reads a single character from the channel with han‐
34 dle chan and returns it as the result of the command.
35
36 If not specified chan defaults to stdin.
37
38 It is the responsibility of the caller to make sure that the
39 channel can provide single characters. On unix this can be done,
40 for example, by using the command of package
41 term::ansi::ctrl::unix.
42
43 ::term::receive::listen cmd ?chan?
44 This command sets up a filevent listener for the channel with
45 handle chan and invokes the command prefix cmd whenever charac‐
46 ters have been received, or EOF was reached.
47
48 If not specified chan defaults to stdin.
49
50 The signature of the command prefix is
51
52 cmd process string
53 This method is invoked when characters were received, and
54 string holds them for processing.
55
56 cmd eof
57 This method is invoked when EOF was reached on the chan‐
58 nel we listen on. It will be the last call to be re‐
59 ceived by the callback.
60
61 ::term::receive::unlisten ?chan?
62 This command disables the filevent listener for the channel with
63 handle chan.
64
65 If not specified chan defaults to stdin.
66
68 This document, and the package it describes, will undoubtedly contain
69 bugs and other problems. Please report such in the category term of
70 the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please
71 also report any ideas for enhancements you may have for either package
72 and/or documentation.
73
74 When proposing code changes, please provide unified diffs, i.e the out‐
75 put of diff -u.
76
77 Note further that attachments are strongly preferred over inlined
78 patches. Attachments can be made by going to the Edit form of the
79 ticket immediately after its creation, and then using the left-most
80 button in the secondary navigation bar.
81
83 character input, control, get character, listener, receiver, terminal
84
86 Terminal control
87
89 Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>
90
91
92
93
94tcllib 0.1 term::receive(n)