X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2FguiChatConsole.cpp;h=918f9528bab083ae05b9ae40ebc1c4271dd3d5a8;hb=63867b1a372a4d1a4a4ffdec9d0862b094211a89;hp=5fc576cf8315f83c8a5b6268a83b79c507c43660;hpb=a0566270d9fa075afa36a7e3e68c690b1b23ba90;p=minetest.git diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp index 5fc576cf8..918f9528b 100644 --- a/src/guiChatConsole.cpp +++ b/src/guiChatConsole.cpp @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "main.h" // for g_settings #include "porting.h" #include "tile.h" -#include "IGUIFont.h" +#include "fontengine.h" #include #include "gettext.h" @@ -92,19 +92,11 @@ GUIChatConsole::GUIChatConsole( m_background_color.setBlue(255); } - // load the font - // FIXME should a custom texture_path be searched too? - #if USE_FREETYPE - std::string font_name = g_settings->get("mono_font_path"); - u16 font_size = g_settings->getU16("mono_font_size"); - m_font = gui::CGUITTFont::createTTFont(env, font_name.c_str(), font_size); - #else - std::string font_name = "fontdejavusansmono.png"; - m_font = env->getFont(getTexturePath(font_name).c_str()); - #endif + m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono); + if (m_font == NULL) { - dstream << "Unable to load font: " << font_name << std::endl; + errorstream << "GUIChatConsole: Unable to load mono font "; } else { @@ -120,8 +112,7 @@ GUIChatConsole::GUIChatConsole( } GUIChatConsole::~GUIChatConsole() -{ -} +{} void GUIChatConsole::openConsole(f32 height) { @@ -131,6 +122,11 @@ void GUIChatConsole::openConsole(f32 height) reformatConsole(); } +bool GUIChatConsole::isOpen() const +{ + return m_open; +} + bool GUIChatConsole::isOpenInhibited() const { return m_open_inhibited > 0; @@ -511,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 @@ -535,14 +544,20 @@ bool GUIChatConsole::OnEvent(const SEvent& event) { // Tab or Shift-Tab pressed // Nick completion - std::list names = m_client->getConnectedPlayerNames(); + std::list names = m_client->getConnectedPlayerNames(); bool backwards = event.KeyInput.Shift; m_chat_backend->getPrompt().nickCompletion(names, backwards); return true; } else if(event.KeyInput.Char != 0 && !event.KeyInput.Control) { - m_chat_backend->getPrompt().input(event.KeyInput.Char); + #if (defined(linux) || defined(__linux)) + wchar_t wc = L'_'; + mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) ); + m_chat_backend->getPrompt().input(wc); + #else + m_chat_backend->getPrompt().input(event.KeyInput.Char); + #endif return true; } }