36
37:- module(swi_ide,
38 [ prolog_ide/0, 39 prolog_ide/1 40 ]). 41:- use_module(library(pce)). 42:- require([ pce_image_directory/1,
43 file_directory_name/2
44 ]).
53 56
57:- pce_image_directory(library('trace/icons')). 58
59:- pce_autoload(swi_console, library('swi/swi_console')). 60:- pce_autoload(prolog_debug_status, library('trace/status')). 61:- pce_autoload(prolog_navigator, library('trace/browse')). 62:- pce_autoload(prolog_query_frame, library('trace/query')). 63:- pce_autoload(prolog_trace_exception, library('trace/exceptions')). 64:- pce_autoload(prolog_thread_monitor, library('swi/thread_monitor')). 65:- pce_autoload(prolog_debug_monitor, library('swi/pce_debug_monitor')). 66:- pce_autoload(xref_frame, library('pce_xref')). 67
68
79prolog_ide :-
80 prolog_ide(open_console).
81
82prolog_ide(Action) :-
83 in_pce_thread(send(@prolog_ide, Action)).
84
85
86 89
90:- pce_global(@prolog_ide, new(prolog_ide)).
91:- pce_global(@prolog_exception_window, new(prolog_trace_exception)).
92
93:- pce_begin_class(prolog_ide, application, ).
94
95initialise(IDE) :->
96 ::
97 send_super(IDE, initialise, prolog_ide),
98 send(IDE, kind, service).
99
100open_console(IDE) :->
101 ::
102 ( get(IDE, member, swi_console, Console)
103 -> send(Console, open)
104 ; new(Console, swi_console),
105 send(Console, application, IDE),
106 send(Console, wait)
107 ).
108
109open_debug_status(IDE) :->
110 ::
111 ( get(IDE, member, prolog_debug_status, W)
112 -> send(W, expose)
113 ; send(prolog_debug_status(IDE), open)
114 ).
115
116open_exceptions(IDE, Gui:[bool]) :->
117 ::
118 W = @prolog_exception_window,
119 ( object(W)
120 -> send(W, expose)
121 ; ( Gui == @on
122 -> catch(tdebug, _, guitracer)
123 ; true
124 ),
125 send(W, application, IDE),
126 send(W, open)
127 ).
128
129open_navigator(IDE, Where:[directory|source_location]) :->
130 ::
131 ( send(Where, instance_of, directory)
132 -> get(IDE, navigator, Where, Navigator),
133 send(Navigator, directory, Where)
134 ; send(Where, instance_of, source_location)
135 -> get(Where, file_name, File),
136 file_directory_name(File, Dir),
137 get(Where, line_no, Line),
138 ( integer(Line)
139 -> LineNo = Line
140 ; LineNo = 1
141 ),
142 get(IDE, navigator, Dir, Navigator),
143 send(Navigator, goto, File, LineNo)
144 ; get(IDE, navigator, directory('.'), Navigator)
145 ),
146 send(Navigator, expose).
147
148
149navigator(IDE, Dir:[directory], Navigator:prolog_navigator) :<-
150 ::
151 ( get(IDE, member, prolog_navigator, Navigator)
152 -> true
153 ; new(Navigator, prolog_navigator(Dir)),
154 send(Navigator, application, IDE)
155 ).
156
157open_query_window(IDE) :->
158 ::
159 ( get(IDE, member, prolog_query_frame, QF)
160 -> true
161 ; new(QF, prolog_query_frame),
162 send(QF, application, IDE)
163 ),
164 send(QF, expose).
165
166open_interactor(_) :->
167 ::
168 auto_call(interactor).
169
170thread_monitor(IDE) :->
171 ::
172 ( current_prolog_flag(threads, true)
173 -> ( get(IDE, member, prolog_thread_monitor, Monitor)
174 -> true
175 ; new(Monitor, prolog_thread_monitor),
176 send(Monitor, application, IDE)
177 ),
178 send(Monitor, open)
179 ; send(@display, report, error,
180 'This version of SWI-Prolog is not built \n\c
181 with thread-support')
182 ).
183
184debug_monitor(IDE) :->
185 ::
186 ( get(IDE, member, prolog_debug_monitor, Monitor)
187 -> true
188 ; new(Monitor, prolog_debug_monitor),
189 send(Monitor, application, IDE)
190 ),
191 send(Monitor, open).
192
193xref(IDE) :->
194 ::
195 ( get(IDE, member, xref_frame, XREF)
196 -> send(XREF, open)
197 ; new(XREF, xref_frame),
198 send(XREF, application, IDE),
199 send(XREF, wait),
200 send(XREF, update)
201 ).
202
203:- pce_end_class(prolog_ide)
SWI-Prolog IDE controller
This module defines the application @prolog_ide and the predicate
prolog_ide(+Action)
. The major motivation is be able to delay loading the IDE components to the autoloading of one single predicate. */