Skip to content
Snippets Groups Projects
Commit 0bafbfc7 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Better web browser command for Unix + generalized call (permit
multiple '%s').
parent 14569d0f
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,7 @@ StringXString GeneralOptions_String[] = {
#else
"emacs %s &" ,
#endif
"System command to launch a text editor (OS-dependent)" },
"System command to launch a text editor" },
{ F|S, "TmpFileName" , opt_general_tmp_filename , ".gmsh-tmp" ,
"Temporary file used by the geometry module" },
......@@ -74,9 +74,9 @@ StringXString GeneralOptions_String[] = {
#elif defined(__APPLE__)
"open %s" ,
#else
"mozilla %s &" ,
"if [[ $(ps -e|grep mozilla|grep -v grep) ]]; then mozilla -remote 'openurl(%s)' ; else mozilla %s ; fi &" ,
#endif
"System command to launch a web browser (OS-dependent)" },
"System command to launch a web browser" },
{ 0, NULL , NULL , NULL , NULL }
} ;
......
// $Id: Callbacks.cpp,v 1.192 2003-12-03 04:28:18 geuzaine Exp $
// $Id: Callbacks.cpp,v 1.193 2003-12-03 22:17:49 geuzaine Exp $
//
// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle
//
......@@ -1495,11 +1495,36 @@ void help_about_cb(CALLBACK_ARGS)
WID->create_about_window();
}
void _replace_multi_format(char *in, char *val, char *out){
int i = 0, j = 0;
out[0] = '\0';
while(i < strlen(in)){
if(in[i] == '%' && i != strlen(in)-1){
if(in[i+1] == 's'){
strcat(out, val);
i += 2;
j += strlen(val);
}
else{
Msg(WARNING, "Skipping unknown format '%%%c' in '%s'", in[i+1], in);
i += 2;
}
}
else{
out[j] = in[i];
out[j+1] = '\0';
i++;
j++;
}
}
out[j] = '\0';
}
void help_online_cb(CALLBACK_ARGS)
{
char cmd[1000];
sprintf(cmd, CTX.web_browser, "http://www.geuz.org/gmsh/doc/texinfo/");
Msg(INFO, "Starting web browser '%s'", cmd);
_replace_multi_format(CTX.web_browser, "http://www.geuz.org/gmsh/doc/texinfo/", cmd);
SystemCall(cmd);
}
......@@ -1550,8 +1575,7 @@ void geometry_physical_cb(CALLBACK_ARGS)
void geometry_edit_cb(CALLBACK_ARGS)
{
char cmd[1000];
sprintf(cmd, CTX.editor, CTX.filename);
Msg(INFO, "Starting text editor '%s'", cmd);
_replace_multi_format(CTX.editor, CTX.filename, cmd);
SystemCall(cmd);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment