mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 11:57:35 +00:00
LibVT: Input dragged file path into the terminal on drop
We also support dropping plain text and non-file URLs.
This commit is contained in:
parent
6a64077ed7
commit
b4923938e1
2 changed files with 22 additions and 0 deletions
|
@ -689,6 +689,27 @@ void TerminalWidget::context_menu_event(GContextMenuEvent& event)
|
||||||
m_context_menu->popup(event.screen_position());
|
m_context_menu->popup(event.screen_position());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TerminalWidget::drop_event(GDropEvent& event)
|
||||||
|
{
|
||||||
|
if (event.data_type() == "text") {
|
||||||
|
event.accept();
|
||||||
|
write(m_ptm_fd, event.data().characters(), event.data().length());
|
||||||
|
} else if (event.data_type() == "url-list") {
|
||||||
|
event.accept();
|
||||||
|
auto lines = event.data().split('\n');
|
||||||
|
bool first = true;
|
||||||
|
for (auto& line : lines) {
|
||||||
|
if (!first)
|
||||||
|
write(m_ptm_fd, " ", 1);
|
||||||
|
first = false;
|
||||||
|
|
||||||
|
if (line.starts_with("file://"))
|
||||||
|
line = line.substring(7, line.length() - 7);
|
||||||
|
write(m_ptm_fd, line.characters(), line.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TerminalWidget::did_change_font()
|
void TerminalWidget::did_change_font()
|
||||||
{
|
{
|
||||||
GFrame::did_change_font();
|
GFrame::did_change_font();
|
||||||
|
|
|
@ -100,6 +100,7 @@ private:
|
||||||
virtual void focusin_event(CEvent&) override;
|
virtual void focusin_event(CEvent&) override;
|
||||||
virtual void focusout_event(CEvent&) override;
|
virtual void focusout_event(CEvent&) override;
|
||||||
virtual void context_menu_event(GContextMenuEvent&) override;
|
virtual void context_menu_event(GContextMenuEvent&) override;
|
||||||
|
virtual void drop_event(GDropEvent&) override;
|
||||||
virtual void did_change_font() override;
|
virtual void did_change_font() override;
|
||||||
|
|
||||||
// ^TerminalClient
|
// ^TerminalClient
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue