11#ifndef ARK_ERROR_PRETTYPRINTING_HPP
12#define ARK_ERROR_PRETTYPRINTING_HPP
38 std::optional<std::size_t> skip_start_at = std::nullopt;
39 std::optional<std::size_t> resume_at = std::nullopt;
42 start(0), target(0), target_end(0), end(0)
45 Window(
const std::size_t target_line,
const std::size_t target_line_end,
const std::size_t line_count) :
46 target(target_line), target_end(target_line_end)
48 start = target_line >= 3 ? target_line - 3 : 0;
49 end = target_line_end + 3 <= line_count ? target_line_end + 3 : line_count;
54 return skip_start_at.has_value() && resume_at.has_value();
72 Printer(
const std::string& filename, std::size_t target_line, std::optional<std::size_t> end_target_line,
bool colorize);
81 [[nodiscard]] std::string sliceCode(
internal::FilePos start,
const std::optional<internal::FilePos>& end)
const;
89 void extendWindow(std::size_t line_to_include);
96 void printLine(std::ostream& os);
104 [[nodiscard]]
bool isTargetLine()
const;
112 [[nodiscard]]
bool hasContent()
const;
114 [[nodiscard]]
bool coversLine(std::size_t line_number)
const;
122 [[nodiscard]]
inline std::size_t
current()
const
124 return m_current_line;
129 return m_source[m_current_line];
132 const static inline std::string GhostLinePrefix =
" |";
Defines position utilities (for text in a file) for the parser, formatter, diagnostics.
Source printer for diagnostics.
std::size_t m_current_line
const std::string & currentLine() const
std::vector< std::string > m_source
LineColorContextCounts m_color_ctx
const Window & window() const
std::size_t current() const
Window(const std::size_t target_line, const std::size_t target_line_end, const std::size_t line_count)
std::size_t end
Last line of the context, not displayed.
std::size_t start
First line number to display.