Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
nerrons
purr-data
Commits
7dbbbd11
Commit
7dbbbd11
authored
Mar 21, 2018
by
Albert Gräf
Browse files
Help browser: Add support for -helppath.
parent
39a8f288
Changes
2
Hide whitespace changes
Inline
Side-by-side
pd/nw/pdgui.js
View file @
7dbbbd11
...
...
@@ -2,6 +2,7 @@
var
pwd
;
var
lib_dir
;
var
help_path
;
var
pd_engine_id
;
exports
.
set_pwd
=
function
(
pwd_string
)
{
...
...
@@ -26,13 +27,18 @@ exports.set_pd_engine_id = function (id) {
exports
.
defunkify_windows_path
=
defunkify_windows_path
;
function
gui_set_lib_dir
(
dir
)
{
lib_dir
=
dir
;
function
gui_set_help_path
(
helppath
)
{
// post("gui_set_help_path: " + helppath.join(":"));
help_path
=
helppath
;
// AG: Start building the keyword index for dialog_search.html. We do this
// here so that we can be sure that lib_dir
is
known already.
// here so that we can be sure that lib_dir
and help_path are
known already.
make_index
();
}
function
gui_set_lib_dir
(
dir
)
{
lib_dir
=
dir
;
}
exports
.
get_lib_dir
=
function
()
{
return
lib_dir
;
}
...
...
@@ -124,7 +130,8 @@ function read_file(err, filename, stat) {
}
}
}
else
{
post
(
"
err:
"
+
err
);
// AG: Simply ignore missing/unreadable files and directories.
// post("err: " + err);
}
}
...
...
@@ -135,13 +142,41 @@ function finish_index() {
post
(
"
finished building help index
"
);
}
// AG: pilfered from https://stackoverflow.com/questions/21077670
function
expand_tilde
(
filepath
)
{
if
(
filepath
[
0
]
===
'
~
'
)
{
return
path
.
join
(
process
.
env
.
HOME
,
filepath
.
slice
(
1
));
}
return
filepath
;
}
// AG: This is supposed to be executed only once, after lib_dir has been set.
// Note that dive() traverses lib_dir asynchronously, so we report back in
// finish_index() when this is done.
function
make_index
()
{
var
doc_path
=
lib_dir
;
var
i
=
0
;
var
l
=
help_path
.
length
;
function
make_index_cont
()
{
if
(
i
<
l
)
{
var
doc_path
=
help_path
[
i
++
];
// AG: These paths might not exist, ignore them in this case. Also
// note that we need to expand ~ here.
var
full_path
=
expand_tilde
(
doc_path
);
fs
.
lstat
(
full_path
,
function
(
err
,
stat
)
{
if
(
!
err
)
{
post
(
"
building help index in
"
+
doc_path
);
dive
(
full_path
,
read_file
,
make_index_cont
);
}
else
{
make_index_cont
();
}
});
}
else
{
finish_index
();
}
}
post
(
"
building help index in
"
+
doc_path
);
dive
(
doc_path
,
read_file
,
finish
_index
);
dive
(
doc_path
,
read_file
,
make
_index
_cont
);
}
// AG: This is called from dialog_search.html with a callback that expects to
...
...
pd/src/s_main.c
View file @
7dbbbd11
...
...
@@ -290,6 +290,7 @@ extern void glob_recent_files(t_pd *dummy);
int
sys_main
(
int
argc
,
char
**
argv
)
{
int
i
,
noprefs
;
t_namelist
*
nl
;
sys_externalschedlib
=
0
;
sys_extraflags
=
0
;
sys_gui_preset
=
gensym
(
"default"
);
...
...
@@ -325,6 +326,16 @@ int sys_main(int argc, char **argv)
gui_vmess
(
"gui_set_gui_preset"
,
"s"
,
sys_gui_preset
->
s_name
);
/* send the recent files list */
glob_recent_files
(
0
);
/* AG: send the help path; this must come *after* gui_set_lib_dir so
that the lib_dir is available when help indexing starts */
gui_start_vmess
(
"gui_set_help_path"
,
""
);
gui_start_array
();
for
(
nl
=
sys_helppath
;
nl
;
nl
=
nl
->
nl_next
)
{
gui_s
(
nl
->
nl_string
);
}
gui_end_array
();
gui_end_vmess
();
if
(
sys_externalschedlib
)
return
(
sys_run_scheduler
(
sys_externalschedlibname
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment