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 <neilh@scintilla.org>
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
11namespace Scintilla::Internal {
12
13class LexState;
14/**
15 */
16class ScintillaBase : public Editor, IListBoxDelegate {
17protected:
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 Scintilla::PopUp displayPopupMenu;
33 Menu popup;
34 Scintilla::Internal::AutoComplete ac;
35
36 CallTip ct;
37
38 int listType; ///< 0 is an autocomplete list
39 int maxListWidth; /// Maximum width of list, in average character widths
40 Scintilla::MultiAutoComplete multiAutoCMode; /// Mode for autocompleting when multiple selections are present
41
42 LexState *DocumentLexState();
43 void Colourise(int start, int end);
44
45 ScintillaBase();
46 // Deleted so ScintillaBase objects can not be copied.
47 ScintillaBase(const ScintillaBase &) = delete;
48 ScintillaBase(ScintillaBase &&) = delete;
49 ScintillaBase &operator=(const ScintillaBase &) = delete;
50 ScintillaBase &operator=(ScintillaBase &&) = delete;
51 // ~ScintillaBase() in public section
52 void Initialise() override {}
53 void Finalise() override;
54
55 void InsertCharacter(std::string_view sv, Scintilla::CharacterSource charSource) override;
56 void Command(int cmdId);
57 void CancelModes() override;
58 int KeyCommand(Scintilla::Message iMessage) override;
59
60 void AutoCompleteInsert(Sci::Position startPos, Sci::Position removeLen, const char *text, Sci::Position textLen);
61 void AutoCompleteStart(Sci::Position lenEntered, const char *list);
62 void AutoCompleteCancel();
63 void AutoCompleteMove(int delta);
64 int AutoCompleteGetCurrent() const;
65 int AutoCompleteGetCurrentText(char *buffer) const;
66 void AutoCompleteCharacterAdded(char ch);
67 void AutoCompleteCharacterDeleted();
68 void AutoCompleteCompleted(char ch, Scintilla::CompletionMethods completionMethod);
69 void AutoCompleteMoveToCurrentWord();
70 void AutoCompleteSelection();
71 void ListNotify(ListBoxEvent *plbe) override;
72
73 void CallTipClick();
74 void CallTipShow(Point pt, const char *defn);
75 virtual void CreateCallTipWindow(PRectangle rc) = 0;
76
77 virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0;
78 bool ShouldDisplayPopup(Point ptInWindowCoordinates) const;
79 void ContextMenu(Point pt);
80
81 void ButtonDownWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers) override;
82 void RightButtonDownWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers) override;
83
84 void NotifyStyleToNeeded(Sci::Position endStyleNeeded) override;
85 void NotifyLexerChanged(Document *doc, void *userData) override;
86
87public:
88 ~ScintillaBase() override;
89
90 // Public so scintilla_send_message can use it
91 Scintilla::sptr_t WndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) override;
92};
93
94}
95
96#endif
97