From db25374e65d39dc254ddce11b40ad4a95e6a385b Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 27 Dec 2022 21:56:16 +0100 Subject: 2022-12-27 21:04:00 --- source/luametatex/source/mp/mpc/mp.c | 6 + source/luametatex/source/mp/mpw/mp.w | 7 + source/luametatex/source/tex/texadjust.c | 2 +- source/luametatex/source/tex/texalign.c | 351 +++++++++++++++++++++++++- source/luametatex/source/tex/texbuildpage.c | 2 +- source/luametatex/source/tex/texcommands.c | 1 + source/luametatex/source/tex/texdumpdata.c | 2 +- source/luametatex/source/tex/texdumpdata.h | 2 +- source/luametatex/source/tex/texequivalents.h | 3 + source/luametatex/source/tex/texinserts.c | 2 +- source/luametatex/source/tex/texmaincontrol.c | 27 +- source/luametatex/source/tex/texnesting.c | 4 +- source/luametatex/source/tex/texnodes.h | 13 +- source/luametatex/source/tex/texpackaging.c | 32 +-- source/luametatex/source/tex/texpackaging.h | 35 +++ source/luametatex/source/tex/texrules.c | 2 +- source/luametatex/source/tex/textypes.h | 1 - 17 files changed, 419 insertions(+), 73 deletions(-) (limited to 'source') diff --git a/source/luametatex/source/mp/mpc/mp.c b/source/luametatex/source/mp/mpc/mp.c index a79f7db3f..032d8f34a 100644 --- a/source/luametatex/source/mp/mpc/mp.c +++ b/source/luametatex/source/mp/mpc/mp.c @@ -17038,6 +17038,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_times_operation: + TIMES: if ((mp->cur_exp.type < mp_color_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, mp_times_operation); } else if ((mp->cur_exp.type == mp_known_type) || (p->type == mp_known_type)) { @@ -17222,6 +17223,11 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_do_edges_trans(mp, p, (int) c); mp_finish_binary(mp, old_p, old_exp); return; + case mp_color_type: + case mp_cmykcolor_type: + if (c == mp_scaled_operation) { + goto TIMES; + } default: mp_bad_binary(mp, p, (int) c); break; diff --git a/source/luametatex/source/mp/mpw/mp.w b/source/luametatex/source/mp/mpw/mp.w index fe47d3d82..6acecd35b 100644 --- a/source/luametatex/source/mp/mpw/mp.w +++ b/source/luametatex/source/mp/mpw/mp.w @@ -24713,6 +24713,7 @@ static void mp_do_binary (MP mp, mp_node p, int c) } break; case mp_times_operation: + TIMES: if ((mp->cur_exp.type < mp_color_type) || (p->type < mp_color_type)) { mp_bad_binary(mp, p, mp_times_operation); } else if ((mp->cur_exp.type == mp_known_type) || (p->type == mp_known_type)) { @@ -24904,6 +24905,12 @@ static void mp_do_binary (MP mp, mp_node p, int c) mp_do_edges_trans(mp, p, (int) c); mp_finish_binary(mp, old_p, old_exp); return; + case mp_color_type: + case mp_cmykcolor_type: + if (c == mp_scaled_operation) { + goto TIMES; + } + /* fall through */ default: mp_bad_binary(mp, p, (int) c); break; diff --git a/source/luametatex/source/tex/texadjust.c b/source/luametatex/source/tex/texadjust.c index cb2f8c247..882227ec2 100644 --- a/source/luametatex/source/tex/texadjust.c +++ b/source/luametatex/source/tex/texadjust.c @@ -146,7 +146,7 @@ void tex_run_vadjust(void) tex_normal_paragraph(vadjust_par_context); tex_push_nest(); cur_list.mode = -vmode; - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; } void tex_finish_vadjust_group(void) diff --git a/source/luametatex/source/tex/texalign.c b/source/luametatex/source/tex/texalign.c index ac7712870..f35bb50b5 100644 --- a/source/luametatex/source/tex/texalign.c +++ b/source/luametatex/source/tex/texalign.c @@ -205,6 +205,19 @@ Todo: lefttabskip righttabskip middletabskip */ +typedef struct alignment_row_state { + halfword orientation; + scaled xoffset; + scaled yoffset; + scaled xmove; + scaled ymove; + halfword shift; + halfword source; + halfword target; + halfword anchor; + halfword attrlist; +} alignment_row_state; + typedef struct alignment_state_info { halfword cur_align; /*tex The current position in the preamble list. */ halfword cur_span; /*tex The start of the currently spanned columns in the preamble list. */ @@ -223,11 +236,14 @@ typedef struct alignment_state_info { halfword no_align_level; halfword no_tab_skips; halfword attr_list; - halfword cell_source; - halfword wrap_source; + halfword cell_source; + halfword wrap_source; /*tex There's also a field in the row_state. */ halfword callback; // halfword reverse; // todo // halfword discard_skips; // todo + halfword row_state_set; + halfword padding; + alignment_row_state row_state; } alignment_state_info ; static alignment_state_info lmt_alignment_state = { @@ -253,8 +269,38 @@ static alignment_state_info lmt_alignment_state = { .callback = 0, // .reverse = 0, // .discard_skips = 0, + .row_state_set = 0, + .padding = 0, + .row_state = { + .attrlist = null, + .orientation = 0, + .xoffset = 0, + .yoffset = 0, + .xmove = 0, + .ymove = 0, + .shift = 0, + .source = 0, + .target = 0, + .anchor = 0, + } }; +static void tex_aux_wipe_row_state(void) +{ + delete_attribute_reference(lmt_alignment_state.row_state.attrlist); + lmt_alignment_state.row_state.attrlist = null; + lmt_alignment_state.row_state.orientation = 0; + lmt_alignment_state.row_state.xoffset = 0; + lmt_alignment_state.row_state.yoffset = 0; + lmt_alignment_state.row_state.xmove = 0; + lmt_alignment_state.row_state.ymove = 0; + lmt_alignment_state.row_state.shift = 0; + lmt_alignment_state.row_state.source = 0; + lmt_alignment_state.row_state.target = 0; + lmt_alignment_state.row_state.anchor = 0; + lmt_alignment_state.row_state_set = 0; +} + /*tex We could as well save these in the alignment stack. */ typedef enum saved_align_items { @@ -313,6 +359,7 @@ static void tex_aux_push_alignment(void) { /*tex The new alignment stack node: */ halfword p = tex_new_node(align_stack_node, 0); + /* todo: just a memory copy */ align_stack_align_ptr(p) = lmt_alignment_state.align_ptr; align_stack_cur_align(p) = lmt_alignment_state.cur_align; align_stack_preamble(p) = preamble; @@ -331,6 +378,18 @@ static void tex_aux_push_alignment(void) align_stack_cur_pre_migrate_tail(p) = lmt_alignment_state.cur_pre_migrate_tail; align_stack_no_tab_skips(p) = lmt_alignment_state.no_tab_skips; align_stack_attr_list(p) = lmt_alignment_state.attr_list; + /* */ + align_stack_row_attrlist(p) = lmt_alignment_state.row_state.attrlist; + align_stack_row_orientation(p) = lmt_alignment_state.row_state.orientation; + align_stack_row_yoffset(p) = lmt_alignment_state.row_state.xoffset; + align_stack_row_xoffset(p) = lmt_alignment_state.row_state.yoffset; + align_stack_row_ymove(p) = lmt_alignment_state.row_state.xmove; + align_stack_row_xmove(p) = lmt_alignment_state.row_state.ymove; + align_stack_row_shift(p) = lmt_alignment_state.row_state.shift; + align_stack_row_source(p) = lmt_alignment_state.row_state.source; + align_stack_row_target(p) = lmt_alignment_state.row_state.target; + align_stack_row_anchor(p) = lmt_alignment_state.row_state.anchor; + /* */ lmt_alignment_state.align_ptr = p; lmt_alignment_state.cur_post_adjust_head = tex_new_temp_node(); lmt_alignment_state.cur_pre_adjust_head = tex_new_temp_node(); @@ -339,6 +398,8 @@ static void tex_aux_push_alignment(void) /* */ lmt_alignment_state.cell_source = 0; lmt_alignment_state.wrap_source = 0; + /* todo: put in align_stack, also wipe attr if needed */ + tex_aux_wipe_row_state(); } static void tex_aux_pop_alignment(void) @@ -367,6 +428,18 @@ static void tex_aux_pop_alignment(void) lmt_alignment_state.cur_pre_migrate_tail = align_stack_cur_pre_migrate_tail(p); lmt_alignment_state.no_tab_skips = align_stack_no_tab_skips(p); lmt_alignment_state.attr_list = align_stack_attr_list(p); + /* */ + lmt_alignment_state.row_state.attrlist = align_stack_row_attrlist(p); + lmt_alignment_state.row_state.orientation = align_stack_row_orientation(p); + lmt_alignment_state.row_state.xoffset = align_stack_row_yoffset(p); + lmt_alignment_state.row_state.yoffset = align_stack_row_xoffset(p); + lmt_alignment_state.row_state.xmove = align_stack_row_ymove(p); + lmt_alignment_state.row_state.ymove = align_stack_row_xmove(p); + lmt_alignment_state.row_state.shift = align_stack_row_shift(p); + lmt_alignment_state.row_state.source = align_stack_row_source(p); + lmt_alignment_state.row_state.target = align_stack_row_target(p); + lmt_alignment_state.row_state.anchor = align_stack_row_anchor(p); + /* */ tex_flush_node(p); } @@ -590,7 +663,154 @@ static void tex_aux_trace_no_align(const char *s) static void tex_aux_run_no_align(void) { - tex_scan_left_brace(); + /* */ + int brace = 0; + int done = lmt_alignment_state.row_state_set; + while (1) { + int add = 0; + AGAIN: + switch (tex_scan_character("atrsoxyATRSOXY", 1, 1, 1)) { + case 0: + goto DONE; + case 't': case 'T': + if (tex_scan_mandate_keyword("target", 1)) { + lmt_alignment_state.row_state.target = tex_scan_int(1, NULL); + done = 1; + } + break; + case 'a': case 'A': + switch (tex_scan_character("ntdNTD", 0, 0, 0)) { + case 'd': case 'D': + if (tex_scan_mandate_keyword("add", 2)) { + add = 1; + goto AGAIN; + } + break; + case 't': case 'T': + if (tex_scan_mandate_keyword("attr", 2)) { + halfword i = tex_scan_attribute_register_number(); + halfword v = tex_scan_int(1, NULL); + if (eq_value(register_attribute_location(i)) != v) { + if (lmt_alignment_state.row_state.attrlist) { + lmt_alignment_state.row_state.attrlist = tex_patch_attribute_list(lmt_alignment_state.row_state.attrlist, i, v); + } else { + lmt_alignment_state.row_state.attrlist = tex_copy_attribute_list_set(tex_current_attribute_list(), i, v); + } + done = 1; + } + } + break; + case 'n': case 'N': + if (tex_scan_mandate_keyword("anchor", 2)) { + switch (tex_scan_character("sS", 0, 0, 0)) { + case 's': case 'S': + lmt_alignment_state.row_state.anchor = tex_scan_anchors(0); + break; + default: + lmt_alignment_state.row_state.anchor = tex_scan_anchor(0); + break; + } + done = 1; + } + break; + default: + tex_aux_show_keyword_error("attr|anchor|add"); + goto DONE; + } + break; + case 'r': case 'R': + if (tex_scan_mandate_keyword("reset", 1)) { + tex_aux_wipe_row_state(); + done = 0; + } + break; + case 's': case 'S': + switch (tex_scan_character("hoHO", 0, 0, 0)) { + case 'h': case 'H': + if (tex_scan_mandate_keyword("shift", 2)) { + lmt_alignment_state.row_state.shift = (add ? lmt_alignment_state.row_state.shift : 0) + + tex_scan_dimen(0, 0, 0, 0, NULL); + done = 1; + } + break; + case 'o': case 'O': + if (tex_scan_mandate_keyword("source", 2)) { + lmt_alignment_state.row_state.source = tex_scan_int(1, NULL); + done = 1; + } + break; + default: + tex_aux_show_keyword_error("shift|source"); + goto DONE; + } + break; + case 'o': case 'O': + if (tex_scan_mandate_keyword("orientation", 1)) { + lmt_alignment_state.row_state.orientation = tex_scan_orientation(0); + done = 1; + } + break; + case 'x': case 'X': + switch (tex_scan_character("omOM", 0, 0, 0)) { + case 'o': case 'O' : + if (tex_scan_mandate_keyword("xoffset", 2)) { + lmt_alignment_state.row_state.xoffset = (add ? lmt_alignment_state.row_state.xoffset : 0) + + tex_scan_dimen(0, 0, 0, 0, NULL); + done = 1; + } + break; + case 'm': case 'M' : + if (tex_scan_mandate_keyword("xmove", 2)) { + lmt_alignment_state.row_state.xmove = (add ? lmt_alignment_state.row_state.xmove : 0) + + tex_scan_dimen(0, 0, 0, 0, NULL); + done = 1; + } + break; + default: + tex_aux_show_keyword_error("xoffset|xmove"); + goto DONE; + } + break; + case 'y': case 'Y': + switch (tex_scan_character("omOM", 0, 0, 0)) { + case 'o': case 'O' : + if (tex_scan_mandate_keyword("yoffset", 2)) { + lmt_alignment_state.row_state.yoffset = (add ? lmt_alignment_state.row_state.yoffset : 0) + + tex_scan_dimen(0, 0, 0, 0, NULL); + done = 1; + } + break; + case 'm': case 'M' : + if (tex_scan_mandate_keyword("ymove", 2)) { + lmt_alignment_state.row_state.ymove = (add ? lmt_alignment_state.row_state.ymove : 0) + + tex_scan_dimen(0, 0, 0, 0, NULL); + done = 1; + } + break; + default: + tex_aux_show_keyword_error("yoffset|ymove"); + goto DONE; + } + break; + case '{': + brace = 1; + goto DONE; + default: + goto DONE; + } + add = 0; + } + DONE: + lmt_alignment_state.row_state_set = done; + if (! lmt_alignment_state.row_state.attrlist) { + /* this alse sets the reference when not yet set */ + lmt_alignment_state.row_state.attrlist = tex_current_attribute_list(); + } + add_attribute_reference(lmt_alignment_state.row_state.attrlist); + /* */ + if (! brace) { + tex_scan_left_brace(); + } tex_new_save_level(no_align_group); ++lmt_alignment_state.no_align_level; tex_aux_trace_no_align("entering"); @@ -598,6 +818,7 @@ static void tex_aux_run_no_align(void) tex_normal_paragraph(no_align_par_context); } } + static int tex_aux_nested_no_align(void) { int state = lmt_alignment_state.no_align_level > 0; @@ -846,7 +1067,7 @@ static void tex_aux_initialize_span(halfword p) if (cur_list.mode == -hmode) { cur_list.space_factor = 1000; } else { - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; tex_normal_paragraph(span_par_context); } lmt_alignment_state.cur_span = p; @@ -864,8 +1085,8 @@ static void tex_aux_initialize_span(halfword p) static void tex_aux_initialize_row(void) { tex_push_nest(); - cur_list.mode = (- hmode - vmode) - cur_list.mode; /* weird code */ - if (cur_list.mode == -hmode) { + cur_list.mode = (- hmode - vmode) - cur_list.mode; /* weird code : - 3 - cur_list.mode : so a buogus line */ + if (cur_list.mode == -hmode) { cur_list.space_factor = 0; } else { cur_list.prev_depth = 0; @@ -882,6 +1103,7 @@ static void tex_aux_initialize_row(void) lmt_alignment_state.cur_post_migrate_tail = lmt_alignment_state.cur_post_migrate_head; lmt_alignment_state.cur_pre_migrate_tail = lmt_alignment_state.cur_pre_migrate_head; tex_aux_initialize_span(lmt_alignment_state.cur_align); + /* todo: wipe attr */ } /*tex @@ -1200,12 +1422,114 @@ static void tex_aux_finish_row(void) tex_tail_append(row); cur_list.space_factor = 1000; } + /*tex + Currently this one can be overloaded by the one set on the row via the noalign trickery + which is probably okay. + */ if (lmt_alignment_state.wrap_source) { box_source_anchor(row) = lmt_alignment_state.wrap_source; - tex_set_box_geometry(row, anchor_geometry); + box_geometry(row) |= anchor_geometry; } + /* + This also wipes (list) fields that we might set below, like |xoffset| that is used for + specific alignments purposes. + */ tex_aux_change_list_type(row, unset_node); - tex_attach_attribute_list_attribute(row, lmt_alignment_state.attr_list); + /* */ + tex_attach_attribute_list_attribute(row, lmt_alignment_state.row_state.attrlist ? + lmt_alignment_state.row_state.attrlist : lmt_alignment_state.attr_list); + /*tex + The next blob of code duplicates some of packaging code but because we fetch from different + fields we cannot share. Maybe, when I add this kind of features to other mechanisms (how + about cells!) then the next code will become some helper. + */ + if (lmt_alignment_state.row_state_set) { + halfword orientation = lmt_alignment_state.row_state.orientation; + halfword anchor = lmt_alignment_state.row_state.anchor; + scaled shift = lmt_alignment_state.row_state.shift; + halfword source = lmt_alignment_state.row_state.source; + halfword target = lmt_alignment_state.row_state.target; + scaled xoffset = lmt_alignment_state.row_state.xoffset; + scaled yoffset = lmt_alignment_state.row_state.yoffset; + scaled xmove = lmt_alignment_state.row_state.xmove; + scaled ymove = lmt_alignment_state.row_state.ymove; + singleword geometry = box_geometry(row); + /* */ + if (xoffset || yoffset || xmove || ymove) { + geometry |= offset_geometry; + } + if (orientation) { + geometry |= orientation_geometry; + } + /* */ + if (tex_has_geometry(geometry, offset_geometry) || tex_has_geometry(geometry, orientation_geometry)) { + scaled wd = box_width(row); + scaled ht = box_height(row); + scaled dp = box_depth(row); + if (xmove) { + xoffset = tex_aux_checked_dimen1(xoffset + xmove); + wd = tex_aux_checked_dimen2(wd + xmove); + set_box_package_state(row, package_dimension_size_set); /* safeguard */ + } + if (ymove) { + yoffset = tex_aux_checked_dimen1(yoffset + ymove); + ht = tex_aux_checked_dimen2(ht + ymove); + dp = tex_aux_checked_dimen2(dp - ymove); + } + box_w_offset(row) = wd; + box_h_offset(row) = ht; + box_d_offset(row) = dp; + switch (orientationonly(orientation)) { + case 0 : /* 0 */ + break; + case 2 : /* 180 */ + box_height(row) = dp; + box_depth(row) = ht; + geometry |= orientation_geometry; + break; + case 1 : /* 90 */ + case 3 : /* 270 */ + box_width(row) = ht + dp; + box_height(row) = wd; + box_depth(row) = 0; + geometry |= orientation_geometry; + break; + case 4 : /* 0 */ + box_height(row) = ht + dp; + box_depth(row) = 0; + geometry |= orientation_geometry; + break; + case 5 : /* 180 */ + box_height(row) = 0; + box_depth(row) = ht + dp; + geometry |= orientation_geometry; + break; + default : + break; + } + if (xoffset || yoffset) { + box_x_offset(row) = xoffset; + box_y_offset(row) = yoffset; + geometry |= offset_geometry; + } + } + if (shift) { + box_shift_amount(row) = shift; + } + if (source || target) { + box_source_anchor(row) = source; + box_target_anchor(row) = target; + geometry |= anchor_geometry; + } + box_anchor(row) = anchor; + box_orientation(row) = orientation; + box_geometry(row) = (singleword) geometry; + } + /*tex + We no longer need the row state so best wipe it now! Then we're ready for the next row. + */ + tex_aux_wipe_row_state(); + /* */ if (every_cr_par) { tex_begin_token_list(every_cr_par, every_cr_text); } @@ -1438,10 +1762,12 @@ static void tex_aux_finish_align(void) halfword preptr; halfword colptr; if (cur_list.mode == -vmode) { - tex_aux_change_list_type(rowptr, hlist_node); + /* tex_aux_change_list_type(rowptr, hlist_node); */ /* too much */ + node_type(rowptr) = hlist_node; box_width(rowptr) = box_width(preroll); } else { - tex_aux_change_list_type(rowptr, vlist_node); + /* tex_aux_change_list_type(rowptr, vlist_node); */ /* too much */ + node_type(rowptr) = vlist_node; box_height(rowptr) = box_height(preroll); } node_subtype(rowptr) = align_row_list; @@ -1609,6 +1935,11 @@ static void tex_aux_finish_align(void) if (reverse) { box_list(rowptr) = tex_reversed_node_list(box_list(rowptr)); } + if (has_box_package_state(rowptr, package_dimension_size_set)) { + if (box_w_offset(rowptr) > box_width(rowptr)) { + box_width(rowptr) = box_w_offset(rowptr); + } + } } break; case rule_node: diff --git a/source/luametatex/source/tex/texbuildpage.c b/source/luametatex/source/tex/texbuildpage.c index 0cf8b70e9..fb7a2dde5 100644 --- a/source/luametatex/source/tex/texbuildpage.c +++ b/source/luametatex/source/tex/texbuildpage.c @@ -1131,7 +1131,7 @@ static void tex_aux_fire_up(halfword c) ++lmt_page_builder_state.dead_cycles; tex_push_nest(); cur_list.mode = -vmode; - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; cur_list.mode_line = -lmt_input_state.input_line; tex_begin_token_list(output_routine_par, output_text); tex_new_save_level(output_group); diff --git a/source/luametatex/source/tex/texcommands.c b/source/luametatex/source/tex/texcommands.c index eeef6b9f6..615db76c9 100644 --- a/source/luametatex/source/tex/texcommands.c +++ b/source/luametatex/source/tex/texcommands.c @@ -306,6 +306,7 @@ void tex_initialize_commands(void) tex_primitive(luatex_command, "pxdimen", internal_dimen_cmd, px_dimen_code, internal_dimen_base); tex_primitive(luatex_command, "tabsize", internal_dimen_cmd, tab_size_code, internal_dimen_base); tex_primitive(luatex_command, "pageextragoal", internal_dimen_cmd, page_extra_goal_code, internal_dimen_base); + tex_primitive(luatex_command, "ignoredepthcriterium", internal_dimen_cmd, ignore_depth_criterium_code, internal_dimen_base); /* mostly for myself, tutorials etc */ /*tex Probably never used with \UNICODE\ omnipresent now: */ diff --git a/source/luametatex/source/tex/texdumpdata.c b/source/luametatex/source/tex/texdumpdata.c index dfac980c5..1500ec78b 100644 --- a/source/luametatex/source/tex/texdumpdata.c +++ b/source/luametatex/source/tex/texdumpdata.c @@ -287,7 +287,7 @@ static void tex_aux_undump_fmt_data(dumpstream f) /*tex This should go elsewhere. */ - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; } /* diff --git a/source/luametatex/source/tex/texdumpdata.h b/source/luametatex/source/tex/texdumpdata.h index 6a9eb5fa4..31d422784 100644 --- a/source/luametatex/source/tex/texdumpdata.h +++ b/source/luametatex/source/tex/texdumpdata.h @@ -55,7 +55,7 @@ */ -# define luametatex_format_fingerprint 680 +# define luametatex_format_fingerprint 681 /* These end up in the string pool. */ diff --git a/source/luametatex/source/tex/texequivalents.h b/source/luametatex/source/tex/texequivalents.h index 82e500fb3..ca32280ef 100644 --- a/source/luametatex/source/tex/texequivalents.h +++ b/source/luametatex/source/tex/texequivalents.h @@ -636,6 +636,7 @@ typedef enum dimen_codes { px_dimen_code, tab_size_code, page_extra_goal_code, + ignore_depth_criterium_code, /*tex total number of dimension parameters */ number_dimen_pars, } dimen_codes; @@ -1359,6 +1360,8 @@ extern void tex_forced_word_define (int g, halfword p, singleword flag, halfword # define split_max_depth_par dimen_parameter(split_max_depth_code) # define overfull_rule_par dimen_parameter(overfull_rule_code) # define box_max_depth_par dimen_parameter(box_max_depth_code) +# define ignore_depth_criterium_par dimen_parameter(ignore_depth_criterium_code) + # define top_skip_par glue_parameter(top_skip_code) # define split_top_skip_par glue_parameter(split_top_skip_code) diff --git a/source/luametatex/source/tex/texinserts.c b/source/luametatex/source/tex/texinserts.c index 3d634dd39..4ff07625d 100644 --- a/source/luametatex/source/tex/texinserts.c +++ b/source/luametatex/source/tex/texinserts.c @@ -451,7 +451,7 @@ void tex_run_insert(void) tex_normal_paragraph(insert_par_context); tex_push_nest(); cur_list.mode = -vmode; - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; } void tex_finish_insert_group(void) diff --git a/source/luametatex/source/tex/texmaincontrol.c b/source/luametatex/source/tex/texmaincontrol.c index 62b6d1e1e..11007d9cd 100644 --- a/source/luametatex/source/tex/texmaincontrol.c +++ b/source/luametatex/source/tex/texmaincontrol.c @@ -64,32 +64,6 @@ main_control_state_info lmt_main_control_state = { .quit_loop = 0, }; -/*tex - A few helpers: -*/ - -inline static scaled tex_aux_checked_dimen1(scaled v) -{ - if (v > max_dimen) { - return max_dimen; - } else if (v < -max_dimen) { - return -max_dimen; - } else { - return v; - } -} - -inline static scaled tex_aux_checked_dimen2(scaled v) -{ - if (v > max_dimen) { - return max_dimen; - } else if (v < 0) { - return 0; - } else { - return v; - } -} - /*tex These two helpers, of which the second one is still experimental, actually belong in another file so then might be moved. Watch how the first one has the |unsave| call! @@ -6569,6 +6543,7 @@ void tex_initialize_variables(void) math_left_class_par = unset_noad_class; math_right_class_par = unset_noad_class; variable_family_par = -1, + ignore_depth_criterium_par = ignore_depth; aux_get_date_and_time(&time_par, &day_par, &month_par, &year_par, &lmt_engine_state.utc_time); } } diff --git a/source/luametatex/source/tex/texnesting.c b/source/luametatex/source/tex/texnesting.c index f281eee2e..f29bfe0a2 100644 --- a/source/luametatex/source/tex/texnesting.c +++ b/source/luametatex/source/tex/texnesting.c @@ -247,7 +247,7 @@ void tex_initialize_nesting(void) cur_list.delim = null; cur_list.prev_graf = 0; cur_list.mode_line = 0; - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; cur_list.space_factor = 1000; cur_list.incomplete_noad = null; cur_list.direction_stack = null; @@ -389,7 +389,7 @@ void tex_show_activities(void) switch (abs(n.mode) / (max_command_cmd + 1)) { case 0: { - if (n.prev_depth <= ignore_depth) { + if (n.prev_depth <= ignore_depth_criterium_par) { tex_print_format("%l[prevdepth ignored"); } else { tex_print_format("%l[prevdepth %D", n.prev_depth, pt_unit); diff --git a/source/luametatex/source/tex/texnodes.h b/source/luametatex/source/tex/texnodes.h index 9cc1cbb39..3c9d54452 100644 --- a/source/luametatex/source/tex/texnodes.h +++ b/source/luametatex/source/tex/texnodes.h @@ -1412,7 +1412,7 @@ inline static int tex_same_mathspec(halfword a, halfword b) Here are some more stack related nodes. */ -# define align_stack_node_size 10 +# define align_stack_node_size 15 # define align_stack_align_ptr(a) vinfo(a,1) # define align_stack_cur_align(a) vlink(a,1) # define align_stack_preamble(a) vinfo(a,2) @@ -1432,6 +1432,17 @@ inline static int tex_same_mathspec(halfword a, halfword b) # define align_stack_no_tab_skips(a) vinfo(a,9) # define align_stack_attr_list(a) vlink(a,9) +# define align_stack_row_attrlist(a) vinfo(a,10) +# define align_stack_row_orientation(a) vlink(a,10) +# define align_stack_row_yoffset(a) vinfo(a,11) +# define align_stack_row_xoffset(a) vlink(a,11) +# define align_stack_row_ymove(a) vinfo(a,12) +# define align_stack_row_xmove(a) vlink(a,12) +# define align_stack_row_shift(a) vinfo(a,13) +# define align_stack_row_source(a) vlink(a,13) +# define align_stack_row_target(a) vinfo(a,14) +# define align_stack_row_anchor(a) vlink(a,14) + /*tex If nodes are for nesting conditionals. We have more state information that in (for instance) \LUATEX\ because we have more tracing and more test variants. diff --git a/source/luametatex/source/tex/texpackaging.c b/source/luametatex/source/tex/texpackaging.c index 49a18497c..3cea2b7b8 100644 --- a/source/luametatex/source/tex/texpackaging.c +++ b/source/luametatex/source/tex/texpackaging.c @@ -2323,7 +2323,7 @@ void tex_run_vcenter(void) tex_normal_paragraph(vcenter_par_context); tex_push_nest(); cur_list.mode = -vmode; - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; if (every_vbox_par) { tex_begin_token_list(every_vbox_par, every_vbox_text); } @@ -2358,28 +2358,6 @@ void tex_finish_vcenter_group(void) } } -inline static scaled tex_aux_checked_dimen1(halfword v) -{ - if (v > max_dimen) { - return max_dimen; - } else if (v < -max_dimen) { - return -max_dimen; - } else { - return v; - } -} - -inline static scaled tex_aux_checked_dimen2(halfword v) -{ - if (v > max_dimen) { - return max_dimen; - } else if (v < 0) { - return 0; - } else { - return v; - } -} - static scaled tex_aux_first_height(halfword boxnode) { halfword list = box_list(boxnode); @@ -2816,14 +2794,14 @@ void tex_append_to_vlist(halfword b, int location, const line_break_properties * { if (location >= 0) { halfword result = null; - halfword next_depth = ignore_depth; + halfword next_depth = ignore_depth_criterium_par; int prev_set = 0; int check_depth = 0; if (lmt_append_to_vlist_callback(b, location, cur_list.prev_depth, &result, &next_depth, &prev_set, &check_depth)) { if (prev_set) { cur_list.prev_depth = next_depth; } - if (check_depth && result && (cur_list.prev_depth > ignore_depth)) { + if (check_depth && result && (cur_list.prev_depth > ignore_depth_criterium_par)) { /*tex We only deal with a few types and one can always at the \LUA\ end check for some of these and decide not to apply the correction. @@ -2848,7 +2826,7 @@ void tex_append_to_vlist(halfword b, int location, const line_break_properties * return; } } - if (cur_list.prev_depth > ignore_depth) { + if (cur_list.prev_depth > ignore_depth_criterium_par) { halfword p = tex_aux_depth_correction(b, properties); tex_couple_nodes(cur_list.tail, p); cur_list.tail = p; @@ -3422,7 +3400,7 @@ void tex_begin_box(int boxcontext, scaled shift, halfword slot) update_tex_internal_dir_state(0); cur_list.mode = - mode; if (mode == vmode) { - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; if (every_vbox_par) { tex_begin_token_list(every_vbox_par, every_vbox_text); } diff --git a/source/luametatex/source/tex/texpackaging.h b/source/luametatex/source/tex/texpackaging.h index 0e3c0a471..8cef36619 100644 --- a/source/luametatex/source/tex/texpackaging.h +++ b/source/luametatex/source/tex/texpackaging.h @@ -70,6 +70,19 @@ typedef enum saved_full_spec_items { saved_full_spec_n_of_items = 21, } saved_full_spec_items; +// typedef enum saved_align_spec_items { +// saved_align_spec_item_attr_list = 0, +// saved_align_spec_item_orientation = 1, +// saved_align_spec_item_anchor = 2, +// saved_align_spec_item_geometry = 3, +// saved_align_spec_item_xoffset = 4, +// saved_align_spec_item_yoffset = 5, +// saved_align_spec_item_shift = 6, +// saved_align_spec_item_source = 7, +// saved_align_spec_item_target = 8, +// saved_align_spec_n_of_items = 9, +// } saved_align_spec_items; + typedef enum holding_migration_options { holding_none_option = 0x00, holding_marks_option = 0x01, @@ -212,4 +225,26 @@ typedef enum box_flags { extern void tex_begin_box (int boxcontext, scaled shift, halfword slot); extern int tex_ignore_math_skip (halfword p); +inline static scaled tex_aux_checked_dimen1(halfword v) +{ + if (v > max_dimen) { + return max_dimen; + } else if (v < -max_dimen) { + return -max_dimen; + } else { + return v; + } +} + +inline static scaled tex_aux_checked_dimen2(halfword v) +{ + if (v > max_dimen) { + return max_dimen; + } else if (v < 0) { + return 0; + } else { + return v; + } +} + # endif diff --git a/source/luametatex/source/tex/texrules.c b/source/luametatex/source/tex/texrules.c index 1a3040585..768f640b1 100644 --- a/source/luametatex/source/tex/texrules.c +++ b/source/luametatex/source/tex/texrules.c @@ -141,7 +141,7 @@ void tex_aux_run_vrule(void) void tex_aux_run_hrule(void) { tex_tail_append(tex_aux_scan_rule_spec(h_rule_type, cur_chr)); - cur_list.prev_depth = ignore_depth; + cur_list.prev_depth = ignore_depth_criterium_par; } void tex_aux_run_mrule(void) diff --git a/source/luametatex/source/tex/textypes.h b/source/luametatex/source/tex/textypes.h index 12a0aadf9..05324db83 100644 --- a/source/luametatex/source/tex/textypes.h +++ b/source/luametatex/source/tex/textypes.h @@ -171,7 +171,6 @@ extern halfword tex_badness( # define default_rule 26214 /*tex 0.4pt */ # define ignore_depth -65536000 /*tex The magic dimension value to mean \quote {ignore me}: -1000pt */ -# define ignore_depth_zero_baselineskip -131072000 /*tex Idem but keep zero skip: -2000pt */ # define min_quarterword 0 /*tex The smallest allowable value in a |quarterword|. */ # define max_quarterword 65535 /*tex The largest allowable value in a |quarterword|. */ -- cgit v1.2.3