Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd.
3
All rights reserved.
4
Copyright (C) 2007-2016, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical Algorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#ifndef _HYPER_H_
37
#define _HYPER_H_ 1
38
39
#include "openaxiom-c-macros.h"
40
#include <stdio.h>
41
#include <stdlib.h>
42
#include <unistd.h>
43
#include <limits.h>
44
45
46
#include "com.h"
47
#include "token.h"
48
#include "hash.h"
49
#include "node.h"
50
#include "pixmap.h"
51
52
extern void sigusr2_handler(int sig);
53
extern void sigcld_handler(int sig);
54
extern void clean_socket();
55
extern void init_page_structs(HDWindow * w);
56
extern void push_item_stack();
57
extern void clear_item_stack();
58
extern void pop_item_stack();
59
extern ItemStack * copy_item_stack();
60
extern void free_item_stack(ItemStack * is);
61
extern ButtonList * alloc_button_list();
62
extern CondNode * alloc_condnode();
63
extern HDWindow * alloc_hd_window();
64
extern IfNode * alloc_ifnode();
65
extern InputBox * alloc_inputbox();
66
extern LineStruct * alloc_inputline(int size);
67
extern TextNode * alloc_node();
68
extern HyperDocPage * alloc_page(const char * name);
69
extern PasteNode * alloc_paste_node(char * name);
70
extern RadioBoxes * alloc_rbs();
71
extern void free_button_list(ButtonList * bl);
72
extern void free_hd_window(HDWindow * w);
73
extern void free_input_item(InputItem * sym , short des);
74
extern void free_input_list(InputItem * il);
75
extern void free_node(TextNode * node , short des);
76
extern void free_page(HyperDocPage * page);
77
extern void free_patch(PatchStore * p);
78
extern void free_string(char * str);
79
extern char * resizeBuffer(int size , char * oldBuf , int * oldSize);
80
extern PatchStore * alloc_patchstore();
81
extern InputItem * return_item(char * name);
82
extern void fill_box(Window w , ImageStruct * image);
83
extern void toggle_input_box(HyperLink * link);
84
extern void toggle_radio_box(HyperLink * link);
85
extern void change_input_focus(HyperLink * link);
86
extern void next_input_focus();
87
extern void prev_input_focus();
88
extern int delete_item(char * name);
89
extern XImage * HTReadBitmapFile(Display * display , int screen , char * filename , int * width , int * height);
90
extern ImageStruct * insert_image_struct(char * filename);
91
extern void compute_form_page(HyperDocPage * page);
92
extern int window_width(int cols);
93
extern void ht2_input(void );
94
extern void make_record(void );
95
extern void verify_record(void );
96
extern char * strCopy(char * s);
97
extern void print_paste_line(FILE * pfile , char * str);
98
extern void get_spad_output(FILE * pfile , char * command , int com_type);
99
extern void get_graph_output(char*, const char*, int);
100
extern void add_buffer_to_sym(char * buffer , InputItem * sym);
101
extern void dialog(XEvent * event , KeySym keysym , char * buffer);
102
extern void draw_inputsymbol(InputItem * sym);
103
extern void update_inputsymbol(InputItem * sym);
104
extern HyperDocPage * issue_server_command(HyperLink * link);
105
extern HyperDocPage * issue_unixlink(TextNode * node);
106
extern char * print_to_string(TextNode * command);
107
extern void issue_spadcommand(HyperDocPage * page , TextNode * command , int immediate , int type);
108
extern OpenAxiom::openaxiom_sio * accept_menu_connection(OpenAxiom::openaxiom_sio * server_sock);
109
extern char * print_to_string1(TextNode * command , int * sizeBuf);
110
extern int issue_serverpaste(TextNode * command);
111
extern void issue_unixcommand(TextNode * node);
112
extern int issue_unixpaste(TextNode * node);
113
extern void service_session_socket();
114
extern void send_lisp_command(char * command);
115
extern void escape_string(char * s);
116
extern void unescape_string(char * s);
117
extern char * print_source_to_string1(TextNode * command , int * sizeBuf);
118
extern char * print_source_to_string(TextNode * command);
119
extern void change_cond(char * label , char * newcond);
120
extern int check_condition(TextNode * node);
121
extern void insert_cond(char * label , char * cond);
122
123
124
#ifndef HTADD
125
extern int MenuServerOpened;
126
127
/* These are all the colors one can use in HyperDoc. */
128
129
extern int gActiveColor,
130
gAxiomColor,
131
gBackgroundColor,
132
gBfColor,
133
gControlBackgroundColor,
134
gControlForegroundColor,
135
gEmColor,
136
gInputBackgroundColor,
137
gInputForegroundColor,
138
gItColor,
139
gRmColor,
140
gSlColor,
141
gTtColor;
142
143
/* These are all the different fonts one can use in HyperDoc. */
144
145
extern XFontStruct *gActiveFont,
146
*gAxiomFont,
147
*gBfFont,
148
*gEmFont,
149
*gInputFont,
150
*gItFont,
151
*gRmFont,
152
*gSlFont,
153
*gTitleFont,
154
*gTtFont;
155
156
157
#endif
158
159
#ifndef HTADD
160
/* From hyper.c */
161
extern int gXScreenNumber;
162
extern Display *gXDisplay;
163
extern int gSwitch_to_mono;
164
extern unsigned long * spadColors;
165
extern int gIsEndOfOutput;
166
extern HDWindow *gWindow;
167
extern OpenAxiom::openaxiom_sio *session_server;
168
extern OpenAxiom::openaxiom_sio *spad_socket;
169
extern HashTable gFileHashTable;
170
extern HashTable gImageHashTable; /* A global hash table for images */
171
extern openaxiom_cursor gNormalCursor; /* The normal mouse cursor. */
172
extern openaxiom_cursor gActiveCursor; /* The cursor in active regions. */
173
extern openaxiom_cursor gBusyCursor; /* The clock cursor for when I am busy */
174
extern int gIsAxiomServer; /* true iff HyperDoc is acting as an Axiom server */
175
extern int gArgc; /* original argc from main */
176
extern char **gArgv; /* original argv from main */
177
/* from input.c */
178
extern openaxiom_image *picked;
179
extern int picked_height;
180
extern int picked_width;
181
extern openaxiom_image *unpicked;
182
extern int unpicked_height;
183
extern int unpicked_width;
184
/* from display.c */
185
extern int line_height;
186
extern int need_scroll_up_button;
187
extern int scrolling;
188
extern int need_scroll_down_button;
189
extern int space_width;
190
#endif
191
192
/* Here are some of the functions and constants declared and needed in
193
htadd.c ******/
194
195
#define NoChar -9999
196
#define db_file_name "ht.db"
197
198
199
/* Types of HyperDoc pages */
200
201
#define UlUnknownPage 9993 /*I hate this hack, but I have to know whether*/
202
#define UnknownPage 9994 /*this page has been loaded or not. */
203
#define ErrorPage 9995
204
#define Unixfd 9996
205
#define SpadGen 9997
206
#define Normal 9998
207
#define UnloadedPageType 9999
208
209
/* Commands from Axiom */
210
211
#define EndOfPage 99
212
#define SendLine 98
213
#define StartPage 97 /* A normal HyperDoc page */
214
#define LinkToPage 96
215
#define PopUpPage 95 /* A pop-up page */
216
#define PopUpNamedPage 94
217
#define KillPage 93
218
#define ReplacePage 92
219
#define ReplaceNamedPage 91
220
#define SpadError 90
221
222
/* Constants declaring size of page stacks */
223
224
#define MaxMemoDepth 25 /* max nesting level for memolinks */
225
#define MaxDownlinkDepth 50 /* max downlink nesting depth */
226
227
/* Constants defining the size of various hash tables */
228
229
#define PageHashSize 1000
230
#define FileHashSize 30
231
#define SessionHashSize 10
232
#define MacroHashSize 100
233
#define ImageHashSize 100
234
#define CondHashSize 100
235
#define BoxHashSize 20
236
#define PasteHashSize 100
237
#define PatchHashSize 100
238
239
/* A couple of macros for memo and down links */
240
241
#define need_up_button \
242
(gWindow->fMemoStackIndex ? gWindow->fDownLinkStackIndex >= \
243
gWindow->fDownLinkStackTop[gWindow->fMemoStackIndex-1] \
244
: gWindow->fDownLinkStackIndex)
245
246
#define need_return_button (gWindow->fMemoStackIndex)
247
248
#define need_help_button (gWindow->page->helppage != NULL)
249
250
#define max(x,y) ((x) > (y) ? (x) : (y))
251
252
253
#define pick_box(box) fill_box(box->win, box->selected)
254
#define unpick_box(box) fill_box(box->win, box->unselected)
255
256
#define TopLevelHelpPage "ugHyperPage"
257
#define NoMoreHelpPage "NoMoreHelpPage"
258
#define KeyDefsHelpPage "ugHyperKeysPage"
259
#define InputAreaHelpPage "ugHyperInputPage"
260
261
/* definitions for connecting to the Axiom server */
262
263
#define Connected 0
264
#define NotConnected 1
265
#define SpadBusy 2
266
267
/* some GUI-dependent stuff */
268
269
#define BeepAtTheUser() /* (XBell(gXDisplay, 5)) */
270
#define LoudBeepAtTheUser() /* (XBell(gXDisplay, 50)) */
271
272
extern int connect_spad();
273
274
275
/*** default fonts ***/
276
#define RmFontDefault "-adobe-courier-medium-r-normal--18-*-*-*-m-*-iso8859-1"
277
#define TtFontDefault "-adobe-courier-medium-r-normal--18-*-*-*-m-*-iso8859-1"
278
#define ActiveFontDefault "-adobe-courier-bold-r-normal--18-*-*-*-m-*-iso8859-1"
279
#define AxiomFontDefault "-adobe-courier-bold-o-normal--18-*-*-*-m-*-iso8859-1"
280
#define EmphasizeFontDefault "-adobe-courier-medium-o-normal--18-*-*-*-m-*-iso8859-1"
281
#define BoldFontDefault "-adobe-courier-bold-r-normal--18-*-*-*-m-*-iso8859-1"
282
283
/* external variables and functions. See the source file for a description
284
of their purposes */
285
286
extern HashTable gSessionHashTable; /* hash table of HD windows */
287
288
extern HDWindow *gParentWindow; /* the parent window. The one that
289
* appears when you first start HD */
290
291
extern HyperLink *quitLink; /** a special link to the protected quit page **/
292
293
extern GroupItem *gTopOfGroupStack;
294
295
extern HyperDocPage *gPageBeingParsed;
296
297
298
// Kludge between the more correct 'array of unsigned char' incoming data,
299
// and the unprincipled 'pointer to char' parameters of several X11
300
// functions below.
301
template<int N>
302
inline const char* as_chars(const unsigned char (&ary)[N]) {
303
return reinterpret_cast<const char*>(&ary[0]);
304
}
305
306
#endif
307
308