Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tkUndo.h @ 69:33d812a61356
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 17:55:14 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 69:33d812a61356 |
---|---|
1 /* | |
2 * tkUndo.h -- | |
3 * | |
4 * Declarations shared among the files that implement an undo stack. | |
5 * | |
6 * Copyright (c) 2002 Ludwig Callewaert. | |
7 * | |
8 * See the file "license.terms" for information on usage and redistribution of | |
9 * this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
10 */ | |
11 | |
12 #ifndef _TKUNDO | |
13 #define _TKUNDO | |
14 | |
15 #ifndef _TKINT | |
16 #include "tkInt.h" | |
17 #endif | |
18 | |
19 /* | |
20 * Enum defining the types used in an undo stack. | |
21 */ | |
22 | |
23 typedef enum { | |
24 TK_UNDO_SEPARATOR, /* Marker */ | |
25 TK_UNDO_ACTION /* Command */ | |
26 } TkUndoAtomType; | |
27 | |
28 /* | |
29 * Callback proc type to carry out an undo or redo action via C code. (Actions | |
30 * can also be defined by Tcl scripts). | |
31 */ | |
32 | |
33 typedef int (TkUndoProc)(Tcl_Interp *interp, ClientData clientData, | |
34 Tcl_Obj *objPtr); | |
35 | |
36 /* | |
37 * Struct defining a single action, one or more of which may be defined (and | |
38 * stored in a linked list) separately for each undo and redo action of an | |
39 * undo atom. | |
40 */ | |
41 | |
42 typedef struct TkUndoSubAtom { | |
43 Tcl_Command command; /* Tcl token used to get the current Tcl | |
44 * command name which will be used to execute | |
45 * apply/revert scripts. If NULL then it is | |
46 * assumed the apply/revert scripts already | |
47 * contain everything. */ | |
48 TkUndoProc *funcPtr; /* Function pointer for callback to perform | |
49 * undo/redo actions. */ | |
50 ClientData clientData; /* Data for 'funcPtr'. */ | |
51 Tcl_Obj *action; /* Command to apply the action that was | |
52 * taken. */ | |
53 struct TkUndoSubAtom *next; /* Pointer to the next element in the linked | |
54 * list. */ | |
55 } TkUndoSubAtom; | |
56 | |
57 /* | |
58 * Struct representing a single undo+redo atom to be placed in the stack. | |
59 */ | |
60 | |
61 typedef struct TkUndoAtom { | |
62 TkUndoAtomType type; /* The type that will trigger the required | |
63 * action. */ | |
64 TkUndoSubAtom *apply; /* Linked list of 'apply' actions to perform | |
65 * for this operation. */ | |
66 TkUndoSubAtom *revert; /* Linked list of 'revert' actions to perform | |
67 * for this operation. */ | |
68 struct TkUndoAtom *next; /* Pointer to the next element in the | |
69 * stack. */ | |
70 } TkUndoAtom; | |
71 | |
72 /* | |
73 * Struct defining a single undo+redo stack. | |
74 */ | |
75 | |
76 typedef struct TkUndoRedoStack { | |
77 TkUndoAtom *undoStack; /* The undo stack. */ | |
78 TkUndoAtom *redoStack; /* The redo stack. */ | |
79 Tcl_Interp *interp; /* The interpreter in which to execute the | |
80 * revert and apply scripts. */ | |
81 int maxdepth; | |
82 int depth; | |
83 } TkUndoRedoStack; | |
84 | |
85 /* | |
86 * Basic functions. | |
87 */ | |
88 | |
89 MODULE_SCOPE void TkUndoPushStack(TkUndoAtom **stack, TkUndoAtom *elem); | |
90 MODULE_SCOPE TkUndoAtom *TkUndoPopStack(TkUndoAtom **stack); | |
91 MODULE_SCOPE int TkUndoInsertSeparator(TkUndoAtom **stack); | |
92 MODULE_SCOPE void TkUndoClearStack(TkUndoAtom **stack); | |
93 | |
94 /* | |
95 * Functions for working on an undo/redo stack. | |
96 */ | |
97 | |
98 MODULE_SCOPE TkUndoRedoStack *TkUndoInitStack(Tcl_Interp *interp, int maxdepth); | |
99 MODULE_SCOPE void TkUndoSetMaxDepth(TkUndoRedoStack *stack, int maxdepth); | |
100 MODULE_SCOPE void TkUndoClearStacks(TkUndoRedoStack *stack); | |
101 MODULE_SCOPE void TkUndoFreeStack(TkUndoRedoStack *stack); | |
102 MODULE_SCOPE int TkUndoCanRedo(TkUndoRedoStack *stack); | |
103 MODULE_SCOPE int TkUndoCanUndo(TkUndoRedoStack *stack); | |
104 MODULE_SCOPE void TkUndoInsertUndoSeparator(TkUndoRedoStack *stack); | |
105 MODULE_SCOPE TkUndoSubAtom *TkUndoMakeCmdSubAtom(Tcl_Command command, | |
106 Tcl_Obj *actionScript, TkUndoSubAtom *subAtomList); | |
107 MODULE_SCOPE TkUndoSubAtom *TkUndoMakeSubAtom(TkUndoProc *funcPtr, | |
108 ClientData clientData, Tcl_Obj *actionScript, | |
109 TkUndoSubAtom *subAtomList); | |
110 MODULE_SCOPE void TkUndoPushAction(TkUndoRedoStack *stack, | |
111 TkUndoSubAtom *apply, TkUndoSubAtom *revert); | |
112 MODULE_SCOPE int TkUndoRevert(TkUndoRedoStack *stack); | |
113 MODULE_SCOPE int TkUndoApply(TkUndoRedoStack *stack); | |
114 | |
115 #endif /* _TKUNDO */ |