4
* This file provides a few commands for supporting scripting.
5
* Basically, we just track any X events and flush them to
13
int Nv_script_state = 0;
14
FILE *Nv_script_file = NULL;
17
* ScriptAddString_Cmd --
19
* syntax: Nv_script_add_string string
20
* Output a string to the current script file if one exists
23
int ScriptAddString_Cmd(ClientData clientData, /* Main window associated with
25
Tcl_Interp * interp, /* Current interpreter. */
26
int argc, /* Number of arguments. */
27
char **argv /* Argument strings. */
31
Tcl_SetResult(interp, "Usage: Nv_script_add_string string",
36
if (Nv_script_file != NULL) {
37
fprintf(Nv_script_file, "%s\n", argv[1]);
44
* CloseScripting_Cmd --
46
* Closes the current scriptfile if one exists.
48
int CloseScripting_Cmd(ClientData clientData, /* Main window associated with
50
Tcl_Interp * interp, /* Current interpreter. */
51
int argc, /* Number of arguments. */
52
char **argv /* Argument strings. */
56
Tcl_SetResult(interp, "Usage: Nv_close_scripting", TCL_VOLATILE);
60
if (Nv_script_file != NULL) {
61
fprintf(Nv_script_file, "puts \"script complete\"\n");
62
fclose(Nv_script_file);
71
* Takes one argument to turn scripting on and off. 1=on 0=off
73
int SetState_Cmd(ClientData clientData, /* Main window associated with
75
Tcl_Interp * interp, /* Current interpreter. */
76
int argc, /* Number of arguments. */
77
char **argv /* Argument strings. */
83
Tcl_SetResult(interp, "Usage: Nv_set_script_state [0 | 1]",
88
if (Nv_script_file == NULL) {
89
Tcl_SetResult(interp, "no script file specified", TCL_VOLATILE);
93
Tcl_GetInt(interp, argv[1], &val);
105
* SetScriptFile_Cmd --
107
* Possibly open a new script file with the given name.
109
int SetScriptFile_Cmd(ClientData clientData, /* Main window associated with
111
Tcl_Interp * interp, /* Current interpreter. */
112
int argc, /* Number of arguments. */
113
char **argv /* Argument strings. */
117
Tcl_SetResult(interp, "Usage: Nv_set_script_file file_name",
122
if (Nv_script_file != NULL) {
123
fclose(Nv_script_file);
126
Nv_script_file = fopen(argv[1], "a");
128
/* Do a little initialization for file looping */
129
fprintf(Nv_script_file, "global Nv_mapLoopMode Nv_mapLoopFile\n");
130
fprintf(Nv_script_file, "set Nv_mapLoopMode 0\n");
131
fprintf(Nv_script_file, "set Nv_mapLoopFile \"\"\n");