\newenvironment{prog}{\list{}{}\item\relax}{\endlist}
\DeclareRobustCommand\meta[1]{%
  \ensuremath\langle{\normalfont\textit{#1\/}}\ensuremath\rangle
}
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
\providecommand\marg[1]{%
  {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
\providecommand\oarg[1]{%
  {\ttfamily[}\meta{#1}{\ttfamily]}}
\providecommand\parg[1]{%
  {\ttfamily(}\meta{#1}{\ttfamily)}}

\newcommand*\Package[1]{\textbf{#1}}

\newcommand*\DIAG[1]{\index{Диагностика!#1}}
\DeclareRobustCommand*\PKG[2][]{\Package{#2}\index{Пакет!#2#1}}
\DeclareRobustCommand*\CLS[2][]{\Package{#2}\index{Класс!#2#1}}
\newcommand*\PKGI[2][]{\index{Пакет!#2#1}}
\newcommand*\CLSI[2][]{\index{Класс!#2#1}}
\DeclareRobustCommand*\OPT[1]{\mbox{\ttfamily#1}\index{Опция!#1@{\ttfamily#1}}}
\DeclareRobustCommand*\ENC[1]{\mbox{\ttfamily#1}\index{Кодировка!#1@{\ttfamily#1}}}
\DeclareRobustCommand*\FNT[1]{\mbox{\ttfamily#1}\index{Кодировка!шрифта!#1@{\ttfamily#1}}}
\DeclareRobustCommand*\EXT[1]{\mbox{\ttfamily.#1}\index{Файл с расширением!.#1@{\ttfamily.#1}}}

\DeclareRobustCommand*\cnt[1]{{\ttfamily#1}\index{Счетчик!#1@{\ttfamily#1}}}
\DeclareRobustCommand*\dm[1]{\cs{#1}\index{Размер!#1@\cs{#1}}\index{#1@\cs{#1} (размер)}}
\DeclareRobustCommand*\len[1]{\cs{#1}\index{Длина!#1@\cs{#1}}\index{#1@\cs{#1} (длина)}}

% \InPackage{name}{command-list}
\newcommand\InPackage{\@ifstar{\NCC@inpackx}{\NCC@inpack}}
\def\NCC@inpackx#1#2{%
  \expandafter\def\csname NCC@in@#2\endcsname{#1}%
}
\def\NCC@inpack#1#2{%
  \if!#1!
    \@for\@tempa:=#2\do
      {\expandafter\let\csname NCC@in@\@tempa\endcsname\relax}%
  \else
    \@for\@tempa:=#2\do
      {\expandafter\def\csname NCC@in@\@tempa\endcsname{#1}}%
  \fi
}

\DeclareRobustCommand*\env[1]{{\ttfamily#1}\envi{#1}}
\DeclareRobustCommand*\inPack[1]{\space
  \def\@tempa{#1}\def\@tempb{*}%
  \ifx\@tempa\@tempb[russian]\else(\textit{#1})\fi}
\newcommand*\envi[1]{%
  \@ifundefined{NCC@in@#1}%
    {\index{Окружение!#1@{\ttfamily#1}}}%
    {\index{Окружение!#1@{\ttfamily#1}\inPack{\csname NCC@in@#1\endcsname}}}%
}
\DeclareRobustCommand*\cmd[1]{\cs{#1}\cmdi{#1}}
\newcommand*\cmdi[1]{%
  \@ifundefined{NCC@in@#1}%
    {\index{#1@\cs{#1}}}%
    {\index{#1@\cs{#1}\inPack{\csname NCC@in@#1\endcsname}}}%
}

\DeclareRobustCommand\SP{{\tt \symbol{"20}}} % Символ корыто
\DeclareRobustCommand\SPP{{\tt \symbol{"7E}}} % Символ ~
\DeclareRobustCommand\SPT{{\tt \symbol{"5E}}} % Символ ^
\DeclareRobustCommand\CR{{\tt \symbol{"5C}\symbol{"5C}}} % Команда новой строки
\DeclareRobustCommand\QQ{{\tt \symbol{"22}}} % Двойная кавычка
\DeclareRobustCommand\SPE{!}

\DeclareRobustCommand\FRAME[1]{%
  \setbox\@tempboxa\hbox{#1}%
  \@tempdima\dp\@tempboxa
  \advance\@tempdima\@wholewidth
  \setbox\@tempboxa\hbox{\hskip-.5\@wholewidth
    \vbox{\vskip-\@wholewidth
      \hrule \@height\@wholewidth
      \hbox{\vrule\@width\@wholewidth
        \unhbox\@tempboxa%
        \vrule\@width\@wholewidth
      }%
      \hrule\@height\@wholewidth
      \vskip-\@wholewidth
    }%
    \hskip-.5\@wholewidth
  }%
  \leavevmode
  \raise-\@tempdima\box\@tempboxa
}

\newdimen\NCC@rightsample
\newif\ifNCC@samplebreak
\def\samplebreak{\global\NCC@samplebreaktrue}
\newenvironment*{sample}[1][.5]{\NCC@samplebreakfalse
  \@ifnextchar[{\NCC@sample{#1}}{\NCC@sample{#1}[t]}%
}{\end{minipage}\ifNCC@samplebreak\pagebreak\fi
  \endflushleft\ignorespacesafterend}
\def\NCC@sample#1[#2]{\flushleft
  \@tempdima#1\linewidth
  \NCC@rightsample\linewidth \advance\NCC@rightsample -\@tempdima
  \advance\@tempdima -.02\linewidth
  \advance\NCC@rightsample -.02\linewidth
  \def\NCC@temp{#2}%
  \begin{minipage}[\NCC@temp]{\@tempdima}\small\normalfont
  \let\pagebreak\samplebreak
}
\def\sampleright{%
  \end{minipage}\hfill
  \begin{minipage}[\NCC@temp]{\NCC@rightsample}\small\normalfont
    \ttfamily \let\pagebreak\samplebreak
}

\newcommand*\button[1]{\jvbox{\strut}{\ipic{#1}}}

\endinput
