Warn if no application is defined to open html command reference

This commit is contained in:
stefan schippers 2023-03-15 09:01:10 +01:00
parent 4569a0747a
commit b6a8add190
2 changed files with 23 additions and 2 deletions

View File

@ -531,7 +531,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
Compare currently loaded schematic with another 'sch_file' schematic.
if no file is given prompt user to choose one </pre>
<li><kbd> connected_nets [1|0]</kbd></li><pre>
Selected nets connected to currently selected net or net label/pin.
Select nets connected to currently selected net or net label/pin.
if '1' argument is given, stop at wire junctions </pre>
<li><kbd> copy</kbd></li><pre>
Copy selection to clipboard </pre>

View File

@ -65,10 +65,31 @@ static void xschem_cmd_help(int argc, const char **argv)
if( get_file_path("chromium")[0] == '/' ) goto done;
if( get_file_path("chrome")[0] == '/' ) goto done;
if( get_file_path("xdg-open")[0] == '/' ) goto done;
if(has_x) tcleval("alert_ { No application to display html documentation} {}");
else dbg(0, "No application to display html documentation\n");
return;
done:
my_strncpy(prog, tclresult(), S(prog));
#ifdef __unix__
tclvareval("launcher {", "file://", XSCHEM_SHAREDIR,
"/../doc/xschem/xschem_man/developer_info.html#cmdref", "} ", prog, NULL);
#else
const char *xschem_sharedir=tclgetvar("XSCHEM_SHAREDIR");
if (xschem_sharedir) {
wchar_t app[MAX_PATH] = {0};
char url[PATH_MAX]="", url2[PATH_MAX]="";
my_snprintf(url, S(url), "%s/../doc/xschem_man/developer_info.html", xschem_sharedir);
wchar_t w_url[PATH_MAX];
MultiByteToWideChar(CP_ACP, 0, url, -1, w_url, S(w_url));
int result = (int)FindExecutable(w_url, NULL, app);
/* The file:// url scheme doesn't have any allowance for HTTP parameters.
So, gets ShellExecute for the browser app and then ShellExecute */
my_snprintf(url2, S(url2), "file://%s#cmdref", url);
MultiByteToWideChar(CP_ACP, 0, url2, -1, w_url, S(w_url));
if (result > 32)
ShellExecute(0, NULL, app, w_url, NULL, SW_SHOWNORMAL);
}
#endif
Tcl_ResetResult(interp);
}
@ -443,7 +464,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
/* connected_nets [1|0]
* Selected nets connected to currently selected net or net label/pin.
* Select nets connected to currently selected net or net label/pin.
* if '1' argument is given, stop at wire junctions */
else if(!strcmp(argv[1], "connected_nets"))
{