35
36:- module(link_xpce, []). 37:- if(\+current_prolog_flag(xpce,false)). 38:- set_prolog_flag(generate_debug_info, true). 39
50
51:- multifile
52 user:file_search_path/2. 53
54:- dynamic
55 pcehomestore_/1. 56:- volatile
57 pcehomestore_/1. 58
59pcehome_(Home) :-
60 pcehomestore_(Home), !.
61pcehome_(Home) :-
62 ( getenv('XPCEHOME', RawHome)
63 ; current_prolog_flag(home, PlHome),
64 ( current_prolog_flag(xpce_version, Version),
65 atom_concat('/xpce-', Version, Suffix)
66 ; Suffix = '/xpce'
67 ),
68 atom_concat(PlHome, Suffix, RawHome)
69 ),
70 exists_directory(RawHome), !,
71 absolute_file_name(RawHome, Home),
72 asserta(pcehomestore_(Home)).
73
74user:file_search_path(pce, PceHome) :-
75 current_prolog_flag(xpce, true),
76 pcehome_(PceHome).
77user:file_search_path(library, pce('prolog/lib')).
78user:file_search_path(foreign, pce(ArchLib)) :-
79 current_prolog_flag(arch, Arch),
80 atom_concat('lib/', Arch, ArchLib).
81
84:- reload_library_index. 85
86gui_setup_ :-
87 current_prolog_flag(gui, true), !.
88gui_setup_ :-
89 ( getenv('DISPLAY', D), D \== ''
90 ; current_prolog_flag(windows, true)
91 ), !,
92 create_prolog_flag(gui, true, []),
93 menu_setup_,
94 editor_setup,
95 load_files(user:library(swi_hooks), [silent(true)]). 96
:- 98 current_prolog_flag(console_menu, true),
99 load_files(user:library(win_menu), [silent(true)]).
100menu_setup_.
101
102editor_setup :-
103 current_prolog_flag(editor, default), !,
104 set_prolog_flag(editor, pce_emacs).
105editor_setup.
106
107:- dynamic
108 pce_setup_done/0. 109
110pce_setup_ :-
111 pce_setup_done, !.
112pce_setup_ :-
113 current_prolog_flag(xpce, false), !.
114pce_setup_ :-
115 pcehome_(PceHome),
116 exists_directory(PceHome),
117 ( current_prolog_flag(xpce, true)
118 -> Preload = true
119 ; Preload = false
120 ),
121 set_prolog_flag(xpce, true),
122 gui_setup_,
123 !,
124 asserta(pce_setup_done),
125 ( ( Preload == true
126 ; current_prolog_flag(executable, Executable),
127 file_base_name(Executable, Base),
128 sub_atom_icasechk(Base, _, pce)
129 )
130 -> ensure_loaded(user:library(pce))
131 ; true
132 ).
133pce_setup_ :-
134 asserta(pce_setup_done).
135
136:- initialization pce_setup_. 137:- endif.