Back to index

texmacs  1.0.7.15
Classes | Typedefs | Functions | Variables
server.hpp File Reference
#include "editor.hpp"
#include "url.hpp"
#include "scheme.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  server_rep
class  server

Typedefs

typedef tm_buffer_reptm_buffer
typedef tm_view_reptm_view
typedef tm_window_reptm_window

Functions

 ABSTRACT_CODE (server)
scheme_tree menu_merge (scheme_tree m1, scheme_tree m2)
server get_server ()
void gui_set_output_language (string lan)
tm_buffer create_buffer (url name)
tm_buffer create_buffer (url name, tree doc)
int find_buffer (path p)
int find_buffer (url name)
void attach_view (tm_window win, tm_view vw)
void detach_view (tm_view vw)
tm_view get_passive_view (tm_buffer buf)
void delete_buffer (tm_buffer buf)
void delete_view (tm_view vw)
void new_buffer_in_this_window (url name, tree t)
tm_window new_window (bool map_flag=true, tree geom="")
tm_buffer load_passive_buffer (url name)
tree make_document (tm_view vw, string fm="texmacs")
url get_all_buffers ()
bool buffer_in_menu (url name)
url get_this_buffer ()
void set_name_buffer (url name)
url get_name_buffer ()
url get_name_buffer (path p)
void set_abbr_buffer (url name, string abbr)
string get_abbr_buffer (url name)
void revert_buffer (url name, tree doc)
void new_buffer_in_new_window (url name, tree t, tree geom="")
double last_visited (url name)
bool buffer_modified (url name)
int nr_bufs ()
url create_buffer ()
void switch_to_buffer (int nr)
bool switch_to_buffer (path p)
void switch_to_buffer (url name)
void switch_to_active_buffer (url name)
void revert_buffer ()
void kill_buffer ()
url open_window (tree geom="")
void clone_window ()
void kill_window ()
void kill_window_and_buffer ()
bool no_bufs ()
bool no_name ()
bool help_buffer ()
bool is_aux_buffer (url name)
void set_aux (string aux, url name)
void set_aux_buffer (string aux, url name, tree doc)
void set_help_buffer (url name, tree doc)
void browse_help (int delta)
void set_buffer_tree (url name, tree doc)
tree get_buffer_tree (url name)
void project_attach (string prj_name="")
bool project_attached ()
url project_get ()
int window_current ()
path windows_list ()
path buffer_to_windows (url name)
url window_to_buffer (int id)
tm_view window_find_view (int id)
void window_set_buffer (int id, url name)
void window_focus (int id)
tree load_tree (url name, string fm)
void load_buffer (url name, string fm, int where=0, bool asf=false)
void save_buffer (url name, string fm)
void auto_save ()
bool buffer_unsaved ()
bool exists_unsaved_buffer ()
void pretend_save_buffer ()

Variables

bool rescue_mode

Typedef Documentation

Definition at line 20 of file server.hpp.

typedef tm_view_rep* tm_view

Definition at line 22 of file server.hpp.

Definition at line 23 of file server.hpp.


Function Documentation

void attach_view ( tm_window  win,
tm_view  vw 
)

Definition at line 79 of file tm_data.cpp.

                                        {
  // cout << "Attach view " << vw->buf->buf->name << "\n";
  vw->win= win;
  widget wid= win->wid;
  set_scrollable (wid, vw->ed);
  vw->ed->cvw= wid.rep;
  ASSERT (is_attached (wid), "widget should be attached");
  vw->ed->resume ();
  win->set_window_name (vw->buf->buf->abbr);
  win->set_window_url (is_none (vw->buf->buf->extra)? vw->buf->buf->name: vw->buf->buf->extra);
  // cout << "View attached\n";
}

Here is the call graph for this function:

Here is the caller graph for this function:

void auto_save ( )

Definition at line 231 of file tm_file.cpp.

             {
  int i, n= N(bufs);
  for (i=0; i<n; i++) {
    tm_buffer buf= bufs[i];
    if ((buf->needs_to_be_autosaved () && (!buf->buf->read_only))) {
      url name= buf->buf->name;
      tree vname= verbatim (as_string (name));
      if (!is_scratch (name))
        name= glue (buf->buf->name, rescue_mode? "#": "~");
      if (N(buf->vws)!=0) {
        tree doc= make_document (buf->vws[0]);
        bool err= save_string (name, tree_to_texmacs (doc));
        if (!rescue_mode) {
          if (!err)
            call ("set-temporary-message",
                  "saved " * as_string (name), "save TeXmacs file", 2500);
          else
            set_message (concat ("Error: ", vname, " did not open"),
                         "save TeXmacs file");
        }
      }
      if (!rescue_mode)
        for (int j=0; j<N(buf->vws); j++)
          buf->vws[j]->ed->notify_save (false);
    }
  }
  call ("delayed-auto-save");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void browse_help ( int  delta)
bool buffer_in_menu ( url  name)

Definition at line 179 of file new_buffer.cpp.

                          {
  int nr= find_buffer (name);
  if (nr == -1) return false;
  else return bufs[nr]->buf->in_menu;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool buffer_modified ( url  name)

Definition at line 200 of file new_buffer.cpp.

                           {
  int nr= find_buffer (name);
  if (nr == -1) return false;
  return bufs[nr]->needs_to_be_saved ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 316 of file tm_data.cpp.

                             {
  path p;
  int nr= find_buffer (name);
  if (nr == -1) return path ();
  tm_buffer buf= bufs[nr];
  for (int i=0; i<N(buf->vws); i++)
    if (buf->vws[i]->win != NULL)
      p= path (buf->vws[i]->win->id, p);
  return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool buffer_unsaved ( )

Definition at line 277 of file tm_file.cpp.

                  {
  tm_buffer buf= get_buffer ();
  return buf->needs_to_be_saved ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void clone_window ( )

Definition at line 201 of file tm_data.cpp.

                {
  tm_window win= new_window ();
  tm_buffer buf= get_buffer ();
  tm_view   vw = get_passive_view (buf);
  attach_view (win, vw);
  set_view (vw);
  buf->buf->last_visit= texmacs_time ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 228 of file new_buffer.cpp.

                         {
  int nr= find_buffer (name);
  if (nr != -1) return bufs[nr];
  tm_buffer buf= tm_new<tm_buffer_rep> (name);
  buf->buf->abbr= new_menu_name (name);
  bufs << buf;
  return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tm_buffer create_buffer ( url  name,
tree  doc 
)

Definition at line 238 of file new_buffer.cpp.

                                   {
  int nr= find_buffer (name);
  if (nr != -1) return bufs[nr];
  tm_buffer buf= create_buffer (name);
  tree body= detach_data (doc, buf->data);
  set_document (buf->rp, body);
  if (buf->data->project != "") {
    url prj_name= head (name) * as_string (buf->data->project);
    buf->prj= load_passive_buffer (prj_name);
  }
  return buf;
}

Here is the call graph for this function:

Definition at line 252 of file new_buffer.cpp.

                 {
  int i=1;
  while (true) {
    url name= url_scratch ("no_name_", ".tm", i);
    int nr= find_buffer (name);
    if (nr == -1) {
      new_buffer_in_this_window (name, tree (DOCUMENT));
      return name;
    }
    else i++;
  }
}

Here is the call graph for this function:

void delete_buffer ( tm_buffer  buf)

Definition at line 290 of file new_buffer.cpp.

                              {
  int nr= find_buffer (buf), n= N(bufs);
  if (nr >= 0) {
    for (int i=nr; i<(n-1); i++) bufs[i]= bufs[i+1];
    bufs->resize (n-1);
  }
  for (int i=0; i<N(buf->vws); i++)
    delete_view (buf->vws[i]);
  tm_delete (buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_view ( tm_view  vw)

Definition at line 62 of file tm_data.cpp.

                         {
  tm_buffer buf= vw->buf;
  int i, j, n= N(buf->vws);
  for (i=0; i<n; i++)
    if (buf->vws[i] == vw) {
      array<tm_view> a (n-1);
      for (j=0; j<n-1; j++)
       if (j<i) a[j]= buf->vws[j];
       else a[j]= buf->vws[j+1];
      buf->vws= a;
    }
  // tm_delete (vw);
  // FIXME: causes very annoying segfault;
  // recently introduced during reorganization
}

Here is the call graph for this function:

Here is the caller graph for this function:

void detach_view ( tm_view  vw)

Definition at line 93 of file tm_data.cpp.

                         {
  // cout << "Detach view " << vw->buf->buf->name << "\n";
  tm_window win= vw->win;
  if (win == NULL) return;
  vw->win= NULL;
  widget wid= win->wid;
  ASSERT (is_attached (wid), "widget should be attached");
  vw->ed->suspend ();
  set_scrollable (wid, glue_widget ());
  win->set_window_name ("TeXmacs");
  win->set_window_url (url_none ());
  // cout << "View detached\n";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 283 of file tm_file.cpp.

                         {
  bool flag= false;
  int i, n= N(bufs);
  for (i=0; i<n; i++) {
    tm_buffer buf= bufs[i];
    flag = flag || buf->needs_to_be_saved ();
  }
  return flag;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int find_buffer ( path  p)

Definition at line 77 of file new_buffer.cpp.

                     {
  int i;
  for (i=0; i<N(bufs); i++)
    if (bufs[i]->rp <= p)
      return i;
  return -1;
}

Here is the call graph for this function:

int find_buffer ( url  name)

Definition at line 86 of file new_buffer.cpp.

                       {
  int i;
  for (i=0; i<N(bufs); i++)
    if (bufs[i]->buf->name == name)
      return i;
  return -1;
}

Here is the call graph for this function:

Definition at line 155 of file new_buffer.cpp.

                           {
  int nr= find_buffer (name);
  if (nr == -1) return "";
  else return bufs[nr]->buf->abbr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 50 of file new_buffer.cpp.

                   {
  url u= url_none ();
  for (int i=N(bufs)-1; i>=0; i--)
    u= bufs[i]->buf->name | u;
  return u;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 216 of file new_buffer.cpp.

                           {
  int nr= find_buffer (name);
  if (nr == -1) return "";
  tm_buffer buf= bufs[nr];
  return subtree (the_et, buf->rp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 133 of file new_buffer.cpp.

                   {
  tm_buffer buf= get_buffer ();
  if (!is_none (buf->buf->extra)) return buf->buf->extra;
  return buf->buf->name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 140 of file new_buffer.cpp.

                         {
  int nr= find_buffer (p);
  if (nr == -1) return url_none ();
  return bufs[nr]->buf->name;
}

Here is the call graph for this function:

Definition at line 53 of file tm_data.cpp.

                                 {
  int i;
  for (i=0; i<N(buf->vws); i++)
    if (buf->vws[i]->win == NULL)
      return buf->vws[i];
  return new_view (buf->buf->name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 58 of file tm_server.cpp.

              {
  ASSERT (the_server != NULL, "TeXmacs server not yet started");
  return *the_server;
}

Definition at line 127 of file new_buffer.cpp.

                   {
  tm_buffer buf= get_buffer ();
  return buf->buf->name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 74 of file tm_server.cpp.

                                     {
  set_output_language (lan);
  get_server () -> refresh ();
  gui_refresh ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool help_buffer ( )

Definition at line 271 of file tm_file.cpp.

               {
  tm_buffer buf= get_buffer ();
  return buf->buf->fm == "help";
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_aux_buffer ( url  name)

Definition at line 186 of file new_buffer.cpp.

                         {
  int nr= find_buffer (name);
  if (nr == -1) return false;
  else return !is_none (bufs[nr]->buf->extra);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void kill_buffer ( )

Definition at line 302 of file new_buffer.cpp.

               {
  int i, nr;
  if (N(bufs) <= 1) get_server () -> quit();
  tm_buffer buf= get_buffer();
  for (nr=0; nr<N(bufs); nr++) if (buf == bufs[nr]) break;
  ASSERT (nr != N(bufs), "buffer not found");
  for (nr=0; nr<N(bufs); nr++) if (buf != bufs[nr]) break;
  ASSERT (nr != N(bufs), "no suitable new buffer");
  tm_buffer new_buf = bufs[nr];

  for (i=0; i<N(buf->vws); i++) {
    tm_view old_vw= buf->vws[i];
    if (old_vw->win != NULL) {
      tm_window win = old_vw->win;
      tm_view new_vw= get_passive_view (new_buf);
      detach_view (old_vw);
      attach_view (win, new_vw);
      if (get_view () == old_vw) set_view (new_vw);
    }
  }
  delete_buffer (buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void kill_window ( )

Definition at line 211 of file tm_data.cpp.

               {
  int i, j;
  tm_window win= get_window ();
  for (i=0; i<N(bufs); i++) {
    tm_buffer buf= bufs[i];
    for (j=0; j<N(buf->vws); j++) {
      tm_view vw= buf->vws[j];
      if ((vw->win != NULL) && (vw->win != win)) {
       set_view (vw);
        vw->buf->buf->last_visit= texmacs_time ();
       delete_window (win);
       return;
      }
    }
  }
  if (number_of_servers () == 0) get_server () -> quit ();
  else delete_window (win);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 231 of file tm_data.cpp.

                          {
  if (N(bufs) <= 1) get_server () -> quit();
  int i;
  bool kill= true;
  tm_buffer buf= get_buffer();
  tm_window win= get_window ();
  for (i=0; i<N(buf->vws); i++) {
    tm_view old_vw= buf->vws[i];
    if (old_vw->win != win) kill= false;
  }
  kill_window ();
  if (kill) delete_buffer (buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

double last_visited ( url  name)

Definition at line 193 of file new_buffer.cpp.

                        {
  int nr= find_buffer (name);
  if (nr == -1) return (double) texmacs_time ();
  else return (double) bufs[nr]->buf->last_visit;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void load_buffer ( url  name,
string  fm,
int  where = 0,
bool  asf = false 
)

Definition at line 51 of file tm_file.cpp.

                                                              {
  // cout << "Load= " << u << ", " << fm << "\n";
  string name= as_string (tail (u));
  tree vname= verbatim (name);
  string action= "load " * fm * " file";
  if (fm == "generic")
    action= "load " * suffix_to_format (suffix (u)) * " file";
  
  url v= u;
  u= resolve (u);
  if (is_none (u)) {
    if (fm == "generic" || fm == "texmacs")
      if (is_name (v) || (is_rooted_name (v) && is_rooted (v, "default"))) {
        tree doc (DOCUMENT,
                  compound ("style", "generic"),
                  compound ("body", tree (DOCUMENT, "")));
        switch (where) {
          case 0: new_buffer_in_this_window (v, doc); break;
          case 1: new_buffer_in_new_window (v, doc); break;
          case 2: ::create_buffer (v, doc); break;
          default: FAILED ("bad value for 'where'");
        }
      }
    if (!no_bufs ())
      set_message (concat ("Error: file ", vname, " not found"), action);
    return;
  }
  
  if (fm == "help") {
    extern string get_help_title (url name, tree t);
    tree doc= load_tree (u, fm);
    if (doc == "error") return;
    if (where == 1)
      new_buffer_in_new_window (get_help_title (u, doc), doc);
    set_help_buffer (u, doc);
    return;
  }
  
  v= u;
  if (autosave_flag) v= unglue (v, 1);
  int nr= find_buffer (v);
  tree doc= ((nr == -1)? load_tree (u, fm): tree (DOCUMENT));
  if (doc == "error") return;
  switch (where) {
    case 0: new_buffer_in_this_window (v, doc); break;
    case 1: new_buffer_in_new_window (v, doc); break;
    case 2: ::create_buffer (v, doc); break;
    default: FAILED ("bad value for 'where'");
  }
  nr= find_buffer (v);
  if (nr != -1) {
    tm_buffer buf= bufs[nr];
    if (autosave_flag && N(buf->vws) == 1 && buf->vws[0]->ed != NULL)
      buf->vws[0]->ed->require_save();
    buf->buf->fm= fm;
    if (fm == "help" || is_rooted_web (v)) {
      tm_buffer buf= get_buffer ();
      buf->buf->read_only= true;
    }
  }
  if (fm == "generic" || fm == "texmacs")
    notify_recent_buffer (as_string (u));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 116 of file tm_file.cpp.

                            {
  int nr= find_buffer (u);
  if (nr != -1) return bufs[nr];
  load_buffer (u, "texmacs", 2, false);
  nr= find_buffer (u);
  if (nr != -1) return bufs[nr];
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree load_tree ( url  name,
string  fm 
)

Definition at line 32 of file tm_file.cpp.

                             {
  string s, suf= suffix (u);
  string action= "load " * fm * " file";
  u= resolve (u);
  set_file_focus (u);
  if (is_none (u) || load_string (u, s, false)) {
    tree vname= verbatim (as_string (u));
    set_message (concat ("Error: file ", vname, " not found"), action);
    return "error";
  }
  if (fm == "generic" || fm == "help") fm= get_format (s, suf);
  tree t= generic_to_tree (s, fm * "-document");
  tree links= extract (t, "links");
  if (N (links) != 0)
    (void) call ("register-link-locations", object (u), object (links));
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree make_document ( tm_view  vw,
string  fm = "texmacs" 
)

Definition at line 158 of file tm_file.cpp.

                                      {
  tree body= subtree (the_et, vw->buf->rp);
  if (fm == "verbatim")
    body= vw->ed->exec_verbatim (body);
  if (fm == "html")
    body= vw->ed->exec_html (body);
  if (fm == "latex")
    body= vw->ed->exec_latex (body);

  vw->ed->get_data (vw->buf->data);
  tree doc= attach_data (body, vw->buf->data, !vw->ed->get_save_aux());

  object arg1 (vw->buf->buf->name);
  object arg2 (body);
  tree links= as_tree (call ("get-link-locations", arg1, arg2));
  if (N (links) != 0)
    doc << compound ("links", links);

  return doc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void new_buffer_in_new_window ( url  name,
tree  t,
tree  geom = "" 
)

Definition at line 173 of file tm_data.cpp.

                                                         {
  tm_window win= new_window (true, geom);
  tm_buffer buf= create_buffer (name, doc);
  tm_view   vw = get_passive_view (buf);
  attach_view (win, vw);
  set_view (vw);
  buf->buf->last_visit= texmacs_time ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void new_buffer_in_this_window ( url  name,
tree  t 
)

Definition at line 163 of file tm_data.cpp.

                                               {
  int nr= find_buffer (name);
  if (nr != -1) switch_to_buffer (nr);
  else {
    (void) create_buffer (name, doc);
    switch_to_buffer (name);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

tm_window new_window ( bool  map_flag = true,
tree  geom = "" 
)

Definition at line 119 of file tm_data.cpp.

                                      {
  int mask= 0;
  if (get_preference ("header") == "on") mask += 1;
  if (get_preference ("main icon bar") == "on") mask += 2;
  if (get_preference ("mode dependent icons") == "on") mask += 4;
  if (get_preference ("focus dependent icons") == "on") mask += 8;
  if (get_preference ("user provided icons") == "on") mask += 16;
  if (get_preference ("status bar") == "on") mask += 32;
  command quit= tm_new<kill_window_command_rep> ();
  tm_window win= tm_new<tm_window_rep> (texmacs_widget (mask, quit), geom);
  if (map_flag) win->map ();
  return win;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool no_bufs ( )

Definition at line 63 of file new_buffer.cpp.

           {
  return N(bufs) == 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool no_name ( )

Definition at line 265 of file tm_file.cpp.

           {
  tm_buffer buf= get_buffer ();
  return is_scratch (buf->buf->name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nr_bufs ( )

Definition at line 58 of file new_buffer.cpp.

           {
  return N(bufs);
}

Here is the call graph for this function:

url open_window ( tree  geom = "")

Definition at line 187 of file tm_data.cpp.

                        {
  int i=1;
  while (true) {
    url name= url_scratch ("no_name_", ".tm", i);
    int nr= find_buffer (name);
    if (nr == -1) {
      new_buffer_in_new_window (name, tree (DOCUMENT), geom);
      return name;
    }
    else i++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 294 of file tm_file.cpp.

                       {
  tm_buffer buf= get_buffer ();
  for (int i=0; i<N(buf->vws); i++)
    buf->vws[i]->ed->notify_save ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void project_attach ( string  prj_name = "")

Definition at line 250 of file tm_data.cpp.

                                 {
  int i;
  tm_buffer buf= get_buffer ();
  buf->data->project= prj_name;
  for (i=0; i<N(buf->vws); i++) {
    tm_view vw= buf->vws[i];
    vw->ed->notify_change (THE_DECORATIONS);
    vw->ed->require_save ();
  }
  if (prj_name == "") buf->prj= NULL;
  else {
    url full_name= head (buf->buf->name) * prj_name;
    buf->prj= load_passive_buffer (full_name);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool project_attached ( )

Definition at line 267 of file tm_data.cpp.

                    {
  tm_buffer buf= get_buffer ();
  return buf->data->project != "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 273 of file tm_data.cpp.

               {
  tm_buffer buf= get_buffer ();
  if (buf->data->project == "") return url_none ();
  return buf->prj->buf->name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void revert_buffer ( url  name,
tree  doc 
)

Definition at line 266 of file new_buffer.cpp.

                                   {
  int i, nr= find_buffer (name);
  if (nr == -1) return;
  tm_buffer buf= bufs[nr];
  tree body= detach_data (doc, buf->data);
  if (N(buf->vws)==0) set_document (buf->rp, body);
  else for (i=0; i<N(buf->vws); i++) {
    tm_view vw= buf->vws[i];
    if (i==0) assign (vw->ed->rp, body);
    vw->ed->set_data (buf->data);
    vw->ed->notify_save ();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void revert_buffer ( )

Definition at line 281 of file new_buffer.cpp.

                 {
  tm_buffer buf= get_buffer ();
  web_cache_invalidate (buf->buf->name);
  tree doc= load_tree (buf->buf->name, buf->buf->fm);
  if (doc == "error") set_message ("Error: file not found", "revert buffer");
  else revert_buffer (buf->buf->name, doc);
}

Here is the call graph for this function:

void save_buffer ( url  name,
string  fm 
)

Definition at line 180 of file tm_file.cpp.

                               {
  string name= as_string (u);
  tree vname= verbatim (name);
  if (fm == "generic") {
    fm= suffix_to_format (suffix (u));
    if (fm == "generic") fm= "verbatim";
  }
  string action= "save " * fm * " file";
  u= resolve (u, "");
  if (is_none (u)) {
    set_message (concat ("Error: can't save file ", vname), action);
    return;
  }

  tm_buffer buf= get_buffer ();
  if ((u == buf->buf->name && buf->buf->read_only) ||
      (u == buf->buf->name && has_permission (u,"r") && !has_permission (u,"w")) ||
      (!is_none (buf->buf->extra) && buf->buf->name != "* Aux *")) {
    set_message ("Error: file is read only", action);
    return;
  }
  if ((fm == "texmacs") && (!buf->needs_to_be_saved ()))
    if (buf->buf->name == u) {
      set_message ("No changes need to be saved", action);
      return;
    }

  tm_view vw= get_view ();
  tree doc= make_document (vw, fm);
  string s= tree_to_generic (doc, fm * "-document");
  if (s != "* error: unknown format *") {
    if (save_string (u, s))
      set_message (concat ("Error: ", vname, " did not open"), action);
    else {
      set_message (concat ("saved ", vname), action);
      if (fm == "texmacs") {
        if (no_name () && exists (get_name_buffer ()))
          remove (get_name_buffer ());
        set_name_buffer (u);
        pretend_save_buffer ();
        if (suffix (u) == "ts") get_server () -> style_clear_cache ();
        if ((fm == "generic") || (fm == "texmacs"))
          if (!no_name ())
            notify_recent_buffer (as_string (u));
      }
    }
  }
  else set_message ("Error: unknown format", action);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_abbr_buffer ( url  name,
string  abbr 
)

Definition at line 162 of file new_buffer.cpp.

                                        {
  int nr= find_buffer (name);
  if (nr == -1) return;
  tm_buffer buf= bufs[nr];
  if (buf->buf->abbr == abbr) return;
  buf->buf->abbr= abbr;
  for (int i=0; i<N(buf->vws); i++) {
    tm_view vw2= buf->vws[i];
    if (vw2->win != NULL) {
      vw2->win->set_window_name (buf->buf->abbr);
      vw2->win->set_window_url (is_none (buf->buf->extra)?
                                buf->buf->name: buf->buf->extra);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_aux ( string  aux,
url  name 
)

Definition at line 391 of file new_buffer.cpp.

                               {
  int i, nr= find_buffer (aux);
  if (nr != -1) {
    tm_buffer buf= bufs[nr];
    buf->buf->extra= name;
    if (starts (aux, "Help - ")) {
      buf->buf->fm= "help";
      buf->buf->read_only= true;
    }
    for (i=0; i<N(buf->vws); i++) {
      tm_view vw= buf->vws[i];
      vw->ed->set_base_name (name);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_aux_buffer ( string  aux,
url  name,
tree  doc 
)

Definition at line 408 of file new_buffer.cpp.

                                                {
  int nr= find_buffer (aux);
  if (nr == -1) create_buffer (aux, doc);
  else revert_buffer (aux, doc);
  nr= find_buffer (aux);
  if (nr != -1) {
    set_aux (aux, name);
    switch_to_buffer (nr);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_buffer_tree ( url  name,
tree  doc 
)

Definition at line 207 of file new_buffer.cpp.

                                     {
  int nr= find_buffer (name);
  if (nr == -1) create_buffer (name, tree (DOCUMENT, ""));
  nr= find_buffer (name);
  tm_buffer buf= bufs[nr];
  assign (buf->rp, doc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_help_buffer ( url  name,
tree  doc 
)

Definition at line 444 of file new_buffer.cpp.

                                     {
  set_aux_buffer (get_help_title (name, doc), name, doc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_name_buffer ( url  name)

Definition at line 147 of file new_buffer.cpp.

                           {
  tm_buffer buf= get_buffer ();
  if (buf->buf->name == name) return;
  buf->buf->name= name;
  set_abbr_buffer (name, new_menu_name (name));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void switch_to_active_buffer ( url  name)

Definition at line 363 of file new_buffer.cpp.

                                   {
  // This function is a temporary hack for coq
  // Switching to buffers in other windows should be completely rewritten

  int nr= find_buffer (name);
  if (nr == -1) {
    load_passive_buffer (name);
    nr= find_buffer (name);
  }
  if (nr != -1) {
    int i;
    tm_buffer buf= bufs[nr];
    for (i=0; i<N(buf->vws); i++) // search active view
      if (buf->vws[i]->win != NULL) {
        tm_view vw= buf->vws[i];
        set_view (vw);
        buf->buf->last_visit= texmacs_time ();
        return;
      }
  }
  switch_to_buffer (name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void switch_to_buffer ( int  nr)

Definition at line 330 of file new_buffer.cpp.

                          {
  // cout << "Switching to buffer " << nr << "\n";
  tm_window win    = get_window ();
  tm_buffer buf    = bufs[nr];
  tm_view   old_vw = get_view ();
  tm_view   new_vw = get_passive_view (buf);
  detach_view (old_vw);
  attach_view (win, new_vw);
  set_view (new_vw);
  buf->buf->last_visit= texmacs_time ();
  tm_window nwin= new_vw->win;
  nwin->set_shrinking_factor (nwin->get_shrinking_factor ());
  // cout << "Switched to buffer " << nr << "\n";
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool switch_to_buffer ( path  p)

Definition at line 346 of file new_buffer.cpp.

                          {
  int nr= find_buffer (p);
  if (nr != -1) switch_to_buffer (nr);
  return nr != -1;
}

Here is the call graph for this function:

void switch_to_buffer ( url  name)

Definition at line 353 of file new_buffer.cpp.

                            {
  int nr= find_buffer (name);
  if (nr == -1) {
    load_passive_buffer (name);
    nr= find_buffer (name);
  }
  if (nr != -1) switch_to_buffer (nr);
}

Here is the call graph for this function:

int window_current ( )

Definition at line 305 of file tm_data.cpp.

                  {
  tm_window win= get_window ();
  return win->id;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 338 of file tm_data.cpp.

                          {
  for (int i=0; i<N(bufs); i++)
    for (int j=0; j<N(bufs[i]->vws); j++)
      if (bufs[i]->vws[j]->win != NULL)
       if (bufs[i]->vws[j]->win->id == id)
         return bufs[i]->vws[j];
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void window_focus ( int  id)

Definition at line 361 of file tm_data.cpp.

                      {
  if (id == window_current ()) return;
  tm_view vw= window_find_view (id);
  if (vw == NULL) return;
  set_view (vw);
  vw->buf->buf->last_visit= texmacs_time ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void window_set_buffer ( int  id,
url  name 
)

Definition at line 348 of file tm_data.cpp.

                                     {
  tm_view old_vw= window_find_view (id);
  if (old_vw == NULL || old_vw->buf->buf->name == name) return;
  tm_window win= old_vw->win;
  int nr= find_buffer (name);
  if (nr == -1) return;
  tm_buffer buf   = bufs[nr];
  tm_view   new_vw= get_passive_view (buf);
  detach_view (old_vw);
  attach_view (win, new_vw);
}

Here is the call graph for this function:

Here is the caller graph for this function:

url window_to_buffer ( int  id)

Definition at line 328 of file tm_data.cpp.

                          {
  for (int i=0; i<N(bufs); i++)
    for (int j=0; j<N(bufs[i]->vws); j++)
      if (bufs[i]->vws[j]->win != NULL)
       if (bufs[i]->vws[j]->win->id == id)
         return bufs[i]->buf->name;
  return url_none ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 311 of file tm_data.cpp.

                {
  return the_windows;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 18 of file tm_debug.cpp.