From 3bdc9b9072bba774cd5c604fe185d39ddbdc911e Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 9 Dec 2022 18:16:10 +0100 Subject: 2022-12-09 16:33:00 --- source/luametatex/cmake/lua.cmake | 2 + source/luametatex/source/lua/lmtnodelib.c | 15 +-- source/luametatex/source/luametatex.h | 2 +- source/luametatex/source/tex/texcommands.c | 1 + source/luametatex/source/tex/texconditional.c | 93 +++++++++++---- source/luametatex/source/tex/texdirections.c | 95 ++++++++++++++-- source/luametatex/source/tex/texdirections.h | 1 + source/luametatex/source/tex/texdumpdata.h | 2 +- source/luametatex/source/tex/texequivalents.h | 17 +++ source/luametatex/source/tex/texlinebreak.c | 21 +++- source/luametatex/source/tex/texmaincontrol.c | 158 ++++++++++++++++++-------- source/luametatex/source/tex/texmlist.c | 4 + source/luametatex/source/tex/texnodes.c | 15 +-- source/luametatex/source/tex/texnodes.h | 5 +- source/luametatex/source/tex/texprinting.c | 10 ++ 15 files changed, 328 insertions(+), 113 deletions(-) (limited to 'source/luametatex') diff --git a/source/luametatex/cmake/lua.cmake b/source/luametatex/cmake/lua.cmake index 8e370a05e..ed0ab1803 100644 --- a/source/luametatex/cmake/lua.cmake +++ b/source/luametatex/cmake/lua.cmake @@ -56,6 +56,7 @@ target_include_directories(lua PRIVATE target_compile_definitions(lua PUBLIC # This one should also be set in the lua namespace! # LUAI_HASHLIMIT=6 # obsolete + # LUAI_MAXSHORTLEN=48 LUAI_MAXCSTACK=6000 LUA_UCID # LUA_USE_JUMPTABLE=0 @@ -64,6 +65,7 @@ target_compile_definitions(lua PUBLIC # LUA_NOBUILTIN # disable likely usage # LUAI_ASSERT # LUA_STRFTIMEOPTIONS="aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" + # MINSTRTABSIZE=65536 ) if (UNIX) diff --git a/source/luametatex/source/lua/lmtnodelib.c b/source/luametatex/source/lua/lmtnodelib.c index afaa8bed5..cc7501786 100644 --- a/source/luametatex/source/lua/lmtnodelib.c +++ b/source/luametatex/source/lua/lmtnodelib.c @@ -10116,20 +10116,7 @@ void lmt_node_filter_callback( /*tex redundant as we set top anyway */ lua_pop(L, 2); /*tex find tail in order to update tail */ - start = node_next(head); - if (start) { - /*tex maybe just always slide (harmless and fast) */ - halfword last = node_next(start); - while (last) { - start = last; - last = node_next(start); - } - /*tex we're at the end now */ - *tail = start; - } else { - /*tex we're already at the end */ - *tail = head; - } + *tail = tex_tail_of_node_list(head); lmt_callback_wrapup(L, top); } } diff --git a/source/luametatex/source/luametatex.h b/source/luametatex/source/luametatex.h index a9f739cec..07921d53a 100644 --- a/source/luametatex/source/luametatex.h +++ b/source/luametatex/source/luametatex.h @@ -89,7 +89,7 @@ # define luametatex_version 210 # define luametatex_revision 04 # define luametatex_version_string "2.10.04" -# define luametatex_development_id 20221202 +# define luametatex_development_id 20221208 # define luametatex_name_camelcase "LuaMetaTeX" # define luametatex_name_lowercase "luametatex" diff --git a/source/luametatex/source/tex/texcommands.c b/source/luametatex/source/tex/texcommands.c index 9425141db..c7ec0a2f4 100644 --- a/source/luametatex/source/tex/texcommands.c +++ b/source/luametatex/source/tex/texcommands.c @@ -197,6 +197,7 @@ void tex_initialize_commands(void) tex_primitive(luatex_command, "tracingnodes", internal_int_cmd, tracing_nodes_code, internal_int_base); tex_primitive(luatex_command, "tracingfullboxes", internal_int_cmd, tracing_full_boxes_code, internal_int_base); tex_primitive(luatex_command, "tracingpenalties", internal_int_cmd, tracing_penalties_code, internal_int_base); + tex_primitive(luatex_command, "tracinglists", internal_int_cmd, tracing_lists_code, internal_int_base); tex_primitive(tex_command, "uchyph", internal_int_cmd, uc_hyph_code, internal_int_base); /* obsolete, not needed */ tex_primitive(luatex_command, "variablefam", internal_int_cmd, variable_family_code, internal_int_base); /* obsolete, not used */ tex_primitive(tex_command, "vbadness", internal_int_cmd, vbadness_code, internal_int_base); diff --git a/source/luametatex/source/tex/texconditional.c b/source/luametatex/source/tex/texconditional.c index f89a57ba1..2197e9065 100644 --- a/source/luametatex/source/tex/texconditional.c +++ b/source/luametatex/source/tex/texconditional.c @@ -420,19 +420,65 @@ inline static halfword tex_aux_grab_toks(int expand, int expandlist, int *head) return p ? token_link(p) : null; } +// inline static halfword tex_aux_scan_comparison(int code) +// { +// halfword r; +// do { +// tex_get_x_token(); +// } while (cur_cmd == spacer_cmd); +// r = cur_tok - other_token; +// if ((r < '<') || (r > '>')) { +// tex_aux_missing_equal_error(code); +// return '='; +// } else { +// return r; +// } +// } + +//inline static halfword tex_aux_scan_comparison(int code) +//{ +// do { +// tex_get_x_token(); +// } while (cur_cmd == spacer_cmd); +// if (cur_cmd != other_char_cmd || (cur_chr < '<') || (cur_chr > '>')) { +// tex_aux_missing_equal_error(code); +// return '='; +// } else { +// return cur_chr; +// } +//} + inline static halfword tex_aux_scan_comparison(int code) { - halfword r; - do { + int negate = 0; + while (1) { tex_get_x_token(); - } while (cur_cmd == spacer_cmd); - r = cur_tok - other_token; - if ((r < '<') || (r > '>')) { - tex_aux_missing_equal_error(code); - return '='; - } else { - return r; - } + switch (cur_cmd) { + case letter_cmd: + case other_char_cmd: + switch (cur_chr) { + /* traditional */ + case '=' : return negate ? 3 : 0; + case '<' : return negate ? 4 : 1; + case '>' : return negate ? 5 : 2; + /* bonus */ + case '!' : negate = ! negate ; continue; + /* neat */ + case 0x2208: return negate ? 7 : 6; /* element of */ + case 0x2209: return negate ? 6 : 7; /* not element of */ + case 0x2260: return negate ? 0 : 3; /* not equal */ + case 0x2264: return negate ? 2 : 5; /* less equal */ + case 0x2265: return negate ? 1 : 4; /* greater equal */ + case 0x2270: return negate ? 2 : 5; /* not less equal */ + case 0x2271: return negate ? 1 : 4; /* not greater equal */ + } + case spacer_cmd: + continue; + default: + tex_aux_missing_equal_error(code); + return 0; + } + } } void tex_conditional_if(halfword code, int unless) @@ -497,11 +543,14 @@ void tex_conditional_if(halfword code, int unless) } } switch (cp) { - case '<': result = (n1 < n2); break; - /* case '=': result = (n1 == n2); break; */ - case '>': result = (n1 > n2); break; - /* default: break; */ - default : result = (n1 == n2); break; + case 0: result = (n1 == n2); break; + case 1: result = (n1 < n2); break; + case 2: result = (n1 > n2); break; + case 3: result = (n1 != n2); break; + case 4: result = (n1 >= n2); break; + case 5: result = (n1 <= n2); break; + case 6: result = (n1 & n2) == n1; break; + case 7: result = (n1 & n2) != n1; break; } } goto RESULT; @@ -525,11 +574,15 @@ void tex_conditional_if(halfword code, int unless) } } switch (cp) { - case '<': result = (n1 < n2); break; - /* case '=': result = (n1 == n2); break; */ - case '>': result = (n1 > n2); break; - /* default: break; */ - default : result = (n1 == n2); break; + case 0: result = (n1 == n2); break; + case 1: result = (n1 < n2); break; + case 2: result = (n1 > n2); break; + case 3: result = (n1 != n2); break; + case 4: result = (n1 >= n2); break; + case 5: result = (n1 <= n2); break; + /* maybe we should round */ + case 6: result = (n1/65536 & n2/65536) == n1/65536; break; + case 7: result = (n1/65536 & n2/65536) != n1/65536; break; } } goto RESULT; diff --git a/source/luametatex/source/tex/texdirections.c b/source/luametatex/source/tex/texdirections.c index 400b4c00d..c1bc55928 100644 --- a/source/luametatex/source/tex/texdirections.c +++ b/source/luametatex/source/tex/texdirections.c @@ -16,6 +16,9 @@ model (with rotation and offsets) that can help implementing vertical rendering, but that code is not here. + Todo: |\tracingdirections| but costly so not really. The tracinglist is a middleground but I + might comment it at some point. + */ # include "luametatex.h" @@ -56,6 +59,11 @@ halfword tex_update_dir_state(halfword p, halfword initial) } } +/*tex + The next function runs over the whole list (|first|, |last|) and initial is normally the + direction of the paragraph. +*/ + halfword tex_sanitize_dir_state(halfword first, halfword last, halfword initial) { for (halfword e = first; e && e != last; e = node_next(e)) { @@ -75,15 +83,56 @@ halfword tex_sanitize_dir_state(halfword first, halfword last, halfword initial) } } +/*tex + Here we inject the nodes that inititialize and cancel the direction states as stored in the + (reverse) stack into the list, after |tail|. +*/ + +void tex_append_dir_state(void) +{ + halfword dir = lmt_dir_state.text_dir_ptr; + halfword tail = cur_list.tail; + halfword first = null; + halfword last = null; + if (tracing_paragraph_lists) { + tex_begin_diagnostic(); + tex_print_format("[paragraph: dirstate]"); + tex_show_box(dir); + tex_end_diagnostic(); + } + while (dir) { + if ((node_next(dir)) || (dir_direction(dir) != par_direction_par)) { + halfword tmp = tex_new_dir(normal_dir_subtype, dir_direction(dir)); + tex_attach_attribute_list_copy(tmp, tail); + tex_try_couple_nodes(tmp, first); + first = tmp; + if (! last) { + last = tmp; + } + } + dir = node_next(dir); + } + if (first) { + if (tracing_paragraph_lists) { + tex_begin_diagnostic(); + tex_print_format("[paragraph: injected dirs]"); + tex_show_box(first); + tex_end_diagnostic(); + } + tex_couple_nodes(cur_list.tail, first); + cur_list.tail = last; + } +} + halfword tex_complement_dir_state(halfword tail) { - halfword e = node_next(tail); - for (halfword p = lmt_linebreak_state.dir_ptr; p ; p = node_next(p)) { - halfword s = tex_new_dir(cancel_dir_subtype, dir_direction(p)); - tex_attach_attribute_list_copy(s, tail); - tex_couple_nodes(tail, s); - tex_try_couple_nodes(s, e); - tail = s; + halfword aftertail = node_next(tail); + for (halfword topdir = lmt_linebreak_state.dir_ptr; topdir ; topdir = node_next(topdir)) { + halfword dir = tex_new_dir(cancel_dir_subtype, dir_direction(topdir)); + tex_attach_attribute_list_copy(dir, tail); + tex_couple_nodes(tail, dir); + tex_try_couple_nodes(dir, aftertail); + tail = dir; } return tail; } @@ -106,30 +155,52 @@ halfword tex_new_dir(quarterword subtype, halfword direction) return p; } -/* todo: |\tracingdirections| */ - void tex_push_text_dir_ptr(halfword val) { + if (tracing_direction_lists) { + tex_begin_diagnostic(); + tex_print_format("[direction: push text, level %i, before]", cur_level); + tex_show_box(lmt_dir_state.text_dir_ptr); + tex_end_diagnostic(); + } if (dir_level(lmt_dir_state.text_dir_ptr) == cur_level) { /*tex update */ dir_direction(lmt_dir_state.text_dir_ptr) = val; } else { - /*tex add */ + /*tex we push in front of head */ halfword text_dir_tmp = tex_new_dir(normal_dir_subtype, val); node_next(text_dir_tmp) = lmt_dir_state.text_dir_ptr; lmt_dir_state.text_dir_ptr = text_dir_tmp; } + if (tracing_direction_lists) { + tex_begin_diagnostic(); + tex_print_format("[direction: push text, level %i, after]", cur_level); + tex_show_box(lmt_dir_state.text_dir_ptr); + tex_end_diagnostic(); + } } void tex_pop_text_dir_ptr(void) { halfword text_dir_ptr = lmt_dir_state.text_dir_ptr; - if (dir_level(text_dir_ptr) == cur_level) { - /*tex remove */ + if (tracing_direction_lists) { + tex_begin_diagnostic(); + tex_print_format("[direction: pop text, level %i, before]", cur_level); + tex_show_box(lmt_dir_state.text_dir_ptr); + tex_end_diagnostic(); + } + if (dir_level(text_dir_ptr) == cur_level) { // maybe > and whole chain + /*tex we remove from the head */ halfword text_dir_tmp = node_next(text_dir_ptr); tex_flush_node(text_dir_ptr); lmt_dir_state.text_dir_ptr = text_dir_tmp; } + if (tracing_direction_lists) { + tex_begin_diagnostic(); + tex_print_format("[direction: pop text, level %i, after]", cur_level); + tex_show_box(lmt_dir_state.text_dir_ptr); + tex_end_diagnostic(); + } } void tex_set_math_dir(halfword d) diff --git a/source/luametatex/source/tex/texdirections.h b/source/luametatex/source/tex/texdirections.h index cb85c2485..ce670c921 100644 --- a/source/luametatex/source/tex/texdirections.h +++ b/source/luametatex/source/tex/texdirections.h @@ -119,5 +119,6 @@ extern void tex_set_box_dir (halfword b, singleword d); extern halfword tex_update_dir_state (halfword p, halfword initial); extern halfword tex_sanitize_dir_state (halfword first, halfword last, halfword initial); extern halfword tex_complement_dir_state (halfword tail); +extern void tex_append_dir_state (void); # endif diff --git a/source/luametatex/source/tex/texdumpdata.h b/source/luametatex/source/tex/texdumpdata.h index c8f373ea4..02514bdf3 100644 --- a/source/luametatex/source/tex/texdumpdata.h +++ b/source/luametatex/source/tex/texdumpdata.h @@ -55,7 +55,7 @@ */ -# define luametatex_format_fingerprint 677 +# define luametatex_format_fingerprint 678 /* These end up in the string pool. */ diff --git a/source/luametatex/source/tex/texequivalents.h b/source/luametatex/source/tex/texequivalents.h index 1a6c41b2a..336c9e206 100644 --- a/source/luametatex/source/tex/texequivalents.h +++ b/source/luametatex/source/tex/texequivalents.h @@ -477,6 +477,7 @@ typedef enum int_codes { tracing_nodes_code, /*tex show node numbers too */ tracing_full_boxes_code, /*tex show [over/under]full boxes in the log */ tracing_penalties_code, + tracing_lists_code, uc_hyph_code, /*tex hyphenate words beginning with a capital letter */ output_penalty_code, /*tex penalty found at current page break */ max_dead_cycles_code, /*tex bound on consecutive dead cycles of output */ @@ -1521,6 +1522,22 @@ typedef enum shaping_penalties_mode_bits { # define tracing_nodes_par count_parameter(tracing_nodes_code) # define tracing_full_boxes_par count_parameter(tracing_full_boxes_code) # define tracing_penalties_par count_parameter(tracing_penalties_code) +# define tracing_lists_par count_parameter(tracing_lists_code) + +/*tex + This tracer is mostly there for debugging purposes. Therefore what gets traced and how might + change depending on my needs. +*/ + +typedef enum tracing_lists_codes { + trace_direction_list_code = 0x0001, + trace_paragraph_list_code = 0x0002, + trace_linebreak_list_code = 0x0004, +} tracing_lists_codes; + +# define tracing_direction_lists ((tracing_lists_par & trace_direction_list_code) == trace_direction_list_code) +# define tracing_paragraph_lists ((tracing_lists_par & trace_paragraph_list_code) == trace_paragraph_list_code) +# define tracing_linebreak_lists ((tracing_lists_par & trace_linebreak_list_code) == trace_linebreak_list_code) # define show_box_depth_par count_parameter(show_box_depth_code) # define show_box_breadth_par count_parameter(show_box_breadth_code) diff --git a/source/luametatex/source/tex/texlinebreak.c b/source/luametatex/source/tex/texlinebreak.c index 7c9e6b768..52e7f25d3 100644 --- a/source/luametatex/source/tex/texlinebreak.c +++ b/source/luametatex/source/tex/texlinebreak.c @@ -144,6 +144,12 @@ void tex_line_break_prepare( { /* too much testing of next */ if (node_type(par) == par_node) { + if (tracing_linebreak_lists) { + tex_begin_diagnostic(); + tex_print_format("[linebreak: prepare, before]"); + tex_show_box(par); + tex_end_diagnostic(); + } *tail = *tail ? *tail : tex_tail_of_node_list(par); *final_penalty = tex_new_penalty_node(infinite_penalty, line_penalty_subtype); *parfill_left_skip_glue = tex_new_glue_node(tex_get_par_par(par, par_par_fill_left_skip_code), par_fill_left_skip_glue); @@ -164,7 +170,11 @@ void tex_line_break_prepare( tex_try_couple_nodes(*parfill_left_skip_glue, *parfill_right_skip_glue); *tail = *parfill_right_skip_glue; if (node_next(par)) { + halfword p = par; halfword n = node_next(par); + while (node_next(p) && node_type(node_next(p)) == dir_node) { + p = node_next(p); + } while (n) { if (node_type(n) == glue_node && node_subtype(n) == indent_skip_glue) { *parinit_left_skip_glue = tex_new_glue_node(tex_get_par_par(par, par_par_init_left_skip_code), par_init_left_skip_glue); @@ -173,13 +183,20 @@ void tex_line_break_prepare( tex_attach_attribute_list_copy(*parinit_right_skip_glue, par); tex_try_couple_nodes(*parinit_right_skip_glue, n); tex_try_couple_nodes(*parinit_left_skip_glue, *parinit_right_skip_glue); - tex_try_couple_nodes(par, *parinit_left_skip_glue); + // tex_try_couple_nodes(par, *parinit_left_skip_glue); + tex_try_couple_nodes(p, *parinit_left_skip_glue); break; } else { - n = node_next(n); + n = node_next(n); /* sort of weird and tricky */ } } } + if (tracing_linebreak_lists) { + tex_begin_diagnostic(); + tex_print_format("[linebreak: prepare, after]"); + tex_show_box(par); + tex_end_diagnostic(); + } } } diff --git a/source/luametatex/source/tex/texmaincontrol.c b/source/luametatex/source/tex/texmaincontrol.c index 6de36d7ee..24729d8cb 100644 --- a/source/luametatex/source/tex/texmaincontrol.c +++ b/source/luametatex/source/tex/texmaincontrol.c @@ -960,16 +960,16 @@ static void tex_aux_insert_parindent(int indented) { if (normalize_line_mode_permitted(normalize_line_mode_par, parindent_skip_mode)) { /*tex We cannot use |new_param_glue| yet, because it's a dimen */ - halfword p = tex_new_glue_node(zero_glue, indent_skip_glue); + halfword glue = tex_new_glue_node(zero_glue, indent_skip_glue); if (indented) { - glue_amount(p) = par_indent_par; + glue_amount(glue) = par_indent_par; } - tex_tail_append(p); + tex_tail_append(glue); } else if (indented) { - halfword p = tex_new_null_box_node(hlist_node, indent_list); - box_dir(p) = (singleword) par_direction_par; - box_width(p) = par_indent_par; - tex_tail_append(p); + halfword box = tex_new_null_box_node(hlist_node, indent_list); + box_dir(box) = (singleword) par_direction_par; + box_width(box) = par_indent_par; + tex_tail_append(box); } } @@ -2859,31 +2859,105 @@ void tex_box_end(int boxcontext, halfword boxnode, scaled shift, halfword maincl */ +// void tex_begin_paragraph(int doindent, int context) +// { +// halfword q; +// int indented = doindent; +// int isvmode = cur_list.mode == vmode; +// if (isvmode || cur_list.head != cur_list.tail) { +// /*tex +// Actually we could remove the callback and hook it into the |\everybeforepar| but that one +// started out as a |tex.expandmacro| itself and we don't want the callback overhead every +// time, so now we have both. However, in the end I decided to do this one {\em before} the +// parskip is injected. +// */ +// if (every_before_par_par) { +// tex_begin_inserted_list(tex_get_available_token(token_val(end_local_cmd, 0))); +// tex_begin_token_list(every_before_par_par, every_before_par_text); +// if (tracing_nesting_par > 2) { +// tex_local_control_message("entering local control via \\everybeforepar"); +// } +// tex_local_control(1); +// } +// // if (type(cur_list.tail) == glue_node && subtype(cur_list.tail) == par_skip_glue) { +// // /* ignore */ +// // } else { +// tex_tail_append(tex_new_param_glue_node(par_skip_code, par_skip_glue)); +// // } +// } +// lmt_begin_paragraph_callback(isvmode, &indented, context); +// /*tex We'd better not messed up things in the callback! */ +// cur_list.prev_graf = 0; +// tex_push_nest(); +// cur_list.mode = hmode; +// cur_list.space_factor = default_space_factor; +// /*tex Add local paragraph node */ +// tex_tail_append(tex_new_par_node(vmode_par_par_subtype)); +// // if (end_of_par_par) { +// // update_tex_end_of_par(null); /* option */ +// // } +// q = cur_list.tail; +// /*tex We will move this to after the dir nodes have been dealt with. */ +// tex_aux_insert_parindent(indented); +// /*tex Dir nodes end up before the indent box. */ +// { +// halfword dir_rover = lmt_dir_state.text_dir_ptr; +// while (dir_rover) { +// if ((node_next(dir_rover)) || (dir_direction(dir_rover) != par_direction_par)) { +// halfword dir_graf_tmp = tex_new_dir(normal_dir_subtype, dir_direction(dir_rover)); +// tex_try_couple_nodes(dir_graf_tmp, node_next(q)); +// tex_couple_nodes(q, dir_graf_tmp); +// } +// dir_rover = node_next(dir_rover); +// } +// } +// /*tex We might need to go to the last injected dir and/or indent node. */ +// while (node_next(q)) { +// q = node_next(q); +// } +// cur_list.tail = q; +// /*tex The |\everypar| tokens are injected after dir nodes have been added. */ +// if (every_par_par) { +// tex_begin_token_list(every_par_par, every_par_text); +// } +// if (lmt_nest_state.nest_data.ptr == 1) { +// if (! lmt_page_builder_state.output_active) { +// lmt_page_filter_callback(begin_paragraph_page_context, 0); +// } +// /*tex put |par_skip| glue on current page */ +// tex_build_page(); +// } +// } + +void tex_tail_prepend(halfword n) +{ + tex_couple_nodes(node_prev(cur_list.tail), n); + tex_couple_nodes(n, cur_list.tail); + if (cur_list.tail == cur_list.head) { + cur_list.head = n; + } +} + void tex_begin_paragraph(int doindent, int context) { - halfword q; int indented = doindent; int isvmode = cur_list.mode == vmode; if (isvmode || cur_list.head != cur_list.tail) { - /*tex - Actually we could remove the callback and hook it into the |\everybeforepar| but that one - started out as a |tex.expandmacro| itself and we don't want the callback overhead every - time, so now we have both. However, in the end I decided to do this one {\em before} the - parskip is injected. - */ - if (every_before_par_par) { - tex_begin_inserted_list(tex_get_available_token(token_val(end_local_cmd, 0))); - tex_begin_token_list(every_before_par_par, every_before_par_text); - if (tracing_nesting_par > 2) { - tex_local_control_message("entering local control via \\everybeforepar"); + /*tex + Actually we could remove the callback and hook it into the |\everybeforepar| but that one + started out as a |tex.expandmacro| itself and we don't want the callback overhead every + time, so now we have both. However, in the end I decided to do this one {\em before} the + parskip is injected. + */ + if (every_before_par_par) { + tex_begin_inserted_list(tex_get_available_token(token_val(end_local_cmd, 0))); + tex_begin_token_list(every_before_par_par, every_before_par_text); + if (tracing_nesting_par > 2) { + tex_local_control_message("entering local control via \\everybeforepar"); + } + tex_local_control(1); } - tex_local_control(1); - } - // if (type(cur_list.tail) == glue_node && subtype(cur_list.tail) == par_skip_glue) { - // /* ignore */ - // } else { tex_tail_append(tex_new_param_glue_node(par_skip_code, par_skip_glue)); - // } } lmt_begin_paragraph_callback(isvmode, &indented, context); /*tex We'd better not messed up things in the callback! */ @@ -2891,32 +2965,18 @@ void tex_begin_paragraph(int doindent, int context) tex_push_nest(); cur_list.mode = hmode; cur_list.space_factor = default_space_factor; - /*tex Add local paragraph node */ + /*tex Add local paragraph node */ tex_tail_append(tex_new_par_node(vmode_par_par_subtype)); - // if (end_of_par_par) { - // update_tex_end_of_par(null); /* option */ - // } - q = cur_list.tail; - /*tex We will move this to after the dir nodes have been dealt with. */ - tex_aux_insert_parindent(indented); /*tex Dir nodes end up before the indent box. */ - { - halfword dir_rover = lmt_dir_state.text_dir_ptr; - while (dir_rover) { - if ((node_next(dir_rover)) || (dir_direction(dir_rover) != par_direction_par)) { - halfword dir_graf_tmp = tex_new_dir(normal_dir_subtype, dir_direction(dir_rover)); - tex_try_couple_nodes(dir_graf_tmp, node_next(q)); - tex_couple_nodes(q, dir_graf_tmp); - } - dir_rover = node_next(dir_rover); - } - } - /*tex We might need to go to the last injected dir and/or indent node. */ - while (node_next(q)) { - q = node_next(q); + tex_append_dir_state(); + tex_aux_insert_parindent(indented); + if (tracing_paragraph_lists) { + tex_begin_diagnostic(); + tex_print_format("[paragraph: start, context %i]", context); + tex_show_box(node_next(cur_list.head)); + tex_end_diagnostic(); } - cur_list.tail = q; - /*tex The |\everypar| tokens are injected after dir nodes have been added. */ + /*tex The |\everypar| tokens are injected after all these nodes have been added. */ if (every_par_par) { tex_begin_token_list(every_par_par, every_par_text); } @@ -3396,7 +3456,7 @@ void tex_inject_text_or_line_dir(int val, int check_glue) /*tex |tail| is non zero but we test anyway. */ halfword dirn = tex_new_dir(cancel_dir_subtype, text_direction_par); halfword tail = cur_list.tail; - if (check_glue && tail && node_type(tail) == glue_node) { + if (check_glue && tail && node_type(tail) == glue_node) { // && node_subtype(tail) != indent_skip_glue halfword prev = node_prev(tail); tex_couple_nodes(prev, dirn); tex_couple_nodes(dirn, tail); diff --git a/source/luametatex/source/tex/texmlist.c b/source/luametatex/source/tex/texmlist.c index 83a8a8a96..1d4cbacd8 100644 --- a/source/luametatex/source/tex/texmlist.c +++ b/source/luametatex/source/tex/texmlist.c @@ -135,6 +135,10 @@ as we like. All works fine for Cambria and the \TEX\ community didn't make sure that better features were added (like anchors) for their shapes. + In the end, from the perspective of ConTeXt, the italics code can completely go away which + means that we also no longer have to stare at somewhat fuzzy code originating in dealing + with italics. It depends on how well our latest heuristic tweaks work out. + */ # include "luametatex.h" diff --git a/source/luametatex/source/tex/texnodes.c b/source/luametatex/source/tex/texnodes.c index 7eba8a787..a0601e594 100644 --- a/source/luametatex/source/tex/texnodes.c +++ b/source/luametatex/source/tex/texnodes.c @@ -2667,12 +2667,7 @@ void tex_show_node_list(halfword p, int threshold, int max) tex_print_format(", shifted %D", box_shift_amount(p), pt_unit); } if (valid_direction(box_dir(p))) { - tex_print_str(", direction "); - switch (box_dir(p)) { - case dir_lefttoright: tex_print_str("l2r"); break; - case dir_righttoleft: tex_print_str("r2l"); break; - default : tex_print_str("unset"); break; - } + tex_print_format(", direction %2", box_dir(p)); } if (box_geometry(p)) { tex_print_format(", geometry %x", box_geometry(p)); @@ -2757,17 +2752,13 @@ void tex_show_node_list(halfword p, int threshold, int max) tex_print_node_list(insert_list(p), "list", threshold, max); break; case dir_node: - tex_print_str(", direction "); - switch (dir_direction(p)) { - case direction_l2r : tex_print_str("l2r"); break; - case direction_r2l : tex_print_str("r2l"); break; - default : tex_print_str("unset"); break; - } + tex_print_format(", direction %2, level %i", dir_direction(p), dir_level(p)); break; case par_node: { halfword v; /*tex We're already past processing so we only show the stored values. */ + tex_print_format(", direction %2", par_dir(p)); if (node_subtype(p) == vmode_par_par_subtype) { if (tex_par_state_is_set(p, par_par_shape_code) ) { v = par_par_shape(p) ; if (v) { tex_print_str(", parshape * "); } } if (tex_par_state_is_set(p, par_inter_line_penalties_code) ) { v = par_inter_line_penalties(p) ; if (v) { tex_print_str(", interlinepenalties * "); } } diff --git a/source/luametatex/source/tex/texnodes.h b/source/luametatex/source/tex/texnodes.h index c6cc61ff2..45e53187a 100644 --- a/source/luametatex/source/tex/texnodes.h +++ b/source/luametatex/source/tex/texnodes.h @@ -2092,8 +2092,9 @@ typedef enum boundary_subtypes { # define last_boundary_subtype word_boundary # define last_boundary_code page_boundary -# define boundary_node_size 3 -# define boundary_data(a) vinfo(a,2) +# define boundary_node_size 3 +# define boundary_data(a) vinfo(a,2) +# define boundary_reserved(a) vlink(a,2) // maybe level typedef enum dir_subtypes { normal_dir_subtype, diff --git a/source/luametatex/source/tex/texprinting.c b/source/luametatex/source/tex/texprinting.c index 6d01854b7..bb021047e 100644 --- a/source/luametatex/source/tex/texprinting.c +++ b/source/luametatex/source/tex/texprinting.c @@ -1304,6 +1304,16 @@ const char *tex_print_format_args(const char *format, va_list args) tex_print_uhex(c); break; } + case '2': + { + halfword c = va_arg(args, int); + switch (c) { + case direction_l2r : tex_print_str("l2r"); break; + case direction_r2l : tex_print_str("r2l"); break; + default : tex_print_str("unset"); break; + } + break; + } case '%': tex_print_char('%'); break; -- cgit v1.2.3