Back to index

texmacs  1.0.7.15
Functions
edit_table.cpp File Reference
#include "edit_table.hpp"

Go to the source code of this file.

Functions

static tree empty_cell ()
bool is_empty_cell (tree t)
static tree empty_row (int nr_cols)
static tree empty_table (int nr_rows, int nr_cols)
static void table_get_extents (tree T, int &nr_rows, int &nr_cols)
static void table_set (tree &T, int row, int col, tree t)
static tree table_get (tree T, int row, int col)
static tree shift_subtable (tree st, int sh_row, int sh_col)
static void search_decoration (tree T, int &row, int &col)
static tree table_format_undecorate (tree st, int row, int col, int dec_row, int dec_col)
static tree table_undecorate (tree st, int row, int col)

Function Documentation

static tree empty_cell ( ) [static]

Definition at line 26 of file edit_table.cpp.

              {
  return "";
}

Here is the caller graph for this function:

static tree empty_row ( int  nr_cols) [static]

Definition at line 41 of file edit_table.cpp.

                        {
  int i;
  tree R (ROW, nr_cols);
  for (i=0; i<nr_cols; i++)
    R[i]= tree (CELL, empty_cell ());
  return R;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree empty_table ( int  nr_rows,
int  nr_cols 
) [static]

Definition at line 50 of file edit_table.cpp.

                                       {
  int i;
  tree T (TABLE, nr_rows);
  for (i=0; i<nr_rows; i++)
    T[i]= empty_row (nr_cols);
  return T;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_empty_cell ( tree  t)

Definition at line 31 of file edit_table.cpp.

                       {
  return
    t == "" ||
    (is_func (t, DOCUMENT, 1) && is_empty_cell (t[0])) ||
    (is_compound (t, "cell-inert", 2) && is_empty_cell (t[1])) ||
    (is_compound (t, "cell-input", 3) && is_empty_cell (t[1])) ||
    (is_compound (t, "cell-output", 3) && is_empty_cell (t[2]));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void search_decoration ( tree  T,
int &  row,
int &  col 
) [static]

Definition at line 885 of file edit_table.cpp.

                                               {
  while (is_func (T, TFORMAT)) T= T [N(T)-1];
  for (row=0; row<N(T); row++) {
    tree R= T[row];
    while (is_func (R, TFORMAT)) R= R [N(R)-1];
    for (col=0; col<N(R); col++) {
      tree C= R[col];
      while (is_func (C, TFORMAT)) C= C [N(C)-1];
      if (C == tree (TMARKER)) return;
    }
  }
  FAILED ("decoration not found");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree shift_subtable ( tree  st,
int  sh_row,
int  sh_col 
) [static]

Definition at line 795 of file edit_table.cpp.

                                                 {
  st= copy (st);
  int k, n= N(st);
  for (k=0; k<n-1; k++)
    if (is_func (st[k], CWITH, 6)) {
      st[k][0]= as_string (as_int (st[k][0]) + sh_row);
      st[k][1]= as_string (as_int (st[k][1]) + sh_row);
      st[k][2]= as_string (as_int (st[k][2]) + sh_col);
      st[k][3]= as_string (as_int (st[k][3]) + sh_col);
    }
  return st;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree table_format_undecorate ( tree  st,
int  row,
int  col,
int  dec_row,
int  dec_col 
) [static]

Definition at line 900 of file edit_table.cpp.

                                                                              {
  tree fm (TFORMAT);
  int k, n= N(st);
  for (k=0; k<n-1; k++)
    if ((as_int (st[k][0]) <= (row+1)) && (as_int (st[k][1]) >= (row+1)) &&
       (as_int (st[k][2]) <= (col+1)) && (as_int (st[k][3]) >= (col+1)))
      if (is_func (st[k], CWITH, 6) && (st[k][4] != CELL_DECORATION)) {
       tree with= copy (st[k]);
       with[0]= as_string (dec_row+1);
       with[1]= as_string (dec_row+1);
       with[2]= as_string (dec_col+1);
       with[3]= as_string (dec_col+1);
       fm << with;
      }
  return fm;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree table_get ( tree  T,
int  row,
int  col 
) [static]

Definition at line 80 of file edit_table.cpp.

                                     {
  while (is_func (T, TFORMAT)) T= T [N(T)-1];
  T= T [row];
  while (is_func (T, TFORMAT)) T= T [N(T)-1];
  T= T [col];
  while (is_func (T, TFORMAT)) T= T [N(T)-1];
  if (is_func (T, CELL, 1)) T= T [0];
  return T;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void table_get_extents ( tree  T,
int &  nr_rows,
int &  nr_cols 
) [static]

Definition at line 59 of file edit_table.cpp.

                                                       {
  while (is_func (T, TFORMAT)) T= T[N(T)-1];
  nr_rows= N(T);
  T= T[0];
  while (is_func (T, TFORMAT)) T= T[N(T)-1];
  nr_cols= N(T);
}

Here is the call graph for this function:

static void table_set ( tree T,
int  row,
int  col,
tree  t 
) [static]

Definition at line 68 of file edit_table.cpp.

                                              {
  tree* ptr= &T;
  while (is_func (*ptr, TFORMAT)) ptr= & ((*ptr) [N(*ptr)-1]);
  ptr= & ((*ptr) [row]);
  while (is_func (*ptr, TFORMAT)) ptr= & ((*ptr) [N(*ptr)-1]);
  ptr= & ((*ptr) [col]);
  while (is_func (*ptr, TFORMAT)) ptr= & ((*ptr) [N(*ptr)-1]);
  if (is_func (*ptr, CELL, 1)) ptr= & ((*ptr) [0]);
  *ptr= t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree table_undecorate ( tree  st,
int  row,
int  col 
) [static]

Definition at line 918 of file edit_table.cpp.

                                             {
  int k, n= N(st);
  for (k=0; k<n-1; k++)
    if ((as_int (st[k][0]) == (row+1)) && (as_int (st[k][2]) == (col+1)))
      if (is_func (st[k], CWITH, 6) && (st[k][4] == CELL_DECORATION)) {
       int dec_row= 0, dec_col= 0;
       tree T= copy (st[k][5]);
       search_decoration (T, dec_row, dec_col);
       table_set (T, dec_row, dec_col, table_get (st[n-1], row, col));
       tree F= table_format_undecorate (st, row, col, dec_row, dec_col);
       return F * T;
      }
  FAILED ("decoration not found");
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function: