Remove external treap access
This commit is contained in:
parent
b4c37a8291
commit
1b2c93b2af
1 changed files with 5 additions and 4 deletions
9
main.cpp
9
main.cpp
|
@ -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(position p, count_type len=1) { file.find(p.r)->text.erase(p.c,len); }
|
||||||
void remove(count_type r) { file.remove(r); }
|
void remove(count_type r) { file.remove(r); }
|
||||||
void append(string t) { file.append(t); }
|
void append(string t) { file.append(t); }
|
||||||
|
count_type get_size() { return file.size(); }
|
||||||
|
|
||||||
|
|
||||||
// Load file to buffer
|
// Load file to buffer
|
||||||
|
@ -66,7 +67,7 @@ bool save(string filename) {
|
||||||
if(!outfile.good())
|
if(!outfile.good())
|
||||||
return 1;
|
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;
|
outfile << get_line(i, 0) << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +87,7 @@ void print_line(count_type r) {
|
||||||
// Print file content
|
// Print file content
|
||||||
void print_file(count_type start = 0) {
|
void print_file(count_type start = 0) {
|
||||||
for(count_type i = start; i < file_offset + LINES; i++)
|
for(count_type i = start; i < file_offset + LINES; i++)
|
||||||
if(i < file.size())
|
if(i < get_size())
|
||||||
print_line(i);
|
print_line(i);
|
||||||
else
|
else
|
||||||
clear_line(i);
|
clear_line(i);
|
||||||
|
@ -215,7 +216,7 @@ void move_cursor(char ch) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'j':
|
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) {
|
if(cur.r < LINES-1) {
|
||||||
cur.r += 1;
|
cur.r += 1;
|
||||||
move(cur);
|
move(cur);
|
||||||
|
@ -265,7 +266,7 @@ void jump(position p) {
|
||||||
// Find next string appearance
|
// Find next string appearance
|
||||||
std::pair<bool, position> find(string text) {
|
std::pair<bool, position> find(string text) {
|
||||||
count_type len = text.size();
|
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) {
|
for(count_type _r = 0; _r < file_size; ++_r) {
|
||||||
count_type r = (file_offset + cur.r + _r) % file_size;
|
count_type r = (file_offset + cur.r + _r) % file_size;
|
||||||
|
|
Loading…
Reference in a new issue