Remove external treap access

This commit is contained in:
Matúš Púll 2025-04-20 18:24:23 +02:00
parent b4c37a8291
commit 1b2c93b2af

View file

@ -47,6 +47,7 @@ void insert(position p, char ch) { insert(p, string{ch}); }
void remove(position p, count_type len=1) { file.find(p.r)->text.erase(p.c,len); }
void remove(count_type r) { file.remove(r); }
void append(string t) { file.append(t); }
count_type get_size() { return file.size(); }
// Load file to buffer
@ -66,7 +67,7 @@ bool save(string filename) {
if(!outfile.good())
return 1;
for(count_type i = 0; i < file.size(); ++i)
for(count_type i = 0; i < get_size(); ++i)
outfile << get_line(i, 0) << std::endl;
return 0;
}
@ -86,7 +87,7 @@ void print_line(count_type r) {
// Print file content
void print_file(count_type start = 0) {
for(count_type i = start; i < file_offset + LINES; i++)
if(i < file.size())
if(i < get_size())
print_line(i);
else
clear_line(i);
@ -215,7 +216,7 @@ void move_cursor(char ch) {
break;
case 'j':
if(file_offset + cur.r >= file.size()-1) break;
if(file_offset + cur.r >= get_size()-1) break;
if(cur.r < LINES-1) {
cur.r += 1;
move(cur);
@ -265,7 +266,7 @@ void jump(position p) {
// Find next string appearance
std::pair<bool, position> find(string text) {
count_type len = text.size();
count_type file_size = file.size();
count_type file_size = get_size();
for(count_type _r = 0; _r < file_size; ++_r) {
count_type r = (file_offset + cur.r + _r) % file_size;