diff options
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
-rw-r--r-- | indra/llui/lltexteditor.cpp | 350 |
1 files changed, 175 insertions, 175 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 5f5f47c45c..8373c31baa 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -71,7 +71,7 @@ static LLDefaultChildRegistry::Register<LLTextEditor> r("simple_text_editor"); // Compiler optimization, generate extern template template class LLTextEditor* LLView::getChild<class LLTextEditor>( - const std::string& name, BOOL recurse) const; + const std::string& name, bool recurse) const; // // Constants @@ -84,12 +84,12 @@ const F32 SPELLCHECK_DELAY = 0.5f; // delay between the last keypress and s class LLTextEditor::TextCmdInsert : public LLTextBase::TextCmd { public: - TextCmdInsert(S32 pos, BOOL group_with_next, const LLWString &ws, LLTextSegmentPtr segment) + TextCmdInsert(S32 pos, bool group_with_next, const LLWString &ws, LLTextSegmentPtr segment) : TextCmd(pos, group_with_next, segment), mWString(ws) { } virtual ~TextCmdInsert() {} - virtual BOOL execute( LLTextBase* editor, S32* delta ) + virtual bool execute( LLTextBase* editor, S32* delta ) { *delta = insert(editor, getPosition(), mWString ); LLWStringUtil::truncate(mWString, *delta); @@ -98,13 +98,13 @@ public: } virtual S32 undo( LLTextBase* editor ) { - remove(editor, getPosition(), mWString.length() ); + remove(editor, getPosition(), static_cast<S32>(mWString.length())); return getPosition(); } virtual S32 redo( LLTextBase* editor ) { - insert(editor, getPosition(), mWString ); - return getPosition() + mWString.length(); + insert(editor, getPosition(), mWString); + return getPosition() + static_cast<S32>(mWString.length()); } private: @@ -115,29 +115,29 @@ private: class LLTextEditor::TextCmdAddChar : public LLTextBase::TextCmd { public: - TextCmdAddChar( S32 pos, BOOL group_with_next, llwchar wc, LLTextSegmentPtr segment) - : TextCmd(pos, group_with_next, segment), mWString(1, wc), mBlockExtensions(FALSE) + TextCmdAddChar( S32 pos, bool group_with_next, llwchar wc, LLTextSegmentPtr segment) + : TextCmd(pos, group_with_next, segment), mWString(1, wc), mBlockExtensions(false) { } virtual void blockExtensions() { - mBlockExtensions = TRUE; + mBlockExtensions = true; } - virtual BOOL canExtend(S32 pos) const + virtual bool canExtend(S32 pos) const { // cannot extend text with custom segments - if (!mSegments.empty()) return FALSE; + if (!mSegments.empty()) return false; return !mBlockExtensions && (pos == getPosition() + (S32)mWString.length()); } - virtual BOOL execute( LLTextBase* editor, S32* delta ) + virtual bool execute( LLTextBase* editor, S32* delta ) { *delta = insert(editor, getPosition(), mWString); LLWStringUtil::truncate(mWString, *delta); //mWString = wstring_truncate(mWString, *delta); return (*delta != 0); } - virtual BOOL extendAndExecute( LLTextBase* editor, S32 pos, llwchar wc, S32* delta ) + virtual bool extendAndExecute( LLTextBase* editor, S32 pos, llwchar wc, S32* delta ) { LLWString ws; ws += wc; @@ -151,18 +151,18 @@ public: } virtual S32 undo( LLTextBase* editor ) { - remove(editor, getPosition(), mWString.length() ); + remove(editor, getPosition(), static_cast<S32>(mWString.length())); return getPosition(); } virtual S32 redo( LLTextBase* editor ) { - insert(editor, getPosition(), mWString ); - return getPosition() + mWString.length(); + insert(editor, getPosition(), mWString); + return getPosition() + static_cast<S32>(mWString.length()); } private: LLWString mWString; - BOOL mBlockExtensions; + bool mBlockExtensions; }; @@ -171,15 +171,15 @@ private: class LLTextEditor::TextCmdOverwriteChar : public LLTextBase::TextCmd { public: - TextCmdOverwriteChar( S32 pos, BOOL group_with_next, llwchar wc) + TextCmdOverwriteChar( S32 pos, bool group_with_next, llwchar wc) : TextCmd(pos, group_with_next), mChar(wc), mOldChar(0) {} - virtual BOOL execute( LLTextBase* editor, S32* delta ) + virtual bool execute( LLTextBase* editor, S32* delta ) { mOldChar = editor->getWText()[getPosition()]; overwrite(editor, getPosition(), mChar); *delta = 0; - return TRUE; + return true; } virtual S32 undo( LLTextBase* editor ) { @@ -202,12 +202,12 @@ private: class LLTextEditor::TextCmdRemove : public LLTextBase::TextCmd { public: - TextCmdRemove( S32 pos, BOOL group_with_next, S32 len, segment_vec_t& segments ) : + TextCmdRemove( S32 pos, bool group_with_next, S32 len, segment_vec_t& segments ) : TextCmd(pos, group_with_next), mLen(len) { std::swap(mSegments, segments); } - virtual BOOL execute( LLTextBase* editor, S32* delta ) + virtual bool execute( LLTextBase* editor, S32* delta ) { mWString = editor->getWText().substr(getPosition(), mLen); *delta = remove(editor, getPosition(), mLen ); @@ -216,7 +216,7 @@ public: virtual S32 undo( LLTextBase* editor ) { insert(editor, getPosition(), mWString); - return getPosition() + mWString.length(); + return getPosition() + static_cast<S32>(mWString.length()); } virtual S32 redo( LLTextBase* editor ) { @@ -249,7 +249,7 @@ LLTextEditor::Params::Params() LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : LLTextBase(p), mAutoreplaceCallback(), - mBaseDocIsPristine(TRUE), + mBaseDocIsPristine(true), mPristineCmd( NULL ), mLastCmd( NULL ), mDefaultColor( p.default_color() ), @@ -343,7 +343,7 @@ void LLTextEditor::setText(const LLStringExplicit &utf8str, const LLStyle::Param resetDirty(); } -void LLTextEditor::selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap) +void LLTextEditor::selectNext(const std::string& search_text_in, bool case_insensitive, bool wrap) { if (search_text_in.empty()) { @@ -365,22 +365,22 @@ void LLTextEditor::selectNext(const std::string& search_text_in, BOOL case_insen if (selected_text == search_text) { // We already have this word selected, we are searching for the next. - setCursorPos(mCursorPos + search_text.size()); + setCursorPos(mCursorPos + static_cast<S32>(search_text.size())); } } - S32 loc = text.find(search_text,mCursorPos); + S32 loc = static_cast<S32>(text.find(search_text,mCursorPos)); // If Maybe we wrapped, search again if (wrap && (-1 == loc)) { - loc = text.find(search_text); + loc = static_cast<S32>(text.find(search_text)); } // If still -1, then search_text just isn't found. if (-1 == loc) { - mIsSelecting = FALSE; + mIsSelecting = false; mSelectionEnd = 0; mSelectionStart = 0; return; @@ -388,15 +388,15 @@ void LLTextEditor::selectNext(const std::string& search_text_in, BOOL case_insen setCursorPos(loc); - mIsSelecting = TRUE; + mIsSelecting = true; mSelectionEnd = mCursorPos; mSelectionStart = llmin((S32)getLength(), (S32)(mCursorPos + search_text.size())); } -BOOL LLTextEditor::replaceText(const std::string& search_text_in, const std::string& replace_text, - BOOL case_insensitive, BOOL wrap) +bool LLTextEditor::replaceText(const std::string& search_text_in, const std::string& replace_text, + bool case_insensitive, bool wrap) { - BOOL replaced = FALSE; + bool replaced = false; if (search_text_in.empty()) { @@ -418,7 +418,7 @@ BOOL LLTextEditor::replaceText(const std::string& search_text_in, const std::str if (selected_text == search_text) { insertText(replace_text); - replaced = TRUE; + replaced = true; } } @@ -426,15 +426,15 @@ BOOL LLTextEditor::replaceText(const std::string& search_text_in, const std::str return replaced; } -void LLTextEditor::replaceTextAll(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive) +void LLTextEditor::replaceTextAll(const std::string& search_text, const std::string& replace_text, bool case_insensitive) { startOfDoc(); - selectNext(search_text, case_insensitive, FALSE); + selectNext(search_text, case_insensitive, false); - BOOL replaced = TRUE; + bool replaced = true; while ( replaced ) { - replaced = replaceText(search_text,replace_text, case_insensitive, FALSE); + replaced = replaceText(search_text,replace_text, case_insensitive, false); } } @@ -522,7 +522,7 @@ void LLTextEditor::setShowEmojiHelper(bool show) mShowEmojiHelper = show; } -BOOL LLTextEditor::selectionContainsLineBreaks() +bool LLTextEditor::selectionContainsLineBreaks() { if (hasSelection()) { @@ -534,11 +534,11 @@ BOOL LLTextEditor::selectionContainsLineBreaks() { if (wtext[i] == '\n') { - return TRUE; + return true; } } } - return FALSE; + return false; } @@ -569,7 +569,7 @@ S32 LLTextEditor::indentLine( S32 pos, S32 spaces ) LLWString wtext = getWText(); if (wtext[pos] == ' ') { - delta_spaces += remove( pos, 1, FALSE ); + delta_spaces += remove( pos, 1, false ); } } } @@ -584,7 +584,7 @@ void LLTextEditor::indentSelectedLines( S32 spaces ) LLWString text = getWText(); S32 left = llmin( mSelectionStart, mSelectionEnd ); S32 right = left + llabs( mSelectionStart - mSelectionEnd ); - BOOL cursor_on_right = (mSelectionEnd > mSelectionStart); + bool cursor_on_right = (mSelectionEnd > mSelectionStart); S32 cur = left; // Expand left to start of line @@ -663,9 +663,9 @@ void LLTextEditor::indentSelectedLines( S32 spaces ) } //virtual -BOOL LLTextEditor::canSelectAll() const +bool LLTextEditor::canSelectAll() const { - return TRUE; + return true; } // virtual @@ -707,15 +707,15 @@ void LLTextEditor::handleEmojiCommit(llwchar emoji) } } -BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) +bool LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) { - BOOL handled = FALSE; + bool handled = false; // set focus first, in case click callbacks want to change it // RN: do we really need to have a tab stop? if (hasTabStop()) { - setFocus( TRUE ); + setFocus( true ); } // Let scrollbar have first dibs @@ -728,7 +728,7 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) deselect(); } - BOOL start_select = TRUE; + bool start_select = true; if( start_select ) { // If we're not scrolling (handled by child), then we're selecting @@ -747,7 +747,7 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) mSelectionEnd = mCursorPos; } // assume we're starting a drag select - mIsSelecting = TRUE; + mIsSelecting = true; } else { @@ -756,7 +756,7 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) } } - handled = TRUE; + handled = true; } // Delay cursor flashing @@ -769,11 +769,11 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) return handled; } -BOOL LLTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) +bool LLTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) { if (hasTabStop()) { - setFocus(TRUE); + setFocus(true); } bool show_menu = false; @@ -781,7 +781,7 @@ BOOL LLTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) // Prefer editor menu if it has selection. See EXT-6806. if (hasSelection()) { - S32 click_pos = getDocIndexFromLocalCoord(x, y, FALSE); + S32 click_pos = getDocIndexFromLocalCoord(x, y, false); if (click_pos > mSelectionStart && click_pos < mSelectionEnd) { show_menu = true; @@ -799,16 +799,16 @@ BOOL LLTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) showContextMenu(x, y); } - return TRUE; + return true; } -BOOL LLTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) +bool LLTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) { if (hasTabStop()) { - setFocus(TRUE); + setFocus(true); } if (!LLTextBase::handleMouseDown(x, y, mask)) @@ -820,13 +820,13 @@ BOOL LLTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) pastePrimary(); } } - return TRUE; + return true; } -BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) +bool LLTextEditor::handleHover(S32 x, S32 y, MASK mask) { - BOOL handled = FALSE; + bool handled = false; if(hasMouseCapture() ) { @@ -843,7 +843,7 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) } LL_DEBUGS("UserInput") << "hover handled by " << getName() << " (active)" << LL_ENDL; getWindow()->setCursor(UI_CURSOR_IBEAM); - handled = TRUE; + handled = true; } if( !handled ) @@ -861,16 +861,16 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) if( !handled ) { getWindow()->setCursor(UI_CURSOR_IBEAM); - handled = TRUE; + handled = true; } return handled; } -BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) +bool LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) { - BOOL handled = FALSE; + bool handled = false; // if I'm not currently selecting text if (!(mIsSelecting && hasMouseCapture())) @@ -896,7 +896,7 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) // take selection to 'primary' clipboard updatePrimary(); - handled = TRUE; + handled = true; } // Delay cursor flashing @@ -906,16 +906,16 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) { gFocusMgr.setMouseCapture( NULL ); - handled = TRUE; + handled = true; } return handled; } -BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) +bool LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) { - BOOL handled = FALSE; + bool handled = false; // let scrollbar and text segments have first dibs handled = LLTextBase::handleDoubleClick(x, y, mask); @@ -953,7 +953,7 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) // We don't want handleMouseUp() to "finish" the selection (and thereby // set mSelectionEnd to where the mouse is), so we finish the selection here. - mIsSelecting = FALSE; + mIsSelecting = false; // delay cursor flashing resetCursorBlink(); @@ -961,7 +961,7 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) // take selection to 'primary' clipboard updatePrimary(); - handled = TRUE; + handled = true; } return handled; @@ -1024,7 +1024,7 @@ S32 LLTextEditor::insert(S32 pos, const LLWString &wstr, bool group_with_next_op S32 LLTextEditor::remove(S32 pos, S32 length, bool group_with_next_op) { S32 end_pos = getEditableIndex(pos + length, true); - BOOL removedChar = FALSE; + bool removedChar = false; segment_vec_t segments_to_remove; // store text segments @@ -1046,7 +1046,7 @@ S32 LLTextEditor::overwriteChar(S32 pos, llwchar wc) } else { - return execute(new TextCmdOverwriteChar(pos, FALSE, wc)); + return execute(new TextCmdOverwriteChar(pos, false, wc)); } } @@ -1161,8 +1161,8 @@ S32 LLTextEditor::addChar(S32 pos, llwchar wc) return delta; } - return execute(new TextCmdAddChar(pos, FALSE, wc, LLTextSegmentPtr())); - } + return execute(new TextCmdAddChar(pos, false, wc, LLTextSegmentPtr())); +} void LLTextEditor::addChar(llwchar wc) { @@ -1173,7 +1173,7 @@ void LLTextEditor::addChar(llwchar wc) if( hasSelection() ) { - deleteSelection(TRUE); + deleteSelection(true); } else if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode()) { @@ -1232,7 +1232,7 @@ void LLTextEditor::tryToShowEmojiHelper() } } -void LLTextEditor::addLineBreakChar(BOOL group_together) +void LLTextEditor::addLineBreakChar(bool group_together) { if( !getEnabled() ) { @@ -1240,7 +1240,7 @@ void LLTextEditor::addLineBreakChar(BOOL group_together) } if( hasSelection() ) { - deleteSelection(TRUE); + deleteSelection(true); } else if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode()) { @@ -1256,13 +1256,13 @@ void LLTextEditor::addLineBreakChar(BOOL group_together) } -BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask) +bool LLTextEditor::handleSelectionKey(const KEY key, const MASK mask) { - BOOL handled = FALSE; + bool handled = false; if( mask & MASK_SHIFT ) { - handled = TRUE; + handled = true; switch( key ) { @@ -1343,7 +1343,7 @@ BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask) break; default: - handled = FALSE; + handled = false; break; } } @@ -1357,14 +1357,14 @@ BOOL LLTextEditor::handleSelectionKey(const KEY key, const MASK mask) return handled; } -BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) +bool LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) { - BOOL handled = FALSE; + bool handled = false; // Ignore capslock key if( MASK_NONE == mask ) { - handled = TRUE; + handled = true; switch( key ) { case KEY_UP: @@ -1429,7 +1429,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) break; default: - handled = FALSE; + handled = false; break; } } @@ -1442,7 +1442,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask) return handled; } -void LLTextEditor::deleteSelection(BOOL group_with_next_op ) +void LLTextEditor::deleteSelection(bool group_with_next_op ) { if( getEnabled() && hasSelection() ) { @@ -1457,7 +1457,7 @@ void LLTextEditor::deleteSelection(BOOL group_with_next_op ) } // virtual -BOOL LLTextEditor::canCut() const +bool LLTextEditor::canCut() const { return !mReadOnly && hasSelection(); } @@ -1472,12 +1472,12 @@ void LLTextEditor::cut() S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); S32 length = llabs( mSelectionStart - mSelectionEnd ); LLClipboard::instance().copyToClipboard( getWText(), left_pos, length); - deleteSelection( FALSE ); + deleteSelection( false ); onKeyStroke(); } -BOOL LLTextEditor::canCopy() const +bool LLTextEditor::canCopy() const { return hasSelection(); } @@ -1494,7 +1494,7 @@ void LLTextEditor::copy() LLClipboard::instance().copyToClipboard(getWText(), left_pos, length); } -BOOL LLTextEditor::canPaste() const +bool LLTextEditor::canPaste() const { return !mReadOnly && LLClipboard::instance().isTextAvailable(); } @@ -1549,7 +1549,7 @@ void LLTextEditor::pasteHelper(bool is_primary) // Delete any selected characters (the paste replaces them) if( (!is_primary) && hasSelection() ) { - deleteSelection(TRUE); + deleteSelection(true); } // Clean up string (replace tabs and remove characters that our fonts don't support). @@ -1578,8 +1578,8 @@ void LLTextEditor::cleanStringForPaste(LLWString & clean_string) if( mAllowEmbeddedItems ) { const llwchar LF = 10; - S32 len = clean_string.length(); - for( S32 i = 0; i < len; i++ ) + auto len = clean_string.length(); + for( size_t i = 0; i < len; i++ ) { llwchar wc = clean_string[i]; if( (wc < LLFontFreetype::FIRST_CHAR) && (wc != LF) ) @@ -1606,9 +1606,9 @@ void LLTextEditor::pasteTextWithLinebreaks<LLWString>(const LLWString & clean_st if(pos!=start) { std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,pos-start); - setCursorPos(mCursorPos + insert(mCursorPos, str, TRUE, LLTextSegmentPtr())); + setCursorPos(mCursorPos + insert(mCursorPos, str, true, LLTextSegmentPtr())); } - addLineBreakChar(TRUE); // Add a line break and group with the next addition. + addLineBreakChar(true); // Add a line break and group with the next addition. start = pos+1; pos = clean_string.find('\n',start); @@ -1617,11 +1617,11 @@ void LLTextEditor::pasteTextWithLinebreaks<LLWString>(const LLWString & clean_st if (pos != start) { std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start); - setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr())); + setCursorPos(mCursorPos + insert(mCursorPos, str, false, LLTextSegmentPtr())); } else { - addLineBreakChar(FALSE); // Add a line break and end the grouping. + addLineBreakChar(false); // Add a line break and end the grouping. } } @@ -1637,7 +1637,7 @@ void LLTextEditor::copyPrimary() LLClipboard::instance().copyToClipboard(getWText(), left_pos, length, true); } -BOOL LLTextEditor::canPastePrimary() const +bool LLTextEditor::canPastePrimary() const { return !mReadOnly && LLClipboard::instance().isTextAvailable(true); } @@ -1650,13 +1650,13 @@ void LLTextEditor::updatePrimary() } } -BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) +bool LLTextEditor::handleControlKey(const KEY key, const MASK mask) { - BOOL handled = FALSE; + bool handled = false; if( mask & MASK_CONTROL ) { - handled = TRUE; + handled = true; switch( key ) { @@ -1720,7 +1720,7 @@ BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) break; default: - handled = FALSE; + handled = false; break; } } @@ -1734,11 +1734,11 @@ BOOL LLTextEditor::handleControlKey(const KEY key, const MASK mask) } -BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) +bool LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) { - BOOL handled = TRUE; + bool handled = true; - if (mReadOnly) return FALSE; + if (mReadOnly) return false; switch( key ) { @@ -1752,7 +1752,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) case KEY_BACKSPACE: if( hasSelection() ) { - deleteSelection(FALSE); + deleteSelection(false); } else if( 0 < mCursorPos ) @@ -1771,7 +1771,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) { if( hasSelection() && !mKeepSelectionOnReturn ) { - deleteSelection(FALSE); + deleteSelection(false); } if (mAutoIndent) { @@ -1780,7 +1780,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) } else { - handled = FALSE; + handled = false; break; } break; @@ -1788,7 +1788,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) case KEY_TAB: if (mask & MASK_CONTROL) { - handled = FALSE; + handled = false; break; } if( hasSelection() && selectionContainsLineBreaks() ) @@ -1799,7 +1799,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) { if( hasSelection() ) { - deleteSelection(FALSE); + deleteSelection(false); } S32 offset = getLineOffsetFromDocIndex(mCursorPos); @@ -1813,7 +1813,7 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask) break; default: - handled = FALSE; + handled = false; break; } @@ -1851,15 +1851,15 @@ void LLTextEditor::unindentLineBeforeCloseBrace() } -BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) +bool LLTextEditor::handleKeyHere(KEY key, MASK mask ) { - BOOL handled = FALSE; + bool handled = false; // Special case for TAB. If want to move to next field, report // not handled and let the parent take care of field movement. if (KEY_TAB == key && mTabsToNextField) { - return FALSE; + return false; } if (mReadOnly && mScroller) @@ -1872,7 +1872,7 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) { if (!mReadOnly && mShowEmojiHelper && LLEmojiHelper::instance().handleKey(this, key, mask)) { - return TRUE; + return true; } if (mEnableTooltipPaste && @@ -1889,7 +1889,7 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) // Delete any selected characters (the tooltip text replaces them) if(hasSelection()) { - deleteSelection(TRUE); + deleteSelection(true); } std::basic_string<llwchar>::size_type pos = tool_tip_text.find('\n',0); @@ -1901,7 +1901,7 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) // Add the text cleanStringForPaste(tool_tip_text); pasteTextWithLinebreaks(tool_tip_text); - handled = TRUE; + handled = true; } } else @@ -1929,21 +1929,21 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) } -BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char) +bool LLTextEditor::handleUnicodeCharHere(llwchar uni_char) { if ((uni_char < 0x20) || (uni_char == 0x7F)) // Control character or DEL { - return FALSE; + return false; } - BOOL handled = FALSE; + bool handled = false; // Handle most keys only if the text editor is writeable. if( !mReadOnly ) { if (mShowEmojiHelper && uni_char < 0x80 && LLEmojiHelper::instance().handleKey(this, (KEY)uni_char, MASK_NONE)) { - return TRUE; + return true; } if( mAutoIndent && '}' == uni_char ) @@ -1957,7 +1957,7 @@ BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char) // Keys that add characters temporarily hide the cursor getWindow()->hideCursorUntilMouseMove(); - handled = TRUE; + handled = true; } if( handled ) @@ -1975,7 +1975,7 @@ BOOL LLTextEditor::handleUnicodeCharHere(llwchar uni_char) // virtual -BOOL LLTextEditor::canDoDelete() const +bool LLTextEditor::canDoDelete() const { return !mReadOnly && ( !mPassDelete || ( hasSelection() || (mCursorPos < getLength())) ); } @@ -1988,7 +1988,7 @@ void LLTextEditor::doDelete() } if( hasSelection() ) { - deleteSelection(FALSE); + deleteSelection(false); } else if( mCursorPos < getLength() ) @@ -2032,14 +2032,14 @@ void LLTextEditor::doDelete() void LLTextEditor::blockUndo() { - mBaseDocIsPristine = FALSE; + mBaseDocIsPristine = false; mLastCmd = NULL; std::for_each(mUndoStack.begin(), mUndoStack.end(), DeletePointer()); mUndoStack.clear(); } // virtual -BOOL LLTextEditor::canUndo() const +bool LLTextEditor::canUndo() const { return !mReadOnly && mLastCmd != NULL; } @@ -2070,7 +2070,7 @@ void LLTextEditor::undo() onKeyStroke(); } -BOOL LLTextEditor::canRedo() const +bool LLTextEditor::canRedo() const { return !mReadOnly && (mUndoStack.size() > 0) && (mLastCmd != mUndoStack.front()); } @@ -2149,7 +2149,7 @@ void LLTextEditor::onCommit() LLTextBase::onCommit(); } -void LLTextEditor::setEnabled(BOOL enabled) +void LLTextEditor::setEnabled(bool enabled) { // just treat enabled as read-only flag bool read_only = !enabled; @@ -2182,7 +2182,7 @@ void LLTextEditor::showContextMenu(S32 x, S32 y) // Route menu to this class // previously this was done in ::handleRightMoseDown: //if(hasTabStop()) - // setFocus(TRUE) - why? weird... + // setFocus(true) - why? weird... // and then inside setFocus // .... // gEditMenuHandler = this; @@ -2216,7 +2216,7 @@ void LLTextEditor::showContextMenu(S32 x, S32 y) // If the cursor is on a misspelled word, retrieve suggestions for it std::string misspelled_word = getMisspelledWord(mCursorPos); - if ((is_misspelled = !misspelled_word.empty()) == true) + if ((is_misspelled = !misspelled_word.empty())) { LLSpellChecker::instance().getSuggestions(misspelled_word, mSuggestionList); } @@ -2360,9 +2360,9 @@ void LLTextEditor::draw() // Start or stop the editor from accepting text-editing keystrokes // see also LLLineEditor -void LLTextEditor::setFocus( BOOL new_state ) +void LLTextEditor::setFocus( bool new_state ) { - BOOL old_state = hasFocus(); + bool old_state = hasFocus(); // Don't change anything if the focus state didn't change if (new_state == old_state) return; @@ -2370,7 +2370,7 @@ void LLTextEditor::setFocus( BOOL new_state ) // Notify early if we are losing focus. if (!new_state) { - getWindow()->allowLanguageTextInput(this, FALSE); + getWindow()->allowLanguageTextInput(this, false); } LLTextBase::setFocus( new_state ); @@ -2402,7 +2402,7 @@ void LLTextEditor::setCursorAndScrollToEnd() endOfDoc(); } -void LLTextEditor::getCurrentLineAndColumn( S32* line, S32* col, BOOL include_wordwrap ) +void LLTextEditor::getCurrentLineAndColumn( S32* line, S32* col, bool include_wordwrap ) { *line = getLineNumFromDocIndex(mCursorPos, include_wordwrap); *col = getLineOffsetFromDocIndex(mCursorPos, include_wordwrap); @@ -2444,32 +2444,32 @@ void LLTextEditor::autoIndent() // Inserts new text at the cursor position void LLTextEditor::insertText(const std::string &new_text) { - BOOL enabled = getEnabled(); - setEnabled( TRUE ); + bool enabled = getEnabled(); + setEnabled( true ); // Delete any selected characters (the insertion replaces them) if( hasSelection() ) { - deleteSelection(TRUE); + deleteSelection(true); } - setCursorPos(mCursorPos + insert( mCursorPos, utf8str_to_wstring(new_text), FALSE, LLTextSegmentPtr() )); + setCursorPos(mCursorPos + insert( mCursorPos, utf8str_to_wstring(new_text), false, LLTextSegmentPtr() )); setEnabled( enabled ); } void LLTextEditor::insertText(LLWString &new_text) { - BOOL enabled = getEnabled(); - setEnabled( TRUE ); + bool enabled = getEnabled(); + setEnabled( true ); // Delete any selected characters (the insertion replaces them) if( hasSelection() ) { - deleteSelection(TRUE); + deleteSelection(true); } - setCursorPos(mCursorPos + insert( mCursorPos, new_text, FALSE, LLTextSegmentPtr() )); + setCursorPos(mCursorPos + insert( mCursorPos, new_text, false, LLTextSegmentPtr() )); setEnabled( enabled ); } @@ -2479,10 +2479,10 @@ void LLTextEditor::appendWidget(const LLInlineViewSegment::Params& params, const // Save old state S32 selection_start = mSelectionStart; S32 selection_end = mSelectionEnd; - BOOL was_selecting = mIsSelecting; + bool was_selecting = mIsSelecting; S32 cursor_pos = mCursorPos; S32 old_length = getLength(); - BOOL cursor_was_at_end = (mCursorPos == old_length); + bool cursor_was_at_end = (mCursorPos == old_length); deselect(); @@ -2490,8 +2490,8 @@ void LLTextEditor::appendWidget(const LLInlineViewSegment::Params& params, const LLWString widget_wide_text = utf8str_to_wstring(text); - LLTextSegmentPtr segment = new LLInlineViewSegment(params, old_length, old_length + widget_wide_text.size()); - insert(getLength(), widget_wide_text, FALSE, segment); + LLTextSegmentPtr segment = new LLInlineViewSegment(params, old_length, old_length + static_cast<S32>(widget_wide_text.size())); + insert(getLength(), widget_wide_text, false, segment); // Set the cursor and scroll position if( selection_start != selection_end ) @@ -2521,7 +2521,7 @@ void LLTextEditor::removeTextFromEnd(S32 num_chars) { if (num_chars <= 0) return; - remove(getLength() - num_chars, num_chars, FALSE); + remove(getLength() - num_chars, num_chars, false); S32 len = getLength(); setCursorPos (llclamp(mCursorPos, 0, len)); @@ -2537,7 +2537,7 @@ void LLTextEditor::onSpellCheckPerformed() { if (isPristine()) { - mBaseDocIsPristine = FALSE; + mBaseDocIsPristine = false; } } @@ -2554,7 +2554,7 @@ void LLTextEditor::makePristine() } } -BOOL LLTextEditor::isPristine() const +bool LLTextEditor::isPristine() const { if( mPristineCmd ) { @@ -2567,7 +2567,7 @@ BOOL LLTextEditor::isPristine() const } } -BOOL LLTextEditor::tryToRevertToPristineState() +bool LLTextEditor::tryToRevertToPristineState() { if( !isPristine() ) { @@ -2596,7 +2596,7 @@ BOOL LLTextEditor::tryToRevertToPristineState() } } - return isPristine(); // TRUE => success + return isPristine(); // true => success } void LLTextEditor::updateLinkSegments() @@ -2655,7 +2655,7 @@ void LLTextEditor::onMouseCaptureLost() /////////////////////////////////////////////////////////////////// // Hack for Notecards -BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) +bool LLTextEditor::importBuffer(const char* buffer, S32 length ) { std::istringstream instream(buffer); @@ -2674,20 +2674,20 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) if( 1 != sscanf(tbuf, "Linden text version %d", &version) ) { LL_WARNS() << "Invalid Linden text file header " << LL_ENDL; - return FALSE; + return false; } if( 1 != version ) { LL_WARNS() << "Invalid Linden text file version: " << version << LL_ENDL; - return FALSE; + return false; } instream.getline(tbuf, MAX_STRING); if( 0 != sscanf(tbuf, "{") ) { LL_WARNS() << "Invalid Linden text file format" << LL_ENDL; - return FALSE; + return false; } S32 text_len = 0; @@ -2695,37 +2695,37 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) if( 1 != sscanf(tbuf, "Text length %d", &text_len) ) { LL_WARNS() << "Invalid Linden text length field" << LL_ENDL; - return FALSE; + return false; } if( text_len > mMaxTextByteLength ) { LL_WARNS() << "Invalid Linden text length: " << text_len << LL_ENDL; - return FALSE; + return false; } - BOOL success = TRUE; + bool success = true; char* text = new char[ text_len + 1]; if (text == NULL) { LLError::LLUserWarningMsg::showOutOfMemory(); LL_ERRS() << "Memory allocation failure." << LL_ENDL; - return FALSE; + return false; } instream.get(text, text_len + 1, '\0'); text[text_len] = '\0'; if( text_len != (S32)strlen(text) )/* Flawfinder: ignore */ { LL_WARNS() << llformat("Invalid text length: %d != %d ",strlen(text),text_len) << LL_ENDL;/* Flawfinder: ignore */ - success = FALSE; + success = false; } instream.getline(tbuf, MAX_STRING); if( success && (0 != sscanf(tbuf, "}")) ) { LL_WARNS() << "Invalid Linden text file format: missing terminal }" << LL_ENDL; - success = FALSE; + success = false; } if( success ) @@ -2742,7 +2742,7 @@ BOOL LLTextEditor::importBuffer(const char* buffer, S32 length ) return success; } -BOOL LLTextEditor::exportBuffer(std::string &buffer ) +bool LLTextEditor::exportBuffer(std::string &buffer ) { std::ostringstream outstream(buffer); @@ -2753,7 +2753,7 @@ BOOL LLTextEditor::exportBuffer(std::string &buffer ) outstream << getText(); outstream << "}\n"; - return TRUE; + return true; } void LLTextEditor::updateAllowingLanguageInput() @@ -2766,17 +2766,17 @@ void LLTextEditor::updateAllowingLanguageInput() } if (hasFocus() && !mReadOnly) { - window->allowLanguageTextInput(this, TRUE); + window->allowLanguageTextInput(this, true); } else { - window->allowLanguageTextInput(this, FALSE); + window->allowLanguageTextInput(this, false); } } // Preedit is managed off the undo/redo command stack. -BOOL LLTextEditor::hasPreeditString() const +bool LLTextEditor::hasPreeditString() const { return (mPreeditPositions.size() > 1); } @@ -2792,7 +2792,7 @@ void LLTextEditor::resetPreedit() } else { - deleteSelection(TRUE); + deleteSelection(true); } } if (hasPreeditString()) @@ -2844,7 +2844,7 @@ void LLTextEditor::updatePreedit(const LLWString &preedit_string, if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode()) { mPreeditOverwrittenWString = getWText().substr(insert_preedit_at, mPreeditWString.length()); - removeStringNoUndo(insert_preedit_at, mPreeditWString.length()); + removeStringNoUndo(insert_preedit_at, static_cast<S32>(mPreeditWString.length())); } else { @@ -2865,7 +2865,7 @@ void LLTextEditor::updatePreedit(const LLWString &preedit_string, onKeyStroke(); } -BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const +bool LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const { if (control) { @@ -2888,13 +2888,13 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect const S32 query = (query_offset >= 0 ? preedit_left_position + query_offset : mCursorPos); if (query < preedit_left_position || query > preedit_right_position) { - return FALSE; + return false; } const S32 first_visible_line = getFirstVisibleLine(); if (query < getLineStart(first_visible_line)) { - return FALSE; + return false; } S32 current_line = first_visible_line; @@ -2955,7 +2955,7 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect LLUI::getInstance()->screenRectToGL(preedit_rect_screen, bounds); } - return TRUE; + return true; } void LLTextEditor::getSelectionRange(S32 *position, S32 *length) const @@ -3001,7 +3001,7 @@ void LLTextEditor::markAsPreedit(S32 position, S32 length) mPreeditPositions[0] = position; mPreeditPositions[1] = position + length; mPreeditStandouts.resize(1); - mPreeditStandouts[0] = FALSE; + mPreeditStandouts[0] = false; } else { @@ -3023,11 +3023,11 @@ S32 LLTextEditor::getPreeditFontSize() const return ll_round((F32)mFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]); } -BOOL LLTextEditor::isDirty() const +bool LLTextEditor::isDirty() const { if(mReadOnly) { - return FALSE; + return false; } if( mPristineCmd ) |