diff options
Diffstat (limited to 'gtk')
| -rwxr-xr-x | gtk/PlatGTK.cxx | 90 | ||||
| -rwxr-xr-x | gtk/ScintillaGTK.cxx | 173 | ||||
| -rwxr-xr-x | gtk/ScintillaGTK.h | 12 | ||||
| -rw-r--r-- | gtk/ScintillaGTKAccessible.cxx | 175 | ||||
| -rw-r--r-- | gtk/ScintillaGTKAccessible.h | 18 | ||||
| -rw-r--r-- | gtk/deps.mak | 82 |
6 files changed, 293 insertions, 257 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index db1afc170..7a53bc28e 100755 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -24,6 +24,9 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#include "ScintillaTypes.h" +#include "ScintillaMessages.h" + #include "Debugging.h" #include "Geometry.h" #include "Platform.h" @@ -41,6 +44,7 @@ #endif using namespace Scintilla; +using namespace Scintilla::Internal; namespace { @@ -87,10 +91,10 @@ enum class EncodingType { singleByte, utf8, dbcs }; class FontHandle : public Font { public: PangoFontDescription *pfd = nullptr; - int characterSet; - FontHandle() noexcept : pfd(nullptr), characterSet(-1) { + CharacterSet characterSet; + FontHandle() noexcept : pfd(nullptr), characterSet(CharacterSet::Ansi) { } - FontHandle(PangoFontDescription *pfd_, int characterSet_) noexcept { + FontHandle(PangoFontDescription *pfd_, CharacterSet characterSet_) noexcept { pfd = pfd_; characterSet = characterSet_; } @@ -145,9 +149,9 @@ class SurfaceImpl : public Surface { PangoContext *pcontext = nullptr; PangoLayout *layout = nullptr; Converter conv; - int characterSet = -1; + CharacterSet characterSet = static_cast<CharacterSet>(-1); void PenColourAlpha(ColourRGBA fore) noexcept; - void SetConverter(int characterSet_); + void SetConverter(CharacterSet characterSet_); void CairoRectangle(PRectangle rc) noexcept; public: SurfaceImpl() noexcept; @@ -167,7 +171,7 @@ public: void Clear() noexcept; void Release() noexcept override; - int Supports(int feature) noexcept override; + int SupportsFeature(Supports feature) noexcept override; bool Initialised() override; int LogPixelsY() override; int PixelDivisions() override; @@ -216,60 +220,60 @@ public: void FlushDrawing() override; }; -const int SupportsGTK[] = { - SC_SUPPORTS_LINE_DRAWS_FINAL, - SC_SUPPORTS_FRACTIONAL_STROKE_WIDTH, - SC_SUPPORTS_TRANSLUCENT_STROKE, - SC_SUPPORTS_PIXEL_MODIFICATION, +const Supports SupportsGTK[] = { + Supports::LineDrawsFinal, + Supports::FractionalStrokeWidth, + Supports::TranslucentStroke, + Supports::PixelModification, }; } -const char *CharacterSetID(int characterSet) noexcept { +const char *CharacterSetID(CharacterSet characterSet) noexcept { switch (characterSet) { - case SC_CHARSET_ANSI: + case CharacterSet::Ansi: return ""; - case SC_CHARSET_DEFAULT: + case CharacterSet::Default: return "ISO-8859-1"; - case SC_CHARSET_BALTIC: + case CharacterSet::Baltic: return "ISO-8859-13"; - case SC_CHARSET_CHINESEBIG5: + case CharacterSet::ChineseBig5: return "BIG-5"; - case SC_CHARSET_EASTEUROPE: + case CharacterSet::EastEurope: return "ISO-8859-2"; - case SC_CHARSET_GB2312: + case CharacterSet::GB2312: return "CP936"; - case SC_CHARSET_GREEK: + case CharacterSet::Greek: return "ISO-8859-7"; - case SC_CHARSET_HANGUL: + case CharacterSet::Hangul: return "CP949"; - case SC_CHARSET_MAC: + case CharacterSet::Mac: return "MACINTOSH"; - case SC_CHARSET_OEM: + case CharacterSet::Oem: return "ASCII"; - case SC_CHARSET_RUSSIAN: + case CharacterSet::Russian: return "KOI8-R"; - case SC_CHARSET_OEM866: + case CharacterSet::Oem866: return "CP866"; - case SC_CHARSET_CYRILLIC: + case CharacterSet::Cyrillic: return "CP1251"; - case SC_CHARSET_SHIFTJIS: + case CharacterSet::ShiftJis: return "SHIFT-JIS"; - case SC_CHARSET_SYMBOL: + case CharacterSet::Symbol: return ""; - case SC_CHARSET_TURKISH: + case CharacterSet::Turkish: return "ISO-8859-9"; - case SC_CHARSET_JOHAB: + case CharacterSet::Johab: return "CP1361"; - case SC_CHARSET_HEBREW: + case CharacterSet::Hebrew: return "ISO-8859-8"; - case SC_CHARSET_ARABIC: + case CharacterSet::Arabic: return "ISO-8859-6"; - case SC_CHARSET_VIETNAMESE: + case CharacterSet::Vietnamese: return ""; - case SC_CHARSET_THAI: + case CharacterSet::Thai: return "ISO-8859-11"; - case SC_CHARSET_8859_15: + case CharacterSet::Iso8859_15: return "ISO-8859-15"; default: return ""; @@ -286,7 +290,7 @@ void SurfaceImpl::PenColourAlpha(ColourRGBA fore) noexcept { } } -void SurfaceImpl::SetConverter(int characterSet_) { +void SurfaceImpl::SetConverter(CharacterSet characterSet_) { if (characterSet != characterSet_) { characterSet = characterSet_; conv.Open("UTF-8", CharacterSetID(characterSet), false); @@ -342,7 +346,7 @@ void SurfaceImpl::Clear() noexcept { g_object_unref(pcontext); pcontext = nullptr; conv.Close(); - characterSet = -1; + characterSet = static_cast<CharacterSet>(-1); inited = false; createdGC = false; } @@ -417,8 +421,8 @@ void SurfaceImpl::SetMode(SurfaceMode mode_) { } } -int SurfaceImpl::Supports(int feature) noexcept { - for (const int f : SupportsGTK) { +int SurfaceImpl::SupportsFeature(Supports feature) noexcept { + for (const Supports f : SupportsGTK) { if (f == feature) return 1; } @@ -913,8 +917,8 @@ void SurfaceImpl::MeasureWidths(const Font *font_, std::string_view text, XYPOSI const size_t lenPositions = text.length(); // Either 8-bit or DBCS conversion failed so treat as 8-bit. SetConverter(PFont(font_)->characterSet); - const bool rtlCheck = PFont(font_)->characterSet == SC_CHARSET_HEBREW || - PFont(font_)->characterSet == SC_CHARSET_ARABIC; + const bool rtlCheck = PFont(font_)->characterSet == CharacterSet::Hebrew || + PFont(font_)->characterSet == CharacterSet::Arabic; std::string utfForm = UTF8FromIconv(conv, text); if (utfForm.empty()) { utfForm = UTF8FromLatin1(text); @@ -1120,7 +1124,7 @@ void SurfaceImpl::FlushCachedState() {} void SurfaceImpl::FlushDrawing() { } -std::unique_ptr<Surface> Surface::Allocate(int) { +std::unique_ptr<Surface> Surface::Allocate(Technology) { return std::make_unique<SurfaceImpl>(); } @@ -1385,7 +1389,7 @@ public: #endif } void SetFont(const Font *font) override; - void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_) override; + void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, Technology technology_) override; void SetAverageCharWidth(int width) override; void SetVisibleRows(int rows) override; int GetVisibleRows() const override; @@ -1570,7 +1574,7 @@ static void StyleSet(GtkWidget *w, GtkStyle *, void *) { #endif } -void ListBoxX::Create(Window &parent, int, Point, int, bool, int) { +void ListBoxX::Create(Window &parent, int, Point, int, bool, Technology) { if (widCached != nullptr) { wid = widCached; return; diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 7f7521423..e80081712 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -38,12 +38,16 @@ #include <windows.h> #endif +#include "ScintillaTypes.h" +#include "ScintillaMessages.h" +#include "ScintillaStructures.h" +#include "ILoader.h" +#include "ILexer.h" + #include "Debugging.h" #include "Geometry.h" #include "Platform.h" -#include "ILoader.h" -#include "ILexer.h" #include "Scintilla.h" #include "ScintillaWidget.h" #include "CharacterCategoryMap.h" @@ -90,6 +94,7 @@ #define SC_INDICATOR_UNKNOWN INDICATOR_IME_MAX using namespace Scintilla; +using namespace Scintilla::Internal; // From PlatGTK.cxx extern std::string UTF8FromLatin1(std::string_view text); @@ -363,7 +368,7 @@ void ScintillaGTK::UnRealizeThis(GtkWidget *widget) { Finalise(); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -385,7 +390,7 @@ void ScintillaGTK::MapThis() { ChangeSize(); gdk_window_show(PWindow(wMain)); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -406,7 +411,7 @@ void ScintillaGTK::UnMapThis() { if (PWidget(scrollbarv)) gtk_widget_unmap(PWidget(scrollbarv)); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -423,7 +428,7 @@ void ScintillaGTK::ForAll(GtkCallback callback, gpointer callback_data) { if (PWidget(scrollbarh)) (*callback)(PWidget(scrollbarh), callback_data); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -489,7 +494,7 @@ gint ScintillaGTK::FocusInThis(GtkWidget *) { } } } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; } @@ -509,7 +514,7 @@ gint ScintillaGTK::FocusOutThis(GtkWidget *) { gtk_im_context_focus_out(im_context); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; } @@ -563,7 +568,7 @@ void ScintillaGTK::SizeAllocate(GtkWidget *widget, GtkAllocation *allocation) { sciThis->Resize(allocation->width, allocation->height); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -686,10 +691,10 @@ void ScintillaGTK::Init() { timers[tr].reason = static_cast<TickReason>(tr); timers[tr].scintilla = this; } - vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(INDIC_HIDDEN, ColourRGBA(0, 0, 0xff)); - vs.indicators[SC_INDICATOR_INPUT] = Indicator(INDIC_DOTS, ColourRGBA(0, 0, 0xff)); - vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(INDIC_COMPOSITIONTHICK, ColourRGBA(0, 0, 0xff)); - vs.indicators[SC_INDICATOR_TARGET] = Indicator(INDIC_STRAIGHTBOX, ColourRGBA(0, 0, 0xff)); + vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(IndicatorStyle::Hidden, ColourRGBA(0, 0, 0xff)); + vs.indicators[SC_INDICATOR_INPUT] = Indicator(IndicatorStyle::Dots, ColourRGBA(0, 0, 0xff)); + vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(IndicatorStyle::CompositionThick, ColourRGBA(0, 0, 0xff)); + vs.indicators[SC_INDICATOR_TARGET] = Indicator(IndicatorStyle::StraightBox, ColourRGBA(0, 0, 0xff)); fontOptionsPrevious = FontOptions(PWidget(wText)); } @@ -715,7 +720,7 @@ bool ScintillaGTK::AbandonPaint() { } void ScintillaGTK::DisplayCursor(Window::Cursor c) { - if (cursorMode == SC_CURSORNORMAL) + if (cursorMode == CursorShape::Normal) wText.SetCursor(c); else wText.SetCursor(static_cast<Window::Cursor>(cursorMode)); @@ -867,35 +872,35 @@ std::string ScintillaGTK::EncodedFromUTF8(std::string_view utf8) const { } } -sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { +sptr_t ScintillaGTK::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { try { switch (iMessage) { - case SCI_GRABFOCUS: + case Message::GrabFocus: gtk_widget_grab_focus(PWidget(wMain)); break; - case SCI_GETDIRECTFUNCTION: + case Message::GetDirectFunction: return reinterpret_cast<sptr_t>(DirectFunction); - case SCI_GETDIRECTPOINTER: + case Message::GetDirectPointer: return reinterpret_cast<sptr_t>(this); - case SCI_TARGETASUTF8: + case Message::TargetAsUTF8: return TargetAsUTF8(CharPtrFromSPtr(lParam)); - case SCI_ENCODEDFROMUTF8: + case Message::EncodedFromUTF8: return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam), CharPtrFromSPtr(lParam)); - case SCI_SETRECTANGULARSELECTIONMODIFIER: + case Message::SetRectangularSelectionModifier: rectangularSelectionModifier = static_cast<int>(wParam); break; - case SCI_GETRECTANGULARSELECTIONMODIFIER: + case Message::GetRectangularSelectionModifier: return rectangularSelectionModifier; - case SCI_SETREADONLY: { + case Message::SetReadOnly: { const sptr_t ret = ScintillaBase::WndProc(iMessage, wParam, lParam); if (accessible) { ScintillaGTKAccessible *sciAccessible = ScintillaGTKAccessible::FromAccessible(accessible); @@ -906,10 +911,10 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return ret; } - case SCI_GETACCESSIBILITY: + case Message::GetAccessibility: return accessibilityEnabled; - case SCI_SETACCESSIBILITY: + case Message::SetAccessibility: accessibilityEnabled = static_cast<int>(wParam); if (accessible) { ScintillaGTKAccessible *sciAccessible = ScintillaGTKAccessible::FromAccessible(accessible); @@ -923,14 +928,14 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return ScintillaBase::WndProc(iMessage, wParam, lParam); } } catch (std::bad_alloc &) { - errorStatus = SC_STATUS_BADALLOC; + errorStatus = Status::BadAlloc; } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return 0; } -sptr_t ScintillaGTK::DefWndProc(unsigned int, uptr_t, sptr_t) { +sptr_t ScintillaGTK::DefWndProc(Message, uptr_t, sptr_t) { return 0; } @@ -1145,31 +1150,31 @@ void ScintillaGTK::NotifyFocus(bool focus) { Editor::NotifyFocus(focus); } -void ScintillaGTK::NotifyParent(SCNotification scn) { +void ScintillaGTK::NotifyParent(NotificationData scn) { scn.nmhdr.hwndFrom = PWidget(wMain); scn.nmhdr.idFrom = GetCtrlID(); g_signal_emit(G_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL], 0, GetCtrlID(), &scn); } -void ScintillaGTK::NotifyKey(int key, int modifiers) { - SCNotification scn = {}; - scn.nmhdr.code = SCN_KEY; - scn.ch = key; +void ScintillaGTK::NotifyKey(Keys key, KeyMod modifiers) { + NotificationData scn = {}; + scn.nmhdr.code = Notification::Key; + scn.ch = static_cast<int>(key); scn.modifiers = modifiers; NotifyParent(scn); } void ScintillaGTK::NotifyURIDropped(const char *list) { - SCNotification scn = {}; - scn.nmhdr.code = SCN_URIDROPPED; + NotificationData scn = {}; + scn.nmhdr.code = Notification::URIDropped; scn.text = list; NotifyParent(scn); } -const char *CharacterSetID(int characterSet); +const char *CharacterSetID(CharacterSet characterSet); const char *ScintillaGTK::CharacterSetID() const { return ::CharacterSetID(vs.styles[STYLE_DEFAULT].characterSet); @@ -1293,7 +1298,7 @@ std::string ScintillaGTK::CaseMapString(const std::string &s, CaseMapping caseMa } } -int ScintillaGTK::KeyDefault(int key, int modifiers) { +int ScintillaGTK::KeyDefault(Keys key, KeyMod modifiers) { // Pass up to container in case it is an accelerator NotifyKey(key, modifiers); return 0; @@ -1430,7 +1435,7 @@ void ScintillaGTK::PrimaryGetSelectionThis(GtkClipboard *clip, GtkSelectionData GetSelection(selection_data, info, &primary); } } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -1448,7 +1453,7 @@ void ScintillaGTK::PrimaryClearSelectionThis(GtkClipboard *clip) { Redraw(); } } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -1510,7 +1515,7 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio if (IsUnicodeMode()) { // Unknown encoding so assume in Latin1 dest = UTF8FromLatin1(dest); - selText.Copy(dest, SC_CP_UTF8, 0, isRectangular, false); + selText.Copy(dest, CpUtf8, CharacterSet::Ansi, isRectangular, false); } else { // Assume buffer is in same encoding as selection selText.Copy(dest, pdoc->dbcsCodePage, @@ -1524,7 +1529,7 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio selText.Copy(dest, pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, isRectangular, false); } else { - selText.Copy(dest, SC_CP_UTF8, 0, isRectangular, false); + selText.Copy(dest, CpUtf8, CharacterSet::Ansi, isRectangular, false); } } } @@ -1538,7 +1543,7 @@ void ScintillaGTK::InsertSelection(GtkClipboard *clipBoard, GtkSelectionData *se UndoGroup ug(pdoc); if (selection == GDK_SELECTION_CLIPBOARD) { - ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); + ClearSelection(multiPasteMode == MultiPaste::Each); } InsertPasteShape(selText.Data(), selText.Length(), @@ -1565,7 +1570,7 @@ void ScintillaGTK::ReceivedClipboard(GtkClipboard *clipBoard, GtkSelectionData * try { InsertSelection(clipBoard, selection_data); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -1585,7 +1590,7 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) { // else fprintf(stderr, "Target non string %d %d\n", (int)(selection_data->type), // (int)(atomUTF8)); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -1617,9 +1622,9 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se // from code below std::unique_ptr<SelectionText> newline_normalized; { - std::string tmpstr = Document::TransformLineEnds(text->Data(), text->Length(), SC_EOL_LF); + std::string tmpstr = Document::TransformLineEnds(text->Data(), text->Length(), EndOfLine::Lf); newline_normalized.reset(new SelectionText()); - newline_normalized->Copy(tmpstr, SC_CP_UTF8, 0, text->rectangular, false); + newline_normalized->Copy(tmpstr, CpUtf8, CharacterSet::Ansi, text->rectangular, false); text = newline_normalized.get(); } #endif @@ -1631,7 +1636,7 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se if (*charSet) { std::string tmputf = ConvertText(text->Data(), text->Length(), "UTF-8", charSet, false); converted = std::make_unique<SelectionText>(); - converted->Copy(tmputf, SC_CP_UTF8, 0, text->rectangular, false); + converted->Copy(tmputf, CpUtf8, CharacterSet::Ansi, text->rectangular, false); text = converted.get(); } } @@ -1692,7 +1697,7 @@ void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) { } } } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -1888,7 +1893,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) { SetAdjustmentValue(adjustmentv, static_cast<int>(topLine) + 3); } } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return TRUE; } @@ -1914,14 +1919,14 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) { // If mouse released on scroll bar then the position is relative to the // scrollbar, not the drawing window so just repeat the most recent point. pt = sciThis->ptMouseLast; - const int modifiers = ModifierFlags( + const KeyMod modifiers = ModifierFlags( (event->state & GDK_SHIFT_MASK) != 0, (event->state & GDK_CONTROL_MASK) != 0, (event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0); sciThis->ButtonUpWithModifiers(pt, event->time, modifiers); } } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } return FALSE; } @@ -2010,9 +2015,9 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) { // Text font size zoom } else if (event->state & GDK_CONTROL_MASK) { if (cLineScroll < 0) { - sciThis->KeyCommand(SCI_ZOOMIN); + sciThis->KeyCommand(Message::ZoomIn); } else { - sciThis->KeyCommand(SCI_ZOOMOUT); + sciThis->KeyCommand(Message::ZoomOut); } // Regular scrolling @@ -2021,7 +2026,7 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) { } return TRUE; } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } return FALSE; } @@ -2050,13 +2055,13 @@ gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) { //Platform::DebugPrintf("Move %x %x %d %c %d %d\n", // sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y); const Point pt(static_cast<XYPOSITION>(x), static_cast<XYPOSITION>(y)); - const int modifiers = ModifierFlags( + const KeyMod modifiers = ModifierFlags( (event->state & GDK_SHIFT_MASK) != 0, (event->state & GDK_CONTROL_MASK) != 0, (event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0); sciThis->ButtonMoveWithModifiers(pt, event->time, modifiers); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } return FALSE; } @@ -2244,7 +2249,7 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) { const bool meta = ctrl; ctrl = (event->state & GDK_META_MASK) != 0; #endif - const bool added = KeyDownWithModifiers(key, ModifierFlags(shift, ctrl, alt, meta, super), &consumed) != 0; + const bool added = KeyDownWithModifiers(static_cast<Keys>(key), ModifierFlags(shift, ctrl, alt, meta, super), &consumed) != 0; if (!consumed) consumed = added; //fprintf(stderr, "SK-key: %d %x %x\n",event->keyval, event->state, consumed); @@ -2257,7 +2262,7 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) { } return consumed; } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; } @@ -2289,7 +2294,7 @@ gboolean ScintillaGTK::DrawPreeditThis(GtkWidget *, cairo_t *cr) { g_object_unref(layout); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return TRUE; } @@ -2312,7 +2317,7 @@ gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *) { cairo_destroy(context); g_object_unref(layout); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return TRUE; } @@ -2442,12 +2447,12 @@ void ScintillaGTK::CommitThis(char *commitStr) { if (!IsUnicodeMode()) docChar = ConvertText(u8Char, u8CharLen, charSetSource, "UTF-8", true); - InsertCharacter(docChar, CharacterSource::directInput); + InsertCharacter(docChar, CharacterSource::DirectInput); } g_free(uniStr); ShowCaretAtCurrentPosition(); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -2504,7 +2509,7 @@ void ScintillaGTK::PreeditChangedInlineThis() { if (!IsUnicodeMode()) docChar = ConvertText(u8Char, u8CharLen, charSetSource, "UTF-8", true); - InsertCharacter(docChar, CharacterSource::tentativeInput); + InsertCharacter(docChar, CharacterSource::TentativeInput); DrawImeIndicator(indicator[i], docChar.size()); } @@ -2528,7 +2533,7 @@ void ScintillaGTK::PreeditChangedInlineThis() { EnsureCaretVisible(); ShowCaretAtCurrentPosition(); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } @@ -2562,12 +2567,12 @@ void ScintillaGTK::PreeditChangedWindowedThis() { gtk_widget_hide(PWidget(wPreedit)); } } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } } void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) { - if ((sciThis->imeInteraction == IMEInteraction::internal) || (sciThis->KoreanIME())) { + if ((sciThis->imeInteraction == IMEInteraction::Inline) || (sciThis->KoreanIME())) { sciThis->PreeditChangedInlineThis(); } else { sciThis->PreeditChangedWindowedThis(); @@ -2670,7 +2675,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) { rcPaint.bottom = y2; PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); - std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); + std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(Technology::Default)); surfaceWindow->Init(cr, PWidget(wText)); Paint(surfaceWindow.get(), rcPaint); surfaceWindow->Release(); @@ -2687,7 +2692,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) { rgnUpdate = 0; paintState = PaintState::notPainting; } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; @@ -2732,7 +2737,7 @@ gboolean ScintillaGTK::DrawThis(cairo_t *cr) { } #endif } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; } @@ -2760,7 +2765,7 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os rgnUpdate = gdk_region_copy(ose->region); const PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); - std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); + std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(Technology::Default)); cairo_t *cr = gdk_cairo_create(PWindow(wText)); surfaceWindow->Init(cr, PWidget(wText)); Paint(surfaceWindow.get(), rcPaint); @@ -2778,7 +2783,7 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os } rgnUpdate = nullptr; } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; @@ -2807,7 +2812,7 @@ gboolean ScintillaGTK::Expose(GtkWidget *, GdkEventExpose *ose) { GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarv), ose); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; } @@ -2818,7 +2823,7 @@ void ScintillaGTK::ScrollSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) { try { sciThis->ScrollTo(static_cast<int>(gtk_adjustment_get_value(adj)), false); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -2826,7 +2831,7 @@ void ScintillaGTK::ScrollHSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) { try { sciThis->HorizontalScrollTo(static_cast<int>(gtk_adjustment_get_value(adj))); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -2849,7 +2854,7 @@ void ScintillaGTK::SelectionGet(GtkWidget *widget, sciThis->GetSelection(selection_data, info, &sciThis->primary); } } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -2880,7 +2885,7 @@ gboolean ScintillaGTK::DragMotionThis(GdkDragContext *context, } gdk_drag_status(context, preferredAction, dragtime); } catch (...) { - errorStatus = SC_STATUS_FAILURE; + errorStatus = Status::Failure; } return FALSE; } @@ -2897,7 +2902,7 @@ void ScintillaGTK::DragLeave(GtkWidget *widget, GdkDragContext * /*context*/, gu sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition)); //Platform::DebugPrintf("DragLeave %x\n", sciThis); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -2911,7 +2916,7 @@ void ScintillaGTK::DragEnd(GtkWidget *widget, GdkDragContext * /*context*/) { //Platform::DebugPrintf("DragEnd %x %d\n", sciThis, sciThis->dragWasDropped); sciThis->inDragDrop = DragDrop::none; } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -2922,7 +2927,7 @@ gboolean ScintillaGTK::Drop(GtkWidget *widget, GdkDragContext * /*context*/, //Platform::DebugPrintf("Drop %x\n", sciThis); sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition)); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } return FALSE; } @@ -2934,7 +2939,7 @@ void ScintillaGTK::DragDataReceived(GtkWidget *widget, GdkDragContext * /*contex sciThis->ReceivedDrop(selection_data); sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition)); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -2961,7 +2966,7 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context, } sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition)); } catch (...) { - sciThis->errorStatus = SC_STATUS_FAILURE; + sciThis->errorStatus = Status::Failure; } } @@ -3069,7 +3074,7 @@ gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) { gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) { try { - std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); + std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(Technology::Default)); cairo_t *cr = gdk_cairo_create(WindowFromWidget(widget)); surfaceWindow->Init(cr, widget); surfaceWindow->SetMode(SurfaceMode(ctip->codePage, false)); @@ -3094,13 +3099,13 @@ AtkObject *ScintillaGTK::GetAccessible(GtkWidget *widget) { sptr_t ScintillaGTK::DirectFunction( sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { - return reinterpret_cast<ScintillaGTK *>(ptr)->WndProc(iMessage, wParam, lParam); + return reinterpret_cast<ScintillaGTK *>(ptr)->WndProc(static_cast<Message>(iMessage), wParam, lParam); } /* legacy name for scintilla_object_send_message */ sptr_t scintilla_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { ScintillaGTK *psci = static_cast<ScintillaGTK *>(sci->pscin); - return psci->WndProc(iMessage, wParam, lParam); + return psci->WndProc(static_cast<Message>(iMessage), wParam, lParam); } gintptr scintilla_object_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h index 5461ff37b..715e7ed50 100755 --- a/gtk/ScintillaGTK.h +++ b/gtk/ScintillaGTK.h @@ -6,7 +6,7 @@ #ifndef SCINTILLAGTK_H #define SCINTILLAGTK_H -namespace Scintilla { +namespace Scintilla::Internal { class ScintillaGTKAccessible; @@ -105,9 +105,9 @@ private: std::string UTF8FromEncoded(std::string_view encoded) const override; std::string EncodedFromUTF8(std::string_view utf8) const override; public: // Public for scintilla_send_message - sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; + sptr_t WndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) override; private: - sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; + sptr_t DefWndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) override; struct TimeThunk { TickReason reason; ScintillaGTK *scintilla; @@ -131,13 +131,13 @@ private: void ReconfigureScrollBars() override; void NotifyChange() override; void NotifyFocus(bool focus) override; - void NotifyParent(SCNotification scn) override; - void NotifyKey(int key, int modifiers); + void NotifyParent(Scintilla::NotificationData scn) override; + void NotifyKey(Scintilla::Keys key, Scintilla::KeyMod modifiers); void NotifyURIDropped(const char *list); const char *CharacterSetID() const; std::unique_ptr<CaseFolder> CaseFolderForEncoding() override; std::string CaseMapString(const std::string &s, CaseMapping caseMapping) override; - int KeyDefault(int key, int modifiers) override; + int KeyDefault(Scintilla::Keys key, Scintilla::KeyMod modifiers) override; void CopyToClipboard(const SelectionText &selectedText) override; void Copy() override; void RequestSelection(GdkAtom atomSelection); diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx index 25490277b..bff9a4572 100644 --- a/gtk/ScintillaGTKAccessible.cxx +++ b/gtk/ScintillaGTKAccessible.cxx @@ -89,12 +89,16 @@ #endif // ScintillaGTK.h and stuff it needs +#include "ScintillaTypes.h" +#include "ScintillaMessages.h" +#include "ScintillaStructures.h" +#include "ILoader.h" +#include "ILexer.h" + #include "Debugging.h" #include "Geometry.h" #include "Platform.h" -#include "ILoader.h" -#include "ILexer.h" #include "Scintilla.h" #include "ScintillaWidget.h" #include "CharacterCategoryMap.h" @@ -130,6 +134,7 @@ #include "ScintillaGTKAccessible.h" using namespace Scintilla; +using namespace Scintilla::Internal; struct ScintillaObjectAccessiblePrivate { ScintillaGTKAccessible *pscin; @@ -223,30 +228,30 @@ gchar *ScintillaGTKAccessible::GetTextAfterOffset(int charOffset, break; case ATK_TEXT_BOUNDARY_WORD_START: - startByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1); - startByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 0); - endByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 1); - endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 0); + startByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1); + startByte = sci->WndProc(Message::WordEndPosition, startByte, 0); + endByte = sci->WndProc(Message::WordEndPosition, startByte, 1); + endByte = sci->WndProc(Message::WordEndPosition, endByte, 0); break; case ATK_TEXT_BOUNDARY_WORD_END: - startByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 0); - startByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 1); - endByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 0); - endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 1); + startByte = sci->WndProc(Message::WordEndPosition, byteOffset, 0); + startByte = sci->WndProc(Message::WordEndPosition, startByte, 1); + endByte = sci->WndProc(Message::WordEndPosition, startByte, 0); + endByte = sci->WndProc(Message::WordEndPosition, endByte, 1); break; case ATK_TEXT_BOUNDARY_LINE_START: { - int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); - startByte = sci->WndProc(SCI_POSITIONFROMLINE, line + 1, 0); - endByte = sci->WndProc(SCI_POSITIONFROMLINE, line + 2, 0); + int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); + startByte = sci->WndProc(Message::PositionFromLine, line + 1, 0); + endByte = sci->WndProc(Message::PositionFromLine, line + 2, 0); break; } case ATK_TEXT_BOUNDARY_LINE_END: { - int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); - startByte = sci->WndProc(SCI_GETLINEENDPOSITION, line, 0); - endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line + 1, 0); + int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); + startByte = sci->WndProc(Message::GetLineEndPosition, line, 0); + endByte = sci->WndProc(Message::GetLineEndPosition, line + 1, 0); break; } @@ -273,24 +278,24 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset, break; case ATK_TEXT_BOUNDARY_WORD_START: - endByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 0); - endByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 1); - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 0); - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 1); + endByte = sci->WndProc(Message::WordStartPosition, byteOffset, 0); + endByte = sci->WndProc(Message::WordStartPosition, endByte, 1); + startByte = sci->WndProc(Message::WordStartPosition, endByte, 0); + startByte = sci->WndProc(Message::WordStartPosition, startByte, 1); break; case ATK_TEXT_BOUNDARY_WORD_END: - endByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1); - endByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 0); - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 1); - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 0); + endByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1); + endByte = sci->WndProc(Message::WordStartPosition, endByte, 0); + startByte = sci->WndProc(Message::WordStartPosition, endByte, 1); + startByte = sci->WndProc(Message::WordStartPosition, startByte, 0); break; case ATK_TEXT_BOUNDARY_LINE_START: { - int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); - endByte = sci->WndProc(SCI_POSITIONFROMLINE, line, 0); + int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); + endByte = sci->WndProc(Message::PositionFromLine, line, 0); if (line > 0) { - startByte = sci->WndProc(SCI_POSITIONFROMLINE, line - 1, 0); + startByte = sci->WndProc(Message::PositionFromLine, line - 1, 0); } else { startByte = endByte; } @@ -298,14 +303,14 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset, } case ATK_TEXT_BOUNDARY_LINE_END: { - int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); + int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); if (line > 0) { - endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line - 1, 0); + endByte = sci->WndProc(Message::GetLineEndPosition, line - 1, 0); } else { endByte = 0; } if (line > 1) { - startByte = sci->WndProc(SCI_GETLINEENDPOSITION, line - 2, 0); + startByte = sci->WndProc(Message::GetLineEndPosition, line - 2, 0); } else { startByte = endByte; } @@ -331,46 +336,46 @@ gchar *ScintillaGTKAccessible::GetTextAtOffset(int charOffset, switch (boundaryType) { case ATK_TEXT_BOUNDARY_CHAR: startByte = byteOffset; - endByte = sci->WndProc(SCI_POSITIONAFTER, byteOffset, 0); + endByte = sci->WndProc(Message::PositionAfter, byteOffset, 0); break; case ATK_TEXT_BOUNDARY_WORD_START: - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1); - endByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1); - if (! sci->WndProc(SCI_ISRANGEWORD, startByte, endByte)) { + startByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1); + endByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1); + if (! sci->WndProc(Message::IsRangeWord, startByte, endByte)) { // if the cursor was not on a word, forward back - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 0); - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 1); + startByte = sci->WndProc(Message::WordStartPosition, startByte, 0); + startByte = sci->WndProc(Message::WordStartPosition, startByte, 1); } - endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 0); + endByte = sci->WndProc(Message::WordEndPosition, endByte, 0); break; case ATK_TEXT_BOUNDARY_WORD_END: - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1); - endByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1); - if (! sci->WndProc(SCI_ISRANGEWORD, startByte, endByte)) { + startByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1); + endByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1); + if (! sci->WndProc(Message::IsRangeWord, startByte, endByte)) { // if the cursor was not on a word, forward back - endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 0); - endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 1); + endByte = sci->WndProc(Message::WordEndPosition, endByte, 0); + endByte = sci->WndProc(Message::WordEndPosition, endByte, 1); } - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 0); + startByte = sci->WndProc(Message::WordStartPosition, startByte, 0); break; case ATK_TEXT_BOUNDARY_LINE_START: { - int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); - startByte = sci->WndProc(SCI_POSITIONFROMLINE, line, 0); - endByte = sci->WndProc(SCI_POSITIONFROMLINE, line + 1, 0); + int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); + startByte = sci->WndProc(Message::PositionFromLine, line, 0); + endByte = sci->WndProc(Message::PositionFromLine, line + 1, 0); break; } case ATK_TEXT_BOUNDARY_LINE_END: { - int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); + int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); if (line > 0) { - startByte = sci->WndProc(SCI_GETLINEENDPOSITION, line - 1, 0); + startByte = sci->WndProc(Message::GetLineEndPosition, line - 1, 0); } else { startByte = 0; } - endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line, 0); + endByte = sci->WndProc(Message::GetLineEndPosition, line, 0); break; } @@ -394,16 +399,16 @@ gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset, switch (granularity) { case ATK_TEXT_GRANULARITY_CHAR: startByte = byteOffset; - endByte = sci->WndProc(SCI_POSITIONAFTER, byteOffset, 0); + endByte = sci->WndProc(Message::PositionAfter, byteOffset, 0); break; case ATK_TEXT_GRANULARITY_WORD: - startByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1); - endByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1); + startByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1); + endByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1); break; case ATK_TEXT_GRANULARITY_LINE: { - gint line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); - startByte = sci->WndProc(SCI_POSITIONFROMLINE, line, 0); - endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line, 0); + gint line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); + startByte = sci->WndProc(Message::PositionFromLine, line, 0); + endByte = sci->WndProc(Message::GetLineEndPosition, line, 0); break; } default: @@ -433,11 +438,11 @@ gint ScintillaGTKAccessible::GetCharacterCount() { } gint ScintillaGTKAccessible::GetCaretOffset() { - return CharacterOffsetFromByteOffset(sci->WndProc(SCI_GETCURRENTPOS, 0, 0)); + return CharacterOffsetFromByteOffset(sci->WndProc(Message::GetCurrentPos, 0, 0)); } gboolean ScintillaGTKAccessible::SetCaretOffset(int charOffset) { - sci->WndProc(SCI_GOTOPOS, ByteOffsetFromCharacterOffset(charOffset), 0); + sci->WndProc(Message::GotoPos, ByteOffsetFromCharacterOffset(charOffset), 0); return TRUE; } @@ -461,7 +466,7 @@ gint ScintillaGTKAccessible::GetOffsetAtPoint(gint x, gint y, AtkCoordType coord } // FIXME: should we handle scrolling? - return CharacterOffsetFromByteOffset(sci->WndProc(SCI_CHARPOSITIONFROMPOINTCLOSE, x, y)); + return CharacterOffsetFromByteOffset(sci->WndProc(Message::CharPositionFromPointClose, x, y)); } void ScintillaGTKAccessible::GetCharacterExtents(int charOffset, @@ -471,14 +476,14 @@ void ScintillaGTKAccessible::GetCharacterExtents(int charOffset, Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset); // FIXME: should we handle scrolling? - *x = sci->WndProc(SCI_POINTXFROMPOSITION, 0, byteOffset); - *y = sci->WndProc(SCI_POINTYFROMPOSITION, 0, byteOffset); + *x = sci->WndProc(Message::PointXFromPosition, 0, byteOffset); + *y = sci->WndProc(Message::PointYFromPosition, 0, byteOffset); - int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0); - *height = sci->WndProc(SCI_TEXTHEIGHT, line, 0); + int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0); + *height = sci->WndProc(Message::TextHeight, line, 0); int nextByteOffset = PositionAfter(byteOffset); - int next_x = sci->WndProc(SCI_POINTXFROMPOSITION, 0, nextByteOffset); + int next_x = sci->WndProc(Message::PointXFromPosition, 0, nextByteOffset); if (next_x > *x) { *width = next_x - *x; } else if (nextByteOffset > byteOffset) { @@ -538,7 +543,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetAttributesForStyle(unsigned int styl attr_set = AddTextAttribute(attr_set, ATK_TEXT_ATTR_FAMILY_NAME, g_strdup(style.fontName)); attr_set = AddTextAttribute(attr_set, ATK_TEXT_ATTR_SIZE, g_strdup_printf("%d", style.size / SC_FONT_SIZE_MULTIPLIER)); - attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_WEIGHT, CLAMP(style.weight, 100, 1000)); + attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_WEIGHT, CLAMP(static_cast<int>(style.weight), 100, 1000)); attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_STYLE, style.italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_UNDERLINE, style.underline ? PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE); attr_set = AddTextColorAttribute(attr_set, ATK_TEXT_ATTR_FG_COLOR, style.fore); @@ -554,7 +559,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *s Sci::Position byteOffset; if (charOffset == -1) { - byteOffset = sci->WndProc(SCI_GETCURRENTPOS, 0, 0); + byteOffset = sci->WndProc(Message::GetCurrentPos, 0, 0); } else { byteOffset = ByteOffsetFromCharacterOffset(charOffset); } @@ -601,9 +606,9 @@ gboolean ScintillaGTKAccessible::AddSelection(int startChar, int endChar) { ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte); // use WndProc() to set the selections so it notifies as needed if (n_selections > 1 || ! sci->sel.Empty()) { - sci->WndProc(SCI_ADDSELECTION, startByte, endByte); + sci->WndProc(Message::AddSelection, startByte, endByte); } else { - sci->WndProc(SCI_SETSELECTION, startByte, endByte); + sci->WndProc(Message::SetSelection, startByte, endByte); } return TRUE; @@ -615,11 +620,11 @@ gboolean ScintillaGTKAccessible::RemoveSelection(gint selection_num) { return FALSE; if (n_selections > 1) { - sci->WndProc(SCI_DROPSELECTIONN, selection_num, 0); + sci->WndProc(Message::DropSelectionN, selection_num, 0); } else if (sci->sel.Empty()) { return FALSE; } else { - sci->WndProc(SCI_CLEARSELECTIONS, 0, 0); + sci->WndProc(Message::ClearSelections, 0, 0); } return TRUE; @@ -632,8 +637,8 @@ gboolean ScintillaGTKAccessible::SetSelection(gint selection_num, int startChar, Sci::Position startByte, endByte; ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte); - sci->WndProc(SCI_SETSELECTIONNSTART, selection_num, startByte); - sci->WndProc(SCI_SETSELECTIONNEND, selection_num, endByte); + sci->WndProc(Message::SetSelectionNStart, selection_num, startByte); + sci->WndProc(Message::SetSelectionNEnd, selection_num, endByte); return TRUE; } @@ -666,7 +671,7 @@ void ScintillaGTKAccessible::AtkTextIface::init(::AtkTextIface *iface) { void ScintillaGTKAccessible::SetTextContents(const gchar *contents) { // FIXME: it's probably useless to check for READONLY here, SETTEXT probably does it just fine? if (! sci->pdoc->IsReadOnly()) { - sci->WndProc(SCI_SETTEXT, 0, (sptr_t) contents); + sci->WndProc(Message::SetText, 0, (sptr_t) contents); } } @@ -797,7 +802,7 @@ bool ScintillaGTKAccessible::Enabled() const { // Callbacks void ScintillaGTKAccessible::UpdateCursor() { - Sci::Position pos = sci->WndProc(SCI_GETCURRENTPOS, 0, 0); + Sci::Position pos = sci->WndProc(Message::GetCurrentPos, 0, 0); if (old_pos != pos) { int charPosition = CharacterOffsetFromByteOffset(pos); g_signal_emit_by_name(accessible, "text-caret-moved", charPosition); @@ -867,39 +872,41 @@ void ScintillaGTKAccessible::NotifyReadOnly() { void ScintillaGTKAccessible::SetAccessibility(bool enabled) { // Called by ScintillaGTK when application has enabled or disabled accessibility if (enabled) - sci->pdoc->AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF32); + sci->pdoc->AllocateLineCharacterIndex(LineCharacterIndexType::Utf32); else - sci->pdoc->ReleaseLineCharacterIndex(SC_LINECHARACTERINDEX_UTF32); + sci->pdoc->ReleaseLineCharacterIndex(LineCharacterIndexType::Utf32); } -void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) { +void ScintillaGTKAccessible::Notify(GtkWidget *, gint, NotificationData *nt) { if (!Enabled()) return; switch (nt->nmhdr.code) { - case SCN_MODIFIED: { - if (nt->modificationType & SC_MOD_INSERTTEXT) { + case Notification::Modified: { + if (FlagSet(nt->modificationType, ModificationFlags::InsertText)) { int startChar = CharacterOffsetFromByteOffset(nt->position); int lengthChar = sci->pdoc->CountCharacters(nt->position, nt->position + nt->length); g_signal_emit_by_name(accessible, "text-changed::insert", startChar, lengthChar); UpdateCursor(); } - if (nt->modificationType & SC_MOD_BEFOREDELETE) { + if (FlagSet(nt->modificationType, ModificationFlags::BeforeDelete)) { int startChar = CharacterOffsetFromByteOffset(nt->position); int lengthChar = sci->pdoc->CountCharacters(nt->position, nt->position + nt->length); g_signal_emit_by_name(accessible, "text-changed::delete", startChar, lengthChar); } - if (nt->modificationType & SC_MOD_DELETETEXT) { + if (FlagSet(nt->modificationType, ModificationFlags::DeleteText)) { UpdateCursor(); } - if (nt->modificationType & SC_MOD_CHANGESTYLE) { + if (FlagSet(nt->modificationType, ModificationFlags::ChangeStyle)) { g_signal_emit_by_name(accessible, "text-attributes-changed"); } } break; - case SCN_UPDATEUI: { - if (nt->updated & SC_UPDATE_SELECTION) { + case Notification::UpdateUI: { + if (FlagSet(nt->updated, Update::Selection)) { UpdateCursor(); } } break; + default: + break; } } @@ -1145,7 +1152,7 @@ static AtkStateSet *scintilla_object_accessible_ref_state_set(AtkObject *accessi if (widget == nullptr) { atk_state_set_add_state(state_set, ATK_STATE_DEFUNCT); } else { - if (! scintilla_send_message(SCINTILLA_OBJECT(widget), SCI_GETREADONLY, 0, 0)) + if (! scintilla_send_message(SCINTILLA_OBJECT(widget), static_cast<int>(Message::GetReadOnly), 0, 0)) atk_state_set_add_state(state_set, ATK_STATE_EDITABLE); #if ATK_CHECK_VERSION(2, 16, 0) else diff --git a/gtk/ScintillaGTKAccessible.h b/gtk/ScintillaGTKAccessible.h index 2168d034c..169dd507a 100644 --- a/gtk/ScintillaGTKAccessible.h +++ b/gtk/ScintillaGTKAccessible.h @@ -6,7 +6,7 @@ #ifndef SCINTILLAGTKACCESSIBLE_H #define SCINTILLAGTKACCESSIBLE_H -namespace Scintilla { +namespace Scintilla::Internal { #ifndef ATK_CHECK_VERSION # define ATK_CHECK_VERSION(x, y, z) 0 @@ -24,25 +24,25 @@ private: bool Enabled() const; void UpdateCursor(); - void Notify(GtkWidget *widget, gint code, SCNotification *nt); - static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) { + void Notify(GtkWidget *widget, gint code, Scintilla::NotificationData *nt); + static void SciNotify(GtkWidget *widget, gint code, Scintilla::NotificationData *nt, gpointer data) { try { static_cast<ScintillaGTKAccessible*>(data)->Notify(widget, code, nt); } catch (...) {} } Sci::Position ByteOffsetFromCharacterOffset(Sci::Position startByte, int characterOffset) { - if (!(sci->pdoc->LineCharacterIndex() & SC_LINECHARACTERINDEX_UTF32)) { + if (!FlagSet(sci->pdoc->LineCharacterIndex(), Scintilla::LineCharacterIndexType::Utf32)) { return startByte + characterOffset; } if (characterOffset > 0) { // Try and reduce the range by reverse-looking into the character offset cache Sci::Line lineStart = sci->pdoc->LineFromPosition(startByte); - Sci::Position posStart = sci->pdoc->IndexLineStart(lineStart, SC_LINECHARACTERINDEX_UTF32); - Sci::Line line = sci->pdoc->LineFromPositionIndex(posStart + characterOffset, SC_LINECHARACTERINDEX_UTF32); + Sci::Position posStart = sci->pdoc->IndexLineStart(lineStart, Scintilla::LineCharacterIndexType::Utf32); + Sci::Line line = sci->pdoc->LineFromPositionIndex(posStart + characterOffset, Scintilla::LineCharacterIndexType::Utf32); if (line != lineStart) { startByte += sci->pdoc->LineStart(line) - sci->pdoc->LineStart(lineStart); - characterOffset -= sci->pdoc->IndexLineStart(line, SC_LINECHARACTERINDEX_UTF32) - posStart; + characterOffset -= sci->pdoc->IndexLineStart(line, Scintilla::LineCharacterIndexType::Utf32) - posStart; } } Sci::Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset); @@ -62,12 +62,12 @@ private: } Sci::Position CharacterOffsetFromByteOffset(Sci::Position byteOffset) { - if (!(sci->pdoc->LineCharacterIndex() & SC_LINECHARACTERINDEX_UTF32)) { + if (!FlagSet(sci->pdoc->LineCharacterIndex(), Scintilla::LineCharacterIndexType::Utf32)) { return byteOffset; } const Sci::Line line = sci->pdoc->LineFromPosition(byteOffset); const Sci::Position lineStart = sci->pdoc->LineStart(line); - return sci->pdoc->IndexLineStart(line, SC_LINECHARACTERINDEX_UTF32) + sci->pdoc->CountCharacters(lineStart, byteOffset); + return sci->pdoc->IndexLineStart(line, Scintilla::LineCharacterIndexType::Utf32) + sci->pdoc->CountCharacters(lineStart, byteOffset); } void CharacterRangeFromByteRange(Sci::Position startByte, Sci::Position endByte, int *startChar, int *endChar) { diff --git a/gtk/deps.mak b/gtk/deps.mak index c98dddfa1..11ed82d2b 100644 --- a/gtk/deps.mak +++ b/gtk/deps.mak @@ -3,6 +3,8 @@ PlatGTK.o: \ PlatGTK.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ ../include/Scintilla.h \ ../include/Sci_Position.h \ @@ -14,6 +16,9 @@ ScintillaGTK.o: \ ScintillaGTK.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ + ../include/ScintillaStructures.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ @@ -56,6 +61,9 @@ ScintillaGTKAccessible.o: \ ScintillaGTKAccessible.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ + ../include/ScintillaStructures.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ @@ -96,9 +104,9 @@ AutoComplete.o: \ ../src/AutoComplete.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ ../src/CharacterType.h \ ../src/Position.h \ ../src/AutoComplete.h @@ -106,9 +114,9 @@ CallTip.o: \ ../src/CallTip.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ ../src/Position.h \ ../src/CallTip.h CaseConvert.o: \ @@ -122,8 +130,8 @@ CaseFolder.o: \ CellBuffer.o: \ ../src/CellBuffer.cxx \ ../src/Debugging.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Position.h \ ../src/SplitVector.h \ ../src/Partitioning.h \ @@ -155,8 +163,8 @@ DBCS.o: \ Decoration.o: \ ../src/Decoration.cxx \ ../src/Debugging.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Position.h \ ../src/SplitVector.h \ ../src/Partitioning.h \ @@ -168,7 +176,8 @@ Document.o: \ ../include/ILoader.h \ ../include/Sci_Position.h \ ../include/ILexer.h \ - ../include/Scintilla.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/CharacterType.h \ ../src/CharacterCategoryMap.h \ ../src/Position.h \ @@ -188,11 +197,12 @@ EditModel.o: \ ../src/EditModel.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ ../include/ILexer.h \ - ../include/Scintilla.h \ ../src/CharacterCategoryMap.h \ ../src/Position.h \ ../src/UniqueString.h \ @@ -218,11 +228,13 @@ Editor.o: \ ../src/Editor.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ + ../include/ScintillaStructures.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ ../include/ILexer.h \ - ../include/Scintilla.h \ ../src/CharacterType.h \ ../src/CharacterCategoryMap.h \ ../src/Position.h \ @@ -254,11 +266,13 @@ EditView.o: \ ../src/EditView.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ + ../include/ScintillaStructures.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ ../include/ILexer.h \ - ../include/Scintilla.h \ ../src/CharacterType.h \ ../src/CharacterCategoryMap.h \ ../src/Position.h \ @@ -292,24 +306,24 @@ Indicator.o: \ ../src/Indicator.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ ../src/Indicator.h \ ../src/XPM.h KeyMap.o: \ ../src/KeyMap.cxx \ ../src/Debugging.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/KeyMap.h LineMarker.o: \ ../src/LineMarker.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ ../src/XPM.h \ ../src/LineMarker.h \ ../src/UniConversion.h @@ -317,11 +331,13 @@ MarginView.o: \ ../src/MarginView.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ + ../include/ScintillaStructures.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ ../include/ILexer.h \ - ../include/Scintilla.h \ ../src/CharacterCategoryMap.h \ ../src/Position.h \ ../src/UniqueString.h \ @@ -349,9 +365,9 @@ PerLine.o: \ ../src/PerLine.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ ../src/Position.h \ ../src/SplitVector.h \ ../src/Partitioning.h \ @@ -361,11 +377,12 @@ PositionCache.o: \ ../src/PositionCache.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ ../include/ILexer.h \ - ../include/Scintilla.h \ ../src/CharacterCategoryMap.h \ ../src/Position.h \ ../src/UniqueString.h \ @@ -394,8 +411,8 @@ RESearch.o: \ RunStyles.o: \ ../src/RunStyles.cxx \ ../src/Debugging.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Position.h \ ../src/SplitVector.h \ ../src/Partitioning.h \ @@ -404,11 +421,13 @@ ScintillaBase.o: \ ../src/ScintillaBase.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ + ../include/ScintillaStructures.h \ ../src/Platform.h \ ../include/ILoader.h \ ../include/Sci_Position.h \ ../include/ILexer.h \ - ../include/Scintilla.h \ ../src/CharacterCategoryMap.h \ ../src/Position.h \ ../src/UniqueString.h \ @@ -438,17 +457,17 @@ ScintillaBase.o: \ Selection.o: \ ../src/Selection.cxx \ ../src/Debugging.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Position.h \ ../src/Selection.h Style.o: \ ../src/Style.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ ../src/Style.h UniConversion.o: \ ../src/UniConversion.cxx \ @@ -460,9 +479,9 @@ ViewStyle.o: \ ../src/ViewStyle.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ + ../include/ScintillaMessages.h \ ../src/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ ../src/Position.h \ ../src/UniqueString.h \ ../src/Indicator.h \ @@ -474,5 +493,6 @@ XPM.o: \ ../src/XPM.cxx \ ../src/Debugging.h \ ../src/Geometry.h \ + ../include/ScintillaTypes.h \ ../src/Platform.h \ ../src/XPM.h |
