From ea7db7ef4e50ac00695fe05302de63096b9a794a Mon Sep 17 00:00:00 2001 From: Matuush Date: Wed, 16 Apr 2025 14:14:25 +0200 Subject: [PATCH] Make get_line DRY --- main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index a74fbee..05d874c 100644 --- a/main.cpp +++ b/main.cpp @@ -23,16 +23,15 @@ position clp; treap selection; // Accessing the file -string get_line(count_type r) { +string get_line(count_type r, bool clean = true) { string line = (*file.find(file_offset+r)).text; + if(!clean) + return line; for(count_type i = 0; i < line.size(); ++i) if(line[i] == '\t') line[i] = ' '; return line; } -string get_line_raw(count_type r) { - return file.find(file_offset+r)->text; -} char get(position p) { return get_line(file_offset+p.r)[p.c]; } void set(position p, char ch) { file.find(file_offset+p.r)->text[p.c] = ch; } void new_line(count_type r, string text = "") { file.insert(file_offset+r, text); } @@ -70,7 +69,7 @@ bool save(string filename) { return 1; for(count_type i = 0; i < file.size(); ++i) - outfile << get_line_raw(i-file_offset) << std::endl; + outfile << get_line(i-file_offset, 0) << std::endl; return 0; }