⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node.cc

📁 早期freebsd实现
💻 CC
📖 第 1 页 / 共 5 页
字号:
{  n->ascii_print(out);}int italic_corrected_node::ends_sentence(){  return n->ends_sentence();}int italic_corrected_node::overlaps_horizontally(){  return n->overlaps_horizontally();}int italic_corrected_node::overlaps_vertically(){  return n->overlaps_vertically();}node *italic_corrected_node::last_char_node(){  return n->last_char_node();}tfont *italic_corrected_node::get_tfont(){  return n->get_tfont();}hyphenation_type italic_corrected_node::get_hyphenation_type(){  return n->get_hyphenation_type();}node *italic_corrected_node::add_self(node *nd, hyphen_list **p){  nd = n->add_self(nd, p);  hunits not_interested;  nd = nd->add_italic_correction(&not_interested);  n = 0;  delete this;  return nd;}hyphen_list *italic_corrected_node::get_hyphen_list(hyphen_list *tail){  return n->get_hyphen_list(tail);}int italic_corrected_node::character_type(){  return n->character_type();}class break_char_node : public node {  node *ch;  char break_code;public:  break_char_node(node *, int, node * = 0);  ~break_char_node();  node *copy();  hunits width();  vunits vertical_width();  node *last_char_node();  int character_type();  int ends_sentence();  node *add_self(node *, hyphen_list **);  hyphen_list *get_hyphen_list(hyphen_list *s = 0);  void tprint(troff_output_file *);  void zero_width_tprint(troff_output_file *);  void ascii_print(ascii_output_file *);  void asciify(macro *m);  hyphenation_type get_hyphenation_type();  int overlaps_vertically();  int overlaps_horizontally();  units size();  tfont *get_tfont();  int same(node *);  const char *type();};break_char_node::break_char_node(node *n, int c, node *x): node(x), ch(n), break_code(c){}break_char_node::~break_char_node(){  delete ch;}node *break_char_node::copy(){  return new break_char_node(ch->copy(), break_code);}hunits break_char_node::width(){  return ch->width();}vunits break_char_node::vertical_width(){  return ch->vertical_width();}node *break_char_node::last_char_node(){  return ch->last_char_node();}int break_char_node::character_type(){  return ch->character_type();}int break_char_node::ends_sentence(){  return ch->ends_sentence();}node *break_char_node::add_self(node *n, hyphen_list **p){  assert((*p)->hyphenation_code == 0);  if ((*p)->breakable && (break_code & 1)) {    n = new space_node(H0, n);    n->freeze_space();  }  next = n;  n = this;  if ((*p)->breakable && (break_code & 2)) {    n = new space_node(H0, n);    n->freeze_space();  }  hyphen_list *pp = *p;  *p = (*p)->next;  delete pp;  return n;}hyphen_list *break_char_node::get_hyphen_list(hyphen_list *tail){  return new hyphen_list(0, tail);}hyphenation_type break_char_node::get_hyphenation_type(){  return HYPHEN_MIDDLE;}void break_char_node::ascii_print(ascii_output_file *ascii){  ch->ascii_print(ascii);}int break_char_node::overlaps_vertically(){  return ch->overlaps_vertically();}int break_char_node::overlaps_horizontally(){  return ch->overlaps_horizontally();}units break_char_node::size(){  return ch->size();}tfont *break_char_node::get_tfont(){  return ch->get_tfont();}node *extra_size_node::copy(){   return new extra_size_node(n); }node *vertical_size_node::copy(){   return new vertical_size_node(n); }node *hmotion_node::copy(){   return new hmotion_node(n);}node *space_char_hmotion_node::copy(){  return new space_char_hmotion_node(n);}node *vmotion_node::copy(){   return new vmotion_node(n);}  node *dummy_node::copy(){   return new dummy_node;}node *transparent_dummy_node::copy(){   return new transparent_dummy_node;}hline_node::~hline_node(){  if (n)    delete n;}node *hline_node::copy(){  return new hline_node(x, n ? n->copy() : 0);}hunits hline_node::width(){  return x < H0 ? H0 : x;}vline_node::~vline_node(){  if (n)    delete n;}node *vline_node::copy(){  return new vline_node(x, n ? n->copy() : 0);}hunits vline_node::width(){  return n == 0 ? H0 : n->width();}zero_width_node::zero_width_node(node *nd) : n(nd){}zero_width_node::~zero_width_node(){  delete_node_list(n);}node *zero_width_node::copy(){  return new zero_width_node(copy_node_list(n));}int node_list_character_type(node *p){  int t = 0;  for (; p; p = p->next)    t |= p->character_type();  return t;}int zero_width_node::character_type(){  return node_list_character_type(n);}void node_list_vertical_extent(node *p, vunits *min, vunits *max){  *min = V0;  *max = V0;  vunits cur_vpos = V0;  vunits v1, v2;  for (; p; p = p->next) {    p->vertical_extent(&v1, &v2);    v1 += cur_vpos;    if (v1 < *min)      *min = v1;    v2 += cur_vpos;    if (v2 > *max)      *max = v2;    cur_vpos += p->vertical_width();  }}void zero_width_node::vertical_extent(vunits *min, vunits *max){  node_list_vertical_extent(n, min, max);}overstrike_node::overstrike_node() : max_width(H0), list(0){}overstrike_node::~overstrike_node(){  delete_node_list(list);}node *overstrike_node::copy(){  overstrike_node *on = new overstrike_node;  for (node *tem = list; tem; tem = tem->next)    on->overstrike(tem->copy());  return on;}void overstrike_node::overstrike(node *n){  if (n == 0)    return;  hunits w = n->width();  if (w > max_width)    max_width = w;  for (node **p = &list; *p; p = &(*p)->next)    ;  n->next = 0;  *p = n;}hunits overstrike_node::width(){  return max_width;}bracket_node::bracket_node() : max_width(H0), list(0){}bracket_node::~bracket_node(){  delete_node_list(list);}node *bracket_node::copy(){  bracket_node *on = new bracket_node;  for (node *tem = list; tem; tem = tem->next)    on->bracket(tem->copy());  return on;}void bracket_node::bracket(node *n){  if (n == 0)    return;  hunits w = n->width();  if (w > max_width)    max_width = w;  n->next = list;  list = n;}hunits bracket_node::width(){  return max_width;}int node::nspaces(){  return 0;}int node::merge_space(hunits){  return 0;}#if 0space_node *space_node::free_list = 0;void *space_node::operator new(size_t n){  assert(n == sizeof(space_node));  if (!free_list) {    free_list = (space_node *)new char[sizeof(space_node)*BLOCK];    for (int i = 0; i < BLOCK - 1; i++)      free_list[i].next = free_list + i + 1;    free_list[BLOCK-1].next = 0;  }  space_node *p = free_list;  free_list = (space_node *)(free_list->next);  p->next = 0;  return p;}inline void space_node::operator delete(void *p){  if (p) {    ((space_node *)p)->next = free_list;    free_list = (space_node *)p;  }}#endifspace_node::space_node(hunits nn, node *p) : node(p), n(nn), set(0){}space_node::space_node(hunits nn, int s, node *p) : node(p), n(nn), set(s){}#if 0space_node::~space_node(){}#endifnode *space_node::copy(){  return new space_node(n, set);}int space_node::nspaces(){  return set ? 0 : 1;}int space_node::merge_space(hunits h){  n += h;  return 1;}hunits space_node::width(){  return n;}void node::spread_space(int*, hunits*){}void space_node::spread_space(int *nspaces, hunits *desired_space){  if (!set) {    assert(*nspaces > 0);    if (*nspaces == 1) {      n += *desired_space;      *desired_space = H0;    }    else {      hunits extra = *desired_space / *nspaces;      *desired_space -= extra;      n += extra;    }    *nspaces -= 1;    set = 1;  }}void node::freeze_space(){}void space_node::freeze_space(){  set = 1;}diverted_space_node::diverted_space_node(vunits d, node *p): node(p), n(d){}node *diverted_space_node::copy(){  return new diverted_space_node(n);}diverted_copy_file_node::diverted_copy_file_node(symbol s, node *p): node(p), filename(s){}node *diverted_copy_file_node::copy(){  return new diverted_copy_file_node(filename);}int node::ends_sentence(){  return 0;}int kern_pair_node::ends_sentence(){  switch (n2->ends_sentence()) {  case 0:    return 0;  case 1:    return 1;  case 2:    break;  default:    assert(0);  }  return n1->ends_sentence();}int node_list_ends_sentence(node *n){  for (; n != 0; n = n->next)    switch (n->ends_sentence()) {    case 0:      return 0;    case 1:      return 1;    case 2:      break;    default:      assert(0);    }  return 2;}    int dbreak_node::ends_sentence(){  return node_list_ends_sentence(none);}int node::overlaps_horizontally(){  return 0;}int node::overlaps_vertically(){  return 0;}int node::discardable(){  return 0;}int space_node::discardable(){  return set ? 0 : 1;}vunits node::vertical_width(){  return V0;}vunits vline_node::vertical_width(){  return x;}vunits vmotion_node::vertical_width(){  return n;}int node::character_type(){  return 0;}hunits node::subscript_correction(){  return H0;}hunits node::italic_correction(){  return H0;}hunits node::left_italic_correction(){  return H0;}hunits node::skew(){  return H0;}/* vertical_extent methods */void node::vertical_extent(vunits *min, vunits *max){  vunits v = vertical_width();  if (v < V0) {    *min = v;    *max = V0;  }  else {    *max = v;    *min = V0;  }}void vline_node::vertical_extent(vunits *min, vunits *max){  if (n == 0)    node::vertical_extent(min, max);  else {    vunits cmin, cmax;    n->vertical_extent(&cmin, &cmax);    vunits h = n->size();    if (x < V0) {      if (-x < h) {	*min = x;	*max = V0;      }      else {	// we print the first character and then move up, so	*max = cmax;	// we print the last character and then move up h	*min = cmin + h;	if (*min > V0)	  *min = V0;	*min += x;      }    }    else {      if (x < h) {	*max = x;	*min = V0;      }      else {	// we move down by h and then print the first character, so	*min = cmin + h;	if (*min > V0)	  *min = V0;	*max = x + cmax;      }    }  }}/* ascii_print methods */static void ascii_print_reverse_node_list(ascii_output_file *ascii, node *n){  if (n == 0)    return;  ascii_print_reverse_node_list(ascii, n->next);  n->ascii_print(ascii);}void dbreak_node::ascii_print(ascii_output_file *ascii){  ascii_print_reverse_node_list(ascii, none);}void kern_pair_node::ascii_print(ascii_output_file *ascii){  n1->ascii_print(ascii);  n2->ascii_print(ascii);}void node::ascii_print(ascii_output_file *){}void space_node::ascii_print(ascii_output_file *ascii){  if (!n.is_zero())    ascii->outc(' ');}void hmotion_node::ascii_print(ascii_output_file *ascii){  // this is pretty arbitrary  if (n >= points_to_units(2))    ascii->outc(' ');}void space_char_hmotion_node::ascii_print(ascii_output_file *ascii)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -