From 06861f43e9898af8a9bccb33d1e1609494238d32 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 9 Oct 2016 14:03:15 +0300 Subject: Add indicator to show if the whole file cannot be shown --- editor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'editor.cpp') diff --git a/editor.cpp b/editor.cpp index 51b9077..08abdde 100644 --- a/editor.cpp +++ b/editor.cpp @@ -38,9 +38,18 @@ int Editor::run_editor() { } int Editor::print_contents_on_line(int line) const { + int output_length = m_contents->size(); + bool truncated = false; + if ((int) m_contents->size() > line + OUTPUT_LINE_MAX) { + output_length = line + OUTPUT_LINE_MAX; + truncated = true; + } for (int i = line; i < std::min((int) m_contents->size(), line + OUTPUT_LINE_MAX); i++) { std::cout << i << " " << m_contents->at(i) << '\n'; } + if (truncated) { + std::cout << "...\n"; + } } int Editor::edit_command() { -- cgit v1.3