diff --git a/nel/include/nel/gui/css_parser.h b/nel/include/nel/gui/css_parser.h index a6dc92022..65b6a11b0 100644 --- a/nel/include/nel/gui/css_parser.h +++ b/nel/include/nel/gui/css_parser.h @@ -38,7 +38,7 @@ namespace NLGUI private: // stylesheet currently parsed - ucstring _Style; + std::string _Style; // keep track of current position in _Style size_t _Position; @@ -70,49 +70,49 @@ namespace NLGUI void preprocess(); // parse selectors + combinators - std::vector parse_selector(const ucstring &sel, std::string &pseudoElement) const; + std::vector parse_selector(const std::string &sel, std::string &pseudoElement) const; // parse selector and style - void parseRule(const ucstring &selectorString, const ucstring &styleString); + void parseRule(const std::string &selectorString, const std::string &styleString); inline bool is_eof() const { return _Position >= _Style.size(); } - inline bool is_whitespace(ucchar ch) const + inline bool is_whitespace(char ch) const { - return (ch == (ucchar)' ' || ch == (ucchar)'\t' || ch == (ucchar)'\n'); + return (ch == ' ' || ch == '\t' || ch == '\n'); } - inline bool is_hex(ucchar ch) const + inline bool is_hex(char ch) const { - return ((ch >= (ucchar)'0' && ch <= (ucchar)'9') || - (ch >= (ucchar)'a' && ch <= (ucchar)'f') || - (ch >= (ucchar)'A' && ch <= (ucchar)'F')); + return ((ch >= '0' && ch <= '9') || + (ch >= 'a' && ch <= 'f') || + (ch >= 'A' && ch <= 'F')); } inline bool maybe_escape() const { // escaping newline (\n) only allowed inside strings - return (_Style.size() - _Position) >= 1 && _Style[_Position] == (ucchar)'\\' && _Style[_Position+1] != '\n'; + return (_Style.size() - _Position) >= 1 && _Style[_Position] == '\\' && _Style[_Position+1] != '\n'; } - inline bool is_quote(ucchar ch) const + inline bool is_quote(char ch) const { - return ch== (ucchar)'"' || ch == (ucchar)'\''; + return ch== '"' || ch == '\''; } - inline bool is_block_open(ucchar ch) const + inline bool is_block_open(char ch) const { - return ch == (ucchar)'{' || ch == (ucchar)'[' || ch == (ucchar)'('; + return ch == (char)'{' || ch == (char)'[' || ch == (char)'('; } - inline bool is_block_close(ucchar ch, ucchar open) const + inline bool is_block_close(char ch, char open) const { - return ((open == '{' && ch == (ucchar)'}') || - (open == '[' && ch == (ucchar)']') || - (open == '(' && ch == (ucchar)')')); + return ((open == '{' && ch == (char)'}') || + (open == '[' && ch == (char)']') || + (open == '(' && ch == (char)')')); } inline bool is_comment_open() const @@ -120,25 +120,25 @@ namespace NLGUI if (_Position+1 > _Style.size()) return false; - return _Style[_Position] == (ucchar)'/' && _Style[_Position+1] == (ucchar)'*'; + return _Style[_Position] == (char)'/' && _Style[_Position+1] == (char)'*'; } - inline bool is_nonascii(ucchar ch) const + inline bool is_nonascii(char ch) const { return ch >= 0x80 /*&& ch <= 255*/; } - inline bool is_alpha(ucchar ch) const + inline bool is_alpha(char ch) const { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); } - inline bool is_digit(ucchar ch) const + inline bool is_digit(char ch) const { return ch >= '0' && ch <= '9'; } - inline bool is_nmchar(ucchar ch) const + inline bool is_nmchar(char ch) const { // checking escape here does not check if next char is '\n' or not return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/; diff --git a/nel/include/nel/gui/event_descriptor.h b/nel/include/nel/gui/event_descriptor.h index 95bdad212..dd2ae19c4 100644 --- a/nel/include/nel/gui/event_descriptor.h +++ b/nel/include/nel/gui/event_descriptor.h @@ -82,13 +82,13 @@ public: return _Key; } // return the char that has been pressed. The key event type MUST be 'keychar', else => assert - ucchar getChar() const + u32char getChar() const { nlassert(_KeyEvent == keychar); return _Char; } // return the string that has been sent. The key event type MUST be 'keystring', else => assert - ucstring getString() const + std::string getString() const { nlassert(_KeyEvent == keystring); return _String; @@ -141,9 +141,9 @@ private: union { NLMISC::TKey _Key; - ucchar _Char; + u32char _Char; }; - ucstring _String; + std::string _String; }; // ---------------------------------------------------------------------------- diff --git a/nel/include/nel/gui/group_container.h b/nel/include/nel/gui/group_container.h index 399f9c056..361ae70b9 100644 --- a/nel/include/nel/gui/group_container.h +++ b/nel/include/nel/gui/group_container.h @@ -248,6 +248,13 @@ namespace NLGUI // Get the header color draw. NB: depends if grayed, and if active. NLMISC::CRGBA getDrawnHeaderColor () const; + std::string getTitleRaw () const; + void setTitleRaw (const std::string &title); + std::string getTitleOpenedRaw () const; + void setTitleOpenedRaw (const std::string &title); + std::string getTitleClosedRaw () const; + void setTitleClosedRaw (const std::string &title); + ucstring getUCTitleOpened () const; void setUCTitleOpened (const ucstring &title); ucstring getUCTitleClosed () const; @@ -287,9 +294,15 @@ namespace NLGUI REFLECT_STRING("title", getTitle, setTitle); REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); - REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); - REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); - REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); + + REFLECT_STRING("title_raw", getTitleRaw, setTitleRaw); + REFLECT_STRING("title_opened_raw", getTitleOpenedRaw, setTitleOpenedRaw); + REFLECT_STRING("title_closed_raw", getTitleClosedRaw, setTitleClosedRaw); + + REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // FIXME: Lua UTF-8 + REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // FIXME: Lua UTF-8 + REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // FIXME: Lua UTF-8 + REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString); REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH); REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH); diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h index 36b8d63b4..9b2998be0 100644 --- a/nel/include/nel/gui/group_editbox.h +++ b/nel/include/nel/gui/group_editbox.h @@ -65,15 +65,15 @@ namespace NLGUI /// Accessors std::string getInputString() const; std::string getPrompt() const; - const u32string &getInputStringRef() const { return _InputString; } - const u32string &getPromptRef() const { return _Prompt; } + const ::u32string &getInputStringRef() const { return _InputString; } + const ::u32string &getPromptRef() const { return _Prompt; } /** Set the prompt * NB : line returns are encoded as '\n', not '\r\n' */ void setPrompt(const std::string &s); void setInputString(const std::string &str); - void setInputStringRef(const u32string &str) {_InputString = str; }; + void setInputStringRef(const ::u32string &str) {_InputString = str; }; void setInputStringAsInt(sint32 val); sint32 getInputStringAsInt() const; void setInputStringAsInt64(sint64 val); @@ -82,8 +82,8 @@ namespace NLGUI float getInputStringAsFloat() const; void setInputStringAsUtf16(const ucstring &str); ucstring getInputStringAsUtf16() const; - void setInputStringAsUtf32(const u32string &str); - u32string getInputStringAsUtf32() const { return _InputString; } + void setInputStringAsUtf32(const ::u32string &str); + ::u32string getInputStringAsUtf32() const { return _InputString; } void setColor(NLMISC::CRGBA col); @@ -98,7 +98,7 @@ namespace NLGUI static CGroupEditBox *getMenuFather() { return _MenuFather; } - void setCommand(const ucstring &command, bool execute); + void setCommand(const std::string &command, bool execute); // Stop parent from blinking void stopParentBlink() { if (_Parent) _Parent->disableBlink(); } @@ -122,7 +122,7 @@ namespace NLGUI sint32 getMaxHistoric() const {return _MaxHistoric;} sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} - const u32string &getHistoric(uint32 index) const {return _Historic[index];} + const ::u32string &getHistoric(uint32 index) const {return _Historic[index];} uint32 getNumHistoric() const {return (uint32)_Historic.size ();} // Get on change action handler @@ -140,7 +140,7 @@ namespace NLGUI // Paste the selection into buffer void paste(); // Write the string into buffer - void writeString(const ucstring &str, bool replace = true, bool atEnd = true); + void writeString(const ucstring &str, bool replace = true, bool atEnd = true); // UTF-16 because of Clipboard implementation // Expand the expression (true if there was a '/' at the start of the line) bool expand(); @@ -171,7 +171,7 @@ namespace NLGUI virtual void onKeyboardCaptureLost(); // set the input string as "default". will be reseted at first click (used for user information) - void setDefaultInputString(const ucstring &str); + void setDefaultInputString(const std::string &str); // For Interger and PositiveInteger, can specify min and max values void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;} @@ -229,17 +229,17 @@ namespace NLGUI NLMISC::CRGBA _BackSelectColor; // Text info - u32string _Prompt; - u32string _InputString; + ::u32string _Prompt; + ::u32string _InputString; CViewText *_ViewText; // undo / redo - u32string _StartInputString; // value of the input string when focus was acuired first - u32string _ModifiedInputString; + ::u32string _StartInputString; // value of the input string when focus was acuired first + ::u32string _ModifiedInputString; // Historic info - typedef std::deque THistoric; + typedef std::deque<::u32string> THistoric; THistoric _Historic; uint32 _MaxHistoric; sint32 _CurrentHistoricIndex; @@ -276,7 +276,7 @@ namespace NLGUI bool _CanRedo : 1; bool _CanUndo : 1; - std::vector _NegativeFilter; + std::vector _NegativeFilter; sint _CursorTexID; sint32 _CursorWidth; @@ -299,13 +299,13 @@ namespace NLGUI void handleEventString(const NLGUI::CEventDescriptorKey &event); void setup(); void triggerOnChangeAH(); - void appendStringFromClipboard(const ucstring &str); + void appendStringFromClipboard(const ucstring &str); // UTF-16 because of Clipboard implementation - ucstring getSelection(); + ucstring getSelection(); // UTF-16 because of Clipboard implementation static CGroupEditBox *_MenuFather; - static bool isValidAlphaNumSpace(ucchar c) + static bool isValidAlphaNumSpace(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -315,7 +315,7 @@ namespace NLGUI ac==' '; } - static bool isValidAlphaNum(ucchar c) + static bool isValidAlphaNum(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -324,7 +324,7 @@ namespace NLGUI (ac >= 'A' && ac <= 'Z'); } - static bool isValidAlpha(ucchar c) + static bool isValidAlpha(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -332,13 +332,13 @@ namespace NLGUI (ac >= 'A' && ac <= 'Z'); } - static bool isValidPlayerNameChar(ucchar c) + static bool isValidPlayerNameChar(u32char c) { // valid player name (with possible shard prefix / suffix format return isValidAlpha(c) || c=='.' || c=='(' || c==')'; } - static bool isValidFilenameChar(ucchar c) + static bool isValidFilenameChar(u32char c) { if (c == '\\' || c == '/' || @@ -352,12 +352,12 @@ namespace NLGUI return true; } // - bool isFiltered(ucchar c) + bool isFiltered(u32char c) { - uint length = (uint)_NegativeFilter.size(); - for (uint k = 0; k < length; ++k) + ptrdiff_t length = _NegativeFilter.size(); + for (ptrdiff_t k = 0; k < length; ++k) { - if ((ucchar) _NegativeFilter[k] == c) return true; + if (_NegativeFilter[k] == c) return true; } return false; } diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h index 1013a8b10..56605c0cc 100644 --- a/nel/include/nel/gui/group_html.h +++ b/nel/include/nel/gui/group_html.h @@ -320,16 +320,16 @@ namespace NLGUI void clearContext(); // Translate a char - bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const; + bool translateChar(u32char &output, u32char input, u32char lastChar) const; // Add a string in the current paragraph - void addString(const ucstring &str); + void addString(const std::string &str); // Add an image in the current paragraph void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams()); // Add a text area in the current paragraph - CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength); + CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const std::string &content, uint maxlength); // Add a combo box in the current paragraph CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); @@ -350,9 +350,9 @@ namespace NLGUI void flushString(); // Set the title - void setTitle (const ucstring &title); void setTitle (const std::string &title); std::string getTitle() const; + void setTitleRaw (const std::string &title); // Lookup a url in local file system bool lookupLocalFile (std::string &result, const char *url, bool isUrl); @@ -392,10 +392,10 @@ namespace NLGUI bool _TrustedDomain; // Title prefix - ucstring _TitlePrefix; + std::string _TitlePrefix; // Title string - ucstring _TitleString; + std::string _TitleString; // Need to browse next update coords.. bool _BrowseNextTime; @@ -644,7 +644,7 @@ namespace NLGUI std::string Name; // Variable value - ucstring Value; + std::string Value; // Text area group CInterfaceGroup *TextArea; @@ -747,7 +747,7 @@ namespace NLGUI // Current node is a text area bool _TextArea; std::string _TextAreaTemplate; - ucstring _TextAreaContent; + std::string _TextAreaContent; std::string _TextAreaName; uint _TextAreaRow; uint _TextAreaCols; @@ -755,7 +755,7 @@ namespace NLGUI // current mode is in select option bool _SelectOption; - ucstring _SelectOptionStr; + std::string _SelectOptionStr; // Current node is a object std::string _ObjectType; @@ -826,7 +826,7 @@ namespace NLGUI void spliceFragment(std::list::iterator src); // decode all HTML entities - static ucstring decodeHTMLEntities(const ucstring &str); + static std::string decodeHTMLEntities(const std::string &str); struct CDataImageDownload { diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 933f9a747..7c0324f58 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -222,7 +222,7 @@ namespace NLGUI int luaSetLineMaxW(CLuaState &ls); REFLECT_EXPORT_START(CViewText, CViewBase) - REFLECT_STRING("text", getText, setText); + REFLECT_STRING("text_raw", getText, setText); REFLECT_STRING("hardtext", getHardText, setHardText); // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); @@ -262,8 +262,8 @@ namespace NLGUI // width of the font in pixel. Just a Hint for tabing format (computed with '_') float _FontWidth; // strings to use when computing font size - ucstring _FontSizingChars; - ucstring _FontSizingFallback; + ::u32string _FontSizingChars; + ::u32string _FontSizingFallback; // height of the font in pixel. // use getFontHeight float _FontHeight; diff --git a/nel/include/nel/misc/events.h b/nel/include/nel/misc/events.h index c783a85eb..6cfe902b8 100644 --- a/nel/include/nel/misc/events.h +++ b/nel/include/nel/misc/events.h @@ -320,11 +320,11 @@ public: class CEventChar : public CEventKey { public: - CEventChar (ucchar c, TKeyButton button, IEventEmitter* emitter) : CEventKey (button, emitter, EventCharId), _Raw(true) + CEventChar (u32char c, TKeyButton button, IEventEmitter* emitter) : CEventKey (button, emitter, EventCharId), _Raw(true) { Char=c; } - ucchar Char; + u32char Char; virtual CEvent *clone() const {return new CEventChar(*this);} void setRaw( bool raw ) { _Raw = raw; } @@ -341,11 +341,11 @@ private: class CEventString : public CEventKey { public: - CEventString (const ucstring &str, IEventEmitter* emitter) : CEventKey (noKeyButton, emitter, EventStringId) + CEventString (const std::string &str, IEventEmitter* emitter) : CEventKey (noKeyButton, emitter, EventStringId) { String = str; } - ucstring String; + std::string String; virtual CEvent *clone() const {return new CEventString(*this);} }; diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h index 61291f421..ab8a25a58 100644 --- a/nel/include/nel/misc/utf_string_view.h +++ b/nel/include/nel/misc/utf_string_view.h @@ -54,11 +54,11 @@ public: inline CUtfStringView(const ucstring &utf16Str) : m_Str(utf16Str.c_str()), m_Size(utf16Str.size() << 1), m_Iterator(utf16Iterator) {} inline CUtfStringView(const ucchar *utf16Str) : m_Str(utf16Str), m_Size(strlen((const char *)utf16Str) & (ptrdiff_t)(-2)), m_Iterator(utf16Iterator) {} - inline CUtfStringView(const u32string &utf32Str) : m_Str(utf32Str.c_str()), m_Size(utf32Str.size() << 2), m_Iterator(utf32Iterator) {} + inline CUtfStringView(const ::u32string &utf32Str) : m_Str(utf32Str.c_str()), m_Size(utf32Str.size() << 2), m_Iterator(utf32Iterator) {} std::string toUtf8(bool reEncode = false) const; // Makes a copy ucstring toUtf16(bool reEncode = false) const; // Makes a copy - u32string toUtf32() const; // Makes a copy + ::u32string toUtf32() const; // Makes a copy std::wstring toWide() const; // Platform dependent, UTF-16 or UTF-32. Makes a copy. std::string toAscii() const; // Returns only values 0-127, 7-bit ASCII. Makes a copy. diff --git a/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 211ed27fd..bb954ba4d 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1265,6 +1265,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return 0; } + // https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar + if (message == WM_UNICHAR) + return (wParam == UNICODE_NOCHAR); + return DefWindowProcW(hWnd, message, wParam, lParam); } diff --git a/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/nel/src/3d/driver/opengl/driver_opengl_window.cpp index f04ad304e..dc48ecbf0 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -183,6 +183,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return 0; } + // https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar + if (message == WM_UNICHAR) + return (wParam == UNICODE_NOCHAR); + return trapMessage ? 0 : DefWindowProcW(hWnd, message, wParam, lParam); } diff --git a/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/nel/src/3d/driver/opengl/unix_event_emitter.cpp index d4153dde5..2945b90e7 100644 --- a/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -29,6 +29,7 @@ #include #include #include "nel/misc/debug.h" +#include "nel/misc/utf_string_view.h" #ifdef DEBUG_NEW #define new DEBUG_NEW @@ -537,8 +538,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) if (c > 0) { #ifdef X_HAVE_UTF8_STRING - ucstring ucstr; - ucstr.fromUtf8(Text); + ::u32string ucstr = NLMISC::CUtfStringView(Text).toUtf32(); CEventChar *charEvent = new CEventChar (ucstr[0], getKeyButton(event.xbutton.state), this); @@ -549,7 +549,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) #else for (int i = 0; i < c; i++) { - CEventChar *charEvent = new CEventChar ((ucchar)(unsigned char)Text[i], getKeyButton(event.xbutton.state), this); + CEventChar *charEvent = new CEventChar ((u32char)(unsigned char)Text[i], getKeyButton(event.xbutton.state), this); // raw if not processed by IME charEvent->setRaw(keyCode != 0); diff --git a/nel/src/gui/css_parser.cpp b/nel/src/gui/css_parser.cpp index e59cf832b..ebc8d8d34 100644 --- a/nel/src/gui/css_parser.cpp +++ b/nel/src/gui/css_parser.cpp @@ -65,7 +65,7 @@ namespace NLGUI _Rules.clear(); _Style.clear(); - _Style.fromUtf8(cssString); + _Style = cssString; preprocess(); _Position = 0; @@ -73,7 +73,7 @@ namespace NLGUI { skipWhitespace(); - if (_Style[_Position] == (ucchar)'@') + if (_Style[_Position] == '@') readAtRule(); else readRule(); @@ -89,13 +89,13 @@ namespace NLGUI // style: "color: red; font-size: 10px;" // // @internal - void CCssParser::parseRule(const ucstring &selectorString, const ucstring &styleString) + void CCssParser::parseRule(const std::string &selectorString, const std::string &styleString) { - std::vector selectors; - NLMISC::explode(selectorString, ucstring(","), selectors); + std::vector selectors; + NLMISC::explode(selectorString, std::string(","), selectors); TStyleVec props; - props = parseDecls(styleString.toUtf8()); + props = parseDecls(styleString); // duplicate props to each selector in selector list, // example 'div > p, h1' creates 'div>p' and 'h1' @@ -129,7 +129,7 @@ namespace NLGUI skipIdentifier(); // skip at-rule statement - while(!is_eof() && _Style[_Position] != (ucchar)';') + while(!is_eof() && _Style[_Position] != ';') { if (maybe_escape()) { @@ -174,9 +174,9 @@ namespace NLGUI _Position++; else if (is_quote(_Style[_Position])) skipString(); - else if (_Style[_Position] == (ucchar)'[') + else if (_Style[_Position] == '[') skipBlock(); - else if (_Style[_Position] == (ucchar)'{') + else if (_Style[_Position] == '{') break; else _Position++; @@ -184,7 +184,7 @@ namespace NLGUI if (!is_eof()) { - ucstring selector; + std::string selector; selector.append(_Style, start, _Position - start); skipWhitespace(); @@ -194,7 +194,7 @@ namespace NLGUI skipBlock(); if (_Position <= _Style.size()) { - ucstring rules; + std::string rules; rules.append(_Style, start + 1, _Position - start - 2); parseRule(selector, rules); @@ -215,7 +215,7 @@ namespace NLGUI for(uint i=0; i<6 && is_hex(_Style[_Position]); i++) _Position++; - if (_Style[_Position] == (ucchar)' ') + if (_Style[_Position] == ' ') _Position++; } else if (_Style[_Position] != 0x0A) @@ -246,23 +246,23 @@ namespace NLGUI // cannot start with digit valid = false; } - else if ((_Position - start) == 0 && _Style[_Position-1] == (ucchar)'-') + else if ((_Position - start) == 0 && _Style[_Position-1] == '-') { // cannot start with -# valid = false; } } - else if (_Style[_Position] == (ucchar)'_') + else if (_Style[_Position] == '_') { // valid } - else if (_Style[_Position] >= 0x0080) + else if (_Style[_Position] >= 0x80) { // valid } - else if (_Style[_Position] == (ucchar)'-') + else if (_Style[_Position] == '-') { - if ((_Position - start) == 1 && _Style[_Position-1] == (ucchar)'-') + if ((_Position - start) == 1 && _Style[_Position-1] == '-') { // cannot start with -- valid = false; @@ -285,7 +285,7 @@ namespace NLGUI // @internal void CCssParser::skipBlock() { - ucchar startChar = _Style[_Position]; + char startChar = _Style[_Position]; // block start _Position++; @@ -311,7 +311,7 @@ namespace NLGUI // @internal void CCssParser::skipString() { - ucchar endChar = _Style[_Position]; + char endChar = _Style[_Position]; // quote start _Position++; @@ -338,7 +338,7 @@ namespace NLGUI // *************************************************************************** // parse selector list // @internal - std::vector CCssParser::parse_selector(const ucstring &sel, std::string &pseudoElement) const + std::vector CCssParser::parse_selector(const std::string &sel, std::string &pseudoElement) const { std::vector result; CCssSelector current; @@ -346,10 +346,10 @@ namespace NLGUI pseudoElement.clear(); bool failed = false; - ucstring::size_type start = 0, pos = 0; + std::string::size_type start = 0, pos = 0; while(pos < sel.size()) { - ucstring uc; + std::string uc; uc = sel[pos]; if (is_nmchar(sel[pos]) && current.empty()) { @@ -358,7 +358,7 @@ namespace NLGUI while(pos < sel.size() && is_nmchar(sel[pos])) pos++; - current.Element = toLower(sel.substr(start, pos - start).toUtf8()); + current.Element = toLower(sel.substr(start, pos - start)); start = pos; continue; } @@ -371,7 +371,7 @@ namespace NLGUI while(pos < sel.size() && is_nmchar(sel[pos])) pos++; - current.Id = toLower(sel.substr(start, pos - start).toUtf8()); + current.Id = toLower(sel.substr(start, pos - start)); start = pos; } else if (sel[pos] == '.') @@ -383,7 +383,7 @@ namespace NLGUI while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.')) pos++; - current.setClass(toLower(sel.substr(start, pos - start).toUtf8())); + current.setClass(toLower(sel.substr(start, pos - start))); start = pos; } else if (sel[pos] == '[') @@ -399,9 +399,9 @@ namespace NLGUI start = pos; } - ucstring key; - ucstring value; - ucchar op = ' '; + std::string key; + std::string value; + char op = ' '; // key while(pos < sel.size() && is_nmchar(sel[pos])) @@ -420,7 +420,7 @@ namespace NLGUI if (sel[pos] == ']') { - current.addAttribute(key.toUtf8()); + current.addAttribute(key); } else { @@ -496,14 +496,14 @@ namespace NLGUI // [value="attr" i] if (value.size() > 2 && value[value.size()-2] == ' ') { - ucchar lastChar = value[value.size()-1]; + char lastChar = value[value.size()-1]; if (lastChar == 'i' || lastChar == 'I' || lastChar == 's' || lastChar == 'S') { value = value.substr(0, value.size()-2); cs = !((lastChar == 'i' || lastChar == 'I')); } } - current.addAttribute(key.toUtf8(), trimQuotes(value).toUtf8(), (char)op, cs); + current.addAttribute(key, trimQuotes(value), (char)op, cs); } // op error } // no value @@ -549,7 +549,7 @@ namespace NLGUI } } - std::string key = toLower(sel.substr(start, pos - start).toUtf8()); + std::string key = toLower(sel.substr(start, pos - start)); if (key.empty()) { failed = true; @@ -647,7 +647,7 @@ namespace NLGUI size_t start; size_t charsLeft; bool quote = false; - ucchar quoteChar; + char quoteChar; while(!is_eof()) { charsLeft = _Style.size() - _Position - 1; @@ -660,8 +660,8 @@ namespace NLGUI if (charsLeft >= 1 && _Style[_Position] == 0x0D && _Style[_Position+1] == 0x0A) len++; - ucstring tmp; - tmp += 0x000A; + std::string tmp; + tmp += 0x0A; _Style.replace(_Position, 1, tmp); } else if (_Style[_Position] == 0x00) @@ -686,12 +686,12 @@ namespace NLGUI } else if (!quote && is_comment_open()) { - size_t pos = _Style.find(ucstring("*/"), _Position + 2); + size_t pos = _Style.find("*/", _Position + 2); if (pos == std::string::npos) pos = _Style.size(); _Style.erase(_Position, pos - _Position + 2); - ucstring uc; + std::string uc; uc = _Style[_Position]; // _Position is already at correct place diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp index e6b69326b..141c7ba9b 100644 --- a/nel/src/gui/group_container.cpp +++ b/nel/src/gui/group_container.cpp @@ -3955,8 +3955,8 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setTitle (const std::string &title) { - if (_Localize) setUCTitle (CI18N::get(title)); - else setUCTitle (title); + if (_Localize) setTitleRaw (CI18N::get(title)); + else setTitleRaw (title); } // *************************************************************************** @@ -3968,8 +3968,8 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setTitleOpened (const std::string &title) { - if (_Localize) setUCTitleOpened (CI18N::get(title)); - else setUCTitleOpened (title); + if (_Localize) setTitleOpenedRaw (CI18N::get(title)); + else setTitleOpenedRaw (title); } // *************************************************************************** @@ -3981,51 +3981,87 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setTitleClosed (const std::string &title) { - if (_Localize) setUCTitleClosed (CI18N::get(title)); - else setUCTitleClosed (title); + if (_Localize) setTitleClosedRaw (CI18N::get(title)); + else setTitleClosedRaw (title); } // *************************************************************************** - void CGroupContainer::setUCTitleOpened(const ucstring &title) + void CGroupContainer::setTitleOpenedRaw(const std::string &title) { - _TitleTextOpened = title.toUtf8(); + _TitleTextOpened = title; if (_TitleOpened != NULL) - _TitleOpened->setText (title.toUtf8()); + _TitleOpened->setText (title); invalidateCoords(); } // *************************************************************************** - void CGroupContainer::setUCTitleClosed(const ucstring &title) + void CGroupContainer::setTitleClosedRaw(const std::string &title) { - _TitleTextClosed = title.toUtf8(); + _TitleTextClosed = title; if (_TitleClosed != NULL) _TitleClosed->setText (_TitleTextClosed); invalidateCoords(); } + // *************************************************************************** + void CGroupContainer::setTitleRaw(const std::string &title) + { + setTitleOpenedRaw(title); + setTitleClosedRaw(title); + } + + // *************************************************************************** + std::string CGroupContainer::getTitleRaw () const + { + return getTitleOpened(); + } + + // *************************************************************************** + std::string CGroupContainer::getTitleOpenedRaw () const + { + return _TitleTextOpened; + } + + // *************************************************************************** + std::string CGroupContainer::getTitleClosedRaw () const + { + return _TitleTextClosed; + } + + // *************************************************************************** + void CGroupContainer::setUCTitleOpened(const ucstring &title) + { + setTitleOpenedRaw(title.toUtf8()); + } + + // *************************************************************************** + void CGroupContainer::setUCTitleClosed(const ucstring &title) + { + setTitleClosedRaw(title.toUtf8()); + } + // *************************************************************************** void CGroupContainer::setUCTitle(const ucstring &title) { - setUCTitleOpened(title); - setUCTitleClosed(title); + setTitleRaw(title.toUtf8()); } // *************************************************************************** ucstring CGroupContainer::getUCTitle () const { - return getUCTitleOpened(); + return ucstring::makeFromUtf8(getTitleRaw()); } // *************************************************************************** ucstring CGroupContainer::getUCTitleOpened () const { - return _TitleTextOpened; + return ucstring::makeFromUtf8(getTitleOpenedRaw()); } // *************************************************************************** ucstring CGroupContainer::getUCTitleClosed () const { - return _TitleTextClosed; + return ucstring::makeFromUtf8(getTitleClosedRaw()); } // *************************************************************************** diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index 768c69066..47a36d0a1 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -96,7 +96,7 @@ namespace NLGUI _ViewTextDeltaX(0) { - _Prompt = u32string(1, (u32char)'>'); + _Prompt = ::u32string(1, (u32char)'>'); _BackSelectColor= CRGBA::White; _TextSelectColor= CRGBA::Black; } @@ -264,9 +264,9 @@ namespace NLGUI std::string s; s.reserve( _NegativeFilter.size() ); - std::vector< char >::const_iterator itr; - for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr ) - s.push_back( *itr ); + std::vector< u32char >::const_iterator itr; + for (itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr) + CUtfStringView::append(s, *itr); return s; } @@ -450,10 +450,10 @@ namespace NLGUI if( name == "negative_filter" ) { _NegativeFilter.clear(); - - std::string::size_type i; - for( i = 0; i < value.size(); i++ ) - _NegativeFilter.push_back( value[ i ] ); + ::u32string::size_type i; + ::u32string ustr = CUtfStringView(value).toUtf32(); + for( i = 0; i < ustr.size(); i++ ) + _NegativeFilter.push_back(ustr[i]); } else CInterfaceGroup::setProperty( name, value ); @@ -539,9 +539,9 @@ namespace NLGUI std::string s; s.reserve( _NegativeFilter.size() ); - std::vector< char >::const_iterator itr; + std::vector< u32char >::const_iterator itr; for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr ) - s.push_back( *itr ); + CUtfStringView::append(s, *itr); xmlSetProp( node, BAD_CAST "negative_filter", BAD_CAST s.c_str() ); @@ -657,9 +657,11 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" ); if (prop) { - uint length = (uint)strlen(prop); - _NegativeFilter.resize(length); - std::copy((const char *) prop, (const char *) prop + length, _NegativeFilter.begin()); + _NegativeFilter.clear(); + ::u32string::size_type i; + ::u32string ustr = CUtfStringView(prop).toUtf32(); + for( i = 0; i < ustr.size(); i++ ) + _NegativeFilter.push_back(ustr[i]); } return true; @@ -829,10 +831,10 @@ namespace NLGUI // ---------------------------------------------------------------------------- void CGroupEditBox::writeString(const ucstring &str16, bool replace, bool atEnd) { - u32string str = CUtfStringView(str16).toUtf32(); + ::u32string str = CUtfStringView(str16).toUtf32(); sint length = (sint)str.length(); - u32string toAppend; + ::u32string toAppend; // filter character depending on the entry type switch (_EntryType) { @@ -854,7 +856,7 @@ namespace NLGUI } } // remove '\r' characters - toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (ucchar) '\r'), toAppend.end()); + toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (u32char) '\r'), toAppend.end()); } break; @@ -965,7 +967,7 @@ namespace NLGUI { length = _MaxNumChar - (sint)_InputString.length(); } - u32string toAdd = toAppend.substr(0, length); + ::u32string toAdd = toAppend.substr(0, length); sint32 minPos; sint32 maxPos; if (_CurrSelection == this) @@ -1015,7 +1017,7 @@ namespace NLGUI _CursorAtPreviousLineEnd = false; if (_ClearOnEscape) { - setInputStringAsUtf32(u32string()); + setInputStringAsUtf32(::u32string()); triggerOnChangeAH(); } CWidgetManager::getInstance()->setCaptureKeyboard(NULL); @@ -1077,7 +1079,7 @@ namespace NLGUI cutSelection(); } - ucchar c = isKeyRETURN ? '\n' : rEDK.getChar(); + u32char c = isKeyRETURN ? '\n' : rEDK.getChar(); if (isFiltered(c)) return; switch(_EntryType) { @@ -1124,8 +1126,8 @@ namespace NLGUI if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX)) { // estimate new string - u32string copyStr= _InputString; - u32string::iterator it = copyStr.begin() + _CursorPos; + ::u32string copyStr= _InputString; + ::u32string::iterator it = copyStr.begin() + _CursorPos; copyStr.insert(it, c); sint32 value; fromString(CUtfStringView(copyStr).toUtf8(), value); @@ -1137,8 +1139,8 @@ namespace NLGUI if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX)) { // estimate new string - u32string copyStr= _InputString; - u32string::iterator it = copyStr.begin() + _CursorPos; + ::u32string copyStr= _InputString; + ::u32string::iterator it = copyStr.begin() + _CursorPos; copyStr.insert(it, c); // \todo yoyo: this doesn't really work i think.... uint32 value; @@ -1151,7 +1153,7 @@ namespace NLGUI if ((uint) _InputString.length() < _MaxNumChar) { makeTopWindow(); - u32string::iterator it = _InputString.begin() + _CursorPos; + ::u32string::iterator it = _InputString.begin() + _CursorPos; _InputString.insert(it, c); ++ _CursorPos; triggerOnChangeAH(); @@ -1263,7 +1265,7 @@ namespace NLGUI // else delete last character else if(_InputString.size () > 0 && _CursorPos != 0) { - u32string::iterator it = _InputString.begin() + (_CursorPos - 1); + ::u32string::iterator it = _InputString.begin() + (_CursorPos - 1); _InputString.erase(it); -- _CursorPos; _CursorAtPreviousLineEnd = false; @@ -1436,7 +1438,7 @@ namespace NLGUI std::string usTmp; if (_EntryType == Password) { - usTmp = CUtfStringView(_Prompt + u32string(_InputString.size(), 0x2022)).toUtf8(); + usTmp = CUtfStringView(_Prompt + ::u32string(_InputString.size(), 0x2022)).toUtf8(); } else { @@ -1634,7 +1636,7 @@ namespace NLGUI { setInputStringAsUtf32(CUtfStringView(str).toUtf32()); } - void CGroupEditBox::setInputStringAsUtf32(const u32string &str) + void CGroupEditBox::setInputStringAsUtf32(const ::u32string &str) { _InputString = str; if (_CursorPos > (sint32) str.length()) @@ -1650,10 +1652,10 @@ namespace NLGUI // *************************************************************************** - void CGroupEditBox::setDefaultInputString(const ucstring &str) + void CGroupEditBox::setDefaultInputString(const std::string &str) { _DefaultInputString= true; - setInputStringAsUtf32(CUtfStringView(str).toUtf32()); + setInputString(str); } // *************************************************************************** @@ -1771,14 +1773,14 @@ namespace NLGUI } // *************************************************************************** - void CGroupEditBox::setCommand(const ucstring &command, bool execute) + void CGroupEditBox::setCommand(const std::string &command, bool execute) { // do nothing if frozen if(_Frozen) return; // set the string and maybe execute - setInputStringAsUtf16((ucchar) '/' + command); + setInputString('/' + command); if (execute) { // stop selection @@ -1878,7 +1880,7 @@ namespace NLGUI void CGroupEditBox::onQuit() { // clear the text and restore backup pos before final save - setInputStringAsUtf32(u32string()); + setInputStringAsUtf32(::u32string()); _CurrSelection = NULL; } @@ -1886,7 +1888,7 @@ namespace NLGUI void CGroupEditBox::onLoadConfig() { // config is not saved when there's an empty string, so restore that default state. - setInputStringAsUtf32(u32string()); + setInputStringAsUtf32(::u32string()); _CurrSelection = NULL; _PrevNumLine = 1; } @@ -1901,7 +1903,7 @@ namespace NLGUI if (_DefaultInputString) { _DefaultInputString= false; - setInputStringAsUtf32(u32string()); + setInputStringAsUtf32(::u32string()); } _CanRedo = false; _CanUndo = false; diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index b559b409f..f7a62cc90 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -1034,7 +1034,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::addText (const char * buf, int len) + void CGroupHTML::addText (const char *buf, int len) { if (_Browsing) { @@ -1042,44 +1042,43 @@ namespace NLGUI return; // Build a UTF8 string - string inputString(buf, buf+len); - if (_ParsingLua && _TrustedDomain) { // we are parsing a lua script - _LuaScript += inputString; + _LuaScript += string(buf, buf + len); // no more to do return; } // Build a unicode string - ucstring inputUCString; - inputUCString.fromUtf8(inputString); + CUtfStringView inputStringView(buf, len); // Build the final unicode string - ucstring tmp; + string tmp; tmp.reserve(len); - uint ucLen = (uint)inputUCString.size(); - for (uint i=0; i(textArea->getGroup("eb")); if (eb) { - eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf8()); + eb->setInputString(decodeHTMLEntities(content)); if (style.hasStyle("background-color")) { CViewBitmap *bg = dynamic_cast(eb->getView("bg")); @@ -3310,7 +3309,7 @@ namespace NLGUI { if (_CurrentViewLink) { - u32string str = CUtfStringView(_CurrentViewLink->getText()).toUtf32(); // FIXME: Optimize reverse UTF iteration + ::u32string str = CUtfStringView(_CurrentViewLink->getText()).toUtf32(); // FIXME: Optimize reverse UTF iteration if (!str.empty()) return str[str.length()-1]; } @@ -3402,7 +3401,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::setTitle (const ucstring &title) + void CGroupHTML::setTitleRaw (const std::string &title) { CInterfaceElement *parent = getParent(); if (parent) @@ -3412,7 +3411,7 @@ namespace NLGUI CGroupContainer *container = dynamic_cast(parent); if (container) { - container->setUCTitle (title); + container->setTitleRaw (title); } } } @@ -3420,21 +3419,18 @@ namespace NLGUI void CGroupHTML::setTitle(const std::string &title) { - ucstring uctitle; - uctitle.fromUtf8(title); - _TitleString.clear(); if(!_TitlePrefix.empty()) { _TitleString = _TitlePrefix + " - "; } - _TitleString += uctitle; + _TitleString += title; - setTitle(_TitleString); + setTitleRaw(_TitleString); } std::string CGroupHTML::getTitle() const { - return _TitleString.toUtf8(); + return _TitleString; }; // *************************************************************************** @@ -4685,9 +4681,7 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 3, LUA_TBOOLEAN); string name = ls.toString(1); - - ucstring text; - text.fromUtf8(ls.toString(2)); + string text = ls.toString(2); if (!_Forms.empty()) { @@ -4717,7 +4711,7 @@ namespace NLGUI const char *funcName = "addString"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - addString(ucstring::makeFromUtf8(ls.toString(1))); + addString(ls.toString(1)); return 0; } @@ -4945,7 +4939,7 @@ namespace NLGUI } // *************************************************************************** - inline bool isDigit(ucchar c, uint base = 16) + inline bool isDigit(char c, uint base = 16) { if (c>='0' && c<='9') return true; if (base != 16) return false; @@ -4955,7 +4949,7 @@ namespace NLGUI } // *************************************************************************** - inline ucchar convertHexDigit(ucchar c) + inline char convertHexDigit(char c) { if (c>='0' && c<='9') return c-'0'; if (c>='A' && c<='F') return c-'A'+10; @@ -4964,9 +4958,10 @@ namespace NLGUI } // *************************************************************************** - ucstring CGroupHTML::decodeHTMLEntities(const ucstring &str) + std::string CGroupHTML::decodeHTMLEntities(const std::string &str) { - ucstring result; + std::string result; + result.reserve(str.size() + (str.size() >> 2)); uint last, pos; for (uint i=0; igetNumChildren() == 0) { - ucstring tmp("\n"); - addString(tmp); + addString("\n"); } else { @@ -6086,8 +6080,7 @@ namespace NLGUI { // Get the string name string name = elm.getAttribute("name"); - ucstring ucValue; - ucValue.fromUtf8(elm.getAttribute("value")); + string ucValue = elm.getAttribute("value"); uint size = 20; uint maxlength = 1024; @@ -6121,12 +6114,12 @@ namespace NLGUI string normal = elm.getAttribute("src"); string pushed; string over; - ucstring ucValue = ucstring("on"); + string ucValue = "on"; bool checked = elm.hasAttribute("checked"); // TODO: unknown if empty attribute should override or not if (elm.hasNonEmptyAttribute("value")) - ucValue.fromUtf8(elm.getAttribute("value")); + ucValue = elm.getAttribute("value"); if (type == "radio") { @@ -6191,8 +6184,7 @@ namespace NLGUI string name = elm.getAttribute("name"); // Get the value - ucstring ucValue; - ucValue.fromUtf8(elm.getAttribute("value")); + string ucValue = elm.getAttribute("value"); // Add an entry CGroupHTML::CForm::CEntry entry; @@ -6224,8 +6216,7 @@ namespace NLGUI if (elm.hasNonEmptyAttribute("value")) fromString(elm.getAttribute("value"), _UL.back().Value); - ucstring str; - str.fromUtf8(_UL.back().getListMarkerText()); + string str = _UL.back().getListMarkerText(); addString (str); // list-style-type: outside @@ -6429,7 +6420,7 @@ namespace NLGUI // use option text as value if (!elm.hasAttribute("value")) { - _Forms.back().Entries.back().SelectValues.back() = _SelectOptionStr.toUtf8(); + _Forms.back().Entries.back().SelectValues.back() = _SelectOptionStr; } // insert the parsed text into the select control @@ -6437,7 +6428,7 @@ namespace NLGUI if (cb) { uint lineIndex = cb->getNumTexts(); - cb->addText(_SelectOptionStr.toUtf8()); + cb->addText(_SelectOptionStr); if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex) { cb->setGrayed(lineIndex, true); @@ -6449,7 +6440,7 @@ namespace NLGUI if (sb) { uint lineIndex = sb->getNumLine(); - sb->addLine(_SelectOptionStr.toUtf8(), "", ""); + sb->addLine(_SelectOptionStr, "", ""); if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex) { diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index b5744925f..d8552f153 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -118,9 +118,10 @@ namespace NLGUI // Letter size // - "_" that should be the character with the lowest part // - A with an accent for the highest part - _FontSizingChars.fromUtf8("_\xc3\x84"); + // https://www.compart.com/en/unicode/U+00C4 + _FontSizingChars = { (u32char)'_', 0x000000C4 }; // fallback if SizingChars are not supported by font - _FontSizingFallback.fromUtf8("|"); + _FontSizingFallback = { (u32char)'|' }; computeFontSize (); } @@ -396,12 +397,12 @@ namespace NLGUI else if ( name == "sizing_chars" ) { - return _FontSizingChars.toUtf8(); + return CUtfStringView(_FontSizingChars).toUtf8(); } else if ( name == "sizing_fallback" ) { - return _FontSizingFallback.toUtf8(); + return CUtfStringView(_FontSizingFallback).toUtf8(); } else return ""; @@ -688,13 +689,13 @@ namespace NLGUI else if( name == "sizing_chars" ) { - _FontSizingChars.fromUtf8(value); + _FontSizingChars = CUtfStringView(value).toUtf32(); return true; } else if( name == "sizing_fallback" ) { - _FontSizingFallback.fromUtf8(value); + _FontSizingFallback = CUtfStringView(value).toUtf32(); return true; } else @@ -766,8 +767,8 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "clamp_right", BAD_CAST toString( _ClampRight ).c_str() ); xmlSetProp( node, BAD_CAST "auto_clamp_offset", BAD_CAST toString( _AutoClampOffset ).c_str() ); xmlSetProp( node, BAD_CAST "continuous_update", BAD_CAST toString( _ContinuousUpdate ).c_str() ); - xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST _FontSizingChars.toUtf8().c_str() ); - xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST _FontSizingFallback.toUtf8().c_str() ); + xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST CUtfStringView(_FontSizingChars).toUtf8().c_str() ); + xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST CUtfStringView(_FontSizingFallback).toUtf8().c_str() ); return true; } @@ -953,16 +954,16 @@ namespace NLGUI } // "_Ä" lowest/highest chars (underscore, A+diaeresis) - _FontSizingChars.fromUtf8("_\xc3\x84"); + _FontSizingChars = { (u32char)'_', 0x000000C4 }; prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_chars" ); if (prop) - _FontSizingChars.fromUtf8((const char*)prop); + _FontSizingChars = CUtfStringView((const char*)prop).toUtf32(); // fallback if SizingChars are not supported by font - _FontSizingFallback.fromUtf8("|"); + _FontSizingFallback = { (u32char)'|' }; prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_fallback" ); if (prop) - _FontSizingFallback.fromUtf8((const char*)prop); + _FontSizingFallback = CUtfStringView((const char*)prop).toUtf32(); computeFontSize (); } @@ -1468,9 +1469,9 @@ namespace NLGUI void CViewText::setFontSizing(const std::string &chars, const std::string &fallback) { _FontSizingChars.clear(); - _FontSizingChars.fromUtf8(chars); + _FontSizingChars = CUtfStringView(chars).toUtf32(); _FontSizingFallback.clear(); - _FontSizingFallback.fromUtf8(fallback); + _FontSizingFallback = CUtfStringView(fallback).toUtf32(); } // *************************************************************************** @@ -1683,7 +1684,7 @@ namespace NLGUI nMaxWidth *= _Scale; //for (i = 0; i < textSize; ++i) CUtfStringView sv(_Text); - u32string ucStrLetter(1, ' '); + ::u32string ucStrLetter(1, ' '); for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i) { if(isFormatTagChange(i, formatTagIndex)) @@ -1863,7 +1864,7 @@ namespace NLGUI uint i; for(i= (uint)spaceEnd;i<(uint)_Text.length();i++) { - ucchar c= _Text[i]; + char c= _Text[i]; if(c==' ' || c=='\n') break; // If change of color tag, stop the word, but don't take the new color now. @@ -1950,7 +1951,7 @@ namespace NLGUI else { float px = numSpaces * _SpaceWidth; - u32string oneChar(1, ' '); + ::u32string oneChar(1, ' '); CUtfStringView wsv(wordValue); CUtfStringView::iterator wit(wsv.begin()), wend(wsv.end()); for (; wit != wend; ++wit) @@ -2198,7 +2199,7 @@ namespace NLGUI if (_ClampRight) { CUtfStringView sv(_Text); - u32string ucStrLetter = u32string(1, (u32char)' '); + ::u32string ucStrLetter = u32string(1, (u32char)' '); for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) { ucStrLetter[0] = *it; @@ -2224,8 +2225,8 @@ namespace NLGUI else { // FIXME: Optimize reverse UTF iteration - u32string uctext = CUtfStringView(_Text).toUtf32(); - u32string ucStrLetter = u32string(1, (u32char)' '); + ::u32string uctext = CUtfStringView(_Text).toUtf32(); + ::u32string ucStrLetter = u32string(1, (u32char)' '); for (sint i = (sint)uctext.size() - 1; i >= 0; --i) { ucStrLetter[0] = uctext[i]; @@ -2358,7 +2359,7 @@ namespace NLGUI charIndex += currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); } // skip all spaces at start of line (unless there are only spaces in the line) - std::string::size_type nextPos = _Text.find_first_not_of((ucchar) ' ', charIndex); + std::string::size_type nextPos = _Text.find_first_not_of(' ', charIndex); if (nextPos != std::string::npos) { if (getLineFromIndex(charIndex) == (sint) line) @@ -2567,7 +2568,7 @@ namespace NLGUI float px = 0.f; UTextContext::CStringInfo si; - u32string singleChar(1, ' '); + ::u32string singleChar(1, ' '); uint i = 0; NLMISC::CUtfStringView sv(textValue); for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i) @@ -3405,7 +3406,7 @@ namespace NLGUI while(textIndexend()); it != end; ++it) res += *it; diff --git a/nel/src/misc/win_event_emitter.cpp b/nel/src/misc/win_event_emitter.cpp index 5b6860794..0d370cffc 100644 --- a/nel/src/misc/win_event_emitter.cpp +++ b/nel/src/misc/win_event_emitter.cpp @@ -162,6 +162,14 @@ bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPA server->postEvent (new CEventKeyUp ((NLMISC::TKey)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); } break; + case WM_UNICHAR: + if (wParam != UNICODE_NOCHAR && _KeyboardEventsEnabled) + { + //if (wParam < KeyCount) + //nlinfo("WM_UNICHAR with %u", wParam); + server->postEvent (new CEventChar ((u32char)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); + } + break; case WM_CHAR: if (_KeyboardEventsEnabled) { diff --git a/ryzom/client/src/actions.cpp b/ryzom/client/src/actions.cpp index 783088b21..428c607f0 100644 --- a/ryzom/client/src/actions.cpp +++ b/ryzom/client/src/actions.cpp @@ -499,9 +499,9 @@ void CCombo::init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons) } // *************************************************************************** -ucstring CCombo::toUCString() const +string CCombo::toString() const { - ucstring ret; + string ret; if ((KeyButtons & shiftKeyButton) && (Key != 0x10)) ret += CI18N::get("uiKeySHIFT") + "+"; if ((KeyButtons & ctrlKeyButton) && (Key != 0x11)) diff --git a/ryzom/client/src/actions.h b/ryzom/client/src/actions.h index 1e1bffb84..3fe976ac4 100644 --- a/ryzom/client/src/actions.h +++ b/ryzom/client/src/actions.h @@ -66,7 +66,7 @@ public: void init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons); /// Get the combo in human readable form - ucstring toUCString() const; + std::string toString() const; // For maps bool operator<(const CCombo &other) const diff --git a/ryzom/client/src/interface_v3/action_handler_edit.cpp b/ryzom/client/src/interface_v3/action_handler_edit.cpp index bde8f5389..c2d3bafbc 100644 --- a/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -70,7 +70,7 @@ static inline uint getCharacterCategory(u32char c) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) * It returns the new index */ -static uint skipUCCharsRight(uint startPos, const u32string &str) +static uint skipUCCharsRight(uint startPos, const ::u32string &str) { uint pos = startPos; uint endIndex = (uint)str.length(); @@ -87,7 +87,7 @@ static uint skipUCCharsRight(uint startPos, const u32string &str) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) * It returns the new index */ -static uint skipUCCharsLeft(uint startPos, const u32string &str) +static uint skipUCCharsLeft(uint startPos, const ::u32string &str) { uint pos = startPos; -- pos; @@ -363,7 +363,7 @@ class CAHEditPreviousLine : public CAHEdit if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine())) { // Get the start of the string. - u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); + ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); // Search all historic string that match startStr. for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++) @@ -435,7 +435,7 @@ class CAHEditNextLine : public CAHEdit if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0) { // Get the start of the string. - u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); + ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); // Search all historic string that match startStr. for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--) @@ -521,8 +521,8 @@ protected: // else cut forwards else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length()) { - u32string inputString = _GroupEdit->getInputStringRef(); - u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); + ::u32string inputString = _GroupEdit->getInputStringRef(); + ::u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); inputString.erase(it); _GroupEdit->setInputStringRef (inputString); if (!_GroupEdit->getAHOnChange().empty()) @@ -660,7 +660,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit else { // it is not a filtered chat, display 'tell' (must be ingame) - _GroupEdit->setCommand(ucstring("tell ") + *lastTellPeople + (ucchar) ' ', false); + _GroupEdit->setCommand("tell " + (*lastTellPeople).toUtf8() + ' ', false); } } }; diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index 354a4c833..e046fbe2d 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -349,13 +349,13 @@ void CChatWindow::enableBlink(uint numBlinks) void CChatWindow::setCommand(const std::string &command, bool execute) { if (!_EB) return; - _EB->setCommand(ucstring(command), execute); + _EB->setCommand(command, execute); } void CChatWindow::setCommand(const ucstring &command,bool execute) { if (!_EB) return; - _EB->setCommand(command, execute); + _EB->setCommand(command.toUtf8(), execute); } diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 669ee62c2..994274571 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -3398,7 +3398,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const if (macroName.empty()) macroName = CI18N::get("uiNotAssigned"); - ucstring assignedTo = macro->Combo.toUCString(); + ucstring assignedTo = macro->Combo.toString(); if (assignedTo.empty()) assignedTo = CI18N::get("uiNotAssigned"); diff --git a/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/ryzom/client/src/interface_v3/group_modal_get_key.cpp index e3791cf8e..6f28e3b65 100644 --- a/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -89,7 +89,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) // Setup the text ! CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); - if (pVT != NULL) pVT->setText(Combo.toUCString().toUtf8()); + if (pVT != NULL) pVT->setText(Combo.toString()); // Check if in use CActionsManager *pCurAM = NULL; diff --git a/ryzom/client/src/interface_v3/group_quick_help.cpp b/ryzom/client/src/interface_v3/group_quick_help.cpp index 0b789fccf..77775489f 100644 --- a/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -244,7 +244,7 @@ void CGroupQuickHelp::beginElement(CHtmlElement &elm) CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (elm.getAttribute("z_action_shortcut").c_str(), params.c_str())); if (ite != actionCombo.end()) { - addString (ite->second.toUCString()); + addString (ite->second.toString()); } } } diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index 82b928211..aa8cd0582 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -665,7 +665,7 @@ static DECLARE_INTERFACE_USER_FCT(getKey) CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName(name.c_str(),param.c_str())); if (it != acmap.end()) { - result.setString (it->second.toUCString().toUtf8()); + result.setString (it->second.toString()); } else { diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp index d62a8746a..c04ce38cd 100644 --- a/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -208,7 +208,7 @@ void getAllComboAction(uint8 nAM, CGroupList *pList, const mapsecond.Combo.Key==KeyCount) keyName= CI18N::get("uiNotAssigned"); else - keyName= remapIT->second.Combo.toUCString(); + keyName= remapIT->second.Combo.toString(); const CBaseAction *baseAction = pAM->getBaseAction(remapIT->second.ActionName); if (baseAction) { @@ -711,7 +711,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setActive(true); // setup the text of the key - pVT->setText(it->second.toUCString().toUtf8()); + pVT->setText(it->second.toString()); // There is already a shortcut so we can display ok button pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); @@ -887,7 +887,7 @@ void CModalContainerEditCmd::validCurrentCommand() { CurrentEditCmdLine.Combo = it->second; // Yes ok let setup the text of the key - pVT->setText(it->second.toUCString().toUtf8()); + pVT->setText(it->second.toString()); // There is already a shortcut so we can display ok button CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -1353,7 +1353,7 @@ public: pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY)); - if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString().toUtf8()); + if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toString()); CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -1365,7 +1365,7 @@ public: pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo; pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY)); - if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString().toUtf8()); + if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toString()); } } }; diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 4b0d2fee9..d097ec239 100644 --- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -897,7 +897,7 @@ public: if (pMCM->CurrentEditMacro.Combo.Key == KeyCount) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); else - pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString().toUtf8()); + pVT->setText(pMCM->CurrentEditMacro.Combo.toString()); } pList->clearGroups(); @@ -1003,7 +1003,7 @@ void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd ¯o) if (pVT != NULL) { if (macro.Combo.Key != KeyCount) - pVT->setText(macro.Combo.toUCString().toUtf8()); + pVT->setText(macro.Combo.toString()); else pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); } diff --git a/ryzom/client/src/interface_v3/task_bar_manager.cpp b/ryzom/client/src/interface_v3/task_bar_manager.cpp index fcc4c30f2..35f27b07d 100644 --- a/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -180,7 +180,7 @@ public: if (pVT != NULL) { if (it != acmap.end()) - pVT->setText(it->second.toUCString().toUtf8()); + pVT->setText(it->second.toString()); else pVT->setText(CI18N::get("uiNotAssigned")); } diff --git a/ryzom/client/src/main_loop_debug.cpp b/ryzom/client/src/main_loop_debug.cpp index 70616e1f7..7c63d9502 100644 --- a/ryzom/client/src/main_loop_debug.cpp +++ b/ryzom/client/src/main_loop_debug.cpp @@ -714,7 +714,7 @@ static std::string getActionKey(const char* name, const char* param = "") CActionsManager::TActionComboMap::const_iterator ite = acmap.find(CAction::CName(name, param)); if (ite != acmap.end()) - return ite->second.toUCString().toString(); + return ite->second.toString(); return CI18N::get("uiNotAssigned"); }