Fix cancellation procedure.
This commit is contained in:
+4
-2
@@ -168,10 +168,12 @@ void BEd::handle(std::string_view cmd, bool eof) {
|
|||||||
std::tie(vase, lang, state) = c.function->pre_text_mode(*this, address, c.argument);
|
std::tie(vase, lang, state) = c.function->pre_text_mode(*this, address, c.argument);
|
||||||
internal::ui::text_mode::TextMode tm(*this, vase, lang, state);
|
internal::ui::text_mode::TextMode tm(*this, vase, lang, state);
|
||||||
auto [a, b] = tm.run();
|
auto [a, b] = tm.run();
|
||||||
if (!b)
|
if (!b) {
|
||||||
text = a;
|
text = a;
|
||||||
else
|
} else {
|
||||||
internal::vase::Shard::release(a);
|
internal::vase::Shard::release(a);
|
||||||
|
throw ed_error("Operation cancelled.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (c.function->handle)
|
if (c.function->handle)
|
||||||
c.function->handle(*this, address, text, c.argument, nullptr);
|
c.function->handle(*this, address, text, c.argument, nullptr);
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
|
|||||||
term_height = rows;
|
term_height = rows;
|
||||||
redraw();
|
redraw();
|
||||||
bool running = true;
|
bool running = true;
|
||||||
|
bool cancelled = false;
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
redraw();
|
redraw();
|
||||||
@@ -176,8 +177,10 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
|
|||||||
case io::KeyEvent::Modifier::ALT:
|
case io::KeyEvent::Modifier::ALT:
|
||||||
case io::KeyEvent::Modifier::CTRL_ALT:
|
case io::KeyEvent::Modifier::CTRL_ALT:
|
||||||
case io::KeyEvent::Modifier::CTRL:
|
case io::KeyEvent::Modifier::CTRL:
|
||||||
if (res.text[0] == 'c')
|
if (res.text[0] == 'c') {
|
||||||
return {vase, true};
|
cancelled = true;
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case io::KeyEvent::Modifier::NONE:
|
case io::KeyEvent::Modifier::NONE:
|
||||||
if (res.text[0] == '\b' || res.text[0] == 0x7f) {
|
if (res.text[0] == '\b' || res.text[0] == 0x7f) {
|
||||||
@@ -314,7 +317,7 @@ std::pair<vase::Shard *, bool> TextMode::run_terminal() {
|
|||||||
uint16_t last_row = start + required_height;
|
uint16_t last_row = start + required_height;
|
||||||
bed.io.move_cursor(last_row, 1);
|
bed.io.move_cursor(last_row, 1);
|
||||||
bed.io.write("\n");
|
bed.io.write("\n");
|
||||||
return {vase, false};
|
return {vase, cancelled};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextMode::grow() {
|
void TextMode::grow() {
|
||||||
|
|||||||
Reference in New Issue
Block a user