aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2014-09-19 22:26:38 +0200
committerKahrl <kahrl@gmx.net>2014-12-10 07:12:08 +0100
commitdaefd0ab367605eabe1a293dd7f6a50964bb3801 (patch)
tree42a0ab12ab933fb891566f3ba62ec36a3b045c8f
parentcfba55ba0a79eb1a4e9250d6dcc7ed4dd2bd519e (diff)
downloadminetest-daefd0ab367605eabe1a293dd7f6a50964bb3801.tar.gz
minetest-daefd0ab367605eabe1a293dd7f6a50964bb3801.tar.bz2
minetest-daefd0ab367605eabe1a293dd7f6a50964bb3801.zip
Add paste command (Ctrl-V) in GUIChatConsole
-rw-r--r--src/chat.cpp9
-rw-r--r--src/chat.h3
-rw-r--r--src/guiChatConsole.cpp13
3 files changed, 24 insertions, 1 deletions
diff --git a/src/chat.cpp b/src/chat.cpp
index 0466b6e26..b78b90145 100644
--- a/src/chat.cpp
+++ b/src/chat.cpp
@@ -407,6 +407,15 @@ void ChatPrompt::input(wchar_t ch)
m_nick_completion_end = 0;
}
+void ChatPrompt::input(const std::wstring &str)
+{
+ m_line.insert(m_cursor, str);
+ m_cursor += str.size();
+ clampView();
+ m_nick_completion_start = 0;
+ m_nick_completion_end = 0;
+}
+
std::wstring ChatPrompt::submit()
{
std::wstring line = m_line;
diff --git a/src/chat.h b/src/chat.h
index e39d97ec2..82ce80875 100644
--- a/src/chat.h
+++ b/src/chat.h
@@ -142,8 +142,9 @@ public:
ChatPrompt(std::wstring prompt, u32 history_limit);
~ChatPrompt();
- // Input character
+ // Input character or string
void input(wchar_t ch);
+ void input(const std::wstring &str);
// Submit, clear and return current line
std::wstring submit();
diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp
index 62ce0d1e1..918f9528b 100644
--- a/src/guiChatConsole.cpp
+++ b/src/guiChatConsole.cpp
@@ -507,6 +507,19 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
scope);
return true;
}
+ else if(event.KeyInput.Key == KEY_KEY_V && event.KeyInput.Control)
+ {
+ // Ctrl-V pressed
+ // paste text from clipboard
+ IOSOperator *os_operator = Environment->getOSOperator();
+ const c8 *text = os_operator->getTextFromClipboard();
+ if (text)
+ {
+ std::wstring wtext = narrow_to_wide(text);
+ m_chat_backend->getPrompt().input(wtext);
+ }
+ return true;
+ }
else if(event.KeyInput.Key == KEY_KEY_U && event.KeyInput.Control)
{
// Ctrl-U pressed