This approach is not a simple environment but a standard minted environment nested in you own float environment. Not exactly the asked but:
☑ Each line in a src code block is numbered (optionally)
☑ The font used for a src code block is monospaced (and syntax highlited)
☑ A border is drawn around a code code block, much like \fbox does (with top caption inside using \stdcaption, for a botom caption outside the box use \caption*)
☑ Each code block "floats" to a position (concretely to top of a new page) so that it will fit all on one page.

\documentclass[a6paper]{article}
\usepackage[margin=1cm, paperheight=5in,paperwidth=5in]{geometry}
\pagestyle{empty}
\usepackage{lipsum}
\let\stdcaption\caption
\setcounter{totalnumber}{1}
\usepackage{minted}
\usepackage{float}
\floatstyle{boxed}
\newfloat{fancycode}{t}{loa}
\floatname{fancycode}{LaTeX code}
\begin{document}
\begin{fancycode}
\stdcaption[Basic Structure]{The basic structure of a \LaTeX\ document.}
\begin{minted}[linenos,bgcolor=orange!05]{latex}
\documentclass{article}
\begin{document}
\end{document}
\end{minted}
\end{fancycode}
\begin{fancycode}
\stdcaption[Preamble]{The \LaTeX\ preamble to do a \texttt{fancycode}.}
\begin{minted}[linenos,bgcolor=cyan!10]{latex}
\usepackage{minted}
\usepackage{float}
\floatstyle{boxed}
\newfloat{fancycode}{t}{loa}
\floatname{fancycode}{LaTeX code}
\end{minted}
\end{fancycode}
\lipsum[1-2]
\listof{fancycode}{Code examples}
\end{document}
srcblockcontain in terms of characters?verbatim-like content, perhaps (symbols like#,_,$,^, ...)? – Werner Jan 07 '19 at 21:05listingspackage? This should be straight-forward with it. Just read the manual. – Martin Scharrer Jan 07 '19 at 21:34