1 /* 2 * txcommands.h -- 3 * 4 * Declarations for textio command routines. 5 * 6 * ********************************************************************* 7 * * Copyright (C) 1985, 1990 Regents of the University of California. * 8 * * Permission to use, copy, modify, and distribute this * 9 * * software and its documentation for any purpose and without * 10 * * fee is hereby granted, provided that the above copyright * 11 * * notice appear in all copies. The University of California * 12 * * makes no representations about the suitability of this * 13 * * software for any purpose. It is provided "as is" without * 14 * * express or implied warranty. Export of this software outside * 15 * * of the United States of America may require an export license. * 16 * ********************************************************************* 17 * 18 * rcsid $Header: /usr/cvsroot/magic-8.0/textio/txcommands.h,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $ 19 */ 20 21 #ifndef _TXCOMMANDS_H 22 #define _TXCOMMANDS_H 23 24 #include "utils/magic.h" 25 #include "utils/geometry.h" 26 27 /* Structure of one Magic command. All commands are in the same format. 28 * Commands are tagged with the point and window at which the command was 29 * invoked. 30 */ 31 32 /* The definitions below should be made variable. Especially with the 33 * Tcl/Tk version of magic, it is possible to auto-generate very long 34 * commands such as, for example, "polygon" 35 */ 36 37 #define TX_MAXARGS 200 38 #define TX_MAX_CMDLEN 2048 39 40 typedef struct { /* A command -- either a button push or 41 * a textual command. 42 */ 43 Point tx_p; /* The location of the pointing device 44 * when this command was invoked. 45 */ 46 int tx_button; /* The event type (button number). 47 * See below. 48 */ 49 int tx_buttonAction; /* The action of the button (if any), such as 50 * TX_BUTTON_UP, DOWN 51 */ 52 int tx_argc; /* The number of textual command words, 53 * including the command itself. 0 means 54 * no textual command. 55 */ 56 char *tx_argv[TX_MAXARGS]; /* An array of pointers to the words (if any) 57 * that make up the command. 58 */ 59 int tx_wid; /* The ID of the window that this command 60 * is destined for. The point 'tx_p' is 61 * in this window's coordinate system. 62 * (See windows.h for window IDs.) 63 */ 64 char tx_argstring[TX_MAX_CMDLEN]; 65 /* The storage used for the command line. 66 * Tx_argv[] points into this. 67 */ 68 } TxCommand; 69 70 /* Structure of one low-level input event. This can be either a button event 71 * (such as a button down or a button up) or a keyboard event (such as a 72 * character typed. 73 */ 74 75 typedef struct { 76 Point txe_p; /* The point at which this action took place.*/ 77 int txe_wid; /* The window that the event occured in (see 78 * windows.h for details, may be defaulted to 79 * WIND_UNKNOWN_WINDOW by some low-level 80 * device drivers). 81 */ 82 int txe_button; /* The event type. */ 83 int txe_buttonAction; /* The button action, if a button. */ 84 int txe_ch; /* The character typed, if a character. */ 85 } TxInputEvent; 86 87 /* Event types (button numbers) in the above structures, carefully chosen so 88 * there is 1 bit per event (as they are used elsewhere in masks). 89 */ 90 #define TX_CHARACTER 0x00 91 #define TX_NO_BUTTON 0x00 /* for backward compat. only */ 92 #define TX_LEFT_BUTTON 0x01 93 #define TX_MIDDLE_BUTTON 0x02 94 #define TX_RIGHT_BUTTON 0x04 95 #define TX_EXPOSE 0x08 /* graphics commands for separate */ 96 #define TX_CONFIGURE 0x10 /* graphics event loops. */ 97 #define TX_CREATE 0x20 98 #define TX_BYPASS 0x40 /* Input line is ready, but needs 99 * and event to trigger the callback 100 */ 101 #define TX_EOF 0x80 /* Never leaves this module, it is 102 * filtered out. 103 */ 104 #define TX_BUTTON_4 0x100 /* For scroll wheels and such */ 105 #define TX_BUTTON_5 0x200 /* For scroll wheels and such */ 106 107 #ifdef MAGIC_WRAPPER 108 extern TxCommand TxCurCommand; 109 #endif 110 111 /* Button actions for the above structures. 112 */ 113 #define TX_BUTTON_DOWN 0 114 #define TX_BUTTON_UP 1 115 #define TX_KEY_DOWN 2 116 117 /* procedures to help in making device command routines */ 118 119 extern TxCommand *TxDeviceStdin(); 120 extern TxCommand *TxButtonMaskToCommand(); 121 extern void TxAddInputDevice(); /* Can read multiple file desc. */ 122 extern void TxAdd1InputDevice(); /* Can read only 1 file desc. */ 123 extern void TxDeleteInputDevice(); 124 extern void TxDelete1InputDevice(); 125 126 /* Routines to manipulate the current point. Only really used for command 127 * scripts. 128 */ 129 extern void TxSetPoint(); 130 extern int TxGetPoint(); 131 extern void TxClearPoint(); 132 133 /* Routine to set up command logging. 134 */ 135 extern void TxLogCommands(); 136 137 138 /* Routines for handling input events. A typical device driver in the 139 * graphics module will get one or more free events via TxNewEvent() and 140 * then put them in the input queue via TxAddEvent(). 141 */ 142 143 extern TxInputEvent *TxNewEvent(); 144 extern void TxAddEvent(); 145 extern void TxPrintEvent(); 146 extern void TxFreeEvent(); 147 extern void TxReleaseButton(); 148 149 /* Routines for dealing with commands. Usually only used within this 150 * module, although they may be used elsewhere. 151 */ 152 extern void TxPrintCommand(); 153 extern TxCommand *TxNewCommand(); 154 extern void TxFreeCommand(); 155 extern void TxParseString(); 156 extern void TxDispatch(); 157 extern int TxCommandNumber; /* Serial number of current command. */ 158 159 #ifdef MAGIC_WRAPPER 160 extern int TxTclDispatch(); 161 #endif 162 163 #endif /* _TXCOMMANDS_H */ 164