1 // Scintilla source code edit control 2 /** @file ScintillaBase.h 3 ** Defines an enhanced subclass of Editor with calltips, autocomplete and context menu. 4 **/ 5 // Copyright 1998-2002 by Neil Hodgson <[email protected]> 6 // The License.txt file describes the conditions under which this software may be distributed. 7 8 #ifndef SCINTILLABASE_H 9 #define SCINTILLABASE_H 10 11 namespace Scintilla { 12 13 class LexState; 14 /** 15 */ 16 class ScintillaBase : public Editor, IListBoxDelegate { 17 protected: 18 /** Enumeration of commands and child windows. */ 19 enum { 20 idCallTip=1, 21 idAutoComplete=2, 22 23 idcmdUndo=10, 24 idcmdRedo=11, 25 idcmdCut=12, 26 idcmdCopy=13, 27 idcmdPaste=14, 28 idcmdDelete=15, 29 idcmdSelectAll=16 30 }; 31 32 int displayPopupMenu; 33 std::map<std::wstring, std::wstring>* menuStringTable = nullptr; 34 Menu popup; 35 AutoComplete ac; 36 37 CallTip ct; 38 39 int listType; ///< 0 is an autocomplete list 40 int maxListWidth; /// Maximum width of list, in average character widths 41 int multiAutoCMode; /// Mode for autocompleting when multiple selections are present 42 43 LexState *DocumentLexState(); 44 void SetLexer(uptr_t wParam); 45 void SetLexerLanguage(const char *languageName); 46 void Colourise(int start, int end); 47 48 ScintillaBase(); 49 // Deleted so ScintillaBase objects can not be copied. 50 ScintillaBase(const ScintillaBase &) = delete; 51 ScintillaBase(ScintillaBase &&) = delete; 52 ScintillaBase &operator=(const ScintillaBase &) = delete; 53 ScintillaBase &operator=(ScintillaBase &&) = delete; 54 // ~ScintillaBase() in public section Initialise()55 void Initialise() override {} 56 void Finalise() override; 57 58 [[deprecated]] 59 // This method is deprecated, use InsertCharacter instead. The treatAsDBCS parameter is no longer used. 60 virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false); 61 62 void InsertCharacter(std::string_view sv, CharacterSource charSource) override; 63 void Command(int cmdId); 64 void CancelModes() override; 65 int KeyCommand(unsigned int iMessage) override; 66 67 void AutoCompleteInsert(Sci::Position startPos, Sci::Position removeLen, const char *text, Sci::Position textLen); 68 void AutoCompleteStart(Sci::Position lenEntered, const char *list); 69 void AutoCompleteCancel(); 70 void AutoCompleteMove(int delta); 71 int AutoCompleteGetCurrent() const; 72 int AutoCompleteGetCurrentText(char *buffer) const; 73 void AutoCompleteCharacterAdded(char ch); 74 void AutoCompleteCharacterDeleted(); 75 void AutoCompleteCompleted(char ch, unsigned int completionMethod); 76 void AutoCompleteMoveToCurrentWord(); 77 void AutoCompleteSelection(); 78 void ListNotify(ListBoxEvent *plbe) override; 79 80 void CallTipClick(); 81 void CallTipShow(Point pt, const char *defn); 82 virtual void CreateCallTipWindow(PRectangle rc) = 0; 83 84 virtual void AddToPopUp(const wchar_t *label, int cmd=0, bool enabled=true) = 0; 85 bool ShouldDisplayPopup(Point ptInWindowCoordinates) const; 86 void ContextMenu(Point pt); 87 88 void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override; 89 void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override; 90 91 void NotifyStyleToNeeded(Sci::Position endStyleNeeded) override; 92 void NotifyLexerChanged(Document *doc, void *userData) override; 93 94 public: 95 ~ScintillaBase() override; 96 97 // Public so scintilla_send_message can use it 98 sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; 99 }; 100 101 } 102 103 #endif 104