Character insert

This commit is contained in:
Matúš Púll 2025-03-18 14:17:56 +01:00
parent 571fefc8c0
commit 62ecb8ec30

View file

@ -18,6 +18,7 @@ int row = 0, col = 0;
// Accessing the file
char get(int r, int s) { return file[r][s]; }
void set(int r, int s, char ch) { file[r][s] = ch; }
void insert_char(int r, int s, char ch) { file[r].insert(s, string{ch}); }
string get_line(int r) { return file[r]; }
void add_line(int r) { file.insert(file.begin() + r, ""); }
void remove_line(int r) { file.erase(file.begin() + r); }
@ -61,8 +62,15 @@ void print_file() {
}
move(row, col);
}
// Print line
void print_line(int r) {
move(r, 0);
clrtoeol();
move(r, 0);
adds(get_line(r));
move(row, col);
}
// TODO psaní do souboru
// TODO mazání v souboru
// TODO skoky a přesuny
@ -150,10 +158,14 @@ int main(int argc, char* argv[]) {
case 'w':
save(filename);
break;
case 'i':
mode = insert;
break;
}
break;
case insert:
// insert
insert_char(row, col++, ch);
print_line(row);
break;
}
refresh();