diff options
Diffstat (limited to 'source/luametatex/source/lua')
-rw-r--r-- | source/luametatex/source/lua/lmtnodelib.c | 57 | ||||
-rw-r--r-- | source/luametatex/source/lua/lmttexiolib.c | 39 | ||||
-rw-r--r-- | source/luametatex/source/lua/lmttexlib.c | 53 |
3 files changed, 109 insertions, 40 deletions
diff --git a/source/luametatex/source/lua/lmtnodelib.c b/source/luametatex/source/lua/lmtnodelib.c index d4a325c21..7896eff65 100644 --- a/source/luametatex/source/lua/lmtnodelib.c +++ b/source/luametatex/source/lua/lmtnodelib.c @@ -4871,32 +4871,33 @@ static int nodelib_shared_fields(lua_State *L) /* These should move to texlib ... which might happen. */ -static int nodelib_shared_values(lua_State *L) -{ - if (lua_type(L, 1) == LUA_TSTRING) { - /* - delimiter options (bit set) - delimiter modes (bit set) - */ - const char *s = lua_tostring(L, 1); - if (lua_key_eq(s, glue) || lua_key_eq(s, fill)) { - return lmt_push_info_values(L, lmt_interface.node_fill_values); - } else if (lua_key_eq(s, dir)) { - return lmt_push_info_values(L, lmt_interface.direction_values); - } else if (lua_key_eq(s, math)) { - /*tex A bit strange place, so moved to lmttexlib. */ - return lmt_push_info_keys(L, lmt_interface.math_parameter_values); - } else if (lua_key_eq(s, style)) { - /*tex A bit strange place, so moved to lmttexlib. */ - return lmt_push_info_values(L, lmt_interface.math_style_values); - } else if (lua_key_eq(s, page)) { - /*tex These are never used, whatsit related. */ - return lmt_push_info_values(L, lmt_interface.page_contribute_values); - } - } - lua_pushnil(L); - return 1; -} +// static int nodelib_shared_values(lua_State *L) +// { +// if (lua_type(L, 1) == LUA_TSTRING) { +// /* +// delimiter options (bit set) +// delimiter modes (bit set) +// */ +// const char *s = lua_tostring(L, 1); +// if (lua_key_eq(s, glue) || lua_key_eq(s, fill)) { +// return lmt_push_info_values(L, lmt_interface.node_fill_values); +// } else if (lua_key_eq(s, dir)) { +// /* moved to lmttexlib */ +// return lmt_push_info_values(L, lmt_interface.direction_values); +// } else if (lua_key_eq(s, math)) { +// /* moved to lmttexlib */ +// return lmt_push_info_keys(L, lmt_interface.math_parameter_values); +// } else if (lua_key_eq(s, style)) { +// /* moved to lmttexlib */ +// return lmt_push_info_values(L, lmt_interface.math_style_values); +// } else if (lua_key_eq(s, page)) { +// /*tex These are never used, whatsit related. */ +// return lmt_push_info_values(L, lmt_interface.page_contribute_values); +// } +// } +// lua_pushnil(L); +// return 1; +// } static int nodelib_shared_subtypes(lua_State *L) { @@ -9916,7 +9917,7 @@ static const struct luaL_Reg nodelib_direct_function_list[] = { { "types", nodelib_shared_types }, { "fields", nodelib_shared_fields }, { "subtypes", nodelib_shared_subtypes }, - { "values", nodelib_shared_values }, + /* { "values", nodelib_shared_values }, */ /* finally all are now in tex. */ { "id", nodelib_shared_id }, { "getcachestate", nodelib_shared_getcachestate }, { "todirect", nodelib_shared_todirect }, @@ -9966,7 +9967,7 @@ static const struct luaL_Reg nodelib_function_list[] = { { "types", nodelib_shared_types }, { "fields", nodelib_shared_fields }, { "subtypes", nodelib_shared_subtypes }, - { "values", nodelib_shared_values }, + /* { "values", nodelib_shared_values }, */ /* finally all are now in tex. */ { "id", nodelib_shared_id }, { "getcachestate", nodelib_shared_getcachestate }, { "todirect", nodelib_shared_todirect }, diff --git a/source/luametatex/source/lua/lmttexiolib.c b/source/luametatex/source/lua/lmttexiolib.c index 416293164..48b28e3dc 100644 --- a/source/luametatex/source/lua/lmttexiolib.c +++ b/source/luametatex/source/lua/lmttexiolib.c @@ -252,6 +252,18 @@ static int texiolib_closeinput(lua_State *L) return 0 ; } +static int texiolib_getinputindex(lua_State *L) +{ + lua_pushinteger(L, lmt_input_state.cur_input.index); + return 1; +} + +static int texiolib_getsourcefilename(lua_State *L) +{ + lua_pushstring(L, lmt_input_state.in_stack[lmt_input_state.in_stack_data.ptr].full_source_filename); + return 1; +} + /*tex This is a private hack, handy for testing runtime math font patches in lfg files with a bit of low level tracing. Setting the logfile is already handles by a callback so we don't support @@ -278,16 +290,25 @@ static int texiolib_setlogfile(lua_State *L) return 0; } +static int texiolib_forceendoffile(lua_State *L) +{ + lmt_token_state.force_eof = 1; + return 0; +} + static const struct luaL_Reg texiolib_function_list[] = { - { "write", texiolib_write }, - { "writenl", texiolib_write_nl }, - { "write_nl", texiolib_write_nl }, /* depricated */ - { "writeselector", texiolib_write_selector }, - { "writeselectornl", texiolib_write_selector_nl }, - { "writeselectorlf", texiolib_write_selector_lf }, - { "closeinput", texiolib_closeinput }, - { "setlogfile", texiolib_setlogfile }, - { NULL, NULL }, + { "write", texiolib_write }, + { "writenl", texiolib_write_nl }, + { "write_nl", texiolib_write_nl }, /* depricated */ + { "writeselector", texiolib_write_selector }, + { "writeselectornl", texiolib_write_selector_nl }, + { "writeselectorlf", texiolib_write_selector_lf }, + { "closeinput", texiolib_closeinput }, + { "setlogfile", texiolib_setlogfile }, + { "getinputindex", texiolib_getinputindex }, /*tex temporary, testing only */ + { "getsourcefilename", texiolib_getsourcefilename }, /*tex temporary, testing only */ + { "forceendoffile", texiolib_forceendoffile }, /*tex temporary, testing only */ + { NULL, NULL }, }; static const struct luaL_Reg texiolib_function_list_only[] = { diff --git a/source/luametatex/source/lua/lmttexlib.c b/source/luametatex/source/lua/lmttexlib.c index e87a88292..426ca222b 100644 --- a/source/luametatex/source/lua/lmttexlib.c +++ b/source/luametatex/source/lua/lmttexlib.c @@ -45,6 +45,7 @@ # define TEX_METATABLE_UCCODE "tex.uccode" # define TEX_METATABLE_HCCODE "tex.hccode" # define TEX_METATABLE_HMCODE "tex.hmcode" +# define TEX_METATABLE_AMCODE "tex.amcode" # define TEX_METATABLE_CATCODE "tex.catcode" # define TEX_METATABLE_MATHCODE "tex.mathcode" # define TEX_METATABLE_DELCODE "tex.delcode" @@ -2107,6 +2108,23 @@ static int texlib_sethmcode(lua_State *L) return 0; } +static int texlib_setamcode(lua_State *L) +{ + int top = lua_gettop(L); + if (top >= 2) { + quarterword level; + int slot = lmt_check_for_level(L, 1, &level, cur_level); + int ch = lmt_checkinteger(L, slot++); + if (character_in_range(ch)) { + halfword val = lmt_checkhalfword(L, slot); + tex_set_am_code(ch, val, level); + } else { + texlib_aux_show_character_error(L, ch); + } + } + return 0; +} + static int texlib_getlccode(lua_State *L) { int ch = lmt_checkinteger(L, 1); @@ -2167,6 +2185,18 @@ static int texlib_gethmcode(lua_State *L) return 1; } +static int texlib_getamcode(lua_State *L) +{ + int ch = lmt_checkinteger(L, 1); + if (character_in_range(ch)) { + lua_pushinteger(L, tex_get_am_code(ch)); + } else { + texlib_aux_show_character_error(L, ch); + lua_pushinteger(L, 0); + } + return 1; +} + /* [global] [cattable] code value */ static int texlib_setcatcode(lua_State *L) @@ -4884,6 +4914,7 @@ static int texlib_getnoadoptionvalues(lua_State *L) lua_push_key_at_index(L, shrink, noad_option_shrink); lua_push_key_at_index(L, stretch, noad_option_stretch); lua_push_key_at_index(L, center, noad_option_center); + lua_push_key_at_index(L, scale, noad_option_scale); return 1; } @@ -4924,7 +4955,7 @@ static int texlib_getlistsignvalues(lua_State *L) return 1; } -static int texlib_getlistgeometryalues(lua_State *L) +static int texlib_getlistgeometryvalues(lua_State *L) { lua_createtable(L, 3, 0); lua_set_string_by_index(L, offset_geometry, "offset"); @@ -5107,7 +5138,7 @@ static int texlib_getkerneloptionvalues(lua_State *L) static int texlib_getcharactertagvalues(lua_State *L) { - lua_createtable(L, 2, 12); + lua_createtable(L, 2, 15); lua_set_string_by_index(L, no_tag, "normal"); lua_set_string_by_index(L, ligatures_tag, "ligatures"); lua_set_string_by_index(L, kerns_tag, "kerns"); @@ -5305,6 +5336,16 @@ static int texlib_gettextcontrolvalues(lua_State *L) return 1; } +static int texlib_getfillvalues(lua_State *L) +{ + return lmt_push_info_values(L, lmt_interface.node_fill_values); +} + +static int texlib_getdirectionvalues(lua_State *L) +{ + return lmt_push_info_values(L, lmt_interface.direction_values); +} + /* relatively new */ static int texlib_getinsertdistance(lua_State *L) @@ -5482,6 +5523,8 @@ static const struct luaL_Reg texlib_function_list[] = { { "gethccode", texlib_gethccode }, { "sethmcode", texlib_sethmcode }, { "gethmcode", texlib_gethmcode }, + { "setamcode", texlib_setamcode }, + { "getamcode", texlib_getamcode }, { "setlccode", texlib_setlccode }, { "getlccode", texlib_getlccode }, { "setmathcode", texlib_setmathcode }, @@ -5567,7 +5610,7 @@ static const struct luaL_Reg texlib_function_list[] = { { "getdiscoptionvalues", texlib_getdiscoptionvalues }, { "getlistanchorvalues", texlib_getlistanchorvalues }, { "getlistsignvalues", texlib_getlistsignvalues }, - { "getlistgeometryvalues", texlib_getlistgeometryalues }, + { "getlistgeometryvalues", texlib_getlistgeometryvalues }, { "getdiscstatevalues", texlib_getdiscstatevalues }, { "getmathparametervalues", texlib_getmathparametervalues }, { "getmathstylenamevalues", texlib_getmathstylenamevalues }, @@ -5589,6 +5632,8 @@ static const struct luaL_Reg texlib_function_list[] = { { "getmathclassoptionvalues", texlib_getmathclassoptionvalues }, { "getnormalizelinevalues", texlib_getnormalizelinevalues }, { "getnormalizeparvalues", texlib_getnormalizeparvalues }, + { "getdirectionvalues", texlib_getdirectionvalues }, + { "getfillvalues", texlib_getfillvalues }, { "geterrorvalues", texlib_geterrorvalues }, { "getiovalues", texlib_getiovalues }, { "getprimitiveorigins", texlib_getprimitiveorigins }, @@ -5642,6 +5687,7 @@ defineindexers(lccode) defineindexers(uccode) defineindexers(hccode) defineindexers(hmcode) +defineindexers(amcode) defineindexers(catcode) defineindexers(mathcode) defineindexers(delcode) @@ -5673,6 +5719,7 @@ int luaopen_tex(lua_State *L) lmt_make_table(L, "uccode", TEX_METATABLE_UCCODE, texlib_index_uccode, texlib_newindex_uccode); lmt_make_table(L, "hccode", TEX_METATABLE_HCCODE, texlib_index_hccode, texlib_newindex_hccode); lmt_make_table(L, "hmcode", TEX_METATABLE_HMCODE, texlib_index_hmcode, texlib_newindex_hmcode); + lmt_make_table(L, "amcode", TEX_METATABLE_AMCODE, texlib_index_amcode, texlib_newindex_amcode); lmt_make_table(L, "catcode", TEX_METATABLE_CATCODE, texlib_index_catcode, texlib_newindex_catcode); lmt_make_table(L, "mathcode", TEX_METATABLE_MATHCODE, texlib_index_mathcode, texlib_newindex_mathcode); lmt_make_table(L, "delcode", TEX_METATABLE_DELCODE, texlib_index_delcode, texlib_newindex_delcode); |