From bc18e41199a3772d300a4fa68bd86402e23f4f7a Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 16 Apr 2013 12:08:00 +0200 Subject: beta 2013.04.16 12:08 --- tex/context/base/cont-yes.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4128 -> 4134 bytes tex/context/base/context-version.png | Bin 40508 -> 40227 bytes tex/context/base/core-sys.lua | 17 +++++++----- tex/context/base/file-job.lua | 9 +++++-- tex/context/base/file-job.mkvi | 4 +-- tex/context/base/math-frc.lua | 51 +++++++++++++++++++++++++++++++++++ tex/context/base/mult-low.lua | 2 +- tex/context/base/pack-com.mkiv | 34 +++++++++++++++-------- tex/context/base/status-files.pdf | Bin 24720 -> 24708 bytes tex/context/base/status-lua.pdf | Bin 211916 -> 211461 bytes tex/context/base/status-mkiv.lua | 6 +++++ tex/context/base/strc-con.mkvi | 15 +++++++++-- tex/context/base/strc-enu.mkvi | 19 ++++++------- tex/context/base/strc-lab.mkiv | 22 +++++++-------- tex/context/base/strc-not.mkvi | 14 +++++----- 16 files changed, 138 insertions(+), 57 deletions(-) create mode 100644 tex/context/base/math-frc.lua (limited to 'tex') diff --git a/tex/context/base/cont-yes.mkiv b/tex/context/base/cont-yes.mkiv index 5eae3eecb..0bea65f5a 100644 --- a/tex/context/base/cont-yes.mkiv +++ b/tex/context/base/cont-yes.mkiv @@ -26,7 +26,7 @@ local arguments = environment.arguments local suffix = environment.suffix - local filename = environment.filename + local filename = environment.filename -- hm, not inputfilename ! if suffix == "xml" or arguments.forcexml then diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 086a2ca97..102fd5c44 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index 5a5146bbd..773b3a4bd 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/core-sys.lua b/tex/context/base/core-sys.lua index 1741bbe0a..009ec16ea 100644 --- a/tex/context/base/core-sys.lua +++ b/tex/context/base/core-sys.lua @@ -67,15 +67,18 @@ function environment.initializefilenames() -- commands.updatefilenames(jobname,f local jobfilename = jobname or inputfilename or tex.jobname or "" local inputfilename = inputfilename or "" - jobfilename = gsub(jobfilename, "^./","") - inputfilename = gsub(inputfilename,"^./","") + local jobfilebase = basename(jobfilename) + local inputfilebase = basename(inputfilename) - environment.jobfilename = jobfilename - environment.jobfilesuffix = lower(suffixonly(jobfilename)) + -- jobfilename = gsub(jobfilename, "^./","") + -- inputfilename = gsub(inputfilename,"^./","") - environment.inputfilename = inputfilename - environment.inputfilebarename = removesuffix(basename(inputfilename)) - environment.inputfilesuffix = lower(suffixonly(inputfilename)) + environment.jobfilename = jobfilebase + environment.jobfilesuffix = lower(suffixonly(jobfilebase)) + + environment.inputfilename = inputfilename -- so here we keep e.g. ./ or explicit paths + environment.inputfilebarename = removesuffix(inputfilebase) + environment.inputfilesuffix = lower(suffixonly(inputfilebase)) environment.outputfilename = outputfilename or environment.inputfilebarename or "" diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index ea4623d77..288a690d2 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -987,8 +987,13 @@ if environment.initex then end -function commands.doifelsecontinuewithfile(inpname) - local continue = addsuffix(inpname,"tex") == addsuffix(environment.inputfilename,"tex") +function commands.doifelsecontinuewithfile(inpname,basetoo) + local inpnamefull = addsuffix(inpname,"tex") + local inpfilefull = addsuffix(environment.inputfilename,"tex") + local continue = inpnamefull == inpfilefull + if basetoo and not continue then + continue = inpnamefull == basename(inpfilefull) + end if continue then report_system("continuing input file %a",inpname) end diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi index 3434e06f0..087f1a685 100644 --- a/tex/context/base/file-job.mkvi +++ b/tex/context/base/file-job.mkvi @@ -193,9 +193,9 @@ \unexpanded\def\loadcldfileonce [#name]{\ctxcommand{usecldfile("#name",true)}} \unexpanded\def\loadanyfileonce [#name]{\ctxcommand{useanyfile("#name",true)}} -%D Handy for modules that have a test/demo appended. +%D Handy for modules that have a test/demo appended (true added). -\unexpanded\def\continueifinputfile#name{\ctxcommand{doifelsecontinuewithfile("#name")}\relax\endinput} % we cannot do \endinput via lua +\unexpanded\def\continueifinputfile#name{\ctxcommand{doifelsecontinuewithfile("#name",true)}\relax\endinput} % we cannot do \endinput via lua % \startproject test % 1: \startmode[*project] project \stopmode \endgraf diff --git a/tex/context/base/math-frc.lua b/tex/context/base/math-frc.lua new file mode 100644 index 000000000..4f531a530 --- /dev/null +++ b/tex/context/base/math-frc.lua @@ -0,0 +1,51 @@ +if not modules then modules = { } end modules ['math-frc'] = { + version = 1.001, + comment = "companion to math-frc.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local utfchar = utf.char + +local context = context +local variables = interfaces.variables + +local v_no = variables.no +local v_yes = variables.yes + +local resolved = { + [0x007B] = "\\{", + [0x007D] = "\\}", +} + +table.setmetatableindex(resolved, function(t,k) + local v = utfchar(k) + t[k] = v + return v +end) + +local normalatop = context.normalatop +local normalover = context.normalover + +function commands.math_frac(how,left,right,width) + if how == v_no then + if left == 0x002E and right == 0x002E then + normalatop() + else + context("\\atopwithdelims%s%s",resolved[left],resolved[right]) + end + elseif how == v_yes then + if left == 0x002E and right == 0x002E then + context("\\normalabove%ssp",width) + else + context("\\abovewithdelims%s%s%ssp",resolved[left],resolved[right],width) + end + else -- v_auto + if left == 0x002E and right == 0x002E then + normalover() + else + context("\\overwithdelims%s%s",resolved[left],resolved[right]) + end + end +end diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index d3c5add10..61f8316bc 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -230,7 +230,7 @@ return { -- "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", -- - "wait", "writestatus", "define", "redefine", + "wait", "writestatus", "define", "defineexpandable", "redefine", -- "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", -- diff --git a/tex/context/base/pack-com.mkiv b/tex/context/base/pack-com.mkiv index 5ac56d07e..6c1363148 100644 --- a/tex/context/base/pack-com.mkiv +++ b/tex/context/base/pack-com.mkiv @@ -88,6 +88,15 @@ \installcommandhandler \??combination {combination} \??combination +\setfalse\c_strc_constructions_define_commands + +\definelabel + [\v!combination] % handy for configuring + [\c!numberconversion=\v!character, + \c!text=] + +\settrue\c_strc_constructions_define_commands + \setupcombination [\c!width=\v!fit, \c!height=\v!fit, @@ -105,6 +114,17 @@ \let\setupcombinations\setupcombination % for the moment (we might distinguish) \installcorenamespace{combinationlocation} +\installcorenamespace{combinationalternative} + +\appendtoks + \setfalse\c_strc_constructions_define_commands + \normalexpanded + {\definelabel + [\v!combination:\currentcombination]% + [\v!combination\ifx\currentcombinationparent\empty\else:\currentcombinationparent\fi]}% + [\s!counter=\currentcombination,\c!levels=1]% + \settrue\c_strc_constructions_define_commands +\to \everydefinecombination \setvalue{\??combinationlocation\v!left }{\let\m_pack_combinations_leftfiller\relax} \setvalue{\??combinationlocation\v!right }{\let\m_pack_combinations_rightfiller\relax} @@ -243,16 +263,8 @@ % and some settings conflict with already used combination settings so instead % we plug in labels. This also permits extensions later on. -\installcorenamespace{combinationalternative} - \appendtoks \edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}% - \setfalse\c_str_define_commands_label % no helper commands - \ifx\currentcombinationparent\empty - \normalexpanded{\definelabel[\v!combination:\currentcombination]}[\c!text=]% - \else - \normalexpanded{\definelabel[\v!combination:\currentcombination][\currentcombinationparent]}[\c!text=]% - \fi \to \everydefinecombination \def\pack_combinations_pickup % we want to add struts but still ignore an empty box @@ -277,7 +289,7 @@ \ifx\p_align\empty\else\setupalign[\p_align]\fi \usecombinationstyleandcolor\c!style\c!color % but label style wins, so independent configuration \begstrut - \strc_labels_command{\v!combination:\currentcombination}% + \normalexpanded{\strc_labels_command{\v!combination\ifx\currentcombination\empty\else:\currentcombination\fi}}% \endstrut \egroup} @@ -286,8 +298,8 @@ \ifx\p_pack_combinations_alternative\v!label \edef\p_continue{\combinationparameter\c!continue}% \ifx\p_continue\v!yes \else - \strc_counters_reset{\v!combination:\currentcombination}% - \fi + \normalexpanded{\strc_labels_reset{\v!combination\ifx\currentcombination\empty\else:\currentcombination\fi}{1}}% + \fi \fi \to \everycombination diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index dedcf1683..a10e413cc 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 04de078cc..900a662a0 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index be26a2030..95139d1d4 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -3762,6 +3762,12 @@ return { loading = "math-ini", status = "okay", }, + { + category = "lua", + filename = "math-frc", + loading = "math-frc", + status = "okay", + }, { category = "lua", comment = "okay, but we might have a few more low level definers some day", diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi index 0f5b202b9..11cd31983 100644 --- a/tex/context/base/strc-con.mkvi +++ b/tex/context/base/strc-con.mkvi @@ -105,6 +105,8 @@ \let\currentconstructionlevel \empty \let\currentconstructionhandler\empty +\settrue\c_strc_constructions_define_commands % use with care, might become a proper key + \appendtoks \ifx\currentconstructionparent\empty \letvalue{\??constructionmain\currentconstruction}\currentconstruction @@ -118,8 +120,10 @@ \to \everydefineconstruction \appendtoks - \setuevalue{\e!start\currentconstruction}{\strc_constructions_start{\currentconstruction}}% - \setuevalue{\e!stop \currentconstruction}{\strc_constructions_stop}% + \ifconditional\c_strc_constructions_define_commands + \setuevalue{\e!start\currentconstruction}{\strc_constructions_start{\currentconstruction}}% + \setuevalue{\e!stop \currentconstruction}{\strc_constructions_stop}% + \fi \to \everydefineconstruction %D Just a basic environment (mostly for testing). We will provide a 'setup' based @@ -961,4 +965,11 @@ \installstructurelistprocessor{construction}{\usestructurelistprocessor{number+title}} +% Helpers: + +\def\currentconstructionnumber{\constructionparameter\s!counter} + +\unexpanded\def\strc_constructions_next_indeed #get#tag#level{\strc_counters_increment_sub{#get{#tag}\s!counter}{#level}} +\unexpanded\def\strc_constructions_reset_indeed#get#tag#level{\strc_counters_reset_sub {#get{#tag}\s!counter}{#level}} + \protect \endinput diff --git a/tex/context/base/strc-enu.mkvi b/tex/context/base/strc-enu.mkvi index 185b4177e..e369bc2e1 100644 --- a/tex/context/base/strc-enu.mkvi +++ b/tex/context/base/strc-enu.mkvi @@ -135,11 +135,11 @@ \setevalue{\??enumeration#tag:\s!parent}{\??enumeration}}% {\normalexpanded{\defineconstruction[#tag][#parent][\s!handler=\v!enumeration,\c!level=#level]}% \setevalue{\??enumeration#tag:\s!parent}{\??enumeration#parent}}% - \setuevalue{\e!next #tag}{\strc_enumerations_next }% - \setuevalue{\c!reset#tag}{\strc_enumerations_reset }% - %setuevalue{\c!set #tag}{\strc_enumerations_set }% - \setuevalue {#tag}{\strc_enumerations_command{#tag}}% - \setuevalue{\e!start#tag}{\strc_enumerations_start {#tag}}% + \setuevalue{\e!next #tag}{\strc_enumerations_next {#tag}{\number#level}}% obsolete + \setuevalue{\c!reset#tag}{\strc_enumerations_reset {#tag}{\number#level}}% obsolete + %setuevalue{\c!set #tag}{\strc_enumerations_set {#tag}{\number#level}}% obsolete + \setuevalue {#tag}{\strc_enumerations_command{#tag}}% we could pass level here as well (faster) + \setuevalue{\e!start#tag}{\strc_enumerations_start {#tag}}% we could pass level here as well (faster) \setuevalue{\e!stop #tag}{\strc_enumerations_stop }} \appendtoks @@ -217,12 +217,9 @@ \let\strc_enumerations_start \strc_descriptions_start \let\strc_enumerations_stop \strc_descriptions_stop -\unexpanded\def\strc_enumerations_next {\strc_counters_increment_sub{\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}} -\unexpanded\def\strc_enumerations_reset {\strc_counters_reset_sub {\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}} -%unexpanded\def\strc_enumerations_set#tag{\strc_counters_set_sub {\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}{#tag}} - -\def\currentconstructionnumber {\constructionparameter\s!counter} -\def\specificconstructionnumber#tag{\namedconstructionparameter{#tag}\s!counter} +\unexpanded\def\strc_enumerations_next {\strc_constructions_next_indeed \namedenumerationparameter} % #1#2 +\unexpanded\def\strc_enumerations_reset{\strc_constructions_reset_indeed\namedenumerationparameter} % #1#2 +%unexpanded\def\strc_enumerations_set {\strc_constructions_set_indeed \namedenumerationparameter} % #1#2 %D Counters (maybe we can share this code): (not ok yet, messy with notes) diff --git a/tex/context/base/strc-lab.mkiv b/tex/context/base/strc-lab.mkiv index 21588a743..ce4cdcc5e 100644 --- a/tex/context/base/strc-lab.mkiv +++ b/tex/context/base/strc-lab.mkiv @@ -15,6 +15,8 @@ \unprotect +% todo: reset and increment will go + %D Labels are implemented somewhat inefficient but have the advantage that they %D can be controlled like other constructions. Who knows when that comes in %D handy? @@ -49,22 +51,17 @@ \c!state=\v!start, \c!levels=3] -\settrue\c_str_define_commands_label - \unexpanded\def\strc_define_commands_label#1#2#3% current level parent {\doifelsenothing{#3} {\normalexpanded{\defineconstruction[#1][\s!handler=\v!label,\c!level=#2]}% \setevalue{\??label#1:\s!parent}{\??label}}% {\normalexpanded{\defineconstruction[#1][#3][\s!handler=\v!label,\c!level=#2]}% \setevalue{\??label#1:\s!parent}{\??label#3}}% - \ifconditional\c_str_define_commands_label - \setuevalue{\e!next #1}{\strc_labels_next }% - \setuevalue{\c!reset#1}{\strc_labels_reset }% - %setuevalue{\c!set #1}{\strc_labels_set }% + \ifconditional\c_strc_constructions_define_commands + \setuevalue{\e!next #1}{\strc_labels_next {#1}{\number#2}}% obsolete + \setuevalue{\c!reset#1}{\strc_labels_reset {#1}{\number#2}}% obsolete + %setuevalue{\c!set #1}{\strc_labels_set {#1}{\number#2}}% obsolete \setuevalue {#1}{\strc_labels_command{#1}}% - \else - % used indirectly - \settrue\c_str_define_commands_label \fi} % todo: \strc_labels_command for user @@ -141,9 +138,10 @@ %D Interfaces: \let\strc_labels_command\strc_descriptions_command -\let\strc_labels_next \strc_enumerations_next -\let\strc_labels_reset \strc_enumerations_reset -%let\strc_labels_set \strc_enumerations_set + +\unexpanded\def\strc_labels_next {\strc_constructions_next_indeed \namedlabelparameter} % #1#2 +\unexpanded\def\strc_labels_reset{\strc_constructions_reset_indeed\namedlabelparameter} % #1#2 +%unexpanded\def\strc_labels_set {\strc_constructions_set_indeed \namedlabelparameter} % #1#2 % similar to enumerations diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi index 921bd0373..76816d035 100644 --- a/tex/context/base/strc-not.mkvi +++ b/tex/context/base/strc-not.mkvi @@ -131,11 +131,9 @@ {\normalexpanded{\defineconstruction[#tag][#parent][\s!handler=\v!notation,\c!level=#level]}% \setevalue{\??note#tag:\s!parent}{\??note#parent}% see later for \s!note \setevalue{\??notation#tag:\s!parent}{\??notation#parent}}% - \setuevalue{\e!next #tag}{\strc_notations_next }% - \setuevalue{\c!reset#tag}{\strc_notations_reset }% - %setuevalue{\c!set #tag}{\strc_notations_set }% - %setuevalue {#tag}{\strc_notations_command{\currentnotation}}% - %setuevalue{\e!start#tag}{\strc_notations_start {\currentnotation}{#tag}}% + \setuevalue{\e!next #tag}{\strc_notations_next {#tag}{\number#level}}% obsolete + \setuevalue{\c!reset#tag}{\strc_notations_reset {#tag}{\number#level}}% obsolete + %setuevalue{\c!set #tag}{\strc_notations_set {#tag}{\number#level}}% obsolete \setuevalue {#tag}{\strc_notations_command{#tag}}% \setuevalue{\e!start#tag}{\strc_notations_start {#tag}{#tag}}% okay? \setuevalue{\e!stop #tag}{\strc_notations_stop }} @@ -221,9 +219,9 @@ % \notation[reference=,title=] % \startnotation[ref] title \stopnotation -\let\strc_notations_next \strc_enumerations_next -\let\strc_notations_reset\strc_enumerations_reset -%let\strc_notations_set \strc_enumerations_set +\unexpanded\def\strc_notations_next {\strc_constructions_next_indeed \namednotationparameter} % #1#2 +\unexpanded\def\strc_notations_reset{\strc_constructions_reset_indeed\namednotationparameter} % #1#2 +%unexpanded\def\strc_notations_set {\strc_constructions_set_indeed \namednotationparameter} % #1#2 \unexpanded\def\strc_notations_command#tag% {\begingroup -- cgit v1.2.3