| List of Examples |
xxv |
| List of Tables |
xxxv |
| Preface |
xli |
I | Tcl Basics |
1 |
1. | Tcl Fundamentals |
3 |
| Tcl Commands |
3 |
| Hello, World! |
4 |
| Variables |
5 |
| Command Substitution |
5 |
| Math Expressions |
6 |
| Backslash Substitution |
7 |
| Grouping with Braces and Double Quotes |
8 |
| Square Brackets Do Not Group |
9 |
| Grouping before Substitution |
9 |
| Grouping Math Expressions with Braces |
10 |
| More Substitution Examples |
10 |
| Procedures |
11 |
| A Factorial Example |
12 |
| More about Variables |
13 |
| Funny Variable Names |
14 |
| The unset Command |
15 |
| Using info to Find Out about Variables |
15 |
| More about Math Expressions |
15 |
| Comments |
16 |
| Substitution and Grouping Summary |
17 |
| Fine Points |
18 |
| Reference |
20 |
| Backslash Sequences |
20 |
| Arithmetic Operators |
20 |
| Built-in Math Functions |
21 |
| Core Tcl Commands |
21 |
2. | Getting Started |
25 |
| The source Command |
26 |
| UNIX Tcl Scripts |
26 |
| Windows 95 Start Menu |
27 |
| The Macintosh and ResEdit |
28 |
| The console Command |
28 |
| Command-Line Arguments |
29 |
| Command-Line Options to Wish |
29 |
| Predefined Variables |
30 |
3. | The Guestbook CGI Application |
31 |
| A Quick Introduction to HTML |
32 |
| CGI for Dynamic Pages |
33 |
| The guestbook.cgi Script |
34 |
| Using a Script Library File |
35 |
| Beginning the HTML Page |
36 |
| Simple Tags and Hypertext Links |
36 |
| Using a Tcl Array for the Database |
38 |
| Sample Output |
39 |
| Defining Forms and Processing Form Data |
39 |
| The newguest.html Form |
40 |
| The newguest.cgi Script |
41 |
| The cgi.tcl Package |
43 |
| Next Steps |
43 |
4. | String Processing in Tcl |
45 |
| The string Command |
45 |
| String Indices |
47 |
| Strings and Expressions |
48 |
| String Matching |
48 |
| Character Classes |
50 |
| Mapping Strings |
51 |
| The append Command |
51 |
| The format Command |
52 |
| The scan Command |
54 |
| The binary Command |
54 |
| Format Templates |
55 |
| Examples |
56 |
| Binary Data and File I/O |
57 |
| Related Chapters |
58 |
5. | Tcl Lists |
59 |
| Tcl Lists |
59 |
| Constructing Lists |
61 |
| The list command |
61 |
| The lappend Command |
62 |
| The concat Command |
62 |
| Getting List Elements: llength, lindex, and lrange |
63 |
| Modifying Lists: linsert and lreplace |
64 |
| Searching Lists: lsearch |
64 |
| Sorting Lists: lsort |
65 |
| The split Command |
65 |
| The join Command |
67 |
| Related Chapters |
67 |
6. | Control Structure Commands |
69 |
| If Then Else |
70 |
| Switch |
71 |
| Comments in switch Commands |
72 |
| While |
73 |
| Foreach |
73 |
| Multiple Loop Variables |
75 |
| Multiple Value Lists |
76 |
| For |
76 |
| Break and Continue |
77 |
| Catch |
77 |
| Catching More Than Errors |
78 |
| Error |
79 |
| Return |
80 |
7. | Procedures and Scope |
81 |
| The proc Command |
81 |
| Changing Command Names with rename |
83 |
| Scope |
83 |
| The global Command |
84 |
| Call by Name Using upvar |
85 |
| Variable Aliases with upvar |
86 |
| Associating State with Data |
86 |
| Namespaces and upvar |
87 |
| Commands That Take Variable Names |
87 |
8. | Tcl Arrays |
89 |
| Array Syntax |
89 |
| Complex Indices |
90 |
| Array Variables |
90 |
| The array Command |
91 |
| Converting Between Arrays and Lists |
92 |
| Passing Arrays by Name |
92 |
| Building Data Structures with Arrays |
93 |
| Simple Records |
93 |
| A Stack |
94 |
| A List of Arrays |
95 |
| A Simple In-Memory Database |
96 |
9. | Working with Files and Programs |
99 |
| Running Programs with exec |
99 |
| The auto_noexec Variable |
101 |
| Limitations of exec on Windows |
101 |
| AppleScript on Macintosh |
101 |
| The file Command |
102 |
| Cross-Platform File Naming |
103 |
| Building up Pathnames: file join |
104 |
| Chopping Pathnames: split, dirname, tail |
105 |
| Manipulating Files and Directories |
105 |
| Copying Files |
106 |
| Creating Directories |
106 |
| Deleting Files |
106 |
| Renaming Files and Directories |
107 |
| File Attributes |
107 |
| Input/Output Command Summary |
109 |
| Opening Files for I/O |
110 |
| Opening a Process Pipeline |
111 |
| Expect |
112 |
| Reading and Writing |
112 |
| The puts and gets Commands |
112 |
| The read Command |
113 |
| Platform-Specific End of Line Characters |
114 |
| Random Access I/O |
114 |
| Closing I/O Channels |
115 |
| The Current Directory � cd and pwd |
115 |
| Matching File Names with glob |
115 |
| Expanding Tilde in File Names |
116 |
| The exit and pid Commands |
116 |
| Environment Variables |
117 |
| The registry Command |
117 |
II | Advanced Tcl |
119 |
10. | Quoting Issues and Eval |
121 |
| Constructing Code with the list Command |
122 |
| The eval Command |
122 |
| Commands That Concatenate Their Arguments |
123 |
| Commands That Use Callbacks |
124 |
| Command Prefix Callbacks |
124 |
| Constructing Procedures Dynamically |
125 |
| Exploiting the concat inside eval |
126 |
| Using eval in a Wrapper Procedure. |
126 |
| Correct Quoting with eval |
128 |
| The uplevel Command |
130 |
| The subst Command |
132 |
| String Processing with subst |
132 |
11. | Regular Expressions |
133 |
| When to Use Regular Expressions |
134 |
| Avoiding a Common Problem |
134 |
| Regular Expression Syntax |
135 |
| Matching Characters |
135 |
| Character Sets |
135 |
| Quantifiers |
136 |
| Alternation |
136 |
| Anchoring a Match |
137 |
| Backslash Quoting |
137 |
| Matching Precedence |
138 |
| Capturing Subpatterns |
138 |
| Advanced Regular Expressions |
138 |
| Compatibility with Patterns in Tcl 8.0 |
139 |
| Backslash Escape Sequences |
139 |
| Character Classes |
140 |
| Nongreedy Quantifiers |
140 |
| Bound Quantifiers |
141 |
| Back References |
141 |
| Look-ahead |
142 |
| Character Codes |
142 |
| Collating Elements |
142 |
| Equivalence Classes |
143 |
| Newline Sensitive Matching |
143 |
| Embedded Options |
144 |
| Expanded Syntax |
144 |
| Syntax Summary |
145 |
| The regexp Command |
148 |
| A Pattern to Match URLs |
149 |
| Sample Regular Expressions |
151 |
| The regsub Command |
152 |
| Transforming Data to Program with regsub |
153 |
| URL Decoding |
153 |
| CGI Argument Parsing |
154 |
| Decoding HTML Entities |
156 |
| A Simple HTML Parser |
158 |
| Stripping HTML Comments |
160 |
| Other Commands That Use Regular Expressions |
160 |
12. | Script Libraries and Packages |
161 |
| Locating Packages: The auto_path Variable |
162 |
| Using Packages |
163 |
| Loading Packages Automatically |
163 |
| Packages Implemented in C Code |
164 |
| Summary of Package Loading |
165 |
| The package Command |
165 |
| Libraries Based on the tclIndex File |
166 |
| The unknown Command |
167 |
| How Auto Loading Works |
168 |
| Disabling the Library Facility: auto_noload |
168 |
| Interactive Conveniences |
169 |
| Auto Execute |
169 |
| History |
169 |
| Abbreviations |
169 |
| Tcl Shell Library Environment |
169 |
| Locating the Tcl Script Library |
170 |
| tcl_findLibrary |
170 |
| Coding Style |
171 |
| A Module Prefix for Procedure Names |
171 |
| A Global Array for State Variables |
172 |
| The Official Tcl Style Guide |
172 |
13. | Reflection and Debugging |
173 |
| The clock Command |
173 |
| The info Command |
176 |
| Variables |
177 |
| Procedures |
178 |
| The Call Stack |
180 |
| Command Evaluation |
180 |
| Scripts and the Library |
181 |
| Version Numbers |
182 |
| Execution Environment |
182 |
| Cross-Platform Support |
182 |
| Tracing Variable Values |
183 |
| Read-Only Variables |
184 |
| Creating an Array with Traces |
184 |
| Interactive Command History |
185 |
| History Syntax |
186 |
| A Comparison to C Shell History Syntax |
187 |
| Debugging |
188 |
| Scriptics� TclPro |
189 |
| TclPro Debugger |
189 |
| TclPro Checker |
189 |
| TclPro Compiler |
189 |
| TclPro Wrapper |
190 |
| Other Tools |
190 |
| The tkinspect Program |
190 |
| The Tuba Debugger |
190 |
| The bgerror Command |
190 |
| The tkerror Command |
191 |
| Performance Tuning |
191 |
| Time stamps in a Log |
191 |
| The Tcl Compiler |
192 |
14. | Namespaces |
195 |
| Using Namespaces |
195 |
| Namespace Variables |
197 |
| Qualified Names |
198 |
| Command Lookup |
198 |
| Nested Namespaces |
199 |
| Importing and Exporting Procedures |
200 |
| Callbacks and Namespaces |
201 |
| Introspection |
202 |
| The namespace Command |
203 |
| Converting Existing Packages to use Namespaces |
203 |
| [incr Tcl] Object System |
204 |
| Notes |
204 |
| Names for Widgets, Images, and Interpreters |
205 |
| The variable command at the global scope |
205 |
| Auto Loading and auto_import |
205 |
| Namespaces and uplevel |
205 |
| Naming Quirks |
205 |
| Miscellaneous |
206 |
15. | Internationalization |
207 |
| Character Sets and Encodings |
208 |
| The System Encoding |
208 |
| File Encodings and fconfigure |
209 |
| Scripts in Different Encodings |
210 |
| Unicode and UTF-8 |
210 |
| The Binary Encoding |
211 |
| Conversions Between Encodings |
211 |
| The encoding Command |
212 |
| Message Catalogs |
212 |
| Specifying a Locale |
213 |
| Managing Message Catalog Files |
213 |
| Message Catalogs and Namespaces |
215 |
| The msgcat package |
216 |
16. | Event-Driven Programming |
217 |
| The Tcl Event Loop |
217 |
| The after Command |
218 |
| The fileevent Command |
219 |
| The vwait Command |
220 |
| The fconfigure Command |
221 |
| Nonblocking I/O |
221 |
| The fblocked Command |
223 |
| Buffering |
223 |
| End of Line Translations |
223 |
| End of File Character |
224 |
| Serial Devices |
224 |
| Character Set Encodings |
224 |
| Configuring Read-Write Channels |
224 |
17. | Socket Programming |
225 |
| Client Sockets |
226 |
| Client Socket Options |
226 |
| Server Sockets |
227 |
| Server Socket Options |
228 |
| The Echo Service |
228 |
| Fetching a URL with HTTP |
230 |
| Proxy Servers |
231 |
| The HEAD Request |
232 |
| The GET and POST Requests |
234 |
| The fcopy Command |
237 |
| The http Package |
237 |
| http::config |
238 |
| http::geturl |
238 |
| http::formatQuery |
241 |
| http::reset |
241 |
| http::cleanup |
241 |
| Basic Authentication |
241 |
18. | TclHttpd Web Server |
243 |
| Integrating TclHttpd with your Application |
244 |
| TclHttpd Architecture |
244 |
| Domain Handlers |
245 |
| Connection State and Query Data |
246 |
| Returning Results |
247 |
| Application Direct URLs |
247 |
| Using Query Data |
248 |
| Returning Other Content Types |
249 |
| Document Types |
249 |
| HTML + Tcl Templates |
250 |
| Where to put your Tcl Code |
251 |
| Templates for Site Structure |
252 |
| Form Handlers |
254 |
| Application Direct Handlers |
255 |
| Template Form Handlers |
256 |
| Self Posting Forms |
257 |
| The form package |
258 |
| Programming Reference |
259 |
| Standard Application-Direct URLs |
263 |
| Status |
263 |
| Debugging |
263 |
| Administration |
265 |
| Sending Email |
265 |
| The TclHttpd Distribution |
266 |
| Quick Start |
266 |
| Inside the Distribution |
267 |
| Server Configuration |
267 |
| Command Line Arguments |
268 |
| Server Name and Port |
268 |
| User and Group ID |
269 |
| Webmaster Email |
269 |
| Document Root |
269 |
| Other Document Settings |
270 |
| Document Templates |
270 |
| Log Files |
271 |
| CGI Directories |
271 |
19. |
Multiple Interpreters and Safe-Tcl |
273 |
| The interp Command |
274 |
| Creating Interpreters |
275 |
| The Interpreter Hierarchy |
275 |
| The Interpreter Name as a Command |
276 |
| Use list with interp eval |
276 |
| Safe Interpreters |
277 |
| Command Aliases |
278 |
| Alias Introspection |
278 |
| Hidden Commands |
279 |
| Substitutions |
280 |
| I/O from Safe Interpreters |
281 |
| The Safe Base |
282 |
| Security Policies |
283 |
| Limited Socket Access |
284 |
| Limited Temporary Files |
286 |
| Safe after Command |
289 |
20. |
Safe-Tk and the Browser Plugin |
293 |
| Tk in Child Interpreters |
294 |
| Embedding Tk Windows |
294 |
| Safe-Tk Restrictions |
295 |
| The Browser Plugin |
296 |
| The embed_args and plugin Variables |
296 |
| Example Plugins |
296 |
| Setting Up the plugin |
297 |
| Plugin Environment Variables |
297 |
| UNIX Configuration |
298 |
| Windows Configuration |
298 |
| Macintosh Configuration |
298 |
| Security Policies and Browser Plugin |
299 |
| The Browser Package |
300 |
| Configuring Security Policies |
301 |
| The config/plugin.cfg File |
301 |
| Policy Configuration Files |
302 |
| Security Policy Features |
303 |
| Creating New Security Policies |
303 |
III | Tk Basics |
305 |
21. | Tk Fundamentals |
307 |
| Hello, World! in Tk |
308 |
| Naming Tk Widgets |
310 |
| Configuring Tk Widgets |
310 |
| Tk Widget Attributes and the Resource Database |
311 |
| The Tk Manual Pages |
312 |
| Summary of the Tk Commands |
312 |
22. | Tk by Example |
315 |
| ExecLog |
315 |
| Window Title |
317 |
| A Frame for Buttons |
318 |
| Command Buttons |
318 |
| A Label and an Entry |
318 |
| Key Bindings and Focus |
318 |
| A Resizable Text and Scrollbar |
319 |
| The Run Procedure |
319 |
| The Log Procedure |
320 |
| The Stop Procedure |
321 |
| Cross-Platform Issues |
321 |
| The Example Browser |
322 |
| More about Resizing Windows |
325 |
| Managing Global State |
325 |
| Searching through Files |
325 |
| Cascaded Menus |
326 |
| A Read-Only Text Widget |
327 |
| A Tcl Shell |
327 |
| Text Marks, Tags, and Bindings |
330 |
| Multiple Interpreters |
330 |
| Native Look and Feel |
330 |
23. | The Pack Geometry Manager |
333 |
| Packing toward a Side |
334 |
| Shrinking Frames and pack propagate |
334 |
| Horizontal and Vertical Stacking |
335 |
| The Cavity Model |
336 |
| Packing Space and Display Space |
337 |
| The -fill Option |
337 |
| Internal Padding with -ipadx and -ipady |
338 |
| External Padding with -padx and -pady |
340 |
| Resizing and -expand |
340 |
| Anchoring |
342 |
| Packing Order |
343 |
| Introspection |
344 |
| Pack the Scrollbar First |
344 |
| Choosing the Parent for Packing |
345 |
| Unpacking a Widget |
345 |
| Packer Summary |
346 |
| The pack Command |
346 |
| Window Stacking Order |
347 |
24. | The Grid Geometry Manager |
349 |
| A Basic Grid |
349 |
| The -sticky Setting |
350 |
| External Padding with -padx and -pady |
351 |
| Internal Padding with -ipadx and -ipady |
352 |
| Multiple Widgets in a Cell |
352 |
| Spanning Rows and Columns |
353 |
| Row and Column Constraints |
354 |
| Row and Column Padding |
354 |
| Minimum Size |
355 |
| Managing Resize Behavior |
355 |
| The grid Command |
356 |
25. | The Place Geometry Manager |
359 |
| place Basics |
359 |
| The Pane Manager |
361 |
| Parsing Arguments and Maintaining State |
362 |
| Sticky Geometry Settings |
362 |
| Event Bindings |
363 |
| Managing the Layout |
363 |
| The place Command |
365 |
26. | Binding Commands to Events |
367 |
| The bind Command |
367 |
| The bindtags Command |
369 |
| Focus and Key Events |
370 |
| Using break and continue in Bindings |
370 |
| Defining New Binding Tags |
371 |
| Event Syntax |
371 |
| Keyboard Events |
371 |
| Mouse Events |
373 |
| Other Events |
374 |
| Bindings on Top-level Windows |
374 |
| Modifiers |
375 |
| Event Sequences |
377 |
| Virtual Events |
378 |
| Event Keywords |
379 |
IV | Tk Widgets |
383 |
27. | Buttons and Menus |
385 |
| Button Commands and Scope Issues |
386 |
| Buttons Associated with Tcl Variables |
390 |
| Button Attributes |
391 |
| Button Operations |
393 |
| Menus and Menubuttons |
394 |
| A Menu Bar |
395 |
| System Menus |
396 |
| Pop-Up Menus |
396 |
| Option Menus |
396 |
| Multicolumn Palette Menus |
397 |
| Keyboard Traversal |
397 |
| Manipulating Menus and Menu Entries |
397 |
| Menu Attributes |
399 |
| A Menu by Name Package |
400 |
| Menu Accelerators |
403 |
28. | The Resource Database |
405 |
| An Introduction to Resources |
405 |
| Resource Patterns |
406 |
| Loading Option Database Files |
407 |
| Adding Individual Database Entries |
408 |
| Accessing the Database |
409 |
| User-Defined Buttons |
409 |
| User-Defined Menus |
411 |
| Application and User Resources |
413 |
| Expanding Variables |
414 |
29. | Simple Tk Widgets |
415 |
| Frames and Toplevel Windows |
415 |
| Attributes for Frames and Toplevels |
416 |
| Embedding Other Applications |
417 |
| Toplevel Window Styles |
417 |
| The Label Widget |
418 |
| Label Width and Wrap Length |
419 |
| Label Attributes |
419 |
| The Message Widget |
420 |
| Message Attributes |
422 |
| Arranging Labels and Messages |
422 |
| The Scale Widget |
423 |
| Scale Bindings |
423 |
| Scale Attributes |
424 |
| Programming Scales |
425 |
| The bell Command |
426 |
30. | Scrollbars |
427 |
| Using Scrollbars |
427 |
| The Scrollbar Protocol |
429 |
| The Scrollbar set Operation |
429 |
| The xview and yview Operations |
431 |
| The Tk 3.6 Protocol |
431 |
| The Scrollbar Widget |
432 |
| Scrollbar Bindings |
432 |
| Scrollbar Attributes |
432 |
| Programming Scrollbars |
433 |
31. | The Entry Widget |
435 |
| Using Entry Widgets |
435 |
| Tips for Using Entry Widgets |
436 |
| The Entry Widget |
437 |
| Entry Attributes |
438 |
| Programming Entry Widgets |
439 |
32. | The Listbox Widget |
441 |
| Using Listboxes |
441 |
| Programming Listboxes |
443 |
| Listbox Bindings |
445 |
| Browse Select Mode |
446 |
| Single Select Mode |
446 |
| Extended Select Mode |
447 |
| Multiple Select Mode |
448 |
| Scroll Bindings |
448 |
| Listbox Attributes |
449 |
| Geometry Gridding |
449 |
33. | The Text Widget |
451 |
| Text Indices |
451 |
| Inserting and Deleting Text |
452 |
| Index Arithmetic |
453 |
| Comparing Indices |
453 |
| Text Marks |
454 |
| Mark Gravity |
454 |
| Text Tags |
455 |
| Tag Attributes |
455 |
| Mixing Attributes from Different Tags |
457 |
| Line Spacing and Justification |
457 |
| Tab Stops |
459 |
| The Selection |
460 |
| Tag Bindings |
460 |
| Searching Text |
461 |
| Embedded Widgets |
462 |
| Embedded Images |
464 |
| Looking inside the Text Widget |
465 |
| Looking at Tags |
465 |
| Looking at Marks |
466 |
| Dumping the Contents |
466 |
| Text Bindings |
467 |
| Text Operations |
469 |
| Text Attributes |
471 |
34. | The Canvas Widget |
473 |
| Canvas Coordinates |
473 |
| Hello, World! |
474 |
| Canvas Tags |
475 |
| The Min Max Scale Example |
477 |
| Canvas Objects |
481 |
| Arc Items |
481 |
| Bitmap Items |
482 |
| Image Items |
483 |
| Line Items |
484 |
| Oval Items |
486 |
| Polygon Items |
486 |
| Rectangle Items |
487 |
| Text Items |
488 |
| Window Items |
492 |
| Canvas Operations |
494 |
| Generating Postscript |
496 |
| Canvas Attributes |
498 |
| Hints |
500 |
| Screen Coordinates vs. Canvas Coordinates |
500 |
| Large Coordinate Spaces |
500 |
| Scaling and Rotation |
500 |
| Resources |
500 |
| Objects with Many Points |
501 |
| Selecting Canvas Items |
501 |
V | Tk Details |
503 |
35. | Selections and the Clipboard |
505 |
| The Selection Model |
505 |
| The selection Command |
507 |
| The clipboard Command |
508 |
| Selection Handlers |
508 |
| A Canvas Selection Handler |
509 |
36. | Focus, Grabs, and Dialogs |
513 |
| Standard Dialogs |
513 |
| Message Box |
514 |
| File Dialogs |
514 |
| Color Dialog |
515 |
| Custom Dialogs |
516 |
| Input Focus |
516 |
| The focus Command |
517 |
| Keyboard Focus Traversal |
517 |
| Grabbing the Focus |
518 |
| The tkwait Command |
518 |
| Destroying Widgets |
519 |
| The focus, grab, tkwait sequence |
519 |
| Prompter Dialog |
521 |
| Keyboard Shortcuts and Focus |
522 |
| Animation with the update Command |
522 |
37. | Tk Widget Attributes |
525 |
| Configuring Attributes |
525 |
| Size |
526 |
| Borders and Relief |
528 |
| The Focus Highlight |
529 |
| Padding and Anchors |
530 |
| Putting It All Together |
531 |
38. | Color, Images, and Cursors |
533 |
| Colors |
534 |
| Color Palettes |
535 |
| Color Values |
535 |
| Colormaps and Visuals |
538 |
| Bitmaps and Images |
539 |
| The image Command |
540 |
| Bitmap Images |
540 |
| The bitmap Attribute |
541 |
| Photo Images |
542 |
| The Text Insert Cursor |
544 |
| The Mouse Cursor |
545 |
39. | Fonts and Text Attributes |
547 |
| Naming a Font |
548 |
| Named Fonts |
549 |
| System Fonts |
549 |
| Unicode Fonts |
549 |
| X Font Names |
550 |
| Font Failures before Tk 8.0 |
551 |
| Font Metrics |
552 |
| The font Command |
552 |
| Text Attributes |
553 |
| Layout |
553 |
| Selection Attributes |
554 |
| Gridding, Resizing, and Geometry |
554 |
| A Font Selection Application |
555 |
40. | Send |
559 |
| The send Command |
560 |
| Send and X Authority |
560 |
| The Sender Script |
561 |
| Communicating Processes |
563 |
| Remote eval through Sockets |
564 |
41. | Window Managers and Window Information |
569 |
| The wm Command |
569 |
| Size, Placement, and Decoration |
570 |
| Icons |
571 |
| Session State |
572 |
| Miscellaneous |
573 |
| The winfo Command |
574 |
| Sending Commands between Applications |
574 |
| Family Relationships |
575 |
| Size |
576 |
| Location |
577 |
| Virtual Root Window |
578 |
| Atoms and IDs |
578 |
| Colormaps and Visuals |
579 |
| The tk Command |
580 |
42. | Managing User Preferences |
581 |
| App-Defaults Files |
581 |
| Defining Preferences |
583 |
| The Preferences User Interface |
585 |
| Managing the Preferences File |
588 |
| Tracing Changes to Preference Variables |
590 |
| Improving the Package |
590 |
43. | A User Interface to Bindings |
593 |
| A Pair of Listboxes Working Together |
595 |
| The Editing Interface |
597 |
| Saving and Loading Bindings |
598 |
VI | C Programming |
601 |
44. | C Programming and Tcl |
603 |
| Basic Concepts |
604 |
| Getting Started |
604 |
| C Command Procedures and Data Objects |
604 |
| SWIG |
605 |
| Tcl Initialization |
605 |
| Calling Out to Tcl Scripts |
606 |
| Using the Tcl C Library |
606 |
| Creating a Loadable Package |
607 |
| The load Command |
607 |
| The Package Initialization Procedure |
608 |
| Using Tcl_PkgProvide |
609 |
| A C Command Procedure |
609 |
| The String Command Interface |
610 |
| Result Codes from Command Procedures |
612 |
| Managing the String Result |
612 |
| The Tcl_Obj Command Interface |
613 |
| Managing Tcl_Obj Reference Counts |
615 |
| Modifying Tcl_Obj Values |
616 |
| Pitfalls of Shared Tcl_Obj Values |
617 |
| The blob Command Example |
618 |
| Creating and Destroying Hash Tables |
618 |
| Tcl_Alloc and Tcl_Free |
620 |
| Parsing Arguments and Tcl_GetIndexFromObj |
620 |
| Creating and Removing Elements from a Hash Table |
623 |
| Building a List |
624 |
| Keeping References to Tcl_Obj Values |
624 |
| Using Tcl_Preserve and Tcl_Release to Guard Data |
625 |
| Strings and Internationalization |
626 |
| The DString Interface |
627 |
| Character Set Conversions |
627 |
| Tcl_Main and Tcl_AppInit |
628 |
| Tk_Main |
630 |
| The Event Loop |
632 |
| Invoking Scripts from C |
633 |
| Variations on Tcl_Eval |
633 |
| Bypassing Tcl_Eval |
634 |
45. | Compiling Tcl and Extensions |
639 |
| Standard Directory Structure |
640 |
| The Source Distribution |
640 |
| The Installation Directory Structure |
641 |
| Building Tcl from Source |
641 |
| Configure and Autoconf |
642 |
| Standard Configure Flags |
643 |
| Installation |
645 |
| Using Stub Libraries |
645 |
| Using autoconf |
646 |
| The tcl.m4 File |
646 |
| Makefile Templates |
647 |
| The Sample Extension |
647 |
| configure.in |
648 |
| Makefile.in |
649 |
| Standard Header Files |
651 |
| Using the Sample Extension |
651 |
46. | Writing a Tk Widget in C |
653 |
| Initializing the Extension |
654 |
| The Widget Data Structure |
654 |
| The Widget Class Command |
655 |
| The Widget Instance Command |
659 |
| Configuring and Reconfiguring Attributes |
662 |
| Specifying Widget Attributes |
666 |
| Displaying the Clock |
671 |
| The Window Event Procedure |
674 |
| Final Cleanup |
675 |
47. | C Library Overview |
677 |
| An Overview of the Tcl C Library |
678 |
| Application Initialization |
678 |
| Creating and Deleting Interpreters |
678 |
| Creating and Deleting Commands |
678 |
| Dynamic Loading and Packages |
678 |
| Managing the Result String |
679 |
| Memory Allocation |
679 |
| Lists |
679 |
| Command Parsing |
679 |
| Command Pipelines |
680 |
| Tracing the Actions of the Tcl Interpreter |
680 |
| Evaluating Tcl Commands |
680 |
| Reporting Script Errors |
681 |
| Manipulating Tcl Variables |
681 |
| Evaluating Expressions |
681 |
| Converting Numbers |
681 |
| Tcl Objects |
681 |
| Primitive Object Types |
682 |
| String Object Types |
682 |
| ByteArrays for Binary Data |
682 |
| Dynamic Strings |
683 |
| Character Set Encodings |
683 |
| AssocData for per Interpreter Data Structures |
683 |
| Hash Tables |
684 |
| Option Processing |
684 |
| Regular Expressions and String Matching |
684 |
| Event Loop Implementation |
684 |
| File Handlers |
685 |
| Timer Events |
685 |
| Idle Callbacks |
685 |
| Input/Output |
685 |
| I/O Channel Drivers |
686 |
| Manipulating File Names |
686 |
| Examining the File System |
686 |
| Thread Support |
686 |
| Working with Signals |
687 |
| Exit Handlers |
687 |
| An Overview of the Tk C Library |
687 |
| Main Programs and Command-Line Arguments |
687 |
| Creating Windows |
687 |
| Application Name for Send |
688 |
| Configuring Windows |
688 |
| Window Coordinates |
688 |
| Window Stacking Order |
688 |
| Window Information |
689 |
| Configuring Widget Attributes |
689 |
| The Selection and Clipboard |
689 |
| Event Loop Interface |
689 |
| Handling Window Events |
689 |
| Event Bindings |
690 |
| Handling Graphic Protocol Errors |
690 |
| Using the Resource Database |
690 |
| Managing Bitmaps |
690 |
| Creating New Image Types |
690 |
| Using an Image in a Widget |
690 |
| Photo Image Types |
691 |
| Canvas Object Support |
691 |
| Geometry Management |
691 |
| String Identifiers (UIDS) |
692 |
| Colors, Colormaps, and Visuals |
692 |
| 3D Borders |
692 |
| Mouse Cursors |
692 |
| Fonts and Text Display |
693 |
| Graphics Contexts |
693 |
| Allocate a Pixmap |
693 |
| Screen Measurements |
693 |
| Relief Style |
693 |
| Text Anchor Positions |
693 |
| Line Cap Styles |
694 |
| Line Join Styles |
694 |
| Text Justification Styles |
694 |
| Atoms |
694 |
| X Resource ID Management |
694 |
VII | Changes |
695 |
48. | Tcl 7.4/Tk 4.0 |
697 |
| wish |
697 |
| Obsolete Features |
697 |
| The cget Operation |
698 |
| Input Focus Highlight |
698 |
| Bindings |
698 |
| Scrollbar Interface |
699 |
| pack info |
699 |
| Focus |
699 |
| The send Command |
700 |
| Internal Button Padding |
700 |
| Radiobutton Value |
700 |
| Entry Widget |
700 |
| Menus |
701 |
| Listboxes |
701 |
| No geometry Attribute |
701 |
| Text Widget |
702 |
| Color Attributes |
702 |
| Color Allocation and tk colormodel |
703 |
| Canvas scrollincrement |
703 |
| The Selection |
703 |
| The bell Command |
703 |
49. | Tcl 7.5/Tk 4.1 |
705 |
| Cross-Platform Scripts |
705 |
| File Name Manipulation |
705 |
| Newline Translations |
705 |
| The tcl_platform Variable |
706 |
| The console Command |
706 |
| The clock Command |
706 |
| The load Command |
706 |
| The package Command |
707 |
| Multiple foreach loop variables |
707 |
| Event Loop Moves from Tk to Tcl |
707 |
| Network Sockets |
707 |
| info hostname |
708 |
| The fconfigure Command |
708 |
| Multiple Interpreters and Safe-Tcl |
708 |
| The grid Geometry Manager |
708 |
| The Text Widget |
708 |
| The Entry Widget |
708 |
50. | Tcl 7.6/Tk 4.2 |
709 |
| More file Operations |
709 |
| Virtual Events |
709 |
| Standard Dialogs |
710 |
| New grid Geometry Manager |
710 |
| Macintosh unsupported1 Command |
710 |
51. | Tcl/Tk 8.0 |
711 |
| The Tcl Compiler |
711 |
| Compile-Time Errors |
712 |
| Binary String Support |
712 |
| Namespaces |
712 |
| Safe-Tcl |
712 |
| New lsort |
713 |
| tcl_precision Variable |
713 |
| Year 2000 Convention |
713 |
| Http Package |
713 |
| Serial Line I/O |
714 |
| Platform-Independent Fonts |
714 |
| The tk scaling Command |
714 |
| Application Embedding |
714 |
| Native Menus and Menubars |
714 |
| CDE Border Width |
715 |
| Native Buttons and Scrollbars |
715 |
| Images in Text Widgets |
715 |
| No Errors from destroy |
715 |
| grid rowconfigure |
715 |
| The Patch Releases |
715 |
| fconfigure -error |
716 |
| tcl_platform(debug) |
716 |
| tcl_findLibrary |
716 |
| auto_mkindex_old |
717 |
| Windows Keysyms for Start and Menu Keys |
717 |
| The MouseWheel Event |
717 |
| Transparent Fill on Canvas Text |
717 |
| safe::loadTk |
717 |
52. | Tcl/Tk 8.1 |
719 |
| Unicode and Internationalization |
719 |
| fconfigure -encoding |
719 |
| The encoding Command |
720 |
| The msgcat Package |
720 |
| UTF-8 and Unicode C API |
720 |
| Thread Safety |
720 |
| The testthread Command |
720 |
| Advanced Regular Expressions |
721 |
| New String Commands |
721 |
| The DDE Extension |
722 |
| Miscellaneous |
722 |
| Serial Line I/O |
722 |
| tcl_platform(user) |
722 |
53. | Tcl/Tk 8.2 |
723 |
| The Trf Patch |
723 |
| Faster String Operations |
723 |
| Empty Array Names |
724 |
| Browser Plugin Compatibility |
724 |
54. | Tcl/Tk 8.3 |
725 |
| Proposed Tcl Changes |
726 |
| Octal Numbers |
726 |
| file channels |
726 |
| Changing File Modify Times |
726 |
| regsub -subst or -command |
726 |
| New glob options |
726 |
| Internationalization |
726 |
| Proposed Tk Changes |
727 |
| The Img Patch |
727 |
| Canvas Improvements |
727 |
| Pointer Warping |
727 |
| Hidden Text |
727 |
| Entry Widget Validation |
727 |
55. | About The CD-ROM |
729 |