使用列表格式化 C 语言

使用列表格式化 C 语言

考虑以下 C 语言代码段:

int llvm_test_diagnostic_handler(void) {
  LLVMContextRef C = LLVMGetGlobalContext();
  LLVMContextSetDiagnosticHandler(C, &diagnosticHandler, 
    &handlerCalled);

我希望在我的文档中使用深色主题。我设置了以下参数来实现这一点:

\usepackage{color}
\usepackage{listings} %CODE STYLE 

\lstloadlanguages{C,C++,csh,Java}

\definecolor{red}{rgb}{0.6,0,0} 
\definecolor{blue}{rgb}{0,0,0.6}
\definecolor{green}{rgb}{0,0.8,0}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\definecolor{cloudwhite}{rgb}{0.9412, 0.9608, 0.8471} 
\definecolor{davysgrey}{rgb}{0.33, 0.33, 0.33}
\definecolor{deepfuchsia}{rgb}{0.76, 0.33, 0.76}
\definecolor{deepskyblue}{rgb}{0.0, 0.75, 1.0}
\definecolor{deepsaffron}{rgb}{1.0, 0.6, 0.2}
\definecolor{deeppink}{rgb}{1.0, 0.08, 0.58}
\definecolor{dodgerblue}{rgb}{0.12, 0.56, 1.0}

\lstset{
    language=csh,
    basicstyle=\footnotesize\ttfamily,
    numbers=left,
    numberstyle=\tiny\color{white},
    numbersep=5pt,
    tabsize=2,
    extendedchars=true,
    breaklines=true,
    frame=b,
    stringstyle=\color{deepsaffron}\ttfamily,
    showspaces=false,
    showtabs=false,
    xleftmargin=17pt,
    framexleftmargin=17pt,
    framexrightmargin=5pt,
    framexbottommargin=4pt,
    commentstyle=\color{green},
    morecomment=[l]{//}, %use comment-line-style!
    morecomment=[s]{/*}{*/}, %for multiline comments
    showstringspaces=false,
    morekeywords={ abstract, event, new, struct,
        as, explicit, null, switch,
        base, extern, object, this,
        bool, false, operator, throw,
        break, finally, out, true,
        byte, fixed, override, try,
        case, float, params, typeof,
        catch, for, private, uint,
        char, foreach, protected, ulong,
        checked, goto, public, unchecked,
        class, if, readonly, unsafe,
        const, implicit, ref, ushort,
        continue, in, return, using,
        decimal, int, sbyte, virtual,
        default, interface, sealed, volatile,
        delegate, internal, short, void,
        do, is, sizeof, while,
        double, lock, stackalloc,
        else, long, static,
        enum, namespace, string},
    keywordstyle=\color{deeppink},
    identifierstyle=\color{deepskyblue},
    backgroundcolor=\color{davysgrey},
}

结果如下:

在此处输入图片描述

唯一的问题是我无法设置white颜色符号,如、、、、、、(等。我该如何实现?)={}*&

相关内容