This MWE has a framed text for some verbatim text (code) with as title ref.
a counter 1, 2, etc.. Is there a way to change this frame text title as
following with the chapter number and a sequential number and the title.

Code Fragment 1.1 (The First Title)
Code Fragment 1.2 (The Second Title)
Code Fragment 2.1 (The Third Title)

MWE:

\startuseMPgraphic{CountFrame}
  picture p; numeric w, h, o;
  p := textext.rt("\wrappedcurrentconstruction");
  w := OverlayWidth; h := OverlayHeight; o := BodyFontSize;
    p := p shifted (2o,h-ypart center p);
    draw p;
    path b;
    b := boundingbox p enlarged (o/10);
    drawoptions (withpen pencircle scaled 1pt withcolor black);
    draw (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner b,h);
    draw b;
    setbounds currentpicture to OverlayBox;
\stopuseMPgraphic

\defineoverlay
  [CountFrame]
  [\useMPgraphic{CountFrame}]

\defineframedtext
  [CountFramedText]
  [frame=off,
   background=CountFrame,
   offset=\bodyfontsize,
   width=\textwidth,
%   style={\switchtobodyfont[11pt,tt]}]
   bodyfont=11pt,
   style={\tt},
   ]

\def\FrameTitle#1%
  {\setMPtext{CountFrame}
  {\hbox spread 1em{\hss\strut#1\hss}}}\setMPtext{CountFrame}
  {}

\defineenumeration
  [Counter]
  [title=yes,
   alternative=empty,
   before=\startCountFramedText,
   after=\stopCountFramedText]

\starttext

\startchapter
  [title=first]

\startCounter
  [title={The First Title},
   reference={tit1}]
   Some verbatim text
\stopCounter

\startCounter
  [title={The Second Title},
   reference={tit2}]
   Some verbatim text
\stopCounter

Refer to \in{code fragment}[tit1] bla

\stopchapter

\startchapter
  [title=second]

\startCounter
  [title={The Third Title},
   reference={tit3}]
   Some verbatim text
\stopCounter

\stopchapter

\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

Reply via email to