\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{listings}
\usepackage{inconsolata}

\definecolor{basicCol}{HTML}{000000}
\definecolor{commentCol}{HTML}{000000}
\definecolor{stringCol}{HTML}{000000}
\definecolor{keywordCol}{HTML}{000000}
\definecolor{identifierCol}{HTML}{000000}

\lstdefinestyle{defaultStyle}{
  escapeinside={@@},
%   basicstyle=\linespread{0.9}\tt\footnotesize,		% reduce line spacing and use typewriter font
  basicstyle=\linespread{0.9}\sf,		% reduce line spacing and use typewriter 
%   keywordstyle=\bfseries\color{blue},
%   keywordstyle=[2]\bfseries\color{Plum},
%   commentstyle=\itshape\color{OliveGreen},		    % green and italic comments
%   identifierstyle=\color{identifierCol},
%   stringstyle=\sf\color{Mahogany},			          % use sanserif font
  stringstyle=\tt,			          % use sanserif font
  mathescape=true,
%   columns=fixed,
  columns=fullflexible,
%   aboveskip=4pt,                                  % spacing above/below code block
%   belowskip=3pt,
  keepspaces=true,
  tabsize=4,
  % frame=lines,
  literate=,
  showlines=true,                                 % show blank lines at end of code
  showspaces=false,
  showstringspaces=false,
  escapechar=\$,
  xleftmargin=\parindentlnth,                     % indent code to paragraph indentation
  moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
  % moredelim=* detects keywords, comments, strings, and other delimiters and applies their formatting
  % moredelim=** allows cumulative application
}

\lstdefinestyle{cfaStyle}{
  escapeinside={@@},
%  basicstyle=\linespread{0.9}\tt\footnotesize,		% reduce line spacing and use typewriter font
  basicstyle=\linespread{0.9}\sf,		% reduce line spacing and use typewriter font
%  keywordstyle=\bfseries\color{blue},
%  keywordstyle=[2]\bfseries\color{Plum},
%  commentstyle=\sf\itshape\color{OliveGreen},		  % green and italic comments
%  identifierstyle=\color{identifierCol},
%  stringstyle=\sf\color{Mahogany},			          % use sanserif font
  stringstyle=\tt,			          % use sanserif font
  mathescape=true,
%  columns=fixed,
  columns=fullflexible,
%  aboveskip=4pt,                                  % spacing above/below code block
%  belowskip=3pt,
  keepspaces=true,
  tabsize=4,
  % frame=lines,
  literate=,
  showlines=true,                                 % show blank lines at end of code
  showspaces=false,
  showstringspaces=false,
  showlines=true,							% show blank lines at end of code
  escapechar=\$,
  xleftmargin=\parindentlnth,                     % indent code to paragraph indentation
  moredelim=[is][\color{red}\bfseries]{**R**}{**R**},    % red highlighting
  morekeywords=[2]{accept, signal, signal_block, wait, waitfor, waituntil},
  abovecaptionskip=5pt,
}

\lstnewenvironment{ccode}[1][]{
  \lstset{
    language = C,
    style=defaultStyle,
    captionpos=b,
    #1
  }
}{}

\lstnewenvironment{cfacode}[1][]{
  \lstset{
    language = CFA,
    style=cfaStyle,
    captionpos=b,
    #1
  }
}{}

\lstnewenvironment{cppcode}[1][]{
  \lstset{
    language = c++,
    style=defaultStyle,
    captionpos=b,
    #1
  }
}{}

\lstnewenvironment{ucppcode}[1][]{
  \lstset{
    language = c++,
    style=defaultStyle,
    captionpos=b,
    #1
  }
}{}

\lstnewenvironment{javacode}[1][]{
  \lstset{
    language = java,
    style=defaultStyle,
    captionpos=b,
    #1
  }
}{}

\lstnewenvironment{gocode}[1][]{
  \lstset{
    language = Golang,
    style=defaultStyle,
    captionpos=b,
    #1
  }
}{}

\newcommand{\zero}{\lstinline{zero_t}\xspace}
\newcommand{\one}{\lstinline{one_t}\xspace}
\newcommand{\ateq}{\lstinline{\@=}\xspace}
\newcommand{\code}[1]{\lstinline[language=CFA,style=cfaStyle]{#1}}
\newcommand{\pscode}[1]{\lstinline[language=pseudo,style=pseudoStyle]{#1}}
