mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibLine: Allow the embedder to optionally handle pasted data itself
If the 'on_paste' callback is set, LibLine will buffer the pasted data and pass it over to the embedder to use as it pleases; in practice, this means that the users of LibLine can now escape or otherwise handle pasted data without the incremental codepoint-by-codepoint buildup.
This commit is contained in:
parent
0ea775f257
commit
d7d847c8c6
2 changed files with 14 additions and 1 deletions
|
@ -974,6 +974,12 @@ void Editor::handle_read_event()
|
|||
}
|
||||
if (is_in_paste && param1 == 201) {
|
||||
m_state = InputState::Free;
|
||||
if (on_paste) {
|
||||
on_paste(Utf32View { m_paste_buffer.data(), m_paste_buffer.size() }, *this);
|
||||
m_paste_buffer.clear_with_capacity();
|
||||
}
|
||||
if (!m_paste_buffer.is_empty())
|
||||
insert(Utf32View { m_paste_buffer.data(), m_paste_buffer.size() });
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -998,7 +1004,10 @@ void Editor::handle_read_event()
|
|||
m_state = InputState::GotEscape;
|
||||
continue;
|
||||
}
|
||||
insert(code_point);
|
||||
if (on_paste)
|
||||
m_paste_buffer.append(code_point);
|
||||
else
|
||||
insert(code_point);
|
||||
continue;
|
||||
case InputState::Free:
|
||||
m_previous_free_state = InputState::Free;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue