Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add paste command (Ctrl-V) in GUIChatConsole
  • Loading branch information
kahrl committed Dec 10, 2014
1 parent cfba55b commit daefd0a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/chat.cpp
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/chat.h
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions src/guiChatConsole.cpp
Expand Up @@ -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
Expand Down

0 comments on commit daefd0a

Please sign in to comment.