Update Scintilla to version 3.6.6

This commit is contained in:
Colomban Wendling 2016-05-22 20:02:28 +02:00
parent d7750a4479
commit 64025cfcfc
14 changed files with 160 additions and 110 deletions

View File

@ -10,21 +10,13 @@
namespace Scintilla {
#endif
typedef GIConv ConverterHandle;
const ConverterHandle iconvhBad = (ConverterHandle)(-1);
// Since various versions of iconv can not agree on whether the src argument
// is char ** or const char ** provide a templatised adaptor.
template<typename T>
size_t iconv_adaptor(size_t(*f_iconv)(ConverterHandle, T, size_t *, char **, size_t *),
ConverterHandle cd, char** src, size_t *srcleft,
char **dst, size_t *dstleft) {
return f_iconv(cd, (T)src, srcleft, dst, dstleft);
}
const GIConv iconvhBad = (GIConv)(-1);
const gsize sizeFailure = static_cast<gsize>(-1);
/**
* Encapsulate iconv safely and avoid iconv_adaptor complexity in client code.
* Encapsulate g_iconv safely.
*/
class Converter {
ConverterHandle iconvh;
GIConv iconvh;
void OpenHandle(const char *fullDestination, const char *charSetSource) {
iconvh = g_iconv_open(fullDestination, charSetSource);
}
@ -45,15 +37,14 @@ public:
operator bool() const {
return Succeeded();
}
void Open(const char *charSetDestination, const char *charSetSource, bool transliterations=true) {
void Open(const char *charSetDestination, const char *charSetSource, bool transliterations) {
Close();
if (*charSetSource) {
// Try allowing approximate transliterations
if (transliterations) {
char fullDest[200];
g_strlcpy(fullDest, charSetDestination, sizeof(fullDest));
g_strlcat(fullDest, "//TRANSLIT", sizeof(fullDest));
OpenHandle(fullDest, charSetSource);
std::string fullDest(charSetDestination);
fullDest.append("//TRANSLIT");
OpenHandle(fullDest.c_str(), charSetSource);
}
if (!Succeeded()) {
// Transliterations failed so try basic name
@ -67,11 +58,11 @@ public:
iconvh = iconvhBad;
}
}
size_t Convert(char** src, size_t *srcleft, char **dst, size_t *dstleft) const {
gsize Convert(char** src, gsize *srcleft, char **dst, gsize *dstleft) const {
if (!Succeeded()) {
return (size_t)(-1);
return sizeFailure;
} else {
return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft);
return g_iconv(iconvh, src, srcleft, dst, dstleft);
}
}
};

View File

@ -655,12 +655,12 @@ static std::string UTF8FromIconv(const Converter &conv, const char *s, int len)
if (conv) {
std::string utfForm(len*3+1, '\0');
char *pin = const_cast<char *>(s);
size_t inLeft = len;
gsize inLeft = len;
char *putf = &utfForm[0];
char *pout = putf;
size_t outLeft = len*3+1;
size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
if (conversions != ((size_t)(-1))) {
gsize outLeft = len*3+1;
gsize conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
if (conversions != sizeFailure) {
*pout = '\0';
utfForm.resize(pout - putf);
return utfForm;
@ -675,11 +675,11 @@ static size_t MultiByteLenFromIconv(const Converter &conv, const char *s, size_t
for (size_t lenMB=1; (lenMB<4) && (lenMB <= len); lenMB++) {
char wcForm[2];
char *pin = const_cast<char *>(s);
size_t inLeft = lenMB;
gsize inLeft = lenMB;
char *pout = wcForm;
size_t outLeft = 2;
size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
if (conversions != ((size_t)(-1))) {
gsize outLeft = 2;
gsize conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
if (conversions != sizeFailure) {
return lenMB;
}
}

View File

@ -933,15 +933,15 @@ static std::string ConvertText(const char *s, size_t len, const char *charSetDes
std::string destForm;
Converter conv(charSetDest, charSetSource, transliterations);
if (conv) {
size_t outLeft = len*3+1;
gsize outLeft = len*3+1;
destForm = std::string(outLeft, '\0');
// g_iconv does not actually write to its input argument so safe to cast away const
char *pin = const_cast<char *>(s);
size_t inLeft = len;
gsize inLeft = len;
char *putf = &destForm[0];
char *pout = putf;
size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
if (conversions == ((size_t)(-1))) {
gsize conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
if (conversions == sizeFailure) {
if (!silent) {
if (len == 1)
fprintf(stderr, "iconv %s->%s failed for %0x '%s'\n",
@ -1181,7 +1181,7 @@ void ScintillaGTK::FullPaint() {
}
PRectangle ScintillaGTK::GetClientRectangle() const {
Window &win = const_cast<Window &>(wMain);
Window win = wMain;
PRectangle rc = win.GetClientPosition();
if (verticalScrollBarVisible)
rc.right -= verticalScrollBarWidth;
@ -1736,14 +1736,21 @@ void ScintillaGTK::Resize(int width, int height) {
//Platform::DebugPrintf("Resize %d %d\n", width, height);
//printf("Resize %d %d\n", width, height);
// GTK+ 3 warns when we allocate smaller than the minimum allocation,
// so we use these variables to store the minimum scrollbar lengths.
int minVScrollBarHeight, minHScrollBarWidth;
// Not always needed, but some themes can have different sizes of scrollbars
#if GTK_CHECK_VERSION(3,0,0)
GtkRequisition requisition;
gtk_widget_get_preferred_size(PWidget(scrollbarv), NULL, &requisition);
GtkRequisition minimum, requisition;
gtk_widget_get_preferred_size(PWidget(scrollbarv), &minimum, &requisition);
minVScrollBarHeight = minimum.height;
verticalScrollBarWidth = requisition.width;
gtk_widget_get_preferred_size(PWidget(scrollbarh), NULL, &requisition);
gtk_widget_get_preferred_size(PWidget(scrollbarh), &minimum, &requisition);
minHScrollBarWidth = minimum.height;
horizontalScrollBarHeight = requisition.height;
#else
minVScrollBarHeight = minHScrollBarWidth = 1;
verticalScrollBarWidth = GTK_WIDGET(PWidget(scrollbarv))->requisition.width;
horizontalScrollBarHeight = GTK_WIDGET(PWidget(scrollbarh))->requisition.height;
#endif
@ -1757,7 +1764,7 @@ void ScintillaGTK::Resize(int width, int height) {
gtk_widget_show(GTK_WIDGET(PWidget(scrollbarh)));
alloc.x = 0;
alloc.y = height - horizontalScrollBarHeight;
alloc.width = Platform::Maximum(1, width - verticalScrollBarWidth);
alloc.width = Platform::Maximum(minHScrollBarWidth, width - verticalScrollBarWidth);
alloc.height = horizontalScrollBarHeight;
gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarh)), &alloc);
} else {
@ -1770,7 +1777,7 @@ void ScintillaGTK::Resize(int width, int height) {
alloc.x = width - verticalScrollBarWidth;
alloc.y = 0;
alloc.width = verticalScrollBarWidth;
alloc.height = Platform::Maximum(1, height - horizontalScrollBarHeight);
alloc.height = Platform::Maximum(minVScrollBarHeight, height - horizontalScrollBarHeight);
gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarv)), &alloc);
} else {
gtk_widget_hide(GTK_WIDGET(PWidget(scrollbarv)));
@ -3166,9 +3173,6 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_
container_class->forall = MainForAll;
}
#define SIG_MARSHAL scintilla_marshal_NONE__INT_POINTER
#define MARSHAL_ARGUMENTS G_TYPE_INT, G_TYPE_POINTER
static void scintilla_class_init(ScintillaClass *klass) {
try {
OBJECT_CLASS *object_class = (OBJECT_CLASS*) klass;
@ -3183,20 +3187,20 @@ static void scintilla_class_init(ScintillaClass *klass) {
G_STRUCT_OFFSET(ScintillaClass, command),
NULL, //(GSignalAccumulator)
NULL, //(gpointer)
SIG_MARSHAL,
scintilla_marshal_VOID__INT_OBJECT,
G_TYPE_NONE,
2, MARSHAL_ARGUMENTS);
2, G_TYPE_INT, GTK_TYPE_WIDGET);
scintilla_signals[NOTIFY_SIGNAL] = g_signal_new(
SCINTILLA_NOTIFY,
G_TYPE_FROM_CLASS(object_class),
sigflags,
G_STRUCT_OFFSET(ScintillaClass, notify),
NULL,
NULL,
SIG_MARSHAL,
NULL, //(GSignalAccumulator)
NULL, //(gpointer)
scintilla_marshal_VOID__INT_BOXED,
G_TYPE_NONE,
2, MARSHAL_ARGUMENTS);
2, G_TYPE_INT, SCINTILLA_TYPE_NOTIFICATION);
klass->command = NULL;
klass->notify = NULL;
@ -3239,3 +3243,21 @@ void scintilla_release_resources(void) {
} catch (...) {
}
}
/* Define a dummy boxed type because g-ir-scanner is unable to
* recognize gpointer-derived types. Note that SCNotificaiton
* is always allocated on stack so copying is not appropriate. */
static void *copy_(void *src) { return src; }
static void free_(void *doc) { }
GType scnotification_get_type(void) {
static gsize type_id = 0;
if (g_once_init_enter(&type_id)) {
gsize id = (gsize) g_boxed_type_register_static(
g_intern_static_string("SCNotification"),
(GBoxedCopyFunc) copy_,
(GBoxedFreeFunc) free_);
g_once_init_leave(&type_id, id);
}
return (GType) type_id;
}

View File

@ -4,7 +4,7 @@
#ifdef G_ENABLE_DEBUG
#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
#define g_marshal_value_peek_char(v) g_value_get_char (v)
#define g_marshal_value_peek_char(v) g_value_get_schar (v)
#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
#define g_marshal_value_peek_int(v) g_value_get_int (v)
#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
@ -21,6 +21,7 @@
#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
#define g_marshal_value_peek_object(v) g_value_get_object (v)
#define g_marshal_value_peek_variant(v) g_value_get_variant (v)
#else /* !G_ENABLE_DEBUG */
/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
* Do not access GValues directly in your code. Instead, use the
@ -44,25 +45,26 @@
#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
#endif /* !G_ENABLE_DEBUG */
/* NONE:INT,POINTER (scintilla-marshal.list:1) */
/* NONE:INT,OBJECT (scintilla-marshal.list:1) */
void
scintilla_marshal_VOID__INT_POINTER (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
typedef void (*GMarshalFunc_VOID__INT_POINTER) (gpointer data1,
gint arg_1,
gpointer arg_2,
gpointer data2);
register GMarshalFunc_VOID__INT_POINTER callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
typedef void (*GMarshalFunc_VOID__INT_OBJECT) (gpointer data1,
gint arg_1,
gpointer arg_2,
gpointer data2);
GMarshalFunc_VOID__INT_OBJECT callback;
GCClosure *cc = (GCClosure*) closure;
gpointer data1, data2;
g_return_if_fail (n_param_values == 3);
@ -76,11 +78,48 @@ scintilla_marshal_VOID__INT_POINTER (GClosure *closure,
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__INT_POINTER) (marshal_data ? marshal_data : cc->callback);
callback = (GMarshalFunc_VOID__INT_OBJECT) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_int (param_values + 1),
g_marshal_value_peek_pointer (param_values + 2),
g_marshal_value_peek_object (param_values + 2),
data2);
}
/* NONE:INT,BOXED (scintilla-marshal.list:2) */
void
scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1,
gint arg_1,
gpointer arg_2,
gpointer data2);
GMarshalFunc_VOID__INT_BOXED callback;
GCClosure *cc = (GCClosure*) closure;
gpointer data1, data2;
g_return_if_fail (n_param_values == 3);
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__INT_BOXED) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_int (param_values + 1),
g_marshal_value_peek_boxed (param_values + 2),
data2);
}

View File

@ -6,14 +6,23 @@
G_BEGIN_DECLS
/* NONE:INT,POINTER (scintilla-marshal.list:1) */
extern void scintilla_marshal_VOID__INT_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
#define scintilla_marshal_NONE__INT_POINTER scintilla_marshal_VOID__INT_POINTER
/* NONE:INT,OBJECT (scintilla-marshal.list:1) */
extern void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
#define scintilla_marshal_NONE__INT_OBJECT scintilla_marshal_VOID__INT_OBJECT
/* NONE:INT,BOXED (scintilla-marshal.list:2) */
extern void scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
#define scintilla_marshal_NONE__INT_BOXED scintilla_marshal_VOID__INT_BOXED
G_END_DECLS

View File

@ -1 +1,2 @@
NONE:INT,POINTER
NONE:INT,OBJECT
NONE:INT,BOXED

View File

@ -1121,6 +1121,13 @@ struct Sci_RangeToFormat {
#define RangeToFormat Sci_RangeToFormat
#ifndef __cplusplus
/* For the GTK+ platform, g-ir-scanner needs to have these typedefs. This
* is not required in C++ code and actually seems to break ScintillaEditPy */
typedef struct Sci_NotifyHeader Sci_NotifyHeader;
typedef struct SCNotification SCNotification;
#endif
struct Sci_NotifyHeader {
/* Compatible with Windows NMHDR.
* hwndFrom is really an environment specific window handle or pointer
@ -1133,7 +1140,7 @@ struct Sci_NotifyHeader {
#define NotifyHeader Sci_NotifyHeader
struct SCNotification {
struct Sci_NotifyHeader nmhdr;
Sci_NotifyHeader nmhdr;
Sci_Position position;
/* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, */
/* SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, */

View File

@ -4729,7 +4729,7 @@ evt void FocusIn=2028(void)
evt void FocusOut=2029(void)
evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod)
# There are no provisional features currently
# There are no provisional APIs currently, but some arguments to SCI_SETTECHNOLOGY are provisional.
cat Provisional

View File

@ -38,14 +38,18 @@ struct _ScintillaObject {
struct _ScintillaClass {
GtkContainerClass parent_class;
void (* command) (ScintillaObject *ttt);
void (* notify) (ScintillaObject *ttt);
void (* command) (ScintillaObject *sci, int cmd, GtkWidget *window);
void (* notify) (ScintillaObject *sci, int id, SCNotification *scn);
};
GType scintilla_object_get_type (void);
GtkWidget* scintilla_object_new (void);
gintptr scintilla_object_send_message (ScintillaObject *sci, unsigned int iMessage, guintptr wParam, gintptr lParam);
GType scnotification_get_type (void);
#define SCINTILLA_TYPE_NOTIFICATION (scnotification_get_type())
#ifndef G_IR_SCANNING
/* The legacy names confuse the g-ir-scanner program */
typedef struct _ScintillaClass ScintillaClass;

View File

@ -50,34 +50,6 @@ index 0871ca2..49dc278 100644
GtkWidget *scintilla_object_new() {
return scintilla_new();
}
diff --git scintilla/gtk/scintilla-marshal.c scintilla/gtk/scintilla-marshal.c
index be57b7c..cee3e73 100644
--- scintilla/gtk/scintilla-marshal.c
+++ scintilla/gtk/scintilla-marshal.c
@@ -35,8 +35,8 @@
#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
-#define g_marshal_value_peek_enum(v) (v)->data[0].v_int
-#define g_marshal_value_peek_flags(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
#define g_marshal_value_peek_float(v) (v)->data[0].v_float
#define g_marshal_value_peek_double(v) (v)->data[0].v_double
#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
@@ -50,10 +50,10 @@
/* NONE:INT,POINTER (scintilla-marshal.list:1) */
void
scintilla_marshal_VOID__INT_POINTER (GClosure *closure,
- GValue *return_value,
+ GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
- gpointer invocation_hint,
+ gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
typedef void (*GMarshalFunc_VOID__INT_POINTER) (gpointer data1,
diff --git scintilla/src/Catalogue.cxx scintilla/src/Catalogue.cxx
index ed47aa8..e58f1ab 100644
--- scintilla/src/Catalogue.cxx

View File

@ -16,7 +16,7 @@
#include <vector>
#include <algorithm>
#ifdef CXX11_REGEX
#ifndef NO_CXX11_REGEX
#include <regex>
#endif
@ -2336,7 +2336,7 @@ public:
}
};
#ifdef CXX11_REGEX
#ifndef NO_CXX11_REGEX
class ByteIterator : public std::iterator<std::bidirectional_iterator_tag, char> {
public:
@ -2696,7 +2696,7 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s
bool caseSensitive, bool, bool, int flags,
int *length) {
#ifdef CXX11_REGEX
#ifndef NO_CXX11_REGEX
if (flags & SCFIND_CXX11REGEX) {
return Cxx11RegexFindText(doc, minPos, maxPos, s,
caseSensitive, length, search);

View File

@ -303,7 +303,7 @@ int Editor::TopLineOfMain() const {
}
PRectangle Editor::GetClientRectangle() const {
Window &win = const_cast<Window &>(wMain);
Window win = wMain;
return win.GetClientPosition();
}
@ -828,6 +828,7 @@ void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos,
}
ShowCaretAtCurrentPosition();
NotifyCaretMove();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
@ -1437,6 +1438,9 @@ void Editor::InvalidateCaret() {
UpdateSystemCaret();
}
void Editor::NotifyCaretMove() {
}
void Editor::UpdateSystemCaret() {
}

View File

@ -365,6 +365,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void DropCaret();
void CaretSetPeriod(int period);
void InvalidateCaret();
virtual void NotifyCaretMove();
virtual void UpdateSystemCaret();
bool Wrapping() const;

View File

@ -1 +1 @@
365
366