FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches
snippet.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5#include <iosfwd>
6
7#include "fe/loc.h"
8#include "fe/term.h"
9
10namespace fe {
11
12/// The underlined source excerpt that goes below a diagnostic.
13/// Streams every source row Snippet::loc spans, each underlining the columns Snippet::loc covers on it.
14/// Streams nothing if Snippet::loc has no Loc::src or does not resolve within it.
15struct Snippet {
18 uint32_t gutter = 5; ///< Width of the line-number column.
19 uint32_t max_rows = 8; ///< Rows streamed before the middle is elided; `0` elides nothing.
20
21 /// `fe/snippet.h` merely *declares* this.
22 /// Link `fe-lib` for the default implementation, or provide your own in namespace `fe`.
23 friend std::ostream& operator<<(std::ostream&, const Snippet&);
24};
25
26} // namespace fe
FG
Foreground colors that can be streamed into an std::ostream.
Definition term.h:60
Definition algo.h:17
Location within a Src: the half-open byte range [Loc::begin, Loc::end).
Definition loc.h:46
The underlined source excerpt that goes below a diagnostic.
Definition snippet.h:15
uint32_t gutter
Width of the line-number column.
Definition snippet.h:18
uint32_t max_rows
Rows streamed before the middle is elided; 0 elides nothing.
Definition snippet.h:19
term::FG color
Definition snippet.h:17
friend std::ostream & operator<<(std::ostream &, const Snippet &)
fe/snippet.h merely declares this.