diff options
| author | Jan Tuomi <jan-sebastian.tuomi@aalto.fi> | 2016-10-09 14:03:15 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan-sebastian.tuomi@aalto.fi> | 2016-10-09 14:50:24 +0300 |
| commit | 06861f43e9898af8a9bccb33d1e1609494238d32 (patch) | |
| tree | 78c4f4cce0ae4017d41da2abfc40611f9d6a1a92 /editor.cpp | |
| parent | d7ae8016693fe60e787d92aad4aa6a50929f80c8 (diff) | |
Add indicator to show if the whole file cannot be shown
Diffstat (limited to 'editor.cpp')
| -rw-r--r-- | editor.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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() { |
