1 /* File: "guide.cpp", Time-stamp: <2007-04-04 11:33:30 feeley> */
2
3 /* Copyright (c) 1994-2007 by Marc Feeley, All Rights Reserved. */
4
5 /*---------------------------------------------------------------------------*/
6
7 #include "guide.h"
8
9 /*---------------------------------------------------------------------------*/
10
SCMOBJ_to_QString(___SCMOBJ src,QString * dst,int arg_num)11 ___ERR_CODE SCMOBJ_to_QString (___SCMOBJ src, QString* dst, int arg_num)
12 {
13 ___SCMOBJ ___temp; // used by ___STRINGP
14
15 if (!___STRINGP(src))
16 return ___STOC_UCS2STRING_ERR+arg_num;
17
18 unsigned int n = ___INT(___STRINGLENGTH(src));
19 QString r;
20
21 while (n-- > 0)
22 {
23 ___UCS4 c = ___INT(___STRINGREF(src,___FIX(n)));
24 if (c > 0xffff) // UCS-2 is 16 bits
25 return ___STOC_UCS2STRING_ERR+arg_num;
26 r.ref (n) = QChar (c);
27 }
28
29 *dst = r;
30
31 return ___NO_ERR;
32 }
33
QString_to_SCMOBJ(QString src,___SCMOBJ * dst,int arg_num)34 ___ERR_CODE QString_to_SCMOBJ (QString src, ___SCMOBJ* dst, int arg_num)
35 {
36 unsigned int n = src.length ();
37 ___SCMOBJ r = ___alloc_scmobj (___sSTRING, n<<___LCS, ___STILL);
38
39 if (___FIXNUMP(r))
40 {
41 *dst = ___FAL;
42 return ___CTOS_HEAP_OVERFLOW_ERR+arg_num;
43 }
44
45 while (n-- > 0)
46 {
47 ___UCS4 c = src.ref (n).unicode ();
48 if (c > ___MAX_CHR)
49 {
50 ___release_scmobj (r);
51 *dst = ___FAL;
52 return ___CTOS_UCS2STRING_ERR+arg_num;
53 }
54 ___STRINGSET(r,___FIX(n),___CHR(c))
55 }
56
57 *dst = r;
58
59 return ___NO_ERR;
60 }
61
62 /*---------------------------------------------------------------------------*/
63
64 #include <qapplication.h>
65 #include "guideuimainwindow.h"
66
67 #include <stdio.h>
68 #include <strings.h>
69 #include "_guide.h"
70
QApplication_new(char ** argv)71 QApplication *QApplication_new (char **argv)
72 {
73 QApplication *app;
74 int argc = 0;
75 char **my_argv;
76 int i;
77
78 while (argv[argc] != 0)
79 argc++;
80
81 my_argv = (char**)___alloc_mem ((argc+1) * sizeof (char*));
82 for (i=0; i<argc; i++)
83 my_argv[i] = strcpy ((char*)___alloc_mem (strlen (argv[i]) + 1),
84 argv[i]);
85 my_argv[i] = 0;
86
87 qInstallMsgHandler( myMessageOutput );
88 app = new QApplication (argc, my_argv);
89
90 app->connect (app, SIGNAL(lastWindowClosed()), app, SLOT(quit()));
91
92 return app;
93 }
94
myMessageOutput(QtMsgType type,const char * msg)95 void myMessageOutput (QtMsgType type, const char *msg)
96 {
97 switch ( type )
98 {
99 case QtDebugMsg:
100 fprintf( stderr, "Debug: %s\n", msg );
101 break;
102 case QtWarningMsg:
103 // Don't show warning messages
104 //fprintf( stderr, "Warning: %s\n", msg );
105 break;
106 case QtFatalMsg:
107 fprintf( stderr, "Fatal: %s\n", msg );
108 abort(); // deliberately core dump
109 }
110 }
111
QApplication_processEvents(QApplication * app)112 void QApplication_processEvents (QApplication *app)
113 {
114 app->processEvents ();
115 }
116
GuideUiMainWindow_new(void)117 GuideUiMainWindow *GuideUiMainWindow_new (void)
118 {
119 GuideUiMainWindow *w = new GuideUiMainWindow ();
120 w->show();
121 return w;
122 }
123
GuideUiScheme_new(GuideUiMainWindow * main_window,QString title,___SCMOBJ scmobj)124 GuideUiScheme *GuideUiScheme_new (GuideUiMainWindow *main_window, QString title,
125 ___SCMOBJ scmobj)
126 {
127 GuideUiScheme *obj = new GuideUiScheme (main_window, title);
128 obj->scmobj = scmobj;
129 return obj;
130 }
131
GuideUiScheme_print_text(GuideUiScheme * repl,QString text)132 void GuideUiScheme_print_text (GuideUiScheme *repl, QString text)
133 {
134 repl->print_text (text);
135 }
136
GuideUiScheme_continuation_set_highlight(GuideUiScheme * repl,int row)137 void GuideUiScheme_continuation_set_highlight (GuideUiScheme *repl, int row)
138 {
139 repl->continuation_set_highlight (row);
140 }
141
GuideUiScheme_continuation_set_cell(GuideUiScheme * repl,int row,int col,QString text)142 void GuideUiScheme_continuation_set_cell (GuideUiScheme *repl, int row, int col,
143 QString text)
144 {
145 repl->continuation_set_cell (row, col, text);
146 }
147
GuideUiScheme_continuation_set_length(GuideUiScheme * repl,int nb_rows)148 void GuideUiScheme_continuation_set_length (GuideUiScheme *repl, int nb_rows)
149 {
150 repl->continuation_set_length (nb_rows);
151 }
152
GuideUiScheme_environment_set_cell(GuideUiScheme * repl,int row,int col,QString text)153 void GuideUiScheme_environment_set_cell (GuideUiScheme *repl, int row, int col,
154 QString text)
155 {
156 repl->environment_set_cell (row, col, text);
157 }
158
GuideUiScheme_environment_set_length(GuideUiScheme * repl,int nb_rows)159 void GuideUiScheme_environment_set_length (GuideUiScheme *repl, int nb_rows)
160 {
161 repl->environment_set_length (nb_rows);
162 }
163
GuideUiScheme_highlight_expr_in_console(GuideUiScheme * repl,int line,int col)164 void GuideUiScheme_highlight_expr_in_console (GuideUiScheme *repl, int line, int
165 col)
166 {
167 repl->highlight_expr_in_console (line, col);
168 }
169
GuideUiScheme_highlight_expr_in_file(GuideUiScheme * repl,int line,int col,QString filename)170 void GuideUiScheme_highlight_expr_in_file (GuideUiScheme *repl, int line, int col,
171 QString filename)
172 {
173 repl->highlight_expr_in_file (line, col, filename);
174 }
175
guide_inspector_current_changed(___SCMOBJ scmobj,int row)176 void guide_inspector_current_changed (___SCMOBJ scmobj, int row)
177 {
178 // printf ("guide_inspector_current_changed (0x%08x, %d)\n", scmobj, row);
179 // fflush (stdout);
180 }
181
182 /*---------------------------------------------------------------------------*/
183
184 /* Local Variables: */
185 /* mode: C++ */
186 /* End: */
187