[chuck-users] ChucK syntax highliting for LaTeX code listings

Jean Menezes da Rocha jean at menezesdarocha.info
Tue Oct 4 20:40:54 EDT 2016


Hi Spencer,

For the moment I came up with a very workaround-ish solution which I bet
isn't by far the most elegant/correct approach. It worked for me, that is a
code which should be included in the LaTeX preamble. I have something like
this:

\usepackage{listings}
\lstset{
    keepspaces=true,
    columns=flexible,
    basicstyle=\footnotesize\ttfamily %nevermind, this is optional
}

% Estilo para ChucK
\lstdefinelanguage{ChucK}
    {
        sensitive=true,
        morecomment=[l]{//},
        morecomment=[s]{/*}{*/},
        morestring=[b]",
        morestring=[d]',
        morekeywords={int,float,time,dur,void,same,string,
            if,else,while,until,for,repeat,break,continue,return,switch,

class,extends,public,static,pure,this,super,interface,implements,
            protected,private,function,fun,spork,const,new,now,true,false,
            maybe,null,NULL,me,pi,samp,ms,second,minute,hour,day,week,
            dac,adc,blackhole,then,before,after,at},

morekeywords={complex,polar,Object,array,Event,UGen,Machine,Math,Std,
            Shred,MidiIn,MidiMsg,OscRecv,OscEvent,OscSend},

morekeywords={SinOsc,PulseOsc,SqrOsc,TriOsc,SawOsc,Phasor,Noise,Impulse,

Step,Gain,SndBuf,HalfRect,FullRect,ZeroX,Mix2,Pan2,GenX,CurveTable,

WarpTable,LiSa,OneZero,TwoZero,OnePole,TwoPole,PoleZero,BiQuad,Filter,

LPF,HPF,BPF,BRF,ResonZ,Dyno,Envelope,ADSR,Delay,DelayA,DelayL,Echo,

JCRev,NRev,PRCRev,Chorus,Modulate,PitShift,SubNoise,Blit,BlitSaw,

BlitSquare,WvIn,WaveLoop,WvOut,StkInstrument,BandedWG,BlowBotl,BlowHole,

Bowed,Brass,Clarinet,Flute,Mandolin,ModalBar,Moog,Saxofony,Shakers,

Sitar,StifKarp,VoicForm,FM,BeeThree,FMVoices,HevyMetl,PercFlut,Rhodey,
            TubeBell,Wurley},

morekeywords={UAna,UAnaBlob,Windowing,FFT,IFFT,DCT,IDCT,Centroid,Flux,
            RMS,RollOff},
        otherkeywords={=>,=^,\%,+,-,*,/,+=>,-=>,*=>,/=>,@,@=>,
            !=,>,>=,<,<=,<<,>>,\&,\&\&,|,||,=,==,^,++,--,~,\%=>,::,
            <<<,>>>}
    }

Then, you should call your listing environment using the lang=ChucK
parameter.

You are warned that this probably contains errors and barely fits most
basic ChucK code.
Nonetheless, it can serve as boilerplate for more proficient TeX users to
create something
more correct and compatible.

Best regards!

P.S.: I did not try using the minted package, as it wasn't compatible with
the template required
by my uni.

Em ter, 4 de out de 2016 às 21:09, Spencer Salazar <
spencer at ccrma.stanford.edu> escreveu:

> Hi Jean,
>
> I don't know of anything like that but it would come in handy for my own
> thesis as well! Let us know if you get anywhere with it.
>
> It might be useful to centralize links to the various ChucK support
> resources that have been developed over the years (vimrc's, syntax
> highlighting definitions, Sublime bundles, etc.)
>
> spencer
>
>
> On Mon, Sep 26, 2016 at 8:19 PM, Jean Menezes da Rocha <
> jean at menezesdarocha.info> wrote:
>
> Hello,
>
> I am wondering if anyone ever wrote some ChucK style for highlighting
> source code in listings inside LaTeX documents. Is there anything like
> that, or should I try and do it from scratch? I would like to show some
> beautiful ChucK code in my thesis.
>
> Thanks in advance!
> --
> Jean Menezes da Rocha
> Compositor
> Professor
> Doutorando em Música pela Universidade Federal da Bahia
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
>
>
> --
> Spencer Salazar
> Doctoral Candidate
> Center for Computer Research in Music and Acoustics
> Stanford University
>
> spencer at ccrma.stanford.edu
> +1 831.277.4654 <+1%20831-277-4654>
> https://ccrma.stanford.edu/~spencer/
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
-- 
Jean Menezes da Rocha
Compositor
Professor
Doutorando em Música pela Universidade Federal da Bahia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20161005/d94371ce/attachment-0001.html>


More information about the chuck-users mailing list