summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2013-12-24 17:52:00 +0100
committerHans Hagen <pragma@wxs.nl>2013-12-24 17:52:00 +0100
commitaa4a1c3b114d386a588677f02f9adf7a81229ccf (patch)
treee917d8e041c043c6d71a6d87d80d8d9ec996a7e8 /tex
parent7782983431dad86a7ee371ea6638b948a599e8c6 (diff)
downloadcontext-aa4a1c3b114d386a588677f02f9adf7a81229ccf.tar.gz
beta 2013.12.24 17:52
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/buff-ver.lua30
-rw-r--r--tex/context/base/buff-ver.mkiv64
-rw-r--r--tex/context/base/context-version.pdfbin4127 -> 4110 bytes
-rw-r--r--tex/context/base/l-table.lua9
-rw-r--r--tex/context/base/l-unicode.lua11
-rw-r--r--tex/context/base/meta-ini.mkiv21
-rw-r--r--tex/context/base/mlib-pps.lua59
-rw-r--r--tex/context/base/mult-def.mkiv1
-rw-r--r--tex/context/base/status-files.pdfbin24635 -> 24627 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin228090 -> 228242 bytes
-rw-r--r--tex/context/base/syst-aux.lua5
-rw-r--r--tex/context/base/syst-aux.mkiv22
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua11
13 files changed, 163 insertions, 70 deletions
diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua
index 772008e39..3300ac6cb 100644
--- a/tex/context/base/buff-ver.lua
+++ b/tex/context/base/buff-ver.lua
@@ -46,20 +46,21 @@ local v_all = variables.all
-- beware, all macros have an argument:
-local doinlineverbatimnewline = context.doinlineverbatimnewline
-local doinlineverbatimbeginline = context.doinlineverbatimbeginline
-local doinlineverbatimemptyline = context.doinlineverbatimemptyline
-local doinlineverbatimstart = context.doinlineverbatimstart
-local doinlineverbatimstop = context.doinlineverbatimstop
-
-local dodisplayverbatimnewline = context.dodisplayverbatimnewline
-local dodisplayverbatimbeginline = context.dodisplayverbatimbeginline
-local dodisplayverbatimemptyline = context.dodisplayverbatimemptyline
-local dodisplayverbatimstart = context.dodisplayverbatimstart
-local dodisplayverbatimstop = context.dodisplayverbatimstop
-
-local verbatim = context.verbatim
-local doverbatimspace = context.doverbatimspace
+local doinlineverbatimnewline = context.doinlineverbatimnewline
+local doinlineverbatimbeginline = context.doinlineverbatimbeginline
+local doinlineverbatimemptyline = context.doinlineverbatimemptyline
+local doinlineverbatimstart = context.doinlineverbatimstart
+local doinlineverbatimstop = context.doinlineverbatimstop
+
+local dodisplayverbatiminitialize = context.dodisplayverbatiminitialize -- the number of arguments might change over time
+local dodisplayverbatimnewline = context.dodisplayverbatimnewline
+local dodisplayverbatimbeginline = context.dodisplayverbatimbeginline
+local dodisplayverbatimemptyline = context.dodisplayverbatimemptyline
+local dodisplayverbatimstart = context.dodisplayverbatimstart
+local dodisplayverbatimstop = context.dodisplayverbatimstop
+
+local verbatim = context.verbatim
+local doverbatimspace = context.doverbatimspace
local CargOne = Carg(1)
@@ -710,6 +711,7 @@ commands.loadvisualizer = visualizers.load
function commands.typebuffer(settings)
local lines = getlines(settings.name)
if lines then
+ dodisplayverbatiminitialize(#lines)
local content, m = filter(lines,settings)
if content and content ~= "" then
-- content = decodecomment(content)
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index dcea15496..bdde5df9d 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -437,21 +437,31 @@
\expandafter\buff_verbatim_typing_start_nop
\fi}
+\unexpanded\def\buff_verbatim_setup_keep_together
+ {\edef\p_keeptogether{\typingparameter\c!keeptogether}%
+ \ifx\p_keeptogether\v!yes
+ \settrue \c_buff_optimize_linebreaks
+ \else
+ \setfalse\c_buff_optimize_linebreaks
+ \fi}
+
\def\buff_verbatim_typing_start_nop
{\typingparameter\c!before
\startpacked[\v!blank]
\buff_verbatim_setup_line_numbering
\buff_verbatim_initialize_typing_one
+ \buff_verbatim_setup_keep_together
\normalexpanded{\buff_verbatim_type_block{\e!start\currenttyping}{\e!stop\currenttyping}}}
\def\buff_verbatim_typing_start_yes[#1]%
{\typingparameter\c!before
\startpacked[\v!blank]
\doifassignmentelse{#1}
- {\setuptyping[\currenttyping][#1]}
- {\doifinset\v!continue{#1}{\setuptyping[\currenttyping][\c!continue=\v!yes]}}%
+ {\setupcurrenttyping[#1]}
+ {\doifinset\v!continue{#1}{\lettypingparameter\c!continue\v!yes}}%
\buff_verbatim_setup_line_numbering
\buff_verbatim_initialize_typing_one
+ \buff_verbatim_setup_keep_together
\normalexpanded{\buff_verbatim_type_block{\e!start\currenttyping}{\e!stop\currenttyping}}}
\unexpanded\def\buff_verbatim_type_block#1#2%
@@ -660,6 +670,7 @@
\setuptyping
[\c!before=\blank,
\c!after=\blank,
+ %\c!keeptogether=yes, % this will become default (when tested enough)
%\c!bodyfont=,
%\c!color=,
\c!space=\v!off,
@@ -835,19 +846,42 @@
% hooks:
-\def\doinlineverbatimstart {}
-\def\doinlineverbatimstop {}
-\def\doinlineverbatimbeginline {}
-\def\doinlineverbatimnewline {\obeyedspace}
-\def\doinlineverbatimemptyline {\obeyedspace}
-
-\def\dodisplayverbatimstart {\buff_verbatim_begin_of_line}
-\def\dodisplayverbatimstop {\buff_verbatim_end_of_line}
-\def\dodisplayverbatimbeginline {\buff_verbatim_begin_of_line}
-\def\dodisplayverbatimnewline {\buff_verbatim_end_of_line\par}
-\def\dodisplayverbatimemptyline {\buff_verbatim_empty_line}
-
-\def\doverbatimspace {\obeyedspace}
+\newcount \c_buff_verbatim_noflines
+\newcount \c_buff_verbatim_current
+\newconditional\c_buff_optimize_linebreaks
+
+\def\doverbatimspace {\obeyedspace}
+
+\unexpanded\def\doinlineverbatimstart {}
+\unexpanded\def\doinlineverbatimstop {}
+\unexpanded\def\doinlineverbatimbeginline {}
+\unexpanded\def\doinlineverbatimnewline {\obeyedspace}
+\unexpanded\def\doinlineverbatimemptyline {\obeyedspace}
+
+\unexpanded\def\dodisplayverbatimstart {\advance\c_buff_verbatim_current\plusone
+ \buff_verbatim_begin_of_line}
+\unexpanded\def\dodisplayverbatimstop {\buff_verbatim_end_of_line}
+\unexpanded\def\dodisplayverbatimbeginline{\advance\c_buff_verbatim_current\plusone
+ \buff_verbatim_begin_of_line}
+\unexpanded\def\dodisplayverbatimnewline {\buff_verbatim_end_of_line
+ \par
+ \ifconditional\c_buff_optimize_linebreaks
+ \buff_verbatim_inject_breaks
+ \fi}
+\unexpanded\def\dodisplayverbatimemptyline{\buff_verbatim_empty_line}
+
+\unexpanded\def\buff_verbatim_inject_breaks
+ {\ifnum\c_buff_verbatim_current=\plusone
+ \nobreak
+ \else\ifnum\c_buff_verbatim_noflines=\plusthree
+ \nobreak
+ \else\ifnum\c_buff_verbatim_current=\numexpr\c_buff_verbatim_noflines-\plusone\relax
+ \nobreak
+ \fi\fi\fi}
+
+\unexpanded\def\dodisplayverbatiminitialize#1%
+ {\c_buff_verbatim_noflines#1\relax
+ \c_buff_verbatim_current\zerocount}
\loadmarkfile{buff-imp-default} % preloaded as otherwise spurious spaces inline due to loading
\loadmarkfile{buff-imp-nested} % preloaded as otherwise spurious spaces inline due to loading
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 6fddaff80..131d44aee 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index c6bbc62d6..f361f3d20 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -129,10 +129,13 @@ local function sortedhash(t,cmp)
s = sortedkeys(t) -- the robust one
end
local n = 0
+ local m = #s
local function kv(s)
- n = n + 1
- local k = s[n]
- return k, t[k]
+ if n < m then
+ n = n + 1
+ local k = s[n]
+ return k, t[k]
+ end
end
return kv, s
else
diff --git a/tex/context/base/l-unicode.lua b/tex/context/base/l-unicode.lua
index 902f6a0d0..6601a4c62 100644
--- a/tex/context/base/l-unicode.lua
+++ b/tex/context/base/l-unicode.lua
@@ -9,7 +9,6 @@ if not modules then modules = { } end modules ['l-unicode'] = {
-- this module will be reorganized
-- todo: utf.sub replacement (used in syst-aux)
-
-- we put these in the utf namespace:
utf = utf or (unicode and unicode.utf8) or { }
@@ -1130,3 +1129,13 @@ if not utf.values then
string.utfvalues = utf.values
end
+
+function utf.chrlen(u) -- u is number
+ return
+ (u < 0x80 and 1) or
+ (u < 0xE0 and 2) or
+ (u < 0xF0 and 3) or
+ (u < 0xF8 and 4) or
+ (u < 0xFC and 5) or
+ (u < 0xFE and 6) or 0
+end
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index 32f72cfe6..147c9c89a 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -849,10 +849,12 @@
% This will change ...
-\def\MPdataMPDfile{\jobname-mpgraph.mpd}
+\def\MPdataMPDfile{\jobname-mpgraph.mpd} % this one will become obsolete
\def\MPdataMPOfile{\jobname-mpgraph.mpo}
\def\MPdataMPYfile{\jobname-mpgraph.mpy}
+% makempy.registerfile(filename)
+
\startMPinitializations
boolean collapse_data; collapse_data:=true;
def data_mpd_file = "\MPdataMPDfile" enddef ;
@@ -1446,6 +1448,23 @@
\setupMPgraphics
[\c!color=\v!local]
+%D This can save some runtime: rename the mpy file from a first run (when stable) to
+%D another file and reuse it. One can also use the original filename, but a copy is
+%D often better.
+%D
+%D \starttyping
+%D \setupMPgraphics
+%D [mpy=\jobname.mpy]
+%D \stoptyping
+
+\appendtoks
+ \edef\p_mpy{\directMPgraphicsparameter{mpy}}%
+ \ifx\p_mpy\empty \else
+ \let\MPdataMPYfile\p_mpy
+ \ctxlua{metapost.makempy.registerfile("\p_mpy")}%
+ \fi
+\to \everysetupMPgraphics
+
%D Done.
\protect \endinput
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index 535c9ff9d..865f76018 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -674,37 +674,48 @@ local start = [[\starttext]]
local preamble = [[\def\MPLIBgraphictext#1{\startTEXpage[scale=10000]#1\stopTEXpage}]]
local stop = [[\stoptext]]
+local mpyfilename = nil
+
+function makempy.registerfile(filename)
+ mpyfilename = filename
+end
+
function makempy.processgraphics(graphics)
- if #graphics > 0 then
- makempy.nofconverted = makempy.nofconverted + 1
- starttiming(makempy)
- local mpofile = tex.jobname .. "-mpgraph"
- local mpyfile = file.replacesuffix(mpofile,"mpy")
- local pdffile = file.replacesuffix(mpofile,"pdf")
- local texfile = file.replacesuffix(mpofile,"tex")
- io.savedata(texfile, { start, preamble, metapost.tex.get(), concat(graphics,"\n"), stop }, "\n")
- local command = format("context --once %s %s", (tex.interactionmode == 0 and "--batchmode") or "", texfile)
+ if #graphics == 0 then
+ return
+ end
+ if mpyfilename and io.exists(mpyfilename) then
+ report_metapost("using file: %s",mpyfilename)
+ return
+ end
+ makempy.nofconverted = makempy.nofconverted + 1
+ starttiming(makempy)
+ local mpofile = tex.jobname .. "-mpgraph"
+ local mpyfile = file.replacesuffix(mpofile,"mpy")
+ local pdffile = file.replacesuffix(mpofile,"pdf")
+ local texfile = file.replacesuffix(mpofile,"tex")
+ io.savedata(texfile, { start, preamble, metapost.tex.get(), concat(graphics,"\n"), stop }, "\n")
+ local command = format("context --once %s %s", (tex.interactionmode == 0 and "--batchmode") or "", texfile)
+ os.execute(command)
+ if io.exists(pdffile) then
+ command = format("pstoedit -ssp -dt -f mpost %s %s", pdffile, mpyfile)
+ logs.newline()
+ report_metapost("running: %s",command)
+ logs.newline()
os.execute(command)
- if io.exists(pdffile) then
- command = format("pstoedit -ssp -dt -f mpost %s %s", pdffile, mpyfile)
- logs.newline()
- report_metapost("running: %s",command)
- logs.newline()
- os.execute(command)
+ if io.exists(mpyfile) then
local result, r = { }, 0
- if io.exists(mpyfile) then
- local data = io.loaddata(mpyfile)
- if data and #data > 0 then
- for figure in gmatch(data,"beginfig(.-)endfig") do
- r = r + 1
- result[r] = formatters["begingraphictextfig%sendgraphictextfig ;\n"](figure)
- end
- io.savedata(mpyfile,concat(result,""))
+ local data = io.loaddata(mpyfile)
+ if data and #data > 0 then
+ for figure in gmatch(data,"beginfig(.-)endfig") do
+ r = r + 1
+ result[r] = formatters["begingraphictextfig%sendgraphictextfig ;\n"](figure)
end
+ io.savedata(mpyfile,concat(result,""))
end
end
- stoptiming(makempy)
end
+ stoptiming(makempy)
end
-- -- the new plugin handler -- --
diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv
index 3d480e187..85ce5d2cb 100644
--- a/tex/context/base/mult-def.mkiv
+++ b/tex/context/base/mult-def.mkiv
@@ -35,6 +35,7 @@
% start todo:
\def\c!fences {fences}
+\def\c!keeptogether {keeptogether}
\def\c!sectionblock {sectionblock}
\def\c!language {language}
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index ffa1b6e2c..59f96fc11 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 11aabfd82..99338da8c 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/syst-aux.lua b/tex/context/base/syst-aux.lua
index 9ef28996a..6b5e18d16 100644
--- a/tex/context/base/syst-aux.lua
+++ b/tex/context/base/syst-aux.lua
@@ -108,3 +108,8 @@ local pattern = Cs(
function commands.thetexdefinition(str)
context(lpegmatch(pattern,str))
end
+
+local upper, lower = utf.upper, utf.lower
+
+function commands.upper(s) context(upper(s)) end
+function commands.lower(s) context(lower(s)) end
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index 8e02432c9..c7be461a3 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -5470,7 +5470,7 @@
%D We have to use a two||step implementation, because the
%D expansion has to take place outside \type{\uppercase}.
%D
-%D These might up as \LUA based helpers (i.e. considere these
+%D These might end up as \LUA based helpers (i.e. consider these
%D obsolete:
\unexpanded\def\syst_helpers_do_IF#1#2%
@@ -5892,7 +5892,7 @@
\ifdefined\normalquitvmode \let\dontleavehmode\normalquitvmode \fi
%D \macros
-%D {uppercasestring,lowercasestring}
+%D {utfupper, utflower, uppercasestring, lowercasestring}
%D
%D The names tell what they do:
%D
@@ -5903,14 +5903,20 @@
%D
%D The first argument may be a \type{\macro}.
-\unexpanded\def\uppercasestring#1\to#2%
- {\uppercase\expandafter{\expandafter\dodoglobal\expandafter\edef\expandafter#2\expandafter{\normalexpanded{#1}}}}
-
-\unexpanded\def\lowercasestring#1\to#2%
- {\lowercase\expandafter{\expandafter\dodoglobal\expandafter\edef\expandafter#2\expandafter{\normalexpanded{#1}}}}
+% \unexpanded\def\uppercasestring#1\to#2%
+% {\uppercase\expandafter{\expandafter\dodoglobal\expandafter\edef\expandafter#2\expandafter{\normalexpanded{#1}}}}
+%
+% \unexpanded\def\lowercasestring#1\to#2%
+% {\lowercase\expandafter{\expandafter\dodoglobal\expandafter\edef\expandafter#2\expandafter{\normalexpanded{#1}}}}
%D These macros are sort of obsolete as we never use uppercase this
-%D way.
+%D way. But nevertheless we provide them:
+
+\def\utfupper#1{\ctxcommand{upper(\!!bs#1\!!es)}} % expandable
+\def\utflower#1{\ctxcommand{lower(\!!bs#1\!!es)}} % expandable
+
+\unexpanded\def\uppercasestring#1\to#2{\dodoglobal\edef#2{\ctxcommand{upper(\!!bs#1\!!es)}}}
+\unexpanded\def\lowercasestring#1\to#2{\dodoglobal\edef#2{\ctxcommand{lower(\!!bs#1\!!es)}}}
%D \macros
%D {handletokens}
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index bf787ba6d..177324145 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 12/22/13 19:05:41
+-- merge date : 12/24/13 17:52:44
do -- begin closure to overcome local limits and interference
@@ -922,10 +922,13 @@ local function sortedhash(t,cmp)
s=sortedkeys(t)
end
local n=0
+ local m=#s
local function kv(s)
- n=n+1
- local k=s[n]
- return k,t[k]
+ if n<m then
+ n=n+1
+ local k=s[n]
+ return k,t[k]
+ end
end
return kv,s
else