13
14
15:- module(pdt_editor_breakpoints,[
16 pdt_set_breakpoint/4, 17 pdt_breakpoint_properties/5,
18 pdt_breakpoint_property/2
19]). 20
21:- if(current_prolog_flag(dialect, swi)). 22
23:- use_module(library(prolog_breakpoints)). 24:- use_module(library(debug)). 25
26pdt_set_breakpoint(File, Line, Offset, Id) :-
27 debug(pdt_breakpoints, 'before existing breakpoint', []),
28 not(existing_breakpoint(File, Offset)),
29 debug(pdt_breakpoints, 'after existing breakpoint', []),
30 debug(pdt_breakpoints, 'before set_breakpoint', []),
31 thread_signal(main,catch(set_breakpoint(File, Line, Offset, Id),_,fail)),
32 debug(pdt_breakpoints, 'after set_breakpoint', []).
33
34existing_breakpoint(File, Offset) :-
35 breakpoint_property(ExistingId, file(File)),
36 breakpoint_property(ExistingId, character_range(StartPos, Length)),
37 EndPos is StartPos + Length,
38 Offset >= StartPos,
39 Offset < EndPos.
40
41pdt_breakpoint_properties(Id, File, Line, Offset, Length) :-
42 breakpoint_property(Id, file(File)),
43 breakpoint_property(Id, line_count(Line)),
44 breakpoint_property(Id, character_range(Offset, Length)).
45
46pdt_breakpoint_property(Id, Property) :-
47 breakpoint_property(Id, Property).
48
49:- multifile(user:message_hook/3). 50:- dynamic(user:message_hook/3). 51
52user:message_hook(breakpoint(set, Id), _Kind, _Lines) :-
53 catch(process_observe:process_notify(add_breakpoint,Id),_,true), fail.
54
55user:message_hook(breakpoint(delete, Id), _Kind, _Lines) :-
56 catch(process_observe:process_notify(remove_breakpoint,Id),_,true), fail.
57
58:- else. 59
60pdt_set_breakpoint(_,_,_,_) :- fail.
61pdt_breakpoint_properties(_,_,_,_) :- fail.
62pdt_breakpoint_property(_,_) :- fail.
63
64:- endif.