35
36:- module(link_xpce, []). 37:- set_prolog_flag(generate_debug_info, true).
50:- op(200, fy, user:(@)). 51:- op(250, yfx, user:(?)). 52:- op(990, xfx, user:(:=)). 53
54:- multifile
55 user:file_search_path/2. 56
57:- dynamic
58 pcehomestore_/1. 59:- volatile
60 pcehomestore_/1. 61
62pcehome_(Home) :-
63 pcehomestore_(Home), !.
64pcehome_(Home) :-
65 ( getenv('XPCEHOME', RawHome)
66 ; current_prolog_flag(home, PlHome),
67 ( current_prolog_flag(xpce_version, Version),
68 atom_concat('/xpce-', Version, Suffix)
69 ; Suffix = '/xpce'
70 ),
71 atom_concat(PlHome, Suffix, RawHome)
72 ),
73 exists_directory(RawHome), !,
74 absolute_file_name(RawHome, Home),
75 asserta(pcehomestore_(Home)).
76
77user:file_search_path(pce, PceHome) :-
78 pcehome_(PceHome).
79user:file_search_path(library, pce('prolog/lib')).
80user:file_search_path(foreign, pce(ArchLib)) :-
81 current_prolog_flag(arch, Arch),
82 atom_concat('lib/', Arch, ArchLib).
83
86:- reload_library_index. 87
88gui_setup_ :-
89 current_prolog_flag(gui, true), !.
90gui_setup_ :-
91 ( getenv('DISPLAY', D), D \== ''
92 ; current_prolog_flag(windows, true)
93 ), !,
94 create_prolog_flag(gui, true, []),
95 menu_setup_,
96 editor_setup,
97 load_files(user:library(swi_hooks), [silent(true)]). 98
:- 100 current_prolog_flag(console_menu, true),
101 load_files(user:library(win_menu), [silent(true)]).
102menu_setup_.
103
104editor_setup :-
105 current_prolog_flag(editor, default), !,
106 set_prolog_flag(editor, pce_emacs).
107editor_setup.
108
109pce_setup_ :-
110 current_prolog_flag(xpce, true), !.
111pce_setup_ :-
112 current_prolog_flag(argv, Argv),
113 \+ memberchk('--nopce', Argv), 114 pcehome_(PceHome),
115 exists_directory(PceHome),
116 gui_setup_,
117 ( memberchk('--pce', Argv)
118 ; current_prolog_flag(executable, Executable),
119 file_base_name(Executable, Base),
120 sub_atom_icasechk(Base, _, pce)
121 ), !,
122 load_files(user:library(pce), [silent(true)]).
123pce_setup_.
124
125:- initialization pce_setup_.
Associate XPCE with SWI-Prolog
This file initialises XPCE, the SWI-Prolog native GUI. XPCE is initialised only if it is detected.
The source-location of this file is packages/xpce/swipl/swipl-rc. It is installed as <plbase>/<exe-base>.rc, where <exe-base> is
swipl-win
to associate with the SWI-Prolog gui application on Windows andswipl
on Unix/X11 platforms. */