From c285f59ce2a05703e3a1232fcaf3ee3aea714b3f Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sun, 18 Feb 2024 12:52:19 +0100 Subject: Replace BOOL with bool in llwindow and dependent classes --- indra/llui/lltexteditor.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/llui/lltexteditor.h') diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index f3939248c2..2b1986ff41 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -92,15 +92,15 @@ public: static S32 spacesPerTab(); // mousehandler overrides - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); - virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); - virtual BOOL handleHover(S32 x, S32 y, MASK mask); - virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask ); - virtual BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask); + virtual bool handleMouseDown(S32 x, S32 y, MASK mask); + virtual bool handleMouseUp(S32 x, S32 y, MASK mask); + virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask); + virtual bool handleHover(S32 x, S32 y, MASK mask); + virtual bool handleDoubleClick(S32 x, S32 y, MASK mask ); + virtual bool handleMiddleMouseDown(S32 x,S32 y,MASK mask); virtual BOOL handleKeyHere(KEY key, MASK mask ); - virtual BOOL handleUnicodeCharHere(llwchar uni_char); + virtual bool handleUnicodeCharHere(llwchar uni_char); virtual void onMouseCaptureLost(); @@ -259,7 +259,7 @@ protected: virtual void markAsPreedit(S32 position, S32 length); virtual void getPreeditRange(S32 *position, S32 *length) const; virtual void getSelectionRange(S32 *position, S32 *length) const; - virtual BOOL getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const; + virtual bool getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const; virtual S32 getPreeditFontSize() const; virtual LLWString getPreeditString() const { return getWText(); } // @@ -276,7 +276,7 @@ protected: LLWString mPreeditWString; LLWString mPreeditOverwrittenWString; std::vector mPreeditPositions; - std::vector mPreeditStandouts; + std::vector mPreeditStandouts; protected: LLUIColor mDefaultColor; -- cgit v1.2.3 From 5486d87b566aabb43fa585de3ee86e5bc77391c9 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 19 Feb 2024 15:44:40 +0100 Subject: Change LLPreeditor::standouts_t to std::deque since std::vector since it's a specialization that does not necessarily behave like standard STL containers --- indra/llui/lltexteditor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/lltexteditor.h') diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 2b1986ff41..26d61b9502 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -276,7 +276,7 @@ protected: LLWString mPreeditWString; LLWString mPreeditOverwrittenWString; std::vector mPreeditPositions; - std::vector mPreeditStandouts; + LLPreeditor::standouts_t mPreeditStandouts; protected: LLUIColor mDefaultColor; -- cgit v1.2.3 From a5261a5fa8fad810ecb5c260d92c3e771822bf58 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 23:46:23 +0100 Subject: Convert BOOL to bool in llui --- indra/llui/lltexteditor.h | 76 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'indra/llui/lltexteditor.h') diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 26d61b9502..b96a433d5d 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -87,7 +87,7 @@ public: void setKeystrokeCallback(const keystroke_signal_t::slot_type& callback); - void setParseHighlights(BOOL parsing) {mParseHighlights=parsing;} + void setParseHighlights(bool parsing) {mParseHighlights=parsing;} static S32 spacesPerTab(); @@ -99,7 +99,7 @@ public: virtual bool handleDoubleClick(S32 x, S32 y, MASK mask ); virtual bool handleMiddleMouseDown(S32 x,S32 y,MASK mask); - virtual BOOL handleKeyHere(KEY key, MASK mask ); + virtual bool handleKeyHere(KEY key, MASK mask ); virtual bool handleUnicodeCharHere(llwchar uni_char); virtual void onMouseCaptureLost(); @@ -109,51 +109,51 @@ public: virtual void onFocusReceived(); virtual void onFocusLost(); virtual void onCommit(); - virtual void setEnabled(BOOL enabled); + virtual void setEnabled(bool enabled); // uictrl overrides virtual void clear(); - virtual void setFocus( BOOL b ); - virtual BOOL isDirty() const; + virtual void setFocus( bool b ); + virtual bool isDirty() const; // LLEditMenuHandler interface virtual void undo(); - virtual BOOL canUndo() const; + virtual bool canUndo() const; virtual void redo(); - virtual BOOL canRedo() const; + virtual bool canRedo() const; virtual void cut(); - virtual BOOL canCut() const; + virtual bool canCut() const; virtual void copy(); - virtual BOOL canCopy() const; + virtual bool canCopy() const; virtual void paste(); - virtual BOOL canPaste() const; + virtual bool canPaste() const; virtual void updatePrimary(); virtual void copyPrimary(); virtual void pastePrimary(); - virtual BOOL canPastePrimary() const; + virtual bool canPastePrimary() const; virtual void doDelete(); - virtual BOOL canDoDelete() const; + virtual bool canDoDelete() const; virtual void selectAll(); - virtual BOOL canSelectAll() const; + virtual bool canSelectAll() const; void selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_pos); virtual bool canLoadOrSaveToFile(); - void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); - BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); - void replaceTextAll(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive); + void selectNext(const std::string& search_text_in, bool case_insensitive, bool wrap = true); + bool replaceText(const std::string& search_text, const std::string& replace_text, bool case_insensitive, bool wrap = true); + void replaceTextAll(const std::string& search_text, const std::string& replace_text, bool case_insensitive); // Undo/redo stack void blockUndo(); // Text editing virtual void makePristine(); - BOOL isPristine() const; - BOOL allowsEmbeddedItems() const { return mAllowEmbeddedItems; } + bool isPristine() const; + bool allowsEmbeddedItems() const { return mAllowEmbeddedItems; } // Autoreplace (formerly part of LLLineEditor) typedef boost::function autoreplace_callback_t; @@ -179,19 +179,19 @@ public: // Does not change highlight or cursor position. void removeTextFromEnd(S32 num_chars); - BOOL tryToRevertToPristineState(); + bool tryToRevertToPristineState(); void setCursorAndScrollToEnd(); - void getCurrentLineAndColumn( S32* line, S32* col, BOOL include_wordwrap ); + void getCurrentLineAndColumn( S32* line, S32* col, bool include_wordwrap ); // Hacky methods to make it into a word-wrapping, potentially scrolling, // read-only text box. - void setCommitOnFocusLost(BOOL b) { mCommitOnFocusLost = b; } + void setCommitOnFocusLost(bool b) { mCommitOnFocusLost = b; } // Hack to handle Notecards - virtual BOOL importBuffer(const char* buffer, S32 length ); - virtual BOOL exportBuffer(std::string& buffer ); + virtual bool importBuffer(const char* buffer, S32 length ); + virtual bool exportBuffer(std::string& buffer ); const LLUUID& getSourceID() const { return mSourceID; } @@ -202,7 +202,7 @@ public: void setShowContextMenu(bool show) { mShowContextMenu = show; } bool getShowContextMenu() const { return mShowContextMenu; } - void setPassDelete(BOOL b) { mPassDelete = b; } + void setPassDelete(bool b) { mPassDelete = b; } protected: void showContextMenu(S32 x, S32 y); @@ -216,13 +216,13 @@ protected: S32 indentLine( S32 pos, S32 spaces ); void unindentLineBeforeCloseBrace(); - virtual BOOL handleSpecialKey(const KEY key, const MASK mask); - BOOL handleNavigationKey(const KEY key, const MASK mask); - BOOL handleSelectionKey(const KEY key, const MASK mask); - BOOL handleControlKey(const KEY key, const MASK mask); + virtual bool handleSpecialKey(const KEY key, const MASK mask); + bool handleNavigationKey(const KEY key, const MASK mask); + bool handleSelectionKey(const KEY key, const MASK mask); + bool handleControlKey(const KEY key, const MASK mask); - BOOL selectionContainsLineBreaks(); - void deleteSelection(BOOL transient_operation); + bool selectionContainsLineBreaks(); + void deleteSelection(bool transient_operation); S32 prevWordPos(S32 cursorPos) const; S32 nextWordPos(S32 cursorPos) const; @@ -241,7 +241,7 @@ protected: // Undoable operations void addChar(llwchar c); // at mCursorPos S32 addChar(S32 pos, llwchar wc); - void addLineBreakChar(BOOL group_together = FALSE); + void addLineBreakChar(bool group_together = false); S32 overwriteChar(S32 pos, llwchar wc); void removeChar(); S32 removeChar(S32 pos); @@ -250,7 +250,7 @@ protected: void focusLostHelper(); void updateAllowingLanguageInput(); - BOOL hasPreeditString() const; + bool hasPreeditString() const; // Overrides LLPreeditor virtual void resetPreedit(); @@ -304,7 +304,7 @@ private: class TextCmdOverwriteChar; class TextCmdRemove; - BOOL mBaseDocIsPristine; + bool mBaseDocIsPristine; TextCmd* mPristineCmd; TextCmd* mLastCmd; @@ -312,11 +312,11 @@ private: typedef std::deque undo_stack_t; undo_stack_t mUndoStack; - BOOL mTabsToNextField; // if true, tab moves focus to next field, else inserts spaces - BOOL mCommitOnFocusLost; - BOOL mTakesFocus; + bool mTabsToNextField; // if true, tab moves focus to next field, else inserts spaces + bool mCommitOnFocusLost; + bool mTakesFocus; - BOOL mAllowEmbeddedItems; + bool mAllowEmbeddedItems; bool mShowContextMenu; bool mEnableTooltipPaste; bool mPassDelete; @@ -335,7 +335,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLTEXTEDITOR_CPP extern template class LLTextEditor* LLView::getChild( - const std::string& name, BOOL recurse) const; + const std::string& name, bool recurse) const; #endif #endif // LL_TEXTEDITOR_H -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/llui/lltexteditor.h | 702 +++++++++++++++++++++++----------------------- 1 file changed, 351 insertions(+), 351 deletions(-) (limited to 'indra/llui/lltexteditor.h') diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 2bffc813a5..be7f7cb256 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -1,351 +1,351 @@ -/** - * @file lltexteditor.h - * @brief LLTextEditor base class - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -// Text editor widget to let users enter a a multi-line ASCII document// - -#ifndef LL_LLTEXTEDITOR_H -#define LL_LLTEXTEDITOR_H - -#include "llrect.h" -#include "llframetimer.h" -#include "llstyle.h" -#include "lleditmenuhandler.h" -#include "llviewborder.h" // for params -#include "lltextbase.h" -#include "lltextvalidate.h" - -#include "llpreeditor.h" -#include "llcontrol.h" - -class LLFontGL; -class LLScrollbar; -class TextCmd; -class LLUICtrlFactory; -class LLScrollContainer; - -class LLTextEditor : - public LLTextBase, - protected LLPreeditor -{ -public: - struct Params : public LLInitParam::Block - { - Optional default_text; - Optional prevalidator; - - Optional embedded_items, - ignore_tab, - commit_on_focus_lost, - show_context_menu, - show_emoji_helper, - enable_tooltip_paste, - auto_indent; - - //colors - Optional default_color; - - Params(); - }; - - void initFromParams(const Params&); -protected: - LLTextEditor(const Params&); - friend class LLUICtrlFactory; -public: - // - // Constants - // - static const llwchar FIRST_EMBEDDED_CHAR = 0x100000; - static const llwchar LAST_EMBEDDED_CHAR = 0x10ffff; - static const S32 MAX_EMBEDDED_ITEMS = LAST_EMBEDDED_CHAR - FIRST_EMBEDDED_CHAR + 1; - - virtual ~LLTextEditor(); - - typedef boost::signals2::signal keystroke_signal_t; - - void setKeystrokeCallback(const keystroke_signal_t::slot_type& callback); - - void setParseHighlights(bool parsing) {mParseHighlights=parsing;} - - static S32 spacesPerTab(); - - void insertEmoji(llwchar emoji); - void handleEmojiCommit(llwchar emoji); - - // mousehandler overrides - virtual bool handleMouseDown(S32 x, S32 y, MASK mask); - virtual bool handleMouseUp(S32 x, S32 y, MASK mask); - virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask); - virtual bool handleHover(S32 x, S32 y, MASK mask); - virtual bool handleDoubleClick(S32 x, S32 y, MASK mask ); - virtual bool handleMiddleMouseDown(S32 x,S32 y,MASK mask); - - virtual bool handleKeyHere(KEY key, MASK mask ); - virtual bool handleUnicodeCharHere(llwchar uni_char); - - virtual void onMouseCaptureLost(); - - // view overrides - virtual void draw(); - virtual void onFocusReceived(); - virtual void onFocusLost(); - virtual void onCommit(); - virtual void setEnabled(bool enabled); - - // uictrl overrides - virtual void clear(); - virtual void setFocus( bool b ); - virtual bool isDirty() const; - - // LLEditMenuHandler interface - virtual void undo(); - virtual bool canUndo() const; - virtual void redo(); - virtual bool canRedo() const; - - virtual void cut(); - virtual bool canCut() const; - virtual void copy(); - virtual bool canCopy() const; - virtual void paste(); - virtual bool canPaste() const; - - virtual void updatePrimary(); - virtual void copyPrimary(); - virtual void pastePrimary(); - virtual bool canPastePrimary() const; - - virtual void doDelete(); - virtual bool canDoDelete() const; - virtual void selectAll(); - virtual bool canSelectAll() const; - - void selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_pos); - - virtual bool canLoadOrSaveToFile(); - - void selectNext(const std::string& search_text_in, bool case_insensitive, bool wrap = true); - bool replaceText(const std::string& search_text, const std::string& replace_text, bool case_insensitive, bool wrap = true); - void replaceTextAll(const std::string& search_text, const std::string& replace_text, bool case_insensitive); - - // Undo/redo stack - void blockUndo(); - - // Text editing - virtual void makePristine(); - bool isPristine() const; - bool allowsEmbeddedItems() const { return mAllowEmbeddedItems; } - - // Autoreplace (formerly part of LLLineEditor) - typedef boost::function autoreplace_callback_t; - autoreplace_callback_t mAutoreplaceCallback; - void setAutoreplaceCallback(autoreplace_callback_t cb) { mAutoreplaceCallback = cb; } - - /*virtual*/ void onSpellCheckPerformed(); - - // - // Text manipulation - // - - // inserts text at cursor - void insertText(const std::string &text); - void insertText(LLWString &text); - - void appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo); - // Non-undoable - void setText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params = LLStyle::Params()); - - - // Removes text from the end of document - // Does not change highlight or cursor position. - void removeTextFromEnd(S32 num_chars); - - bool tryToRevertToPristineState(); - - void setCursorAndScrollToEnd(); - - void getCurrentLineAndColumn( S32* line, S32* col, bool include_wordwrap ); - - // Hacky methods to make it into a word-wrapping, potentially scrolling, - // read-only text box. - void setCommitOnFocusLost(bool b) { mCommitOnFocusLost = b; } - - // Hack to handle Notecards - virtual bool importBuffer(const char* buffer, S32 length ); - virtual bool exportBuffer(std::string& buffer ); - - const LLUUID& getSourceID() const { return mSourceID; } - - const LLTextSegmentPtr getPreviousSegment() const; - const LLTextSegmentPtr getLastSegment() const; - void getSelectedSegments(segment_vec_t& segments) const; - - void setShowContextMenu(bool show) { mShowContextMenu = show; } - bool getShowContextMenu() const { return mShowContextMenu; } - - void showEmojiHelper(); - void setShowEmojiHelper(bool show); - bool getShowEmojiHelper() const { return mShowEmojiHelper; } - - void setPassDelete(bool b) { mPassDelete = b; } - -protected: - void showContextMenu(S32 x, S32 y); - void drawPreeditMarker(); - - void assignEmbedded(const std::string &s); - - void removeCharOrTab(); - - void indentSelectedLines( S32 spaces ); - S32 indentLine( S32 pos, S32 spaces ); - void unindentLineBeforeCloseBrace(); - - virtual bool handleSpecialKey(const KEY key, const MASK mask); - bool handleNavigationKey(const KEY key, const MASK mask); - bool handleSelectionKey(const KEY key, const MASK mask); - bool handleControlKey(const KEY key, const MASK mask); - - bool selectionContainsLineBreaks(); - void deleteSelection(bool transient_operation); - - S32 prevWordPos(S32 cursorPos) const; - S32 nextWordPos(S32 cursorPos) const; - - void autoIndent(); - - void findEmbeddedItemSegments(S32 start, S32 end); - void getSegmentsInRange(segment_vec_t& segments, S32 start, S32 end, bool include_partial) const; - - virtual llwchar pasteEmbeddedItem(llwchar ext_char) { return ext_char; } - - - // Here's the method that takes and applies text commands. - S32 execute(TextCmd* cmd); - - // Undoable operations - void addChar(llwchar c); // at mCursorPos - S32 addChar(S32 pos, llwchar wc); - void addLineBreakChar(bool group_together = false); - S32 overwriteChar(S32 pos, llwchar wc); - void removeChar(); - S32 removeChar(S32 pos); - S32 insert(S32 pos, const LLWString &wstr, bool group_with_next_op, LLTextSegmentPtr segment); - S32 remove(S32 pos, S32 length, bool group_with_next_op); - - void tryToShowEmojiHelper(); - void focusLostHelper(); - void updateAllowingLanguageInput(); - bool hasPreeditString() const; - - // Overrides LLPreeditor - virtual void resetPreedit(); - virtual void updatePreedit(const LLWString &preedit_string, - const segment_lengths_t &preedit_segment_lengths, const standouts_t &preedit_standouts, S32 caret_position); - virtual void markAsPreedit(S32 position, S32 length); - virtual void getPreeditRange(S32 *position, S32 *length) const; - virtual void getSelectionRange(S32 *position, S32 *length) const; - virtual bool getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const; - virtual S32 getPreeditFontSize() const; - virtual LLWString getPreeditString() const { return getWText(); } - // - // Protected data - // - // Probably deserves serious thought to hiding as many of these - // as possible behind protected accessor methods. - // - - // Use these to determine if a click on an embedded item is a drag or not. - S32 mMouseDownX; - S32 mMouseDownY; - - LLWString mPreeditWString; - LLWString mPreeditOverwrittenWString; - std::vector mPreeditPositions; - LLPreeditor::standouts_t mPreeditStandouts; - -protected: - LLUIColor mDefaultColor; - - bool mAutoIndent; - bool mParseOnTheFly; - - void updateLinkSegments(); - void keepSelectionOnReturn(bool keep) { mKeepSelectionOnReturn = keep; } - class LLViewBorder* mBorder; - -private: - // - // Methods - // - void pasteHelper(bool is_primary); - void cleanStringForPaste(LLWString & clean_string); - void pasteTextWithLinebreaks(LLWString & clean_string); - - void onKeyStroke(); - - // Concrete TextCmd sub-classes used by the LLTextEditor base class - class TextCmdInsert; - class TextCmdAddChar; - class TextCmdOverwriteChar; - class TextCmdRemove; - - bool mBaseDocIsPristine; - TextCmd* mPristineCmd; - - TextCmd* mLastCmd; - - typedef std::deque undo_stack_t; - undo_stack_t mUndoStack; - - bool mTabsToNextField; // if true, tab moves focus to next field, else inserts spaces - bool mCommitOnFocusLost; - bool mTakesFocus; - - bool mAllowEmbeddedItems; - bool mShowContextMenu; - bool mShowEmojiHelper; - bool mEnableTooltipPaste; - bool mPassDelete; - bool mKeepSelectionOnReturn; // disabling of removing selected text after pressing of Enter - - LLUUID mSourceID; - - LLCoordGL mLastIMEPosition; // Last position of the IME editor - - keystroke_signal_t mKeystrokeSignal; - LLTextValidate::Validator mPrevalidator; - - LLHandle mContextMenuHandle; -}; // end class LLTextEditor - -// Build time optimization, generate once in .cpp file -#ifndef LLTEXTEDITOR_CPP -extern template class LLTextEditor* LLView::getChild( - const std::string& name, bool recurse) const; -#endif - -#endif // LL_TEXTEDITOR_H +/** + * @file lltexteditor.h + * @brief LLTextEditor base class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// Text editor widget to let users enter a a multi-line ASCII document// + +#ifndef LL_LLTEXTEDITOR_H +#define LL_LLTEXTEDITOR_H + +#include "llrect.h" +#include "llframetimer.h" +#include "llstyle.h" +#include "lleditmenuhandler.h" +#include "llviewborder.h" // for params +#include "lltextbase.h" +#include "lltextvalidate.h" + +#include "llpreeditor.h" +#include "llcontrol.h" + +class LLFontGL; +class LLScrollbar; +class TextCmd; +class LLUICtrlFactory; +class LLScrollContainer; + +class LLTextEditor : + public LLTextBase, + protected LLPreeditor +{ +public: + struct Params : public LLInitParam::Block + { + Optional default_text; + Optional prevalidator; + + Optional embedded_items, + ignore_tab, + commit_on_focus_lost, + show_context_menu, + show_emoji_helper, + enable_tooltip_paste, + auto_indent; + + //colors + Optional default_color; + + Params(); + }; + + void initFromParams(const Params&); +protected: + LLTextEditor(const Params&); + friend class LLUICtrlFactory; +public: + // + // Constants + // + static const llwchar FIRST_EMBEDDED_CHAR = 0x100000; + static const llwchar LAST_EMBEDDED_CHAR = 0x10ffff; + static const S32 MAX_EMBEDDED_ITEMS = LAST_EMBEDDED_CHAR - FIRST_EMBEDDED_CHAR + 1; + + virtual ~LLTextEditor(); + + typedef boost::signals2::signal keystroke_signal_t; + + void setKeystrokeCallback(const keystroke_signal_t::slot_type& callback); + + void setParseHighlights(bool parsing) {mParseHighlights=parsing;} + + static S32 spacesPerTab(); + + void insertEmoji(llwchar emoji); + void handleEmojiCommit(llwchar emoji); + + // mousehandler overrides + virtual bool handleMouseDown(S32 x, S32 y, MASK mask); + virtual bool handleMouseUp(S32 x, S32 y, MASK mask); + virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask); + virtual bool handleHover(S32 x, S32 y, MASK mask); + virtual bool handleDoubleClick(S32 x, S32 y, MASK mask ); + virtual bool handleMiddleMouseDown(S32 x,S32 y,MASK mask); + + virtual bool handleKeyHere(KEY key, MASK mask ); + virtual bool handleUnicodeCharHere(llwchar uni_char); + + virtual void onMouseCaptureLost(); + + // view overrides + virtual void draw(); + virtual void onFocusReceived(); + virtual void onFocusLost(); + virtual void onCommit(); + virtual void setEnabled(bool enabled); + + // uictrl overrides + virtual void clear(); + virtual void setFocus( bool b ); + virtual bool isDirty() const; + + // LLEditMenuHandler interface + virtual void undo(); + virtual bool canUndo() const; + virtual void redo(); + virtual bool canRedo() const; + + virtual void cut(); + virtual bool canCut() const; + virtual void copy(); + virtual bool canCopy() const; + virtual void paste(); + virtual bool canPaste() const; + + virtual void updatePrimary(); + virtual void copyPrimary(); + virtual void pastePrimary(); + virtual bool canPastePrimary() const; + + virtual void doDelete(); + virtual bool canDoDelete() const; + virtual void selectAll(); + virtual bool canSelectAll() const; + + void selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_pos); + + virtual bool canLoadOrSaveToFile(); + + void selectNext(const std::string& search_text_in, bool case_insensitive, bool wrap = true); + bool replaceText(const std::string& search_text, const std::string& replace_text, bool case_insensitive, bool wrap = true); + void replaceTextAll(const std::string& search_text, const std::string& replace_text, bool case_insensitive); + + // Undo/redo stack + void blockUndo(); + + // Text editing + virtual void makePristine(); + bool isPristine() const; + bool allowsEmbeddedItems() const { return mAllowEmbeddedItems; } + + // Autoreplace (formerly part of LLLineEditor) + typedef boost::function autoreplace_callback_t; + autoreplace_callback_t mAutoreplaceCallback; + void setAutoreplaceCallback(autoreplace_callback_t cb) { mAutoreplaceCallback = cb; } + + /*virtual*/ void onSpellCheckPerformed(); + + // + // Text manipulation + // + + // inserts text at cursor + void insertText(const std::string &text); + void insertText(LLWString &text); + + void appendWidget(const LLInlineViewSegment::Params& params, const std::string& text, bool allow_undo); + // Non-undoable + void setText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params = LLStyle::Params()); + + + // Removes text from the end of document + // Does not change highlight or cursor position. + void removeTextFromEnd(S32 num_chars); + + bool tryToRevertToPristineState(); + + void setCursorAndScrollToEnd(); + + void getCurrentLineAndColumn( S32* line, S32* col, bool include_wordwrap ); + + // Hacky methods to make it into a word-wrapping, potentially scrolling, + // read-only text box. + void setCommitOnFocusLost(bool b) { mCommitOnFocusLost = b; } + + // Hack to handle Notecards + virtual bool importBuffer(const char* buffer, S32 length ); + virtual bool exportBuffer(std::string& buffer ); + + const LLUUID& getSourceID() const { return mSourceID; } + + const LLTextSegmentPtr getPreviousSegment() const; + const LLTextSegmentPtr getLastSegment() const; + void getSelectedSegments(segment_vec_t& segments) const; + + void setShowContextMenu(bool show) { mShowContextMenu = show; } + bool getShowContextMenu() const { return mShowContextMenu; } + + void showEmojiHelper(); + void setShowEmojiHelper(bool show); + bool getShowEmojiHelper() const { return mShowEmojiHelper; } + + void setPassDelete(bool b) { mPassDelete = b; } + +protected: + void showContextMenu(S32 x, S32 y); + void drawPreeditMarker(); + + void assignEmbedded(const std::string &s); + + void removeCharOrTab(); + + void indentSelectedLines( S32 spaces ); + S32 indentLine( S32 pos, S32 spaces ); + void unindentLineBeforeCloseBrace(); + + virtual bool handleSpecialKey(const KEY key, const MASK mask); + bool handleNavigationKey(const KEY key, const MASK mask); + bool handleSelectionKey(const KEY key, const MASK mask); + bool handleControlKey(const KEY key, const MASK mask); + + bool selectionContainsLineBreaks(); + void deleteSelection(bool transient_operation); + + S32 prevWordPos(S32 cursorPos) const; + S32 nextWordPos(S32 cursorPos) const; + + void autoIndent(); + + void findEmbeddedItemSegments(S32 start, S32 end); + void getSegmentsInRange(segment_vec_t& segments, S32 start, S32 end, bool include_partial) const; + + virtual llwchar pasteEmbeddedItem(llwchar ext_char) { return ext_char; } + + + // Here's the method that takes and applies text commands. + S32 execute(TextCmd* cmd); + + // Undoable operations + void addChar(llwchar c); // at mCursorPos + S32 addChar(S32 pos, llwchar wc); + void addLineBreakChar(bool group_together = false); + S32 overwriteChar(S32 pos, llwchar wc); + void removeChar(); + S32 removeChar(S32 pos); + S32 insert(S32 pos, const LLWString &wstr, bool group_with_next_op, LLTextSegmentPtr segment); + S32 remove(S32 pos, S32 length, bool group_with_next_op); + + void tryToShowEmojiHelper(); + void focusLostHelper(); + void updateAllowingLanguageInput(); + bool hasPreeditString() const; + + // Overrides LLPreeditor + virtual void resetPreedit(); + virtual void updatePreedit(const LLWString &preedit_string, + const segment_lengths_t &preedit_segment_lengths, const standouts_t &preedit_standouts, S32 caret_position); + virtual void markAsPreedit(S32 position, S32 length); + virtual void getPreeditRange(S32 *position, S32 *length) const; + virtual void getSelectionRange(S32 *position, S32 *length) const; + virtual bool getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const; + virtual S32 getPreeditFontSize() const; + virtual LLWString getPreeditString() const { return getWText(); } + // + // Protected data + // + // Probably deserves serious thought to hiding as many of these + // as possible behind protected accessor methods. + // + + // Use these to determine if a click on an embedded item is a drag or not. + S32 mMouseDownX; + S32 mMouseDownY; + + LLWString mPreeditWString; + LLWString mPreeditOverwrittenWString; + std::vector mPreeditPositions; + LLPreeditor::standouts_t mPreeditStandouts; + +protected: + LLUIColor mDefaultColor; + + bool mAutoIndent; + bool mParseOnTheFly; + + void updateLinkSegments(); + void keepSelectionOnReturn(bool keep) { mKeepSelectionOnReturn = keep; } + class LLViewBorder* mBorder; + +private: + // + // Methods + // + void pasteHelper(bool is_primary); + void cleanStringForPaste(LLWString & clean_string); + void pasteTextWithLinebreaks(LLWString & clean_string); + + void onKeyStroke(); + + // Concrete TextCmd sub-classes used by the LLTextEditor base class + class TextCmdInsert; + class TextCmdAddChar; + class TextCmdOverwriteChar; + class TextCmdRemove; + + bool mBaseDocIsPristine; + TextCmd* mPristineCmd; + + TextCmd* mLastCmd; + + typedef std::deque undo_stack_t; + undo_stack_t mUndoStack; + + bool mTabsToNextField; // if true, tab moves focus to next field, else inserts spaces + bool mCommitOnFocusLost; + bool mTakesFocus; + + bool mAllowEmbeddedItems; + bool mShowContextMenu; + bool mShowEmojiHelper; + bool mEnableTooltipPaste; + bool mPassDelete; + bool mKeepSelectionOnReturn; // disabling of removing selected text after pressing of Enter + + LLUUID mSourceID; + + LLCoordGL mLastIMEPosition; // Last position of the IME editor + + keystroke_signal_t mKeystrokeSignal; + LLTextValidate::Validator mPrevalidator; + + LLHandle mContextMenuHandle; +}; // end class LLTextEditor + +// Build time optimization, generate once in .cpp file +#ifndef LLTEXTEDITOR_CPP +extern template class LLTextEditor* LLView::getChild( + const std::string& name, bool recurse) const; +#endif + +#endif // LL_TEXTEDITOR_H -- cgit v1.2.3