Make get_input clean-up after itself
This commit is contained in:
parent
7259c7ba7a
commit
68b1b176e6
1 changed files with 3 additions and 8 deletions
11
editor.cpp
11
editor.cpp
|
@ -46,6 +46,7 @@ string Editor::get_input(string prompt, F func) {
|
|||
print_text(cur.r, prompt+": " + s);
|
||||
ch = getch();
|
||||
}
|
||||
print_current_line();
|
||||
return s;
|
||||
}
|
||||
// Taking user input - string
|
||||
|
@ -191,14 +192,11 @@ bool Editor::take_action() {
|
|||
break;
|
||||
case 'f':
|
||||
last_find = get_string("to find");
|
||||
print_current_line();
|
||||
case 'n':
|
||||
{
|
||||
auto result = find(last_find);
|
||||
if(!result.first) {
|
||||
print_current_line();
|
||||
if(!result.first)
|
||||
break;
|
||||
}
|
||||
jump(result.second);
|
||||
}
|
||||
print_file(file_offset);
|
||||
|
@ -206,14 +204,11 @@ bool Editor::take_action() {
|
|||
case 's':
|
||||
last_find = get_string("to find");
|
||||
last_replace = get_string("to replace");
|
||||
print_current_line();
|
||||
case 'r':
|
||||
{
|
||||
auto result = find(last_find);
|
||||
if(!result.first) {
|
||||
print_current_line();
|
||||
if(!result.first)
|
||||
break;
|
||||
}
|
||||
jump(result.second);
|
||||
replace(cur + file_offset, last_find.size(), last_replace);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue