jpayne@69: /* jpayne@69: * tkSelect.h -- jpayne@69: * jpayne@69: * Declarations of types shared among the files that implement selection jpayne@69: * support. jpayne@69: * jpayne@69: * Copyright (c) 1995 Sun Microsystems, Inc. jpayne@69: * jpayne@69: * See the file "license.terms" for information on usage and redistribution of jpayne@69: * this file, and for a DISCLAIMER OF ALL WARRANTIES. jpayne@69: */ jpayne@69: jpayne@69: #ifndef _TKSELECT jpayne@69: #define _TKSELECT jpayne@69: jpayne@69: /* jpayne@69: * When a selection is owned by a window on a given display, one of the jpayne@69: * following structures is present on a list of current selections in the jpayne@69: * display structure. The structure is used to record the current owner of a jpayne@69: * selection for use in later retrieval requests. There is a list of such jpayne@69: * structures because a display can have multiple different selections active jpayne@69: * at the same time. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkSelectionInfo { jpayne@69: Atom selection; /* Selection name, e.g. XA_PRIMARY. */ jpayne@69: Tk_Window owner; /* Current owner of this selection. */ jpayne@69: int serial; /* Serial number of last XSelectionSetOwner jpayne@69: * request made to server for this selection jpayne@69: * (used to filter out redundant jpayne@69: * SelectionClear events). */ jpayne@69: Time time; /* Timestamp used to acquire selection. */ jpayne@69: Tk_LostSelProc *clearProc; /* Procedure to call when owner loses jpayne@69: * selection. */ jpayne@69: ClientData clearData; /* Info to pass to clearProc. */ jpayne@69: struct TkSelectionInfo *nextPtr; jpayne@69: /* Next in list of current selections on this jpayne@69: * display. NULL means end of list. */ jpayne@69: } TkSelectionInfo; jpayne@69: jpayne@69: /* jpayne@69: * One of the following structures exists for each selection handler created jpayne@69: * for a window by calling Tk_CreateSelHandler. The handlers are linked in a jpayne@69: * list rooted in the TkWindow structure. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkSelHandler { jpayne@69: Atom selection; /* Selection name, e.g. XA_PRIMARY. */ jpayne@69: Atom target; /* Target type for selection conversion, such jpayne@69: * as TARGETS or STRING. */ jpayne@69: Atom format; /* Format in which selection info will be jpayne@69: * returned, such as STRING or ATOM. */ jpayne@69: Tk_SelectionProc *proc; /* Procedure to generate selection in this jpayne@69: * format. */ jpayne@69: ClientData clientData; /* Argument to pass to proc. */ jpayne@69: int size; /* Size of units returned by proc (8 for jpayne@69: * STRING, 32 for almost anything else). */ jpayne@69: struct TkSelHandler *nextPtr; jpayne@69: /* Next selection handler associated with same jpayne@69: * window (NULL for end of list). */ jpayne@69: } TkSelHandler; jpayne@69: jpayne@69: /* jpayne@69: * When the selection is being retrieved, one of the following structures is jpayne@69: * present on a list of pending selection retrievals. The structure is used to jpayne@69: * communicate between the background procedure that requests the selection jpayne@69: * and the foreground event handler that processes the events in which the jpayne@69: * selection is returned. There is a list of such structures so that there can jpayne@69: * be multiple simultaneous selection retrievals (e.g. on different displays). jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkSelRetrievalInfo { jpayne@69: Tcl_Interp *interp; /* Interpreter for error reporting. */ jpayne@69: TkWindow *winPtr; /* Window used as requestor for selection. */ jpayne@69: Atom selection; /* Selection being requested. */ jpayne@69: Atom property; /* Property where selection will appear. */ jpayne@69: Atom target; /* Desired form for selection. */ jpayne@69: Tk_GetSelProc *proc; /* Procedure to call to handle pieces of jpayne@69: * selection. */ jpayne@69: ClientData clientData; /* Argument for proc. */ jpayne@69: int result; /* Initially -1. Set to a Tcl return value jpayne@69: * once the selection has been retrieved. */ jpayne@69: Tcl_TimerToken timeout; /* Token for current timeout procedure. */ jpayne@69: int idleTime; /* Number of seconds that have gone by without jpayne@69: * hearing anything from the selection jpayne@69: * owner. */ jpayne@69: Tcl_EncodingState encState; /* Holds intermediate state during translations jpayne@69: * of data that cross buffer boundaries. */ jpayne@69: int encFlags; /* Encoding translation state flags. */ jpayne@69: Tcl_DString buf; /* Buffer to hold translation data. */ jpayne@69: struct TkSelRetrievalInfo *nextPtr; jpayne@69: /* Next in list of all pending selection jpayne@69: * retrievals. NULL means end of list. */ jpayne@69: } TkSelRetrievalInfo; jpayne@69: jpayne@69: /* jpayne@69: * The clipboard contains a list of buffers of various types and formats. All jpayne@69: * of the buffers of a given type will be returned in sequence when the jpayne@69: * CLIPBOARD selection is retrieved. All buffers of a given type on the same jpayne@69: * clipboard must have the same format. The TkClipboardTarget structure is jpayne@69: * used to record the information about a chain of buffers of the same type. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkClipboardBuffer { jpayne@69: char *buffer; /* Null terminated data buffer. */ jpayne@69: long length; /* Length of string in buffer. */ jpayne@69: struct TkClipboardBuffer *nextPtr; jpayne@69: /* Next in list of buffers. NULL means end of jpayne@69: * list . */ jpayne@69: } TkClipboardBuffer; jpayne@69: jpayne@69: typedef struct TkClipboardTarget { jpayne@69: Atom type; /* Type conversion supported. */ jpayne@69: Atom format; /* Representation used for data. */ jpayne@69: TkClipboardBuffer *firstBufferPtr; jpayne@69: /* First in list of data buffers. */ jpayne@69: TkClipboardBuffer *lastBufferPtr; jpayne@69: /* Last in list of clipboard buffers. Used to jpayne@69: * speed up appends. */ jpayne@69: struct TkClipboardTarget *nextPtr; jpayne@69: /* Next in list of targets on clipboard. NULL jpayne@69: * means end of list. */ jpayne@69: } TkClipboardTarget; jpayne@69: jpayne@69: /* jpayne@69: * It is possible for a Tk_SelectionProc to delete the handler that it jpayne@69: * represents. If this happens, the code that is retrieving the selection jpayne@69: * needs to know about it so it doesn't use the now-defunct handler structure. jpayne@69: * One structure of the following form is created for each retrieval in jpayne@69: * progress, so that the retriever can find out if its handler is deleted. All jpayne@69: * of the pending retrievals (if there are more than one) are linked into a jpayne@69: * list. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkSelInProgress { jpayne@69: TkSelHandler *selPtr; /* Handler being executed. If this handler is jpayne@69: * deleted, the field is set to NULL. */ jpayne@69: struct TkSelInProgress *nextPtr; jpayne@69: /* Next higher nested search. */ jpayne@69: } TkSelInProgress; jpayne@69: jpayne@69: /* jpayne@69: * Chunk size for retrieving selection. It's defined both in words and in jpayne@69: * bytes; the word size is used to allocate buffer space that's guaranteed to jpayne@69: * be word-aligned and that has an extra character for the terminating NULL. jpayne@69: */ jpayne@69: jpayne@69: #define TK_SEL_BYTES_AT_ONCE 4000 jpayne@69: #define TK_SEL_WORDS_AT_ONCE 1001 jpayne@69: jpayne@69: /* jpayne@69: * Declarations for procedures that are used by the selection-related files jpayne@69: * but shouldn't be used anywhere else in Tk (or by Tk clients): jpayne@69: */ jpayne@69: jpayne@69: MODULE_SCOPE TkSelInProgress *TkSelGetInProgress(void); jpayne@69: MODULE_SCOPE void TkSelSetInProgress(TkSelInProgress *pendingPtr); jpayne@69: MODULE_SCOPE void TkSelClearSelection(Tk_Window tkwin, XEvent *eventPtr); jpayne@69: MODULE_SCOPE int TkSelDefaultSelection(TkSelectionInfo *infoPtr, jpayne@69: Atom target, char *buffer, int maxBytes, jpayne@69: Atom *typePtr); jpayne@69: #ifndef TkSelUpdateClipboard jpayne@69: MODULE_SCOPE void TkSelUpdateClipboard(TkWindow *winPtr, jpayne@69: TkClipboardTarget *targetPtr); jpayne@69: #endif jpayne@69: jpayne@69: #endif /* _TKSELECT */