diff --git a/main.cpp b/main.cpp index 45e3e41..e1dc982 100644 --- a/main.cpp +++ b/main.cpp @@ -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();