Character insert
This commit is contained in:
parent
571fefc8c0
commit
62ecb8ec30
1 changed files with 14 additions and 2 deletions
16
main.cpp
16
main.cpp
|
@ -18,6 +18,7 @@ int row = 0, col = 0;
|
||||||
// Accessing the file
|
// Accessing the file
|
||||||
char get(int r, int s) { return file[r][s]; }
|
char get(int r, int s) { return file[r][s]; }
|
||||||
void set(int r, int s, char ch) { file[r][s] = ch; }
|
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]; }
|
string get_line(int r) { return file[r]; }
|
||||||
void add_line(int r) { file.insert(file.begin() + r, ""); }
|
void add_line(int r) { file.insert(file.begin() + r, ""); }
|
||||||
void remove_line(int r) { file.erase(file.begin() + r); }
|
void remove_line(int r) { file.erase(file.begin() + r); }
|
||||||
|
@ -61,8 +62,15 @@ void print_file() {
|
||||||
}
|
}
|
||||||
move(row, col);
|
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 mazání v souboru
|
||||||
|
|
||||||
// TODO skoky a přesuny
|
// TODO skoky a přesuny
|
||||||
|
@ -150,10 +158,14 @@ int main(int argc, char* argv[]) {
|
||||||
case 'w':
|
case 'w':
|
||||||
save(filename);
|
save(filename);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
mode = insert;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case insert:
|
case insert:
|
||||||
// insert
|
insert_char(row, col++, ch);
|
||||||
|
print_line(row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
|
|
Loading…
Reference in a new issue