1 
2 /******************************************************************************
3 * MODULE     : new_project.cpp
4 * DESCRIPTION: Project management
5 * COPYRIGHT  : (C) 1999-2012  Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11 
12 #include "tm_data.hpp"
13 #include "convert.hpp"
14 #include "file.hpp"
15 #include "web_files.hpp"
16 #include "tm_link.hpp"
17 #include "message.hpp"
18 #include "dictionary.hpp"
19 #include "new_document.hpp"
20 
21 /******************************************************************************
22 * Projects
23 ******************************************************************************/
24 
25 void
project_attach(string prj_name)26 project_attach (string prj_name) {
27   url name= get_current_buffer ();
28   tm_buffer buf= concrete_buffer (name);
29   buf->data->project= prj_name;
30   array<url> vs= buffer_to_views (name);
31   for (int i=0; i<N(vs); i++) {
32     editor ed= view_to_editor (vs[i]);
33     ed->notify_change (THE_DECORATIONS);
34     ed->require_save ();
35   }
36   if (prj_name == "") buf->prj= NULL;
37   else {
38     url full_name= head (buf->buf->name) * prj_name;
39     buf->prj= concrete_buffer_insist (full_name);
40   }
41 }
42 
43 bool
project_attached()44 project_attached () {
45   tm_buffer buf= concrete_buffer (get_current_buffer ());
46   return buf->data->project != "";
47 }
48 
49 url
project_get()50 project_get () {
51   tm_buffer buf= concrete_buffer (get_current_buffer ());
52   if (buf->data->project == "") return url_none ();
53   return buf->prj->buf->name;
54 }
55