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