]> git.lizzy.rs Git - minetest.git/commitdiff
Add paste command (Ctrl-V) in GUIChatConsole
authorKahrl <kahrl@gmx.net>
Fri, 19 Sep 2014 20:26:38 +0000 (22:26 +0200)
committerKahrl <kahrl@gmx.net>
Wed, 10 Dec 2014 06:12:08 +0000 (07:12 +0100)
src/chat.cpp
src/chat.h
src/guiChatConsole.cpp

index 0466b6e263e082929e959fa39d1b5277847997dd..b78b90145f2588e57d2de19fd5ad16cd2ba8e937 100644 (file)
@@ -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;
index e39d97ec2a67252093df25ac978be1dba286471e..82ce80875a2bd7d38e635e13015b7085af070078 100644 (file)
@@ -142,8 +142,9 @@ class ChatPrompt
        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();
index 62ce0d1e1f640e1ba22372c78ae359bc2e913c7a..918f9528bab083ae05b9ae40ebc1c4271dd3d5a8 100644 (file)
@@ -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