aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2019-03-27 08:34:16 +1100
committerNeil <nyamatongwe@gmail.com>2019-03-27 08:34:16 +1100
commitff4e7e74e24d88194e01a78f9c5b2649bbcc1a59 (patch)
treed8ec063c8a5a7afc16022005bd4fe109b22a763e /gtk
parenta29736e309ee7d0b8ca588674024c2deb6923090 (diff)
downloadscintilla-mirror-ff4e7e74e24d88194e01a78f9c5b2649bbcc1a59.tar.gz
Replace NULL/0 with nullptr. Mark noexcept where simple.
Move some static functions into anonymous namespace.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Converter.h12
-rw-r--r--gtk/PlatGTK.cxx203
-rw-r--r--gtk/ScintillaGTK.cxx127
-rw-r--r--gtk/ScintillaGTK.h6
-rw-r--r--gtk/ScintillaGTKAccessible.cxx94
5 files changed, 224 insertions, 218 deletions
diff --git a/gtk/Converter.h b/gtk/Converter.h
index 0ef80ae23..fa9a101f1 100644
--- a/gtk/Converter.h
+++ b/gtk/Converter.h
@@ -15,14 +15,14 @@ const gsize sizeFailure = static_cast<gsize>(-1);
*/
class Converter {
GIConv iconvh;
- void OpenHandle(const char *fullDestination, const char *charSetSource) {
+ void OpenHandle(const char *fullDestination, const char *charSetSource) noexcept {
iconvh = g_iconv_open(fullDestination, charSetSource);
}
- bool Succeeded() const {
+ bool Succeeded() const noexcept {
return iconvh != iconvhBad;
}
public:
- Converter() {
+ Converter() noexcept {
iconvh = iconvhBad;
}
Converter(const char *charSetDestination, const char *charSetSource, bool transliterations) {
@@ -32,7 +32,7 @@ public:
~Converter() {
Close();
}
- operator bool() const {
+ operator bool() const noexcept {
return Succeeded();
}
void Open(const char *charSetDestination, const char *charSetSource, bool transliterations) {
@@ -50,13 +50,13 @@ public:
}
}
}
- void Close() {
+ void Close() noexcept {
if (Succeeded()) {
g_iconv_close(iconvh);
iconvh = iconvhBad;
}
}
- gsize Convert(char** src, gsize *srcleft, char **dst, gsize *dstleft) const {
+ gsize Convert(char** src, gsize *srcleft, char **dst, gsize *dstleft) const noexcept {
if (!Succeeded()) {
return sizeFailure;
} else {
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 40e87c428..fd37b0a6a 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -33,51 +33,57 @@
#include "Converter.h"
-static const double kPi = 3.14159265358979323846;
+#ifdef _MSC_VER
+// Ignore unreferenced local functions in GTK+ headers
+#pragma warning(disable: 4505)
+#endif
+
+using namespace Scintilla;
+
+namespace {
+
+const double kPi = 3.14159265358979323846;
// The Pango version guard for pango_units_from_double and pango_units_to_double
// is more complex than simply implementing these here.
-static int pangoUnitsFromDouble(double d) {
+int pangoUnitsFromDouble(double d) noexcept {
return static_cast<int>(d * PANGO_SCALE + 0.5);
}
-static double doubleFromPangoUnits(int pu) {
+double doubleFromPangoUnits(int pu) noexcept {
return static_cast<double>(pu) / PANGO_SCALE;
}
-static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) {
+cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) noexcept {
return gdk_window_create_similar_surface(window, content, width, height);
}
-static GdkWindow *WindowFromWidget(GtkWidget *w) {
+GdkWindow *WindowFromWidget(GtkWidget *w) noexcept {
return gtk_widget_get_window(w);
}
-#ifdef _MSC_VER
-// Ignore unreferenced local functions in GTK+ headers
-#pragma warning(disable: 4505)
-#endif
-
-using namespace Scintilla;
+GtkWidget *PWidget(WindowID wid) noexcept {
+ return static_cast<GtkWidget *>(wid);
+}
-enum encodingType { singleByte, UTF8, dbcs};
+enum encodingType { singleByte, UTF8, dbcs };
// Holds a PangoFontDescription*.
class FontHandle {
public:
PangoFontDescription *pfd;
int characterSet;
- FontHandle() : pfd(0), characterSet(-1) {
+ FontHandle() noexcept : pfd(nullptr), characterSet(-1) {
}
- FontHandle(PangoFontDescription *pfd_, int characterSet_) {
+ FontHandle(PangoFontDescription *pfd_, int characterSet_) noexcept {
pfd = pfd_;
characterSet = characterSet_;
}
~FontHandle() {
if (pfd)
pango_font_description_free(pfd);
- pfd = 0;
+ pfd = nullptr;
}
static FontHandle *CreateNewFont(const FontParameters &fp);
};
@@ -93,21 +99,19 @@ FontHandle *FontHandle::CreateNewFont(const FontParameters &fp) {
return new FontHandle(pfd,fp.characterSet);
}
- return NULL;
+ return nullptr;
}
// X has a 16 bit coordinate space, so stop drawing here to avoid wrapping
-static const int maxCoordinate = 32000;
+const int maxCoordinate = 32000;
-static FontHandle *PFont(Font &f) {
+FontHandle *PFont(const Font &f) noexcept {
return static_cast<FontHandle *>(f.GetID());
}
-static GtkWidget *PWidget(WindowID wid) {
- return static_cast<GtkWidget *>(wid);
}
-Font::Font() noexcept : fid(0) {}
+Font::Font() noexcept : fid(nullptr) {}
Font::~Font() {}
@@ -119,7 +123,7 @@ void Font::Create(const FontParameters &fp) {
void Font::Release() {
if (fid)
delete static_cast<FontHandle *>(fid);
- fid = 0;
+ fid = nullptr;
}
// Required on OS X
@@ -140,14 +144,14 @@ class SurfaceImpl : public Surface {
int characterSet;
void SetConverter(int characterSet_);
public:
- SurfaceImpl();
+ SurfaceImpl() noexcept;
~SurfaceImpl() override;
void Init(WindowID wid) override;
void Init(SurfaceID sid, WindowID wid) override;
void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override;
- void Clear();
+ void Clear() noexcept;
void Release() override;
bool Initialised() override;
void PenColour(ColourDesired fore) override;
@@ -190,7 +194,7 @@ public:
};
}
-const char *CharacterSetID(int characterSet) {
+const char *CharacterSetID(int characterSet) noexcept {
switch (characterSet) {
case SC_CHARSET_ANSI:
return "";
@@ -248,33 +252,33 @@ void SurfaceImpl::SetConverter(int characterSet_) {
}
}
-SurfaceImpl::SurfaceImpl() : et(singleByte),
-context(0),
-psurf(0),
-x(0), y(0), inited(false), createdGC(false)
-, pcontext(0), layout(0), characterSet(-1) {
+SurfaceImpl::SurfaceImpl() noexcept : et(singleByte),
+context(nullptr),
+psurf(nullptr),
+x(0), y(0), inited(false), createdGC(false),
+pcontext(nullptr), layout(nullptr), characterSet(-1) {
}
SurfaceImpl::~SurfaceImpl() {
Clear();
}
-void SurfaceImpl::Clear() {
+void SurfaceImpl::Clear() noexcept {
et = singleByte;
if (createdGC) {
createdGC = false;
cairo_destroy(context);
}
- context = 0;
+ context = nullptr;
if (psurf)
cairo_surface_destroy(psurf);
- psurf = 0;
+ psurf = nullptr;
if (layout)
g_object_unref(layout);
- layout = 0;
+ layout = nullptr;
if (pcontext)
g_object_unref(pcontext);
- pcontext = 0;
+ pcontext = nullptr;
conv.Close();
characterSet = -1;
x = 0;
@@ -311,8 +315,8 @@ void SurfaceImpl::Init(WindowID wid) {
Release();
PLATFORM_ASSERT(wid);
// if we are only created from a window ID, we can't perform drawing
- psurf = 0;
- context = 0;
+ psurf = nullptr;
+ context = nullptr;
createdGC = false;
pcontext = gtk_widget_create_pango_context(PWidget(wid));
PLATFORM_ASSERT(pcontext);
@@ -388,7 +392,7 @@ void SurfaceImpl::MoveTo(int x_, int y_) {
y = y_;
}
-static int Delta(int difference) {
+static int Delta(int difference) noexcept {
if (difference < 0)
return -1;
else if (difference > 0)
@@ -468,7 +472,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) {
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfacePattern);
- bool canDraw = surfi.psurf != NULL;
+ bool canDraw = surfi.psurf != nullptr;
if (canDraw) {
PLATFORM_ASSERT(context);
// Tile pattern over rectangle
@@ -510,7 +514,7 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi
}
}
-static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) {
+static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) noexcept {
double degrees = kPi / 180.0;
cairo_new_sub_path(context);
@@ -619,7 +623,7 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)
void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfaceSource);
- bool canDraw = surfi.psurf != NULL;
+ bool canDraw = surfi.psurf != nullptr;
if (canDraw) {
PLATFORM_ASSERT(context);
cairo_set_source_surface(context, surfi.psurf,
@@ -744,19 +748,19 @@ public:
XYPOSITION position;
XYPOSITION distance;
int curIndex;
- ClusterIterator(PangoLayout *layout, size_t len) : lenPositions(len), finished(false),
+ ClusterIterator(PangoLayout *layout, size_t len) noexcept : lenPositions(len), finished(false),
positionStart(0), position(0), distance(0), curIndex(0) {
iter = pango_layout_get_iter(layout);
- pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
+ pango_layout_iter_get_cluster_extents(iter, nullptr, &pos);
}
~ClusterIterator() {
pango_layout_iter_free(iter);
}
- void Next() {
+ void Next() noexcept {
positionStart = position;
if (pango_layout_iter_next_cluster(iter)) {
- pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
+ pango_layout_iter_get_cluster_extents(iter, nullptr, &pos);
position = doubleFromPangoUnits(pos.x);
curIndex = pango_layout_iter_get_index(iter);
} else {
@@ -845,7 +849,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, std::string_view text, XYPOSITION *
if (rtlCheck && ((clusterEnd <= clusterStart) || (ligatureLength == 0) || (ligatureLength > 3))) {
// Something has gone wrong: exit quickly but pretend all the characters are equally spaced:
int widthLayout = 0;
- pango_layout_get_size(layout, &widthLayout, NULL);
+ pango_layout_get_size(layout, &widthLayout, nullptr);
XYPOSITION widthTotal = doubleFromPangoUnits(widthLayout);
for (size_t bytePos=0; bytePos<lenPositions; bytePos++) {
positions[bytePos] = widthTotal / lenPositions * (bytePos + 1);
@@ -891,7 +895,7 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, std::string_view text) {
pango_layout_set_text(layout, utfForm.c_str(), utfForm.length());
}
PangoLayoutLine *pangoLine = pango_layout_get_line_readonly(layout,0);
- pango_layout_line_get_extents(pangoLine, NULL, &pos);
+ pango_layout_line_get_extents(pangoLine, nullptr, &pos);
return doubleFromPangoUnits(pos.width);
}
return 1;
@@ -984,7 +988,7 @@ void Window::Destroy() {
} else {
gtk_widget_destroy(GTK_WIDGET(wid));
}
- wid = 0;
+ wid = nullptr;
}
}
@@ -1163,7 +1167,7 @@ struct ListImage {
GdkPixbuf *pixbuf;
};
-static void list_image_free(gpointer, gpointer value, gpointer) {
+static void list_image_free(gpointer, gpointer value, gpointer) noexcept {
ListImage *list_image = static_cast<ListImage *>(value);
if (list_image->pixbuf)
g_object_unref(list_image->pixbuf);
@@ -1200,28 +1204,29 @@ class ListBoxX : public ListBox {
public:
IListBoxDelegate *delegate;
- ListBoxX() : widCached(0), frame(0), list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0),
- renderer(0),
+ ListBoxX() noexcept : widCached(nullptr), frame(nullptr), list(nullptr), scroller(nullptr),
+ pixhash(nullptr), pixbuf_renderer(nullptr),
+ renderer(nullptr),
desiredVisibleRows(5), maxItemCharacters(0),
aveCharWidth(1),
#if GTK_CHECK_VERSION(3,0,0)
- cssProvider(NULL),
+ cssProvider(nullptr),
#endif
delegate(nullptr) {
}
~ListBoxX() override {
if (pixhash) {
- g_hash_table_foreach((GHashTable *) pixhash, list_image_free, NULL);
+ g_hash_table_foreach((GHashTable *) pixhash, list_image_free, nullptr);
g_hash_table_destroy((GHashTable *) pixhash);
}
if (widCached) {
gtk_widget_destroy(GTK_WIDGET(widCached));
- wid = widCached = 0;
+ wid = widCached = nullptr;
}
#if GTK_CHECK_VERSION(3,0,0)
if (cssProvider) {
g_object_unref(cssProvider);
- cssProvider = NULL;
+ cssProvider = nullptr;
}
#endif
}
@@ -1259,7 +1264,7 @@ static int treeViewGetRowHeight(GtkTreeView *view) {
// version is inaccurate for GTK 3.14.
GdkRectangle rect;
GtkTreePath *path = gtk_tree_path_new_first();
- gtk_tree_view_get_background_area(view, path, NULL, &rect);
+ gtk_tree_view_get_background_area(view, path, nullptr, &rect);
gtk_tree_path_free(path);
return rect.height;
#else
@@ -1267,10 +1272,10 @@ static int treeViewGetRowHeight(GtkTreeView *view) {
int vertical_separator=0;
int expander_size=0;
GtkTreeViewColumn *column = gtk_tree_view_get_column(view, 0);
- gtk_tree_view_column_cell_get_size(column, NULL, NULL, NULL, NULL, &row_height);
+ gtk_tree_view_column_cell_get_size(column, nullptr, nullptr, nullptr, nullptr, &row_height);
gtk_widget_style_get(GTK_WIDGET(view),
"vertical-separator", &vertical_separator,
- "expander-size", &expander_size, NULL);
+ "expander-size", &expander_size, nullptr);
row_height += vertical_separator;
row_height = std::max(row_height, expander_size);
return row_height;
@@ -1304,7 +1309,7 @@ static void small_scroller_get_preferred_height(GtkWidget *widget, gint *min, gi
GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
if (GTK_IS_TREE_VIEW(child)) {
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(child));
- int n_rows = gtk_tree_model_iter_n_children(model, NULL);
+ int n_rows = gtk_tree_model_iter_n_children(model, nullptr);
int row_height = treeViewGetRowHeight(GTK_TREE_VIEW(child));
*min = MAX(1, row_height);
@@ -1365,7 +1370,7 @@ static gboolean ButtonRelease(GtkWidget *, GdkEventButton* ev, gpointer p) {
scheme that it would use if it had the focus. */
static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
- g_return_if_fail(w != NULL);
+ g_return_if_fail(w != nullptr);
/* Copy the selected color to active. Note that the modify calls will cause
recursive calls to this function after the value is updated and w->style to
@@ -1377,7 +1382,7 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
// The *override* calls are deprecated now, so only call them for older versions of GTK+.
#elif GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *styleContext = gtk_widget_get_style_context(w);
- if (styleContext == NULL)
+ if (styleContext == nullptr)
return;
GdkRGBA colourForeSelected;
@@ -1388,7 +1393,7 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
gtk_widget_override_color(w, GTK_STATE_FLAG_ACTIVE, &colourForeSelected);
styleContext = gtk_widget_get_style_context(w);
- if (styleContext == NULL)
+ if (styleContext == nullptr)
return;
GdkRGBA colourBaseSelected;
@@ -1399,12 +1404,12 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
gtk_widget_override_background_color(w, GTK_STATE_FLAG_ACTIVE, &colourBaseSelected);
#else
GtkStyle *style = gtk_widget_get_style(w);
- if (style == NULL)
+ if (style == nullptr)
return;
if (!gdk_color_equal(&style->base[GTK_STATE_SELECTED], &style->base[GTK_STATE_ACTIVE]))
gtk_widget_modify_base(w, GTK_STATE_ACTIVE, &style->base[GTK_STATE_SELECTED]);
style = gtk_widget_get_style(w);
- if (style == NULL)
+ if (style == nullptr)
return;
if (!gdk_color_equal(&style->text[GTK_STATE_SELECTED], &style->text[GTK_STATE_ACTIVE]))
gtk_widget_modify_text(w, GTK_STATE_ACTIVE, &style->text[GTK_STATE_SELECTED]);
@@ -1412,7 +1417,7 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
}
void ListBoxX::Create(Window &parent, int, Point, int, bool, int) {
- if (widCached != 0) {
+ if (widCached != nullptr) {
wid = widCached;
return;
}
@@ -1425,13 +1430,13 @@ void ListBoxX::Create(Window &parent, int, Point, int, bool, int) {
wid = widCached = gtk_window_new(GTK_WINDOW_POPUP);
- frame = gtk_frame_new(NULL);
+ frame = gtk_frame_new(nullptr);
gtk_widget_show(PWidget(frame));
gtk_container_add(GTK_CONTAINER(GetID()), PWidget(frame));
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
- scroller = g_object_new(small_scroller_get_type(), NULL);
+ scroller = g_object_new(small_scroller_get_type(), nullptr);
gtk_container_set_border_width(GTK_CONTAINER(scroller), 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -1443,7 +1448,7 @@ void ListBoxX::Create(Window &parent, int, Point, int, bool, int) {
gtk_list_store_new(N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING);
list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- g_signal_connect(G_OBJECT(list), "style-set", G_CALLBACK(StyleSet), NULL);
+ g_signal_connect(G_OBJECT(list), "style-set", G_CALLBACK(StyleSet), nullptr);
#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *styleContext = gtk_widget_get_style_context(GTK_WIDGET(list));
@@ -1478,7 +1483,7 @@ void ListBoxX::Create(Window &parent, int, Point, int, bool, int) {
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
if (g_object_class_find_property(G_OBJECT_GET_CLASS(list), "fixed-height-mode"))
- g_object_set(G_OBJECT(list), "fixed-height-mode", TRUE, NULL);
+ g_object_set(G_OBJECT(list), "fixed-height-mode", TRUE, nullptr);
GtkWidget *widget = PWidget(list); // No code inside the G_OBJECT macro
gtk_container_add(GTK_CONTAINER(PWidget(scroller)), widget);
@@ -1508,7 +1513,7 @@ void ListBoxX::SetFont(Font &font) {
// On GTK < 3.21.0 the units are incorrectly parsed, so a font size in points
// need to use the "px" unit. Normally we only get fonts in points here, so
// don't bother to handle the case the font is actually in pixels on < 3.21.0.
- if (gtk_check_version(3, 21, 0) != NULL || // on < 3.21.0
+ if (gtk_check_version(3, 21, 0) != nullptr || // on < 3.21.0
pango_font_description_get_size_is_absolute(pfd)) {
ssFontSetting << "px; ";
} else {
@@ -1517,7 +1522,7 @@ void ListBoxX::SetFont(Font &font) {
ssFontSetting << "font-weight:"<< pango_font_description_get_weight(pfd) << "; ";
ssFontSetting << "}";
gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(cssProvider),
- ssFontSetting.str().c_str(), -1, NULL);
+ ssFontSetting.str().c_str(), -1, nullptr);
}
#else
gtk_widget_modify_font(PWidget(list), PFont(font)->pfd);
@@ -1555,7 +1560,7 @@ PRectangle ListBoxX::GetDesiredRect() {
// This, apparently unnecessary call, ensures gtk_tree_view_column_cell_get_size
// returns reasonable values.
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_get_preferred_size(GTK_WIDGET(frame), NULL, &req);
+ gtk_widget_get_preferred_size(GTK_WIDGET(frame), nullptr, &req);
#else
gtk_widget_size_request(GTK_WIDGET(frame), &req);
#endif
@@ -1585,7 +1590,7 @@ PRectangle ListBoxX::GetDesiredRect() {
gtk_style_context_get_border(styleContextFrameBorder, stateFlagsFrame, &border_border);
g_object_unref(styleContextFrameBorder);
# else // < 3.20
- if (gtk_check_version(3, 20, 0) == NULL) {
+ if (gtk_check_version(3, 20, 0) == nullptr) {
// default to 1px all around as it's likely what it is, and so we don't miss 2px height
// on GTK 3.20 when built against an earlier version.
border_border.top = border_border.bottom = border_border.left = border_border.right = 1;
@@ -1611,7 +1616,7 @@ PRectangle ListBoxX::GetDesiredRect() {
// Add horizontal padding and borders
int horizontal_separator=0;
gtk_widget_style_get(PWidget(list),
- "horizontal-separator", &horizontal_separator, NULL);
+ "horizontal-separator", &horizontal_separator, nullptr);
rc.right += horizontal_separator;
#if GTK_CHECK_VERSION(3,0,0)
rc.right += (padding.left + padding.right
@@ -1627,7 +1632,7 @@ PRectangle ListBoxX::GetDesiredRect() {
GtkWidget *vscrollbar =
gtk_scrolled_window_get_vscrollbar(GTK_SCROLLED_WINDOW(scroller));
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_get_preferred_size(vscrollbar, NULL, &req);
+ gtk_widget_get_preferred_size(vscrollbar, nullptr, &req);
#else
gtk_widget_size_request(vscrollbar, &req);
#endif
@@ -1663,15 +1668,15 @@ static void init_pixmap(ListImage *list_image) {
list_image->rgba_data->GetWidth(),
list_image->rgba_data->GetHeight(),
list_image->rgba_data->GetWidth() * 4,
- NULL,
- NULL);
+ nullptr,
+ nullptr);
}
}
#define SPACING 5
void ListBoxX::Append(char *s, int type) {
- ListImage *list_image = NULL;
+ ListImage *list_image = nullptr;
if ((type >= 0) && pixhash) {
list_image = static_cast<ListImage *>(g_hash_table_lookup((GHashTable *) pixhash
, (gconstpointer) GINT_TO_POINTER(type)));
@@ -1681,7 +1686,7 @@ void ListBoxX::Append(char *s, int type) {
GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
gtk_list_store_append(GTK_LIST_STORE(store), &iter);
if (list_image) {
- if (NULL == list_image->pixbuf)
+ if (nullptr == list_image->pixbuf)
init_pixmap(list_image);
if (list_image->pixbuf) {
gtk_list_store_set(GTK_LIST_STORE(store), &iter,
@@ -1711,7 +1716,7 @@ void ListBoxX::Append(char *s, int type) {
int ListBoxX::Length() {
if (wid)
return gtk_tree_model_iter_n_children(gtk_tree_view_get_model
- (GTK_TREE_VIEW(list)), NULL);
+ (GTK_TREE_VIEW(list)), nullptr);
return 0;
}
@@ -1726,7 +1731,7 @@ void ListBoxX::Select(int n) {
return;
}
- bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n) != FALSE;
+ bool valid = gtk_tree_model_iter_nth_child(model, &iter, nullptr, n) != FALSE;
if (valid) {
gtk_tree_selection_select_iter(selection, &iter);
@@ -1777,7 +1782,7 @@ int ListBoxX::GetSelection() {
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
- int *indices = gtk_tree_path_get_indices(path);
+ const int *indices = gtk_tree_path_get_indices(path);
// Don't free indices.
if (indices)
index = indices[0];
@@ -1807,10 +1812,10 @@ int ListBoxX::Find(const char *prefix) {
}
void ListBoxX::GetValue(int n, char *value, int len) {
- char *text = NULL;
+ char *text = nullptr;
GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
- bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n) != FALSE;
+ bool valid = gtk_tree_model_iter_nth_child(model, &iter, nullptr, n) != FALSE;
if (valid) {
gtk_tree_model_get(model, &iter, TEXT_COLUMN, &text, -1);
}
@@ -1839,7 +1844,7 @@ void ListBoxX::RegisterRGBA(int type, RGBAImage *image) {
// Drop icon already registered
if (list_image->pixbuf)
g_object_unref(list_image->pixbuf);
- list_image->pixbuf = NULL;
+ list_image->pixbuf = nullptr;
list_image->rgba_data = image;
} else {
list_image = g_new0(ListImage, 1);
@@ -1872,7 +1877,7 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) {
int count = strlen(listText) + 1;
std::vector<char> words(listText, listText+count);
char *startword = &words[0];
- char *numword = NULL;
+ char *numword = nullptr;
int i = 0;
for (; words[i]; i++) {
if (words[i] == separator) {
@@ -1881,7 +1886,7 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) {
*numword = '\0';
Append(startword, numword?atoi(numword + 1):-1);
startword = &words[0] + i + 1;
- numword = NULL;
+ numword = nullptr;
} else if (words[i] == typesep) {
numword = &words[0] + i;
}
@@ -1893,7 +1898,7 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) {
}
}
-Menu::Menu() noexcept : mid(0) {}
+Menu::Menu() noexcept : mid(nullptr) {}
void Menu::CreatePopUp() {
Destroy();
@@ -1904,7 +1909,7 @@ void Menu::CreatePopUp() {
void Menu::Destroy() {
if (mid)
g_object_unref(G_OBJECT(mid));
- mid = 0;
+ mid = nullptr;
}
#if !GTK_CHECK_VERSION(3,22,0)
@@ -1920,12 +1925,12 @@ void Menu::Show(Point pt, Window &w) {
gtk_widget_show_all(GTK_WIDGET(widget));
#if GTK_CHECK_VERSION(3,22,0)
// Rely on GTK+ to do the right thing with positioning
- gtk_menu_popup_at_pointer(widget, NULL);
+ gtk_menu_popup_at_pointer(widget, nullptr);
#else
GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(w.GetID()));
GtkRequisition requisition;
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_get_preferred_size(GTK_WIDGET(widget), NULL, &requisition);
+ gtk_widget_get_preferred_size(GTK_WIDGET(widget), nullptr, &requisition);
#else
gtk_widget_size_request(GTK_WIDGET(widget), &requisition);
#endif
@@ -1935,7 +1940,7 @@ void Menu::Show(Point pt, Window &w) {
if ((pt.y + requisition.height) > rcMonitor.y + rcMonitor.height) {
pt.y = rcMonitor.y + rcMonitor.height - requisition.height;
}
- gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc,
+ gtk_menu_popup(widget, nullptr, nullptr, MenuPositionFunc,
GINT_TO_POINTER((static_cast<int>(pt.y) << 16) | static_cast<int>(pt.x)), 0,
gtk_get_current_event_time());
#endif
@@ -1945,31 +1950,31 @@ class DynamicLibraryImpl : public DynamicLibrary {
protected:
GModule* m;
public:
- explicit DynamicLibraryImpl(const char *modulePath) {
+ explicit DynamicLibraryImpl(const char *modulePath) noexcept {
m = g_module_open(modulePath, G_MODULE_BIND_LAZY);
}
~DynamicLibraryImpl() override {
- if (m != NULL)
+ if (m != nullptr)
g_module_close(m);
}
// Use g_module_symbol to get a pointer to the relevant function.
Function FindFunction(const char *name) override {
- if (m != NULL) {
- gpointer fn_address = NULL;
+ if (m != nullptr) {
+ gpointer fn_address = nullptr;
gboolean status = g_module_symbol(m, name, &fn_address);
if (status)
return static_cast<Function>(fn_address);
else
- return NULL;
+ return nullptr;
} else {
- return NULL;
+ return nullptr;
}
}
bool IsValid() override {
- return m != NULL;
+ return m != nullptr;
}
};
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index cca365975..12b1aa4dd 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -130,11 +130,11 @@ enum {
TARGET_URI
};
-GdkAtom ScintillaGTK::atomClipboard = 0;
-GdkAtom ScintillaGTK::atomUTF8 = 0;
-GdkAtom ScintillaGTK::atomString = 0;
-GdkAtom ScintillaGTK::atomUriList = 0;
-GdkAtom ScintillaGTK::atomDROPFILES_DND = 0;
+GdkAtom ScintillaGTK::atomClipboard = nullptr;
+GdkAtom ScintillaGTK::atomUTF8 = nullptr;
+GdkAtom ScintillaGTK::atomString = nullptr;
+GdkAtom ScintillaGTK::atomUriList = nullptr;
+GdkAtom ScintillaGTK::atomDROPFILES_DND = nullptr;
static const GtkTargetEntry clipboardCopyTargets[] = {
{ (gchar *) "UTF8_STRING", 0, TARGET_UTF8_STRING },
@@ -161,24 +161,25 @@ ScintillaGTK *ScintillaGTK::FromWidget(GtkWidget *widget) {
}
ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
- adjustmentv(0), adjustmenth(0),
+ adjustmentv(nullptr), adjustmenth(nullptr),
verticalScrollBarWidth(30), horizontalScrollBarHeight(30),
evbtn(nullptr),
buttonMouse(0),
capturedMouse(false), dragWasDropped(false),
lastKey(0), rectangularSelectionModifier(SCMOD_CTRL),
- parentClass(0),
- atomSought(0),
- im_context(NULL), lastNonCommonScript(PANGO_SCRIPT_INVALID_CODE),
+ parentClass(nullptr),
+ atomSought(nullptr),
+ im_context(nullptr),
+ lastNonCommonScript(PANGO_SCRIPT_INVALID_CODE),
lastWheelMouseDirection(0),
wheelMouseIntensity(0),
smoothScrollY(0),
smoothScrollX(0),
- rgnUpdate(0),
+ rgnUpdate(nullptr),
repaintFullWindow(false),
styleIdleID(0),
accessibilityEnabled(SC_ACCESSIBILITY_ENABLED),
- accessible(0) {
+ accessible(nullptr) {
sci = sci_;
wMain = GTK_WIDGET(sci);
@@ -279,9 +280,9 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
gtk_im_context_set_client_window(im_context, WindowFromWidget(widget));
GtkWidget *widtxt = PWidget(wText); // // No code inside the G_OBJECT macro
g_signal_connect_after(G_OBJECT(widtxt), "style_set",
- G_CALLBACK(ScintillaGTK::StyleSetText), NULL);
+ G_CALLBACK(ScintillaGTK::StyleSetText), nullptr);
g_signal_connect_after(G_OBJECT(widtxt), "realize",
- G_CALLBACK(ScintillaGTK::RealizeText), NULL);
+ G_CALLBACK(ScintillaGTK::RealizeText), nullptr);
gtk_widget_realize(widtxt);
gtk_widget_realize(PWidget(scrollbarv));
gtk_widget_realize(PWidget(scrollbarh));
@@ -327,7 +328,7 @@ void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
gtk_widget_unrealize(PWidget(wPreedit));
gtk_widget_unrealize(PWidget(wPreeditDraw));
g_object_unref(im_context);
- im_context = NULL;
+ im_context = nullptr;
if (GTK_WIDGET_CLASS(parentClass)->unrealize)
GTK_WIDGET_CLASS(parentClass)->unrealize(widget);
@@ -408,7 +409,7 @@ void ScintillaGTK::ForAll(GtkCallback callback, gpointer callback_data) {
void ScintillaGTK::MainForAll(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data) {
ScintillaGTK *sciThis = FromWidget((GtkWidget *)container);
- if (callback != NULL && include_internals) {
+ if (callback && include_internals) {
sciThis->ForAll(callback, callback_data);
}
}
@@ -427,7 +428,7 @@ public:
explicit PreEditString(GtkIMContext *im_context) {
gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
- validUTF8 = g_utf8_validate(str, strlen(str), NULL);
+ validUTF8 = g_utf8_validate(str, strlen(str), nullptr);
uniStr = g_utf8_to_ucs4_fast(str, strlen(str), &uniStrLen);
pscript = pango_script_for_unichar(uniStr[0]);
}
@@ -443,9 +444,9 @@ public:
gint ScintillaGTK::FocusInThis(GtkWidget *) {
try {
SetFocusState(true);
- if (im_context != NULL) {
+ if (im_context) {
PreEditString pes(im_context);
- if (PWidget(wPreedit) != NULL) {
+ if (PWidget(wPreedit)) {
if (strlen(pes.str) > 0) {
gtk_widget_show(PWidget(wPreedit));
} else {
@@ -470,9 +471,9 @@ gint ScintillaGTK::FocusOutThis(GtkWidget *) {
try {
SetFocusState(false);
- if (PWidget(wPreedit) != NULL)
+ if (PWidget(wPreedit))
gtk_widget_hide(PWidget(wPreedit));
- if (im_context != NULL)
+ if (im_context)
gtk_im_context_focus_out(im_context);
} catch (...) {
@@ -492,8 +493,8 @@ void ScintillaGTK::SizeRequest(GtkWidget *widget, GtkRequisition *requisition) {
requisition->height = 1;
GtkRequisition child_requisition;
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_get_preferred_size(PWidget(sciThis->scrollbarh), NULL, &child_requisition);
- gtk_widget_get_preferred_size(PWidget(sciThis->scrollbarv), NULL, &child_requisition);
+ gtk_widget_get_preferred_size(PWidget(sciThis->scrollbarh), nullptr, &child_requisition);
+ gtk_widget_get_preferred_size(PWidget(sciThis->scrollbarv), nullptr, &child_requisition);
#else
gtk_widget_size_request(PWidget(sciThis->scrollbarh), &child_requisition);
gtk_widget_size_request(PWidget(sciThis->scrollbarv), &child_requisition);
@@ -577,7 +578,7 @@ void ScintillaGTK::Init() {
#if GTK_CHECK_VERSION(3,0,0)
// we need a runtime check because we don't want double buffering when
// running on >= 3.9.2
- if (gtk_check_version(3,9,2) != NULL /* on < 3.9.2 */)
+ if (gtk_check_version(3,9,2) != nullptr /* on < 3.9.2 */)
#endif
{
#if !GTK_CHECK_VERSION(3,14,0)
@@ -636,14 +637,14 @@ void ScintillaGTK::Init() {
if (g_object_class_find_property(G_OBJECT_GET_CLASS(
G_OBJECT(gtk_settings_get_default())), "gtk-cursor-blink")) {
g_object_get(G_OBJECT(
- gtk_settings_get_default()), "gtk-cursor-blink", &blinkOn, NULL);
+ gtk_settings_get_default()), "gtk-cursor-blink", &blinkOn, nullptr);
}
if (blinkOn &&
g_object_class_find_property(G_OBJECT_GET_CLASS(
G_OBJECT(gtk_settings_get_default())), "gtk-cursor-blink-time")) {
gint value;
g_object_get(G_OBJECT(
- gtk_settings_get_default()), "gtk-cursor-blink-time", &value, NULL);
+ gtk_settings_get_default()), "gtk-cursor-blink-time", &value, nullptr);
caret.period = gint(value / 1.75);
} else {
caret.period = 0;
@@ -664,9 +665,9 @@ void ScintillaGTK::Finalise() {
FineTickerCancel(tr);
}
if (accessible) {
- gtk_accessible_set_widget(GTK_ACCESSIBLE(accessible), NULL);
+ gtk_accessible_set_widget(GTK_ACCESSIBLE(accessible), nullptr);
g_object_unref(accessible);
- accessible = 0;
+ accessible = nullptr;
}
ScintillaBase::Finalise();
@@ -907,7 +908,7 @@ bool ScintillaGTK::SetIdle(bool on) {
if (!idler.state) {
idler.state = true;
idler.idlerID = GUINT_TO_POINTER(
- gdk_threads_add_idle_full(G_PRIORITY_DEFAULT_IDLE, IdleCallback, this, NULL));
+ gdk_threads_add_idle_full(G_PRIORITY_DEFAULT_IDLE, IdleCallback, this, nullptr));
}
} else {
// Stop idler, if it's running
@@ -1183,7 +1184,7 @@ CaseFolder *ScintillaGTK::CaseFolderForEncoding() {
return new CaseFolderDBCS(charSetBuffer);
}
}
- return 0;
+ return nullptr;
}
}
@@ -1262,7 +1263,7 @@ void ScintillaGTK::Paste() {
atomSought = atomUTF8;
GtkClipboard *clipBoard =
gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard);
- if (clipBoard == NULL)
+ if (clipBoard == nullptr)
return;
// helper class for the asynchronous paste not to risk calling in a destroyed ScintillaGTK
@@ -1270,7 +1271,7 @@ void ScintillaGTK::Paste() {
ScintillaGTK *sci;
void Destroyed() override {
- sci = 0;
+ sci = nullptr;
}
public:
@@ -1281,7 +1282,7 @@ void ScintillaGTK::Paste() {
static void ClipboardReceived(GtkClipboard *, GtkSelectionData *selection_data, gpointer data) {
Helper *self = static_cast<Helper*>(data);
- if (self->sci != 0) {
+ if (self->sci) {
self->sci->ReceivedSelection(selection_data);
}
delete self;
@@ -1338,7 +1339,7 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) {
bool ScintillaGTK::OwnPrimarySelection() {
return (wSelection.Created() &&
(gdk_selection_owner_get(GDK_SELECTION_PRIMARY) == PWindow(wSelection)) &&
- (PWindow(wSelection) != NULL));
+ (PWindow(wSelection) != nullptr));
}
void ScintillaGTK::ClaimSelection() {
@@ -1352,7 +1353,7 @@ void ScintillaGTK::ClaimSelection() {
} else if (OwnPrimarySelection()) {
primarySelection = true;
if (primary.Empty())
- gtk_selection_owner_set(NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
+ gtk_selection_owner_set(nullptr, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
} else {
primarySelection = false;
primary.Clear();
@@ -1521,7 +1522,7 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
void ScintillaGTK::StoreOnClipboard(SelectionText *clipText) {
GtkClipboard *clipBoard =
gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard);
- if (clipBoard == NULL) // Occurs if widget isn't in a toplevel
+ if (clipBoard == nullptr) // Occurs if widget isn't in a toplevel
return;
if (gtk_clipboard_set_with_data(clipBoard, clipboardCopyTargets, nClipboardCopyTargets,
@@ -1638,7 +1639,7 @@ void ScintillaGTK::Resize(int width, int height) {
#if GTK_CHECK_VERSION(3, 0, 0)
// please GTK 3.20 and ask wText what size it wants, although we know it doesn't really need
// anything special as it's ours.
- gtk_widget_get_preferred_size(PWidget(wText), &requisition, NULL);
+ gtk_widget_get_preferred_size(PWidget(wText), &requisition, nullptr);
alloc.width = requisition.width;
alloc.height = requisition.height;
#endif
@@ -1808,7 +1809,7 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) {
ScintillaGTK *sciThis = FromWidget(widget);
try {
- if (widget == NULL || event == NULL)
+ if (widget == nullptr || event == nullptr)
return FALSE;
#if defined(GDK_WINDOWING_WAYLAND)
@@ -2347,7 +2348,7 @@ void ScintillaGTK::PreeditChangedInlineThis() {
PreEditString preeditStr(im_context);
const char *charSetSource = CharacterSetID();
- if (!preeditStr.validUTF8 || (charSetSource == NULL)) {
+ if (!preeditStr.validUTF8 || (charSetSource == nullptr)) {
ShowCaretAtCurrentPosition();
return;
}
@@ -2444,7 +2445,7 @@ void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) {
}
void ScintillaGTK::StyleSetText(GtkWidget *widget, GtkStyle *, void*) {
- RealizeText(widget, NULL);
+ RealizeText(widget, nullptr);
}
void ScintillaGTK::RealizeText(GtkWidget *widget, void*) {
@@ -2453,9 +2454,9 @@ void ScintillaGTK::RealizeText(GtkWidget *widget, void*) {
#if GTK_CHECK_VERSION(3,22,0)
// Appears unnecessary
#elif GTK_CHECK_VERSION(3,0,0)
- gdk_window_set_background_pattern(WindowFromWidget(widget), NULL);
+ gdk_window_set_background_pattern(WindowFromWidget(widget), nullptr);
#else
- gdk_window_set_back_pixmap(WindowFromWidget(widget), NULL, FALSE);
+ gdk_window_set_back_pixmap(WindowFromWidget(widget), nullptr, FALSE);
#endif
}
}
@@ -2469,12 +2470,12 @@ void ScintillaGTK::Dispose(GObject *object) {
if (PWidget(sciThis->scrollbarv)) {
gtk_widget_unparent(PWidget(sciThis->scrollbarv));
- sciThis->scrollbarv = NULL;
+ sciThis->scrollbarv = nullptr;
}
if (PWidget(sciThis->scrollbarh)) {
gtk_widget_unparent(PWidget(sciThis->scrollbarh));
- sciThis->scrollbarh = NULL;
+ sciThis->scrollbarh = nullptr;
}
scintilla_class_parent_class->dispose(object);
@@ -2495,7 +2496,7 @@ void ScintillaGTK::Destroy(GObject *object) {
sciThis->Finalise();
delete sciThis;
- scio->pscin = 0;
+ scio->pscin = nullptr;
scintilla_class_parent_class->finalize(object);
} catch (...) {
// Its dead so nowhere to save the status
@@ -2511,7 +2512,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) {
rcPaint = GetClientRectangle();
- PLATFORM_ASSERT(rgnUpdate == NULL);
+ PLATFORM_ASSERT(rgnUpdate == nullptr);
rgnUpdate = cairo_copy_clip_rectangle_list(cr);
if (rgnUpdate && rgnUpdate->status != CAIRO_STATUS_SUCCESS) {
// If not successful then ignore
@@ -2584,7 +2585,7 @@ gboolean ScintillaGTK::DrawThis(cairo_t *cr) {
// or keep the default handler
#if GTK_CHECK_VERSION(3,0,0)
// we want to forward on any >= 3.9.2 runtime
- if (gtk_check_version(3,9,2) == NULL) {
+ if (gtk_check_version(3,9,2) == nullptr) {
gtk_container_propagate_draw(
GTK_CONTAINER(PWidget(wMain)), PWidget(wText), cr);
}
@@ -2611,7 +2612,7 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os
rcPaint.right = ose->area.x + ose->area.width;
rcPaint.bottom = ose->area.y + ose->area.height;
- PLATFORM_ASSERT(rgnUpdate == NULL);
+ PLATFORM_ASSERT(rgnUpdate == nullptr);
rgnUpdate = gdk_region_copy(ose->region);
PRectangle rcClient = GetClientRectangle();
paintingAllText = rcPaint.Contains(rcClient);
@@ -2631,7 +2632,7 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os
if (rgnUpdate) {
gdk_region_destroy(rgnUpdate);
}
- rgnUpdate = 0;
+ rgnUpdate = nullptr;
} catch (...) {
errorStatus = SC_STATUS_FAILURE;
}
@@ -2856,13 +2857,13 @@ void ScintillaGTK::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo
Editor::QueueIdleWork(items, upTo);
if (!styleIdleID) {
// Only allow one style needed to be queued
- styleIdleID = gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE, StyleIdle, this, NULL);
+ styleIdleID = gdk_threads_add_idle_full(G_PRIORITY_HIGH_IDLE, StyleIdle, this, nullptr);
}
}
void ScintillaGTK::SetDocPointer(Document *document) {
- Document *oldDoc = 0;
- ScintillaGTKAccessible *sciAccessible = 0;
+ Document *oldDoc = nullptr;
+ ScintillaGTKAccessible *sciAccessible = nullptr;
if (accessible) {
sciAccessible = ScintillaGTKAccessible::FromAccessible(accessible);
if (sciAccessible && pdoc) {
@@ -2980,15 +2981,15 @@ GType scintilla_get_type() {
if (!scintilla_type) {
static GTypeInfo scintilla_info = {
(guint16) sizeof (ScintillaObjectClass),
- NULL, //(GBaseInitFunc)
- NULL, //(GBaseFinalizeFunc)
+ nullptr, //(GBaseInitFunc)
+ nullptr, //(GBaseFinalizeFunc)
(GClassInitFunc) scintilla_class_init,
- NULL, //(GClassFinalizeFunc)
- NULL, //gconstpointer data
+ nullptr, //(GClassFinalizeFunc)
+ nullptr, //gconstpointer data
(guint16) sizeof (ScintillaObject),
0, //n_preallocs
(GInstanceInitFunc) scintilla_init,
- NULL //(GTypeValueTable*)
+ nullptr //(GTypeValueTable*)
};
scintilla_type = g_type_register_static(
GTK_TYPE_CONTAINER, "ScintillaObject", &scintilla_info, (GTypeFlags) 0);
@@ -3074,8 +3075,8 @@ static void scintilla_class_init(ScintillaClass *klass) {
G_TYPE_FROM_CLASS(object_class),
sigflags,
G_STRUCT_OFFSET(ScintillaClass, command),
- NULL, //(GSignalAccumulator)
- NULL, //(gpointer)
+ nullptr, //(GSignalAccumulator)
+ nullptr, //(gpointer)
scintilla_marshal_VOID__INT_OBJECT,
G_TYPE_NONE,
2, G_TYPE_INT, GTK_TYPE_WIDGET);
@@ -3085,14 +3086,14 @@ static void scintilla_class_init(ScintillaClass *klass) {
G_TYPE_FROM_CLASS(object_class),
sigflags,
G_STRUCT_OFFSET(ScintillaClass, notify),
- NULL, //(GSignalAccumulator)
- NULL, //(gpointer)
+ nullptr, //(GSignalAccumulator)
+ nullptr, //(gpointer)
scintilla_marshal_VOID__INT_BOXED,
G_TYPE_NONE,
2, G_TYPE_INT, SCINTILLA_TYPE_NOTIFICATION);
- klass->command = NULL;
- klass->notify = NULL;
+ klass->command = nullptr;
+ klass->notify = nullptr;
scintilla_class_parent_class = G_OBJECT_CLASS(g_type_class_peek_parent(klass));
ScintillaGTK::ClassInit(object_class, widget_class, container_class);
} catch (...) {
@@ -3109,7 +3110,7 @@ static void scintilla_init(ScintillaObject *sci) {
/* legacy name for scintilla_object_new */
GtkWidget* scintilla_new() {
- GtkWidget *widget = GTK_WIDGET(g_object_new(scintilla_get_type(), NULL));
+ GtkWidget *widget = GTK_WIDGET(g_object_new(scintilla_get_type(), nullptr));
gtk_widget_set_direction(widget, GTK_TEXT_DIR_LTR);
return widget;
diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h
index 7cff34ff3..ab485ee96 100644
--- a/gtk/ScintillaGTK.h
+++ b/gtk/ScintillaGTK.h
@@ -99,7 +99,7 @@ private:
TickReason reason;
ScintillaGTK *scintilla;
guint timer;
- TimeThunk() : reason(tickCaret), scintilla(NULL), timer(0) {}
+ TimeThunk() : reason(tickCaret), scintilla(nullptr), timer(0) {}
};
TimeThunk timers[tickDwell+1];
bool FineTickerRunning(TickReason reason) override;
@@ -256,7 +256,7 @@ class GObjectWatcher {
PLATFORM_ASSERT(obj == weakRef);
Destroyed();
- weakRef = 0;
+ weakRef = nullptr;
}
static void WeakNotify(gpointer data, GObject *obj) {
@@ -278,7 +278,7 @@ public:
virtual void Destroyed() {}
bool IsDestroyed() const {
- return weakRef != 0;
+ return weakRef != nullptr;
}
};
diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx
index 510db1945..89e929b87 100644
--- a/gtk/ScintillaGTKAccessible.cxx
+++ b/gtk/ScintillaGTKAccessible.cxx
@@ -150,7 +150,7 @@ ScintillaGTKAccessible *ScintillaGTKAccessible::FromAccessible(GtkAccessible *ac
// FIXME: do we need the check below? GTK checks that in all methods, so maybe
GtkWidget *widget = gtk_accessible_get_widget(accessible);
if (! widget) {
- return 0;
+ return nullptr;
}
return SCINTILLA_OBJECT_ACCESSIBLE_GET_PRIVATE(accessible)->pscin;
@@ -166,16 +166,16 @@ ScintillaGTKAccessible::ScintillaGTKAccessible(GtkAccessible *accessible_, GtkWi
ScintillaGTKAccessible::~ScintillaGTKAccessible() {
if (gtk_accessible_get_widget(accessible)) {
- g_signal_handlers_disconnect_matched(sci->sci, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, this);
+ g_signal_handlers_disconnect_matched(sci->sci, G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
}
}
gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Sci::Position startByte, Sci::Position endByte) {
- g_return_val_if_fail(startByte >= 0, NULL);
+ g_return_val_if_fail(startByte >= 0, nullptr);
// FIXME: should we swap start/end if necessary?
- g_return_val_if_fail(endByte >= startByte, NULL);
+ g_return_val_if_fail(endByte >= startByte, nullptr);
- gchar *utf8Text = NULL;
+ gchar *utf8Text = nullptr;
const char *charSetBuffer;
// like TargetAsUTF8, but avoids a double conversion
@@ -210,7 +210,7 @@ gchar *ScintillaGTKAccessible::GetText(int startChar, int endChar) {
gchar *ScintillaGTKAccessible::GetTextAfterOffset(int charOffset,
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
- g_return_val_if_fail(charOffset >= 0, NULL);
+ g_return_val_if_fail(charOffset >= 0, nullptr);
Sci::Position startByte, endByte;
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
@@ -252,7 +252,7 @@ gchar *ScintillaGTKAccessible::GetTextAfterOffset(int charOffset,
default:
*startChar = *endChar = -1;
- return NULL;
+ return nullptr;
}
CharacterRangeFromByteRange(startByte, endByte, startChar, endChar);
@@ -261,7 +261,7 @@ gchar *ScintillaGTKAccessible::GetTextAfterOffset(int charOffset,
gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset,
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
- g_return_val_if_fail(charOffset >= 0, NULL);
+ g_return_val_if_fail(charOffset >= 0, nullptr);
Sci::Position startByte, endByte;
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
@@ -314,7 +314,7 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset,
default:
*startChar = *endChar = -1;
- return NULL;
+ return nullptr;
}
CharacterRangeFromByteRange(startByte, endByte, startChar, endChar);
@@ -323,7 +323,7 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset,
gchar *ScintillaGTKAccessible::GetTextAtOffset(int charOffset,
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
- g_return_val_if_fail(charOffset >= 0, NULL);
+ g_return_val_if_fail(charOffset >= 0, nullptr);
Sci::Position startByte, endByte;
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
@@ -376,7 +376,7 @@ gchar *ScintillaGTKAccessible::GetTextAtOffset(int charOffset,
default:
*startChar = *endChar = -1;
- return NULL;
+ return nullptr;
}
CharacterRangeFromByteRange(startByte, endByte, startChar, endChar);
@@ -386,7 +386,7 @@ gchar *ScintillaGTKAccessible::GetTextAtOffset(int charOffset,
#if ATK_CHECK_VERSION(2, 10, 0)
gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset,
AtkTextGranularity granularity, int *startChar, int *endChar) {
- g_return_val_if_fail(charOffset >= 0, NULL);
+ g_return_val_if_fail(charOffset >= 0, nullptr);
Sci::Position startByte, endByte;
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
@@ -408,7 +408,7 @@ gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset,
}
default:
*startChar = *endChar = -1;
- return NULL;
+ return nullptr;
}
CharacterRangeFromByteRange(startByte, endByte, startChar, endChar);
@@ -530,10 +530,10 @@ static AtkAttributeSet *AddTextColorAttribute(AtkAttributeSet *attributes, AtkTe
}
AtkAttributeSet *ScintillaGTKAccessible::GetAttributesForStyle(unsigned int styleNum) {
- AtkAttributeSet *attr_set = NULL;
+ AtkAttributeSet *attr_set = nullptr;
if (styleNum >= sci->vs.styles.size())
- return NULL;
+ return nullptr;
Style &style = sci->vs.styles[styleNum];
attr_set = AddTextAttribute(attr_set, ATK_TEXT_ATTR_FAMILY_NAME, g_strdup(style.fontName));
@@ -550,7 +550,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetAttributesForStyle(unsigned int styl
}
AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *startChar, int *endChar) {
- g_return_val_if_fail(charOffset >= -1, NULL);
+ g_return_val_if_fail(charOffset >= -1, nullptr);
Sci::Position byteOffset;
if (charOffset == -1) {
@@ -560,7 +560,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *s
}
int length = sci->pdoc->Length();
- g_return_val_if_fail(byteOffset <= length, NULL);
+ g_return_val_if_fail(byteOffset <= length, nullptr);
const char style = StyleAt(byteOffset, true);
// compute the range for this style
@@ -586,7 +586,7 @@ gint ScintillaGTKAccessible::GetNSelections() {
gchar *ScintillaGTKAccessible::GetSelection(gint selection_num, int *startChar, int *endChar) {
if (selection_num < 0 || (unsigned int) selection_num >= sci->sel.Count())
- return NULL;
+ return nullptr;
Sci::Position startByte = sci->sel.Range(selection_num).Start().Position();
Sci::Position endByte = sci->sel.Range(selection_num).End().Position();
@@ -740,7 +740,7 @@ void ScintillaGTKAccessible::PasteText(int charPosition) {
Sci::Position bytePosition;
void Destroyed() override {
- scia = 0;
+ scia = nullptr;
}
Helper(ScintillaGTKAccessible *scia_, Sci::Position bytePos_) :
@@ -766,7 +766,7 @@ void ScintillaGTKAccessible::PasteText(int charPosition) {
static void TextReceivedCallback(GtkClipboard *clipboard, const gchar *text, gpointer data) {
Helper *helper = static_cast<Helper*>(data);
try {
- if (helper->scia != 0) {
+ if (helper->scia != nullptr) {
helper->TextReceived(clipboard, text);
}
} catch (...) {}
@@ -928,20 +928,20 @@ void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) {
// AtkText
gchar *ScintillaGTKAccessible::AtkTextIface::GetText(AtkText *text, int start_offset, int end_offset) {
- WRAPPER_METHOD_BODY(text, GetText(start_offset, end_offset), NULL);
+ WRAPPER_METHOD_BODY(text, GetText(start_offset, end_offset), nullptr);
}
gchar *ScintillaGTKAccessible::AtkTextIface::GetTextAfterOffset(AtkText *text, int offset, AtkTextBoundary boundary_type, int *start_offset, int *end_offset) {
- WRAPPER_METHOD_BODY(text, GetTextAfterOffset(offset, boundary_type, start_offset, end_offset), NULL)
+ WRAPPER_METHOD_BODY(text, GetTextAfterOffset(offset, boundary_type, start_offset, end_offset), nullptr)
}
gchar *ScintillaGTKAccessible::AtkTextIface::GetTextBeforeOffset(AtkText *text, int offset, AtkTextBoundary boundary_type, int *start_offset, int *end_offset) {
- WRAPPER_METHOD_BODY(text, GetTextBeforeOffset(offset, boundary_type, start_offset, end_offset), NULL)
+ WRAPPER_METHOD_BODY(text, GetTextBeforeOffset(offset, boundary_type, start_offset, end_offset), nullptr)
}
gchar *ScintillaGTKAccessible::AtkTextIface::GetTextAtOffset(AtkText *text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) {
- WRAPPER_METHOD_BODY(text, GetTextAtOffset(offset, boundary_type, start_offset, end_offset), NULL)
+ WRAPPER_METHOD_BODY(text, GetTextAtOffset(offset, boundary_type, start_offset, end_offset), nullptr)
}
#if ATK_CHECK_VERSION(2, 10, 0)
gchar *ScintillaGTKAccessible::AtkTextIface::GetStringAtOffset(AtkText *text, gint offset, AtkTextGranularity granularity, gint *start_offset, gint *end_offset) {
- WRAPPER_METHOD_BODY(text, GetStringAtOffset(offset, granularity, start_offset, end_offset), NULL)
+ WRAPPER_METHOD_BODY(text, GetStringAtOffset(offset, granularity, start_offset, end_offset), nullptr)
}
#endif
gunichar ScintillaGTKAccessible::AtkTextIface::GetCharacterAtOffset(AtkText *text, gint offset) {
@@ -963,16 +963,16 @@ void ScintillaGTKAccessible::AtkTextIface::GetCharacterExtents(AtkText *text, gi
WRAPPER_METHOD_BODY(text, GetCharacterExtents(offset, x, y, width, height, coords), )
}
AtkAttributeSet *ScintillaGTKAccessible::AtkTextIface::GetRunAttributes(AtkText *text, gint offset, gint *start_offset, gint *end_offset) {
- WRAPPER_METHOD_BODY(text, GetRunAttributes(offset, start_offset, end_offset), NULL)
+ WRAPPER_METHOD_BODY(text, GetRunAttributes(offset, start_offset, end_offset), nullptr)
}
AtkAttributeSet *ScintillaGTKAccessible::AtkTextIface::GetDefaultAttributes(AtkText *text) {
- WRAPPER_METHOD_BODY(text, GetDefaultAttributes(), NULL)
+ WRAPPER_METHOD_BODY(text, GetDefaultAttributes(), nullptr)
}
gint ScintillaGTKAccessible::AtkTextIface::GetNSelections(AtkText *text) {
WRAPPER_METHOD_BODY(text, GetNSelections(), 0)
}
gchar *ScintillaGTKAccessible::AtkTextIface::GetSelection(AtkText *text, gint selection_num, gint *start_pos, gint *end_pos) {
- WRAPPER_METHOD_BODY(text, GetSelection(selection_num, start_pos, end_pos), NULL)
+ WRAPPER_METHOD_BODY(text, GetSelection(selection_num, start_pos, end_pos), nullptr)
}
gboolean ScintillaGTKAccessible::AtkTextIface::AddSelection(AtkText *text, gint start, gint end) {
WRAPPER_METHOD_BODY(text, AddSelection(start, end), FALSE)
@@ -1011,7 +1011,7 @@ static GType scintilla_object_accessible_factory_get_type(void);
static void scintilla_object_accessible_init(ScintillaObjectAccessible *accessible);
static void scintilla_object_accessible_class_init(ScintillaObjectAccessibleClass *klass);
-static gpointer scintilla_object_accessible_parent_class = NULL;
+static gpointer scintilla_object_accessible_parent_class = nullptr;
// @p parent_type is only required on GTK 3.2 to 3.6, and only on the first call
@@ -1021,27 +1021,27 @@ static GType scintilla_object_accessible_get_type(GType parent_type G_GNUC_UNUSE
if (g_once_init_enter(&type_id_result)) {
GTypeInfo tinfo = {
0, /* class size */
- (GBaseInitFunc) NULL, /* base init */
- (GBaseFinalizeFunc) NULL, /* base finalize */
+ (GBaseInitFunc) nullptr, /* base init */
+ (GBaseFinalizeFunc) nullptr, /* base finalize */
(GClassInitFunc) scintilla_object_accessible_class_init, /* class init */
- (GClassFinalizeFunc) NULL, /* class finalize */
- NULL, /* class data */
+ (GClassFinalizeFunc) nullptr, /* class finalize */
+ nullptr, /* class data */
0, /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) scintilla_object_accessible_init, /* instance init */
- NULL /* value table */
+ nullptr /* value table */
};
const GInterfaceInfo atk_text_info = {
(GInterfaceInitFunc) ScintillaGTKAccessible::AtkTextIface::init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
+ (GInterfaceFinalizeFunc) nullptr,
+ nullptr
};
const GInterfaceInfo atk_editable_text_info = {
(GInterfaceInitFunc) ScintillaGTKAccessible::AtkEditableTextIface::init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
+ (GInterfaceFinalizeFunc) nullptr,
+ nullptr
};
#if HAVE_GTK_A11Y_H
@@ -1082,13 +1082,13 @@ static GType scintilla_object_accessible_get_type(GType parent_type G_GNUC_UNUSE
}
static AtkObject *scintilla_object_accessible_new(GType parent_type, GObject *obj) {
- g_return_val_if_fail(SCINTILLA_IS_OBJECT(obj), NULL);
+ g_return_val_if_fail(SCINTILLA_IS_OBJECT(obj), nullptr);
AtkObject *accessible = (AtkObject *) g_object_new(scintilla_object_accessible_get_type(parent_type),
#if HAVE_WIDGET_SET_UNSET
"widget", obj,
#endif
- NULL);
+ nullptr);
atk_object_initialize(accessible, obj);
return accessible;
@@ -1100,7 +1100,7 @@ static AtkObject *scintilla_object_accessible_new(GType parent_type, GObject *ob
// @p cache pointer to store the AtkObject between repeated calls. Might or might not be filled.
// @p widget_parent_class pointer to the widget's parent class (to chain up method calls).
AtkObject *ScintillaGTKAccessible::WidgetGetAccessibleImpl(GtkWidget *widget, AtkObject **cache, gpointer widget_parent_class G_GNUC_UNUSED) {
- if (*cache != NULL) {
+ if (*cache != nullptr) {
return *cache;
}
@@ -1150,7 +1150,7 @@ static AtkStateSet *scintilla_object_accessible_ref_state_set(AtkObject *accessi
AtkStateSet *state_set = ATK_OBJECT_CLASS(scintilla_object_accessible_parent_class)->ref_state_set(accessible);
GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE(accessible));
- if (widget == NULL) {
+ 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))
@@ -1170,11 +1170,11 @@ static AtkStateSet *scintilla_object_accessible_ref_state_set(AtkObject *accessi
static void scintilla_object_accessible_widget_set(GtkAccessible *accessible) {
GtkWidget *widget = gtk_accessible_get_widget(accessible);
- if (widget == NULL)
+ if (widget == nullptr)
return;
ScintillaObjectAccessiblePrivate *priv = SCINTILLA_OBJECT_ACCESSIBLE_GET_PRIVATE(accessible);
- if (priv->pscin != 0)
+ if (priv->pscin)
delete priv->pscin;
priv->pscin = new ScintillaGTKAccessible(accessible, widget);
}
@@ -1182,7 +1182,7 @@ static void scintilla_object_accessible_widget_set(GtkAccessible *accessible) {
#if HAVE_WIDGET_SET_UNSET
static void scintilla_object_accessible_widget_unset(GtkAccessible *accessible) {
GtkWidget *widget = gtk_accessible_get_widget(accessible);
- if (widget == NULL)
+ if (widget == nullptr)
return;
ScintillaObjectAccessiblePrivate *priv = SCINTILLA_OBJECT_ACCESSIBLE_GET_PRIVATE(accessible);
@@ -1206,7 +1206,7 @@ static void scintilla_object_accessible_finalize(GObject *object) {
if (priv->pscin) {
delete priv->pscin;
- priv->pscin = 0;
+ priv->pscin = nullptr;
}
G_OBJECT_CLASS(scintilla_object_accessible_parent_class)->finalize(object);
@@ -1235,7 +1235,7 @@ static void scintilla_object_accessible_class_init(ScintillaObjectAccessibleClas
static void scintilla_object_accessible_init(ScintillaObjectAccessible *accessible) {
ScintillaObjectAccessiblePrivate *priv = SCINTILLA_OBJECT_ACCESSIBLE_GET_PRIVATE(accessible);
- priv->pscin = 0;
+ priv->pscin = nullptr;
}
#if HAVE_GTK_FACTORY