aboutsummaryrefslogtreecommitdiffstats
path: root/editor.cpp
diff options
context:
space:
mode:
authorJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-10-09 14:03:15 +0300
committerJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-10-09 14:50:24 +0300
commit06861f43e9898af8a9bccb33d1e1609494238d32 (patch)
tree78c4f4cce0ae4017d41da2abfc40611f9d6a1a92 /editor.cpp
parentd7ae8016693fe60e787d92aad4aa6a50929f80c8 (diff)
Add indicator to show if the whole file cannot be shown
Diffstat (limited to 'editor.cpp')
-rw-r--r--editor.cpp9
1 files changed, 9 insertions, 0 deletions
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() {