View source with raw comments or as raw
   1/*  Part of XPCE --- The SWI-Prolog GUI toolkit
   2
   3    Author:        Jan Wielemaker and Anjo Anjewierden
   4    E-mail:        jan@swi.psy.uva.nl
   5    WWW:           http://www.swi.psy.uva.nl/projects/xpce/
   6    Copyright (c)  2001-2014, University of Amsterdam
   7    All rights reserved.
   8
   9    Redistribution and use in source and binary forms, with or without
  10    modification, are permitted provided that the following conditions
  11    are met:
  12
  13    1. Redistributions of source code must retain the above copyright
  14       notice, this list of conditions and the following disclaimer.
  15
  16    2. Redistributions in binary form must reproduce the above copyright
  17       notice, this list of conditions and the following disclaimer in
  18       the documentation and/or other materials provided with the
  19       distribution.
  20
  21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32    POSSIBILITY OF SUCH DAMAGE.
  33*/
  34
  35:- module(pce_swi_hooks, []).
  36
  37/** <module> Hook XPCE based graphics tools into IDE
  38
  39Loading this file enables the graphical  frontends for the online manual
  40and profiler. This file is normally   loaded from swipl.rc (swipl-win.rc
  41on Windows); the file that makes XPCE known to Prolog.
  42
  43This file uses call/1 to call the real work to avoid undefined predicate
  44messages when using make/0 (calling list_undefined/0).
  45
  46Since  the  introduction   of   the    more   advanced   autoloader   in
  47library(prolog_autoload), using call/1 no longer   suffices to stop this
  48file from being loaded.
  49*/
  50
  51:- set_module(class(development)).
  52
  53:- multifile
  54    prolog:debug_control_hook/1,
  55    prolog:help_hook/1,
  56    prolog:show_profile_hook/1,             % new
  57    prolog:show_profile_hook/2.             % compatibility
  58
  59
  60                 /*******************************
  61                 *          DEBUG HOOKS         *
  62                 *******************************/
  63
  64prolog:debug_control_hook(spy(Method)) :-
  65    call(spypce(Method)).
  66prolog:debug_control_hook(nospy(Method)) :-
  67    call(nospypce(Method)).
  68
  69
  70                 /*******************************
  71                 *           HELP HOOK          *
  72                 *******************************/
  73
  74prolog:help_hook(help) :-
  75    !,
  76    call(prolog_help).
  77prolog:help_hook(apropos(What)) :-
  78    !,
  79    call(prolog_apropos(What)).
  80prolog:help_hook(help(What)) :-
  81    !,
  82    call((   in_pce_thread_sync(pce_to_method(What, Method))
  83         ->  manpce(Method)
  84         ;   current_prolog_flag(pldoc_collecting, _),
  85             doc_browser(What)
  86         ->  true
  87         ;   prolog_help(What)
  88         )).
  89
  90
  91                 /*******************************
  92                 *           PROFILING          *
  93                 *******************************/
  94
  95prolog:show_profile_hook(_Options) :-
  96    call(pce_show_profile).
  97prolog:show_profile_hook(_Style, _Top) :-
  98    call(pce_show_profile).
  99
 100
 101                 /*******************************
 102                 *             SOURCE           *
 103                 *******************************/
 104
 105%!  prolog:alternate_syntax(?Syntax, +Module, -Setup, -Restore)
 106%
 107%   Implements operator handling for reading   arbitrary  terms from
 108%   XPCE classes.
 109
 110:- multifile
 111    prolog:alternate_syntax/4.
 112
 113prolog:alternate_syntax(pce_class, M, pce_expansion:push_compile_operators(M),
 114                                      pce_expansion:pop_compile_operators) :-
 115    current_prolog_flag(xpce, true).