Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Aditya Mahajan

On Sat, 16 May 2020, Nicola wrote:


On 2020-05-16, Aditya Mahajan  wrote:

On Sat, 16 May 2020, Aditya Mahajan wrote:



Moreover, if you comment line line 126 of `2context.vim`

 "let s:id  = synIDtrans (s:id)

[If you make a local copy of 2context.vim, then you need to run the
file with `--mode=dev-vim` to ensure that the local copy is used]

Then the ruby example generates the following file:

\SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ 
}\SYN[rubyMethodName]{foobar}\SYNEOL{}
\SYNBOL{}\SYN[rubyMethodBlock]{  
print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello 
World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}

So, if you are willing to define wrappers for all ruby syntax blocks,
then I can provide a configuration option so that `2context` does not
apply that line.



That might provide a finer control over the highlighting, but the main
issue here seems to be that the generated file has Identifier instead of
Function, Special instead of Delimiter and Constant instead of String.
Looking at 2context.vim, AFAICS s:id_name seems computed correctly.
Maybe, the script does not set the appropriate filetype?


filetype is set correctly (since we get `ruby` options), but something 
weird is happening even with 2html.vim. Here is a minimal example:

```test.rb
# Ruby program listing
def foobar
  print("Hello World")
end
```

Run:

vim -u NONE -c "syntax manual" -c "set syntax=ruby" -c "source 
/usr/share/nvim/runtime/syntax/2html.vim" -c "wqa" test.rb

gives

```test.rb.html
http://www.w3.org/TR/html4/strict.dtd;>


...



# Ruby program listing
def foobar
  print(Hello World)
end





```

which is similar to what 2context.vim gets. If I source tohtml.vim or 
2context.vim from an existing vim session, then the tags are correct. I have 
not been able to figure out why this is happening.

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Arithmetic Overflow error in MetaFun

2020-05-16 Thread Hans Hagen

On 5/16/2020 4:48 PM, Keith McKay wrote:

Answering my own problem here.

I've just searched through the mailing list archives and it seems that 
if I add [instance=doublefun] I do not get the Arithmetic Overflow 
error. Joy!

fwiw, we have also instance=decimalfun

concerning arithmic:

in metapost we have

scaled  : upto 4K bp
double  : 64 bit floats
decimal : configurable accuracy
complex : dual doubles (only in luametafun)

in lmtx lua we have:

integer  : lua tries to be clever but mixing leads to double
float: lua tries to be clever
decimal  : userdata arbitrary precision (only in lmtx)
complex  : userdata dual doubles (only in lmtx)

(in lmtx we have an extended math library and these function are also 
available in luametafun)


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Nicola
On 2020-05-16, Aditya Mahajan  wrote:
> On Sat, 16 May 2020, Aditya Mahajan wrote:

> Moreover, if you comment line line 126 of `2context.vim`
>
>  "let s:id  = synIDtrans (s:id)
>
> [If you make a local copy of 2context.vim, then you need to run the
> file with `--mode=dev-vim` to ensure that the local copy is used]
>
> Then the ruby example generates the following file:
>
> \SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{}
> \SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ 
> }\SYN[rubyMethodName]{foobar}\SYNEOL{}
> \SYNBOL{}\SYN[rubyMethodBlock]{  
> print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello 
> World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{}
> \SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}
>
> So, if you are willing to define wrappers for all ruby syntax blocks,
> then I can provide a configuration option so that `2context` does not
> apply that line.

That might provide a finer control over the highlighting, but the main
issue here seems to be that the generated file has Identifier instead of
Function, Special instead of Delimiter and Constant instead of String.
Looking at 2context.vim, AFAICS s:id_name seems computed correctly.
Maybe, the script does not set the appropriate filetype?

Nicola


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

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


[NTG-context] \goto not working from within \textext()

2020-05-16 Thread Gerben Wierda
This does give me ythe look of a link, but not a working link. Outside of 
textext() it works. Is there a way to get a working link in a MetaFun picture?

Thx,

G

  \setupinteraction
[state=start,
 color=blue,
 style=bold]

\starttext
\goto{works}[url(https://ea.rna.nl/2011/06/05/on-the-use-of-colours-in-archimate/)]
\setupMPpage
  [background=color,
   backgroundcolor=gray]
\startMPpage[instance=doublefun]
draw textext("\goto{doesn’t 
work}[url(https://ea.rna.nl/2011/06/05/on-the-use-of-colours-in-archimate/)]");
\stopMPpage

\stoptext

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

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


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Aditya Mahajan

On Sat, 16 May 2020, Aditya Mahajan wrote:


On Sat, 16 May 2020, Nicola wrote:


On 2020-05-14, Aditya Mahajan  wrote:

On Thu, 14 May 2020, Nicola wrote:


Quick question: Is \startcolorscheme... \stopcolorscheme (still)
supported by t-vim?



It is supposed to work. If it doesn't, then it is a bug. Could you
provide a complete MWE.


Please find a MWE at the bottom of this post.

The expected behaviour is that the keyword `function` in the JavaScript
snippet and `foobar` in the Ruby snippet should be colored and in
italics, as comments are. The respective Vim highlight groups are
`javaScriptFunction` and `rubyMethodName`, which both resolve to
`Function`.


The reason that there is no highlighting is because the generated `.vimout` 
does not contain any `\SYN[rubyMethodName]` or `\SYN[javaScriptFunction]` for 
the following reason:


Vim has the concept of a hierarchy of names for the syntax highlighting 
regions. For example, $VIMRUNTIME/syntax/ruby.rb contains the following 
lines:


hi def link rubyMethodName  rubyFunction
hi def link rubyFunction  Function

So, `rubyMethodName` maps to `rubyFunction`, which in turn maps to 
`Function`. Now, a vim colorscheme first checks if a highlighting style is 
available for `rubyMethodName`; if not it tries `rubyFunction`; and if not it 
tries `Function`.


Although something similar might have been possible in 2context.vim, I follow 
the `TOHtml` function of vim, and simply created a single tag for each syntax 
highlighting element, which in this case is `Function`. So, there is no tag 
generated for `rubyMethodName` and that is why changing the syntaxhighlight 
for that doesn't change anything.


Moreover, if you comment line line 126 of `2context.vim`

"let s:id  = synIDtrans (s:id)

[If you make a local copy of 2context.vim, then you need to run the file with 
`--mode=dev-vim` to ensure that the local copy is used]

Then the ruby example generates the following file:

\SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ 
}\SYN[rubyMethodName]{foobar}\SYNEOL{}
\SYNBOL{}\SYN[rubyMethodBlock]{  
print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello 
World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}

So, if you are willing to define wrappers for all ruby syntax blocks, then I 
can provide a configuration option so that `2context` does not apply that line.

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Arithmetic Overflow error in MetaFun

2020-05-16 Thread Hans Hagen

On 5/16/2020 4:36 PM, Keith McKay wrote:

Colleagues

I'm having problems with an Arithmetic Overflow error when calculating 
the x and y values for functions of the form:


y = ax^4 + bx^3 + cx^2 + dx + e

to which I then add a bit of randomness and other embellishments. I have 
had a look in the Metafun and Metafont manuals but nothing jumps out at 
me. In the minimum working example below, this Arithmetic Overflow 
occurs when xord =13.5 but I can get the calculation to work if I 
separate out the equation and then add together, since it seems to be 
failing on the pow(xord,4) instruction. Is there a switch in MetaFont 
that should be set or a better way of getting round this Arithmetic 
Overflow error?


\startMPpage[instance=doublefun]

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Arithmetic Overflow error in MetaFun

2020-05-16 Thread Keith McKay

Answering my own problem here.

I've just searched through the mailing list archives and it seems that 
if I add [instance=doublefun] I do not get the Arithmetic Overflow 
error. Joy!


Thanks

Best Wishes

Keith McKay

On 16/05/2020 15:36, Keith McKay wrote:


Colleagues

I'm having problems with an Arithmetic Overflow error when calculating 
the x and y values for functions of the form:


y = ax^4 + bx^3 + cx^2 + dx + e

to which I then add a bit of randomness and other embellishments. I 
have had a look in the Metafun and Metafont manuals but nothing jumps 
out at me. In the minimum working example below, this Arithmetic 
Overflow occurs when xord =13.5 but I can get the calculation to work 
if I separate out the equation and then add together, since it seems 
to be failing on the pow(xord,4) instruction. Is there a switch in 
MetaFont that should be set or a better way of getting round this 
Arithmetic Overflow error?


Thanks

Best Wishes

Keith McKay

%MWE%%%

\setuppapersize [A4,landscape]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

path p;

p := unitsquare scaled .1cm ;

path pat;

pat := (0.0*cm,19.935*cm);

for xord = 0 step 0.1 until 25:

show xord;

fails at xord = 13.5%

yord := ((-0.000268117) * pow(xord,4)) +(0.0136949 * pow(xord, 3)) + 
((-0.16608) * sqr(xord)) + ((-0.771743) * xord) + 19.935;


%comment out above and uncomment below and it works

% yord1 := (-0.000268117) * sqr(xord);

% yord1a := yord1 * sqr(xord);

% yord2 := (0.0136949 * pow(xord, 3));

% yord3 := ((-0.16608) * sqr(xord));

% yord4 := ((-0.771743) * xord);

% yord := yord1 + yord1a + yord2 + yord3 + yord4 + 19.935;

xrand := (uniformdeviate(1) - 0.5)*2;

yrand := uniformdeviate(1) - 0.5;

xcoord := xord + xrand;

ycoord := yord + yrand;

if odd xord:

pat := pat ... (xcoord*cm, ycoord*cm);

else:

pat := pat --- (xcoord*cm, ycoord*cm);

fill p shifted (xcoord*cm, ycoord*cm) withcolor 
(uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)) ;


fi;

draw pat withpen pencircle scaled (uniformdeviate(0.75)*mm) withcolor 
(uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)); 
%withtransparency (1, .5);


drawdot (xcoord*cm, ycoord*cm) withpen pencircle scaled 
(uniformdeviate(2.5)*mm) withcolor 
(uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));


endfor;

StopPage;

\stopMPpage

\stoptext

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

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


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Aditya Mahajan

On Sat, 16 May 2020, Nicola wrote:


On 2020-05-14, Aditya Mahajan  wrote:

On Thu, 14 May 2020, Nicola wrote:


Quick question: Is \startcolorscheme... \stopcolorscheme (still)
supported by t-vim?



It is supposed to work. If it doesn't, then it is a bug. Could you
provide a complete MWE.


Please find a MWE at the bottom of this post.

The expected behaviour is that the keyword `function` in the JavaScript
snippet and `foobar` in the Ruby snippet should be colored and in
italics, as comments are. The respective Vim highlight groups are
`javaScriptFunction` and `rubyMethodName`, which both resolve to
`Function`.


The reason that there is no highlighting is because the generated `.vimout` 
does not contain any `\SYN[rubyMethodName]` or `\SYN[javaScriptFunction]` for 
the following reason:

Vim has the concept of a hierarchy of names for the syntax highlighting 
regions. For example, $VIMRUNTIME/syntax/ruby.rb contains the following lines:

hi def link rubyMethodName  rubyFunction
hi def link rubyFunction  Function

So, `rubyMethodName` maps to `rubyFunction`, which in turn maps to `Function`. 
Now, a vim colorscheme first checks if a highlighting style is available for 
`rubyMethodName`; if not it tries `rubyFunction`; and if not it tries 
`Function`.

Although something similar might have been possible in 2context.vim, I follow 
the `TOHtml` function of vim, and simply created a single tag for each syntax 
highlighting element, which in this case is `Function`. So, there is no tag 
generated for `rubyMethodName` and that is why changing the syntaxhighlight for 
that doesn't change anything.

Now, as I was looking into this, I noticed that `foobar` gets mapped to 
`Identifier` rather than `Function`. I am not sure why that is happening and I 
will look into that.

Aditya

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

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


[NTG-context] Arithmetic Overflow error in MetaFun

2020-05-16 Thread Keith McKay

Colleagues

I'm having problems with an Arithmetic Overflow error when calculating 
the x and y values for functions of the form:


y = ax^4 + bx^3 + cx^2 + dx + e

to which I then add a bit of randomness and other embellishments. I have 
had a look in the Metafun and Metafont manuals but nothing jumps out at 
me. In the minimum working example below, this Arithmetic Overflow 
occurs when xord =13.5 but I can get the calculation to work if I 
separate out the equation and then add together, since it seems to be 
failing on the pow(xord,4) instruction. Is there a switch in MetaFont 
that should be set or a better way of getting round this Arithmetic 
Overflow error?


Thanks

Best Wishes

Keith McKay

%MWE%%%

\setuppapersize [A4,landscape]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

path p;

p := unitsquare scaled .1cm ;

path pat;

pat := (0.0*cm,19.935*cm);

for xord = 0 step 0.1 until 25:

show xord;

fails at xord = 13.5%

yord := ((-0.000268117) * pow(xord,4)) +(0.0136949 * pow(xord, 3)) + 
((-0.16608) * sqr(xord)) + ((-0.771743) * xord) + 19.935;


%comment out above and uncomment below and it works

% yord1 := (-0.000268117) * sqr(xord);

% yord1a := yord1 * sqr(xord);

% yord2 := (0.0136949 * pow(xord, 3));

% yord3 := ((-0.16608) * sqr(xord));

% yord4 := ((-0.771743) * xord);

% yord := yord1 + yord1a + yord2 + yord3 + yord4 + 19.935;

xrand := (uniformdeviate(1) - 0.5)*2;

yrand := uniformdeviate(1) - 0.5;

xcoord := xord + xrand;

ycoord := yord + yrand;

if odd xord:

pat := pat ... (xcoord*cm, ycoord*cm);

else:

pat := pat --- (xcoord*cm, ycoord*cm);

fill p shifted (xcoord*cm, ycoord*cm) withcolor 
(uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)) ;


fi;

draw pat withpen pencircle scaled (uniformdeviate(0.75)*mm) withcolor 
(uniformdeviate(1),uniformdeviate(1),uniformdeviate(1)); 
%withtransparency (1, .5);


drawdot (xcoord*cm, ycoord*cm) withpen pencircle scaled 
(uniformdeviate(2.5)*mm) withcolor 
(uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));


endfor;

StopPage;

\stopMPpage

\stoptext

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

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


Re: [NTG-context] Blank page added after pagecolumns

2020-05-16 Thread Joey McCollum
I thought that the "yes" and "nop" suffixes were related to "page=yes" and
"page=no" for a few reasons. First, because I thought "nop" could be
shorthand for "no page." More importantly, however, I thought they might be
related because setting page=no in \definepagecolumns does not appear to
have any effect, and patching \page_col_stop_yes to do what
\page_col_stop_nop does had the desired effect. But as you have shown,
doing this causes problems with the transition back to a single-column
layout, so I suppose that the \page_col_stop_yes and \page_col_stop_nop
macros are meant to implement behavior dependent on the number of columns.
Your suggestion to add a column if the column at the end of the environment
is not the last one is elegant and works on different variations of the
MWE, including cases with more than two columns.

Joey

On Sat, May 16, 2020 at 4:12 AM Wolfgang Schuster <
wolfgang.schuster.li...@gmail.com> wrote:

> Joey McCollum schrieb am 16.05.2020 um 05:45:
> > All right, I've found a tentative solution that appears to work in all
> > cases, but I'd like to know more about why the code I'm patching was
> > implemented in the first place, because I don't want to break anything
> > else. According to the code in page-pcl.mkiv, the \stoppagecolumns macro
> > has two implementations, \page_col_stop_yes and \page_col_stop_nop. The
> > choice of which implementation is used is determined by which of two
> > implementations of \startpagecolumns (\page_col_start_yes
> > and \page_col_start_nop) is used. That choice, in turn, is made in
> > the \page_col_start macro, in the following lines:
> >
> > ```
> > \c_page_col_n_of_columns\pagecolumnsparameter\c!n\relax
> > \ifnum\c_page_col_n_of_columns>\plusone
> >   \expandafter\page_col_start_yes
> > \else
> >   \expandafter\page_col_start_nop
> > \fi
> > ```
> >
> > so if the number of columns (i.e., the n option for the
> > pagecolumns environment) is more than one, the "yes" implementation of
> > the start and stop commands is used.
> >
> > But this seems wrong. The naming convention for the two implementations
> > ("yes" and "nop") suggests that they should be related the parameters
> > "page=yes" and "page=no" (hence, no page, which is what I think "nop"
> > abbreviates), but the choice of which implementation to use is
> > determined not by the page parameter, but by the n parameter. Is this an
> > error in the code, or am I just understanding this incorrectly? Is there
> > some reason why a layout with more than one column would need special
> > instructions to add a blank page after stopping the environment?
>
> Why do you think "yes" and "nop" are related to the page-key?
>
> > In any event, I was able to solve the problem by patching the
> > \page_col_start_yes macro to invoke the \page_col_start_nop macro as
> > follows:
> >
> > ```
> >
> > \unprotect
> >
> > \def\page_col_stop_yes
> > {\page_col_stop_nop}
> >
> > \protect
> >
> > ```
> >
> > With this fix, the MWE I provided works regardless of which column the
> > text ends in. I'm content to consider the problem solved, but I would
> > certainly appreciate any feedback on my thoughts and questions about
> > page-pcl.mkiv.
>
> You broke now now normal single columns text after the pagecolumns
> environment. A better fix is to add a check for the \column command at
> the end of the environment and add it only when we aren't in the last
> column.
>
> \unexpanded\def\page_col_stop_yes
>{%\column % \page_otr_eject_page
> \ifnum\c_page_col_current<\c_page_col_n_of_columns
>   \column
> \fi
> \page
> \endgroup
>   % \setupoutputroutine[\s!singlecolumn]%
> \page_otr_command_set_vsize
> \page_otr_command_set_hsize
> \page
> \endgroup}
>
> Wolfgang
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Nicola
On 2020-05-14, Aditya Mahajan  wrote:
> On Thu, 14 May 2020, Nicola wrote:
>
>> Quick question: Is \startcolorscheme... \stopcolorscheme (still)
>> supported by t-vim?

> It is supposed to work. If it doesn't, then it is a bug. Could you
> provide a complete MWE.

Please find a MWE at the bottom of this post.

The expected behaviour is that the keyword `function` in the JavaScript
snippet and `foobar` in the Ruby snippet should be colored and in
italics, as comments are. The respective Vim highlight groups are
`javaScriptFunction` and `rubyMethodName`, which both resolve to
`Function`.

The actual behaviour is that comments are highlighted correctly, but
I do not get any syntax highlighting for functions.

Thanks for t-vim, btw: I can't express in words how nice an idea it is!

Nicola


\setupcolors[state=start]

\definecolor[colorone][r=0.251, g=0.349, b=0.322]
\definecolor[colortwo][r=0.612, g=0.608, b=0.478]
\definecolor[colorthree]  [r=1.0,   g=0.827, b=0.576]
\definecolor[colorfour]   [r=1.0,   g=0.592, b=0.310]
\definecolor[colorfive]   [r=0.960, g=0.310, b=0.161]
\definecolor[nearlywhite] [r=0.988, g=0.988, b=0.988]

\setupinteraction[state=start]
\setupcolors[textcolor=colorone]
\setupbackgrounds[page][background=color,backgroundcolor=nearlywhite]

\usemodule[vim]
\unprotect
\startcolorscheme[oceansunset]
  \definesyntaxgroup[Comment][\c!color={colorfive},\c!style=italic]
  \definesyntaxgroup[Function][\c!color={colorfive},\c!style=italic]
  % \definesyntaxgroup[rubyMethodName][\c!color={colorfive},\c!style=italic]
  % \definesyntaxgroup[javaScriptFunction][\c!color={colorfive},\c!style=italic]
\stopcolorscheme
\protect

\definevimtyping[JAVASCRIPT][
  syntax=javascript,
  alternative=oceansunset,
  escape=on
]

\definevimtyping[RUBY][
  syntax=ruby,
  alternative=oceansunset,
  escape=on
]

\starttext
\startJAVASCRIPT
// JavaScript program listing
function foobar() {
  print("Hello World");
}
\stopJAVASCRIPT

\startRUBY
# Ruby program listing
def foobar
  print("Hello World")
end
\stopRUBY
\stoptext


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

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


Re: [NTG-context] Custom list layout with PDF bookmarks

2020-05-16 Thread Henning Hraban Ramm

> Am 16.05.2020 um 08:30 schrieb Wolfgang Schuster 
> :
> 
> Bruce Horrocks schrieb am 16.05.2020 um 00:47:
>> When I customise the table of contents layout I lose the automatic 
>> hyperlinks. Is there a simple configuration option that I have missed or do 
>> I need to create my own links somehow?
>> 
>> Example:
>> 
>> \setupinteraction[state=start]
>> \setupinteractionscreen[option=bookmark]
>> 
>> \define[3]\SectionListEntry
>>   {\par \leftaligned\bgroup
>>  \hbox to 2em{#3}%
>>  \hskip   1em
>>  \vtop{\hsize\dimexpr\textwidth-3em\relax#2}
>>   \egroup \par}
>> 
>> % Comment out this next line to regain section hyperlinks in the ToC
>> \setuplist[section][alternative=command,command=\SectionListEntry]
> 
> alternative=command : Cutsom TOC without hyperlinks
> 
> alternative=interactive : Custom TOC with hyperlinks

Thank you! Wikified: https://wiki.contextgarden.net/Command/setuplist

Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Blank page added after pagecolumns

2020-05-16 Thread Wolfgang Schuster

Joey McCollum schrieb am 16.05.2020 um 05:45:
All right, I've found a tentative solution that appears to work in all 
cases, but I'd like to know more about why the code I'm patching was 
implemented in the first place, because I don't want to break anything 
else. According to the code in page-pcl.mkiv, the \stoppagecolumns macro 
has two implementations, \page_col_stop_yes and \page_col_stop_nop. The 
choice of which implementation is used is determined by which of two 
implementations of \startpagecolumns (\page_col_start_yes 
and \page_col_start_nop) is used. That choice, in turn, is made in 
the \page_col_start macro, in the following lines:


```
\c_page_col_n_of_columns\pagecolumnsparameter\c!n\relax
    \ifnum\c_page_col_n_of_columns>\plusone
      \expandafter\page_col_start_yes
    \else
      \expandafter\page_col_start_nop
    \fi
```

so if the number of columns (i.e., the n option for the 
pagecolumns environment) is more than one, the "yes" implementation of 
the start and stop commands is used.


But this seems wrong. The naming convention for the two implementations 
("yes" and "nop") suggests that they should be related the parameters 
"page=yes" and "page=no" (hence, no page, which is what I think "nop" 
abbreviates), but the choice of which implementation to use is 
determined not by the page parameter, but by the n parameter. Is this an 
error in the code, or am I just understanding this incorrectly? Is there 
some reason why a layout with more than one column would need special 
instructions to add a blank page after stopping the environment?


Why do you think "yes" and "nop" are related to the page-key?

In any event, I was able to solve the problem by patching the 
\page_col_start_yes macro to invoke the \page_col_start_nop macro as 
follows:


```

\unprotect

\def\page_col_stop_yes
{\page_col_stop_nop}

\protect

```

With this fix, the MWE I provided works regardless of which column the 
text ends in. I'm content to consider the problem solved, but I would 
certainly appreciate any feedback on my thoughts and questions about 
page-pcl.mkiv.


You broke now now normal single columns text after the pagecolumns 
environment. A better fix is to add a check for the \column command at 
the end of the environment and add it only when we aren't in the last 
column.


\unexpanded\def\page_col_stop_yes
  {%\column % \page_otr_eject_page
   \ifnum\c_page_col_current<\c_page_col_n_of_columns
 \column
   \fi
   \page
   \endgroup
 % \setupoutputroutine[\s!singlecolumn]%
   \page_otr_command_set_vsize
   \page_otr_command_set_hsize
   \page
   \endgroup}

Wolfgang
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Custom list layout with PDF bookmarks

2020-05-16 Thread Wolfgang Schuster

Bruce Horrocks schrieb am 16.05.2020 um 00:47:

When I customise the table of contents layout I lose the automatic hyperlinks. 
Is there a simple configuration option that I have missed or do I need to 
create my own links somehow?

Example:

\setupinteraction[state=start]
\setupinteractionscreen[option=bookmark]

\define[3]\SectionListEntry
   {\par \leftaligned\bgroup
  \hbox to 2em{#3}%
  \hskip   1em
  \vtop{\hsize\dimexpr\textwidth-3em\relax#2}
   \egroup \par}

% Comment out this next line to regain section hyperlinks in the ToC
\setuplist[section][alternative=command,command=\SectionListEntry]


alternative=command : Cutsom TOC without hyperlinks

alternative=interactive : Custom TOC with hyperlinks

 begin example
\define[3]\SectionListEntry
  {\hbox\bgroup
 \hbox to 2em{#1}%
 \hfill
 \vtop{\hsize\dimexpr\textwidth-3em\relax#2}%
   \egroup}

\setuplist
  [section]
  [alternative=interactive,
   command=\SectionListEntry,
    before=\endgraf,
 after=\endgraf]
 end example

Wolfgang

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

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


Re: [NTG-context] Custom list layout with PDF bookmarks

2020-05-16 Thread Henning Hraban Ramm

> Am 16.05.2020 um 00:47 schrieb Bruce Horrocks :
> 
> When I customise the table of contents layout I lose the automatic 
> hyperlinks. Is there a simple configuration option that I have missed or do I 
> need to create my own links somehow?
> 
> Example:
> 
> \setupinteraction[state=start]
> \setupinteractionscreen[option=bookmark] 
> 
> \define[3]\SectionListEntry
>  {\par \leftaligned\bgroup
> \hbox to 2em{#3}%
> \hskip   1em
> \vtop{\hsize\dimexpr\textwidth-3em\relax#2}
>  \egroup \par}
> 
> % Comment out this next line to regain section hyperlinks in the ToC
> \setuplist[section][alternative=command,command=\SectionListEntry]
> 
> \starttext
> Table of Contents
> \placecontent[criterium=all]
> \placebookmarks[chapter,subject]

Should be \placebookmarks[chapter,section]. Move it in front of \starttext.

But that still doesn’t set chapter bookmarks - strange.


Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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