Re: [frogs] chord-name-engraver plus capo - schemeing away ...

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


On 27 August 2010 21:49, Wols Lists <antlists@xxxxxxxxxxxxxxx> wrote:

> There's a function called "parenthesize" in define-markup-commands.scm
> that looks like it does what I want (line 3154), but
> ly_lily_module_constant can't find it, and I don't know whether I've got
> the call to it in the line below correct or not, anyway.

ly_lily_module_constant ("parenthesize-markup")

> And lastly, the call to line-markup blows up with "invalid arguments".
> I've found another function - markup-join (markup.scm, l514) - should I
> be using that? But I think it wants a pair, and scm_cons does not seem
> to be the function that creates a pair. There's probably more to it than
> that, though.

scm_cons does create a pair, but you need a list for the arguments to \line.

Just to prove how nasty doing markup in C++ is, here's the above code corrected:

  SCM paren_proc = ly_lily_module_constant ("parenthesize-markup");
  SCM line_proc = ly_lily_module_constant ("line-markup");
  SCM hspace_proc = ly_lily_module_constant ("hspace-markup");
  SCM final_markup = scm_list_n (line_proc,
				 scm_list_3 (markup,
					     scm_list_2 (hspace_proc,
							 scm_from_int (1)),
					     scm_list_2 (paren_proc, capo_markup)),
				 SCM_UNDEFINED);
					
  chord_name_->set_property ("text", final_markup);

I feel dirty after messing with that. ;)

I haven't used scm_call, since the markup isn't evaluated until the
stencil's created: the 'text property just stores the markup pending
its conversion to a stencil via Text_interface::interpret_markup.

BTW, I forgot that there's no word-space set for ChordName markup,
since it would mess up the spacing of the individual elements, so I
had to add some space using \hspace instead.

Cheers,
Neil

---
----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/