Back to index

texmacs  1.0.7.15
Classes | Functions | Variables
tm_data.cpp File Reference
#include "tm_data.hpp"
#include "convert.hpp"
#include "file.hpp"
#include "web_files.hpp"
#include "tm_link.hpp"
#include "message.hpp"
#include "dictionary.hpp"
#include "new_document.hpp"

Go to the source code of this file.

Classes

class  kill_window_command_rep

Functions

tm_view new_view (url name)
tm_view get_passive_view (tm_buffer buf)
void delete_view (tm_view vw)
void attach_view (tm_window win, tm_view vw)
void detach_view (tm_view vw)
tm_window new_window (bool map_flag, tree geom)
bool delete_view_from_window (tm_window win)
void delete_window (tm_window win)
void new_buffer_in_this_window (url name, tree doc)
void new_buffer_in_new_window (url name, tree doc, tree geom)
url open_window (tree geom)
void clone_window ()
void kill_window ()
void kill_window_and_buffer ()
void project_attach (string prj_name)
bool project_attached ()
url project_get ()
int create_window_id ()
static path reset (path p, int i)
void destroy_window_id (int i)
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)

Variables

url tm_init_buffer_file = url_none ()
url my_init_buffer_file = url_none ()
static int last_window = 1
static path the_windows

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:

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:

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 287 of file tm_data.cpp.

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:

Definition at line 134 of file tm_data.cpp.

                                        {
  int i, j;
  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 == win) {
       detach_view (vw);
       delete_view (vw);
       return true;
      }
    }
  }
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_window ( tm_window  win)

Definition at line 151 of file tm_data.cpp.

                              {
  while (delete_view_from_window (win)) {}
  win->unmap ();
  destroy_window_widget (win->win);
  tm_delete (win);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void destroy_window_id ( int  i)

Definition at line 300 of file tm_data.cpp.

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 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:

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:

void new_buffer_in_new_window ( url  name,
tree  doc,
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  doc 
)

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_view new_view ( url  name)

Definition at line 29 of file tm_data.cpp.

                    {
  // cout << "Creating new view\n";

  tm_buffer buf= create_buffer (name);
  editor    ed = new_editor (get_server () -> get_server (), buf);
  tm_view   vw = tm_new<tm_view_rep> (buf, ed);
  buf->vws << vw;
  ed->set_data (buf->data);

  tm_view temp_vw= get_view (false);
  set_view (vw);
  if (is_none (tm_init_buffer_file))
    tm_init_buffer_file= "$TEXMACS_PATH/progs/init-buffer.scm";
  if (is_none (my_init_buffer_file))
    my_init_buffer_file= "$TEXMACS_HOME_PATH/progs/my-init-buffer.scm";
  if (exists (tm_init_buffer_file)) exec_file (tm_init_buffer_file);
  if (exists (my_init_buffer_file)) exec_file (my_init_buffer_file);
  set_view (temp_vw);

  // cout << "View created\n";
  return vw;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tm_window new_window ( bool  map_flag,
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:

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:

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:

static path reset ( path  p,
int  i 
) [static]

Definition at line 293 of file tm_data.cpp.

                      {
  if (is_nil (p)) return p;
  else if (p->item == i) return p->next;
  else return path (p->item, reset (p->next, i));
}

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

int last_window = 1 [static]

Definition at line 283 of file tm_data.cpp.

Definition at line 22 of file tm_data.cpp.

path the_windows [static]

Definition at line 284 of file tm_data.cpp.

Definition at line 21 of file tm_data.cpp.