void tex::show_cur_page() { ptr p, q; int t; if (page_head == page_tail) return; print_nl("### current page:"); if (output_active) print(" (held over for next output)"); show_box(link(page_head)); if (page_contents > EMPTY) { print_nl("total height "); print_totals(); print_nl(" goal height "); print_scaled(page_goal); p = link(page_ins_head); while (p != page_ins_head) { print_ln(); print_esc("insert"); t = subtype(p); print_int(t); print(" adds "); t = x_over_n(page_ins_height(p), 1000) * count(t); print_scaled(t); if (type(p) == SPLIT_UP) { q = page_head; t = 0; do { q = link(q); if (type(q) == INS_NODE && subtype(q) == subtype(p)) incr(t); } while (q != broken_ins(p)); print(", #"); print_int(t); print(" might split"); } p = link(p); } } }
bool tex::insert_box(ptr p) { bool wait; ptr q, r, t; int n; q = link(page_ins_head); while (subtype(q) != subtype(p)) q = link(q); if (best_ins_ptr(q) == null) return TRUE; wait = FALSE; r = last_ins_ptr(q); link(r) = ins_ptr(p); if (best_ins_ptr(q) == p) { if (type(q) == SPLIT_UP && broken_ins(q) == p && broken_ptr(q) != null) { while (link(r) != broken_ptr(q)) r = link(r); link(r) = null; split_top_skip = split_top_ptr(p); ins_ptr(p) = prune_page_top(broken_ptr(q)); if (ins_ptr(p) != null) { t = vpack(ins_ptr(p), 0, ADDITIONAL); ins_height(p) = box_height(t) + box_depth(t); free_node(t, BOX_NODE_SIZE); wait = TRUE; } } best_ins_ptr(q) = null; n = subtype(q); t = list_ptr(box(n)); free_node(box(n), BOX_NODE_SIZE); box(n) = vpack(t, 0, ADDITIONAL); } else { while (link(r) != null) r = link(r); last_ins_ptr(q) = r; } return wait; }
void tex::insert_page(ptr p) { int n; ptr q, r; scal h, w; scal delta; if (page_contents == EMPTY) freeze_page_specs(INSERTS_ONLY); n = subtype(p); r = page_ins_head; while (n >= subtype(link(r))) r = link(r); if (subtype(r) != n) { q = new_node(PAGE_INS_NODE_SIZE); link(q) = link(r); r = link(r) = q; subtype(r) = n; type(r) = INSERTING; ensure_vbox(n); page_ins_height(r) = (box(n) == null) ? 0 : box_height(box(n)) + box_depth(box(n)); best_ins_ptr(r) = null; q = skip(n); if (count(n) == 1000) h = page_ins_height(r); else h = x_over_n(page_ins_height(r), 1000) * count(n); page_goal -= h + glue_width(q); page_so_far[2 + stretch_order(q)] += stretch(q); page_shrink += shrink(q); if (shrink_order(q) != NORMAL && shrink(q) != 0) { print_err("Infinite glue shrinkage inserted from "); print_esc("skip"); print_int(n); help_inf_shrink_ins(); error(); } } if (type(r) == SPLIT_UP) { insert_penalties += float_cost(p); return; } last_ins_ptr(r) = p; delta = page_goal - page_total - page_depth + page_shrink; if (count(n) == 1000) { h = ins_height(p); } else { h = x_over_n(ins_height(p), 1000) * count(n); } if ((h <= 0 || h <= delta) && ins_height(p) + page_ins_height(r) <= dimen(n)) { page_goal -= h; page_ins_height(r) += ins_height(p); } else { if (count(n) <= 0) { w = MAX_DIMEN; } else { w = page_goal - page_total - page_depth; if (count(n) != 1000) { w = x_over_n(w, count(n)) * 1000; } } if (w > dimen(n) - page_ins_height(r)) { w = dimen(n) - page_ins_height(r); } q = vert_break(ins_ptr(p), w, ins_depth(p)); page_ins_height(r) += best_height_plus_depth; if (tracing_pages > 0) show_split(n, w, q); if (count(n) != 1000) { best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * count(n); } page_goal -= best_height_plus_depth; type(r) = SPLIT_UP; broken_ptr(r) = q; broken_ins(r) = p; if (q == null) { insert_penalties += EJECT_PENALTY; } else if (type(q) == PENALTY_NODE) { insert_penalties += penalty(q); } } }
void show_activities(void) { /*tex Index into |nest|: */ int p; /*tex The mode: */ int m; /*tex For showing the current page: */ halfword q, r; /*tex Ditto: */ int t; tprint_nl(""); print_ln(); for (p = nest_ptr; p >= 0; p--) { m = nest[p].mode_field; tprint_nl("### "); print_mode(m); tprint(" entered at line "); print_int(abs(nest[p].ml_field)); if (nest[p].ml_field < 0) tprint(" (\\output routine)"); if (p == 0) { /*tex Show the status of the current page */ if (page_head != page_tail) { tprint_nl("### current page:"); if (output_active) tprint(" (held over for next output)"); show_box(vlink(page_head)); if (page_contents > empty) { tprint_nl("total height "); print_totals(); tprint_nl(" goal height "); print_scaled(page_goal); r = vlink(page_ins_head); while (r != page_ins_head) { print_ln(); tprint_esc("insert"); t = subtype(r); print_int(t); tprint(" adds "); if (count(t) == 1000) t = height(r); else t = x_over_n(height(r), 1000) * count(t); print_scaled(t); if (type(r) == split_up_node) { q = page_head; t = 0; do { q = vlink(q); if ((type(q) == ins_node) && (subtype(q) == subtype(r))) incr(t); } while (q != broken_ins(r)); tprint(", #"); print_int(t); tprint(" might split"); } r = vlink(r); } } } if (vlink(contrib_head) != null) tprint_nl("### recent contributions:"); } show_box(vlink(nest[p].head_field)); /*tex Show the auxiliary field, |a|. */ switch (abs(m) / (max_command_cmd + 1)) { case 0: tprint_nl("prevdepth "); if (nest[p].prev_depth_field <= ignore_depth) tprint("ignored"); else print_scaled(nest[p].prev_depth_field); if (nest[p].pg_field != 0) { tprint(", prevgraf "); print_int(nest[p].pg_field); if (nest[p].pg_field != 1) tprint(" lines"); else tprint(" line"); } break; case 1: tprint_nl("spacefactor "); print_int(nest[p].space_factor_field); break; case 2: if (nest[p].incompleat_noad_field != null) { tprint("this will be denominator of:"); show_box(nest[p].incompleat_noad_field); } break; } } }