ARB
AW_edit.cxx
Go to the documentation of this file.
1 // ================================================================ //
2 // //
3 // File : AW_edit.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // ================================================================ //
10 
11 #include "aw_edit.hxx"
12 #include "aw_msg.hxx"
13 
14 #include <arb_msg.h>
15 
16 void AW_edit(const char *path) {
17  // Start external editor on file 'path' (asynchronously)
18  //
19  // Note: no longer use ARB_TEXTEDIT directly -> now completely delegates logic to script ../SH/arb_textedit
20 
21  arb_assert(!strchr(path, '$')); // AW_edit previously supported expansion of environment variables (please perform at caller where needed!)
22 
23  char *quotedFile = GBK_singlequote(path);
24  char *command = GBS_global_string_copy("arb_textedit %s &", quotedFile);
25 
26  GB_ERROR error = GBK_system(command);
27  aw_message_if(error);
28 
29  free(command);
30  free(quotedFile);
31 }
32 
33 void AW_edit_notified(const char *path, const FileChangedCallback& callback) {
34  // like AW_edit, but also installs a callback called whenever file is changed.
35  // The callback remains active forever.
36 
37  AW_edit(path);
38  AW_add_inotification(path, callback);
39 }
40 
GB_ERROR GBK_system(const char *system_command)
Definition: arb_msg.cxx:571
#define arb_assert(cond)
Definition: arb_assert.h:245
const char * GB_ERROR
Definition: arb_core.h:25
void AW_edit(const char *path)
Definition: AW_edit.cxx:16
void AW_edit_notified(const char *path, const FileChangedCallback &callback)
Definition: AW_edit.cxx:33
void AW_add_inotification(const char *file, const FileChangedCallback &fccb)
Definition: AW_inotify.cxx:473
static void error(const char *msg)
Definition: mkptypes.cxx:96
char * GBK_singlequote(const char *arg)
Definition: arb_msg.cxx:599
static char * command
Definition: arb_a2ps.c:319
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:194