aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/PlatGTK.cxx14
-rw-r--r--gtk/ScintillaGTK.cxx1475
-rw-r--r--gtk/scintilla.mak4
-rw-r--r--include/Scintilla.h3
-rw-r--r--include/Scintilla.iface5
-rw-r--r--src/Editor.h3
-rw-r--r--vcbuild/SciLexer.dsp6
-rw-r--r--win32/PlatWin.cxx84
-rw-r--r--win32/ScintillaWin.cxx1086
-rw-r--r--win32/makefile2
-rw-r--r--win32/scintilla.mak4
-rw-r--r--win32/scintilla_vc6.mak4
12 files changed, 1465 insertions, 1225 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index fecd3b965..9bc207896 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -2021,12 +2021,16 @@ static void SelectionAC(GtkWidget *, gint row, gint,
#endif
static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
- ListBoxX* lb = reinterpret_cast<ListBoxX*>(p);
- if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) {
- lb->doubleClickAction(lb->doubleClickActionData);
- return TRUE;
- }
+ try {
+ ListBoxX* lb = reinterpret_cast<ListBoxX*>(p);
+ if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) {
+ lb->doubleClickAction(lb->doubleClickActionData);
+ return TRUE;
+ }
+ } catch (...) {
+ // No pointer back to Scintilla to save status
+ }
return FALSE;
}
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 4256bca4a..e506dd1b4 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -3,6 +3,7 @@
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#include <new>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -220,7 +221,9 @@ private:
void UnMapThis();
static void UnMap(GtkWidget *widget);
static gint CursorMoved(GtkWidget *widget, int xoffset, int yoffset, ScintillaGTK *sciThis);
+ gint FocusInThis(GtkWidget *widget);
static gint FocusIn(GtkWidget *widget, GdkEventFocus *event);
+ gint FocusOutThis(GtkWidget *widget);
static gint FocusOut(GtkWidget *widget, GdkEventFocus *event);
static void SizeRequest(GtkWidget *widget, GtkRequisition *requisition);
static void SizeAllocate(GtkWidget *widget, GtkAllocation *allocation);
@@ -243,12 +246,12 @@ private:
static gboolean KeyPress(GtkWidget *widget, GdkEventKey *event);
static gboolean KeyRelease(GtkWidget *widget, GdkEventKey *event);
#if GTK_MAJOR_VERSION >= 2
- static gboolean ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis);
gboolean ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose);
- static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis);
+ static gboolean ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis);
void CommitThis(char *str);
- static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis);
+ static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis);
void PreeditChangedThis();
+ static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis);
#endif
static gint StyleSetText(GtkWidget *widget, GtkStyle *previous, void*);
static gint RealizeText(GtkWidget *widget, void*);
@@ -398,7 +401,7 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
GdkCursor *cursor = gdk_cursor_new(GDK_XTERM);
attrs.cursor = cursor;
widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attrs,
- GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR);
+ GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR);
gdk_window_set_user_data(widget->window, widget);
gdk_window_set_background(widget->window, &widget->style->bg[GTK_STATE_NORMAL]);
gdk_window_show(widget->window);
@@ -414,10 +417,10 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
GdkICAttributesType attrmask = GDK_IC_ALL_REQ;
GdkIMStyle style;
GdkIMStyle supported_style = (GdkIMStyle) (GDK_IM_PREEDIT_NONE |
- GDK_IM_PREEDIT_NOTHING |
- GDK_IM_PREEDIT_POSITION |
- GDK_IM_STATUS_NONE |
- GDK_IM_STATUS_NOTHING);
+ GDK_IM_PREEDIT_NOTHING |
+ GDK_IM_PREEDIT_POSITION |
+ GDK_IM_STATUS_NONE |
+ GDK_IM_STATUS_NOTHING);
if (widget->style && widget->style->font->type != GDK_FONT_FONTSET)
supported_style = (GdkIMStyle) ((int) supported_style & ~GDK_IM_PREEDIT_POSITION);
@@ -467,7 +470,7 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
wPreeditDraw = gtk_drawing_area_new();
GtkWidget *predrw = PWidget(wPreeditDraw); // No code inside the G_OBJECT macro
g_signal_connect(G_OBJECT(predrw), "expose_event",
- G_CALLBACK(ExposePreedit), this);
+ G_CALLBACK(ExposePreedit), this);
gtk_container_add(GTK_CONTAINER(PWidget(wPreedit)), predrw);
gtk_widget_realize(PWidget(wPreedit));
gtk_widget_realize(predrw);
@@ -475,23 +478,23 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
im_context = gtk_im_multicontext_new();
g_signal_connect(G_OBJECT(im_context), "commit",
- G_CALLBACK(Commit), this);
+ G_CALLBACK(Commit), this);
g_signal_connect(G_OBJECT(im_context), "preedit_changed",
- G_CALLBACK(PreeditChanged), this);
+ G_CALLBACK(PreeditChanged), this);
gtk_im_context_set_client_window(im_context, widget->window);
#endif
#endif
GtkWidget *widtxt = PWidget(wText); // // No code inside the G_OBJECT macro
#if GLIB_MAJOR_VERSION < 2
gtk_signal_connect_after(GTK_OBJECT(widtxt), "style_set",
- GtkSignalFunc(ScintillaGTK::StyleSetText), NULL);
+ GtkSignalFunc(ScintillaGTK::StyleSetText), NULL);
gtk_signal_connect_after(GTK_OBJECT(widtxt), "realize",
- GtkSignalFunc(ScintillaGTK::RealizeText), NULL);
+ GtkSignalFunc(ScintillaGTK::RealizeText), NULL);
#else
g_signal_connect_after(G_OBJECT(widtxt), "style_set",
- G_CALLBACK(ScintillaGTK::StyleSetText), NULL);
+ G_CALLBACK(ScintillaGTK::StyleSetText), NULL);
g_signal_connect_after(G_OBJECT(widtxt), "realize",
- G_CALLBACK(ScintillaGTK::RealizeText), NULL);
+ G_CALLBACK(ScintillaGTK::RealizeText), NULL);
#endif
gtk_widget_realize(widtxt);
gtk_widget_realize(PWidget(scrollbarv));
@@ -504,34 +507,38 @@ void ScintillaGTK::Realize(GtkWidget *widget) {
}
void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
- if (GTK_WIDGET_MAPPED(widget)) {
- gtk_widget_unmap(widget);
- }
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
- gtk_widget_unrealize(PWidget(wText));
- gtk_widget_unrealize(PWidget(scrollbarv));
- gtk_widget_unrealize(PWidget(scrollbarh));
+ try {
+ if (GTK_WIDGET_MAPPED(widget)) {
+ gtk_widget_unmap(widget);
+ }
+ GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
+ gtk_widget_unrealize(PWidget(wText));
+ gtk_widget_unrealize(PWidget(scrollbarv));
+ gtk_widget_unrealize(PWidget(scrollbarh));
#ifdef INTERNATIONAL_INPUT
#if GTK_MAJOR_VERSION < 2
- if (ic) {
- gdk_ic_destroy(ic);
- ic = NULL;
- }
- if (ic_attr) {
- gdk_ic_attr_destroy(ic_attr);
- ic_attr = NULL;
- }
+ if (ic) {
+ gdk_ic_destroy(ic);
+ ic = NULL;
+ }
+ if (ic_attr) {
+ gdk_ic_attr_destroy(ic_attr);
+ ic_attr = NULL;
+ }
#else
- gtk_widget_unrealize(PWidget(wPreedit));
- gtk_widget_unrealize(PWidget(wPreeditDraw));
- g_object_unref(im_context);
- im_context = NULL;
+ gtk_widget_unrealize(PWidget(wPreedit));
+ gtk_widget_unrealize(PWidget(wPreeditDraw));
+ g_object_unref(im_context);
+ im_context = NULL;
#endif
#endif
- if (GTK_WIDGET_CLASS(parentClass)->unrealize)
- GTK_WIDGET_CLASS(parentClass)->unrealize(widget);
+ if (GTK_WIDGET_CLASS(parentClass)->unrealize)
+ GTK_WIDGET_CLASS(parentClass)->unrealize(widget);
- Finalise();
+ Finalise();
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::UnRealize(GtkWidget *widget) {
@@ -548,16 +555,20 @@ static void MapWidget(GtkWidget *widget) {
}
void ScintillaGTK::MapThis() {
- //Platform::DebugPrintf("ScintillaGTK::map this\n");
- GTK_WIDGET_SET_FLAGS(PWidget(wMain), GTK_MAPPED);
- MapWidget(PWidget(wText));
- MapWidget(PWidget(scrollbarh));
- MapWidget(PWidget(scrollbarv));
- wMain.SetCursor(Window::cursorArrow);
- scrollbarv.SetCursor(Window::cursorArrow);
- scrollbarh.SetCursor(Window::cursorArrow);
- ChangeSize();
- gdk_window_show(PWidget(wMain)->window);
+ try {
+ //Platform::DebugPrintf("ScintillaGTK::map this\n");
+ GTK_WIDGET_SET_FLAGS(PWidget(wMain), GTK_MAPPED);
+ MapWidget(PWidget(wText));
+ MapWidget(PWidget(scrollbarh));
+ MapWidget(PWidget(scrollbarv));
+ wMain.SetCursor(Window::cursorArrow);
+ scrollbarv.SetCursor(Window::cursorArrow);
+ scrollbarh.SetCursor(Window::cursorArrow);
+ ChangeSize();
+ gdk_window_show(PWidget(wMain)->window);
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::Map(GtkWidget *widget) {
@@ -566,13 +577,17 @@ void ScintillaGTK::Map(GtkWidget *widget) {
}
void ScintillaGTK::UnMapThis() {
- //Platform::DebugPrintf("ScintillaGTK::unmap this\n");
- GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED);
- DropGraphics();
- gdk_window_hide(PWidget(wMain)->window);
- gtk_widget_unmap(PWidget(wText));
- gtk_widget_unmap(PWidget(scrollbarh));
- gtk_widget_unmap(PWidget(scrollbarv));
+ try {
+ //Platform::DebugPrintf("ScintillaGTK::unmap this\n");
+ GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED);
+ DropGraphics();
+ gdk_window_hide(PWidget(wMain)->window);
+ gtk_widget_unmap(PWidget(wText));
+ gtk_widget_unmap(PWidget(scrollbarh));
+ gtk_widget_unmap(PWidget(scrollbarv));
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::UnMap(GtkWidget *widget) {
@@ -581,9 +596,13 @@ void ScintillaGTK::UnMap(GtkWidget *widget) {
}
void ScintillaGTK::ForAll(GtkCallback callback, gpointer callback_data) {
- (*callback) (PWidget(wText), callback_data);
- (*callback) (PWidget(scrollbarv), callback_data);
- (*callback) (PWidget(scrollbarh), callback_data);
+ try {
+ (*callback) (PWidget(wText), callback_data);
+ (*callback) (PWidget(scrollbarv), callback_data);
+ (*callback) (PWidget(scrollbarh), callback_data);
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::MainForAll(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data) {
@@ -622,92 +641,109 @@ gint ScintillaGTK::CursorMoved(GtkWidget *, int, int, ScintillaGTK *) {
}
#endif
-gint ScintillaGTK::FocusIn(GtkWidget *widget, GdkEventFocus * /*event*/) {
- ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- //Platform::DebugPrintf("ScintillaGTK::focus in %x\n", sciThis);
- GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
- sciThis->SetFocusState(true);
-
+gint ScintillaGTK::FocusInThis(GtkWidget *widget) {
+ try {
+ GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
+ SetFocusState(true);
#ifdef INTERNATIONAL_INPUT
#if GTK_MAJOR_VERSION < 2
- if (sciThis->ic)
- gdk_im_begin(sciThis->ic, widget->window);
+ if (ic)
+ gdk_im_begin(ic, widget->window);
#else
- if (sciThis->im_context != NULL) {
- gchar *str = NULL;
- gint cursor_pos;
-
- gtk_im_context_get_preedit_string(sciThis->im_context, &str, NULL, &cursor_pos);
- if (PWidget(sciThis->wPreedit) != NULL) {
- if (strlen(str) > 0) {
- gtk_widget_show(PWidget(sciThis->wPreedit));
- } else {
- gtk_widget_hide(PWidget(sciThis->wPreedit));
+ if (im_context != NULL) {
+ gchar *str = NULL;
+ gint cursor_pos;
+
+ gtk_im_context_get_preedit_string(im_context, &str, NULL, &cursor_pos);
+ if (PWidget(wPreedit) != NULL) {
+ if (strlen(str) > 0) {
+ gtk_widget_show(PWidget(wPreedit));
+ } else {
+ gtk_widget_hide(PWidget(wPreedit));
+ }
}
+ g_free(str);
+ gtk_im_context_focus_in(im_context);
}
- g_free(str);
- gtk_im_context_focus_in(sciThis->im_context);
- }
#endif
#endif
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
return FALSE;
}
-gint ScintillaGTK::FocusOut(GtkWidget *widget, GdkEventFocus * /*event*/) {
+gint ScintillaGTK::FocusIn(GtkWidget *widget, GdkEventFocus * /*event*/) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- //Platform::DebugPrintf("ScintillaGTK::focus out %x\n", sciThis);
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
- sciThis->SetFocusState(false);
+ return sciThis->FocusInThis(widget);
+}
+
+gint ScintillaGTK::FocusOutThis(GtkWidget *widget) {
+ try {
+ GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
+ SetFocusState(false);
#ifdef INTERNATIONAL_INPUT
#if GTK_MAJOR_VERSION < 2
- gdk_im_end();
+ gdk_im_end();
#else
- if (PWidget(sciThis->wPreedit) != NULL)
- gtk_widget_hide(PWidget(sciThis->wPreedit));
- if (sciThis->im_context != NULL)
- gtk_im_context_focus_out(sciThis->im_context);
+ if (PWidget(wPreedit) != NULL)
+ gtk_widget_hide(PWidget(wPreedit));
+ if (im_context != NULL)
+ gtk_im_context_focus_out(im_context);
#endif
#endif
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
return FALSE;
}
+gint ScintillaGTK::FocusOut(GtkWidget *widget, GdkEventFocus * /*event*/) {
+ ScintillaGTK *sciThis = ScintillaFromWidget(widget);
+ return sciThis->FocusOutThis(widget);
+}
+
void ScintillaGTK::SizeRequest(GtkWidget *widget, GtkRequisition *requisition) {
+ ScintillaGTK *sciThis = ScintillaFromWidget(widget);
requisition->width = 600;
requisition->height = gdk_screen_height();
- ScintillaGTK *sciThis = ScintillaFromWidget(widget);
GtkRequisition child_requisition;
gtk_widget_size_request(PWidget(sciThis->scrollbarh), &child_requisition);
gtk_widget_size_request(PWidget(sciThis->scrollbarv), &child_requisition);
}
void ScintillaGTK::SizeAllocate(GtkWidget *widget, GtkAllocation *allocation) {
- widget->allocation = *allocation;
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- if (GTK_WIDGET_REALIZED(widget))
- gdk_window_move_resize(widget->window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ try {
+ widget->allocation = *allocation;
+ if (GTK_WIDGET_REALIZED(widget))
+ gdk_window_move_resize(widget->window,
+ widget->allocation.x,
+ widget->allocation.y,
+ widget->allocation.width,
+ widget->allocation.height);
- sciThis->Resize(allocation->width, allocation->height);
+ sciThis->Resize(allocation->width, allocation->height);
#ifdef INTERNATIONAL_INPUT
#if GTK_MAJOR_VERSION < 2
- if (sciThis->ic && (gdk_ic_get_style(sciThis->ic) & GDK_IM_PREEDIT_POSITION)) {
- gint width, height;
+ if (sciThis->ic && (gdk_ic_get_style(sciThis->ic) & GDK_IM_PREEDIT_POSITION)) {
+ gint width, height;
- gdk_window_get_size(widget->window, &width, &height);
- sciThis->ic_attr->preedit_area.width = width;
- sciThis->ic_attr->preedit_area.height = height;
+ gdk_window_get_size(widget->window, &width, &height);
+ sciThis->ic_attr->preedit_area.width = width;
+ sciThis->ic_attr->preedit_area.height = height;
- gdk_ic_set_attr(sciThis->ic, sciThis->ic_attr, GDK_IC_PREEDIT_AREA);
- }
+ gdk_ic_set_attr(sciThis->ic, sciThis->ic_attr, GDK_IC_PREEDIT_AREA);
+ }
#endif
#endif
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::Initialise() {
@@ -958,32 +994,38 @@ bool ScintillaGTK::ValidCodePage(int codePage) const {
}
sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
- switch (iMessage) {
+ try {
+ switch (iMessage) {
- case SCI_GRABFOCUS:
- gtk_widget_grab_focus(PWidget(wMain));
- break;
+ case SCI_GRABFOCUS:
+ gtk_widget_grab_focus(PWidget(wMain));
+ break;
- case SCI_GETDIRECTFUNCTION:
- return reinterpret_cast<sptr_t>(DirectFunction);
+ case SCI_GETDIRECTFUNCTION:
+ return reinterpret_cast<sptr_t>(DirectFunction);
- case SCI_GETDIRECTPOINTER:
- return reinterpret_cast<sptr_t>(this);
+ case SCI_GETDIRECTPOINTER:
+ return reinterpret_cast<sptr_t>(this);
#ifdef SCI_LEXER
- case SCI_LOADLEXERLIBRARY:
- LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(wParam));
- break;
+ case SCI_LOADLEXERLIBRARY:
+ LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(wParam));
+ break;
#endif
- case SCI_TARGETASUTF8:
- return TargetAsUTF8(reinterpret_cast<char*>(lParam));
+ case SCI_TARGETASUTF8:
+ return TargetAsUTF8(reinterpret_cast<char*>(lParam));
- case SCI_ENCODEDFROMUTF8:
- return EncodedFromUTF8(reinterpret_cast<char*>(wParam),
- reinterpret_cast<char*>(lParam));
+ case SCI_ENCODEDFROMUTF8:
+ return EncodedFromUTF8(reinterpret_cast<char*>(wParam),
+ reinterpret_cast<char*>(lParam));
- default:
- return ScintillaBase::WndProc(iMessage, wParam, lParam);
+ default:
+ return ScintillaBase::WndProc(iMessage, wParam, lParam);
+ }
+ } catch (std::bad_alloc&) {
+ errorStatus = SC_STATUS_BADALLOC;
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
return 0l;
}
@@ -1459,36 +1501,40 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio
}
void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) {
- if ((selection_data->selection == atomClipboard) ||
- (selection_data->selection == GDK_SELECTION_PRIMARY)) {
- if ((atomSought == atomUTF8) && (selection_data->length <= 0)) {
- atomSought = atomString;
- gtk_selection_convert(GTK_WIDGET(PWidget(wMain)),
- selection_data->selection, atomSought, GDK_CURRENT_TIME);
- } else if ((selection_data->length > 0) &&
- ((selection_data->type == GDK_TARGET_STRING) || (selection_data->type == atomUTF8))) {
- SelectionText selText;
- GetGtkSelectionText(selection_data, selText);
-
- pdoc->BeginUndoAction();
- if (selection_data->selection != GDK_SELECTION_PRIMARY) {
- ClearSelection();
- }
- int selStart = SelectionStart();
+ try {
+ if ((selection_data->selection == atomClipboard) ||
+ (selection_data->selection == GDK_SELECTION_PRIMARY)) {
+ if ((atomSought == atomUTF8) && (selection_data->length <= 0)) {
+ atomSought = atomString;
+ gtk_selection_convert(GTK_WIDGET(PWidget(wMain)),
+ selection_data->selection, atomSought, GDK_CURRENT_TIME);
+ } else if ((selection_data->length > 0) &&
+ ((selection_data->type == GDK_TARGET_STRING) || (selection_data->type == atomUTF8))) {
+ SelectionText selText;
+ GetGtkSelectionText(selection_data, selText);
+
+ pdoc->BeginUndoAction();
+ if (selection_data->selection != GDK_SELECTION_PRIMARY) {
+ ClearSelection();
+ }
+ int selStart = SelectionStart();
- if (selText.rectangular) {
- PasteRectangular(selStart, selText.s, selText.len);
- } else {
- pdoc->InsertString(currentPos, selText.s, selText.len);
- SetEmptySelection(currentPos + selText.len);
+ if (selText.rectangular) {
+ PasteRectangular(selStart, selText.s, selText.len);
+ } else {
+ pdoc->InsertString(currentPos, selText.s, selText.len);
+ SetEmptySelection(currentPos + selText.len);
+ }
+ pdoc->EndUndoAction();
+ EnsureCaretVisible();
}
- pdoc->EndUndoAction();
- EnsureCaretVisible();
}
- }
// else fprintf(stderr, "Target non string %d %d\n", (int)(selection_data->type),
// (int)(atomUTF8));
- Redraw();
+ Redraw();
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::ReceivedDrop(GtkSelectionData *selection_data) {
@@ -1506,7 +1552,7 @@ void ScintillaGTK::ReceivedDrop(GtkSelectionData *selection_data) {
DropAt(posDrop, selText.s, false, selText.rectangular);
}
} else if (selection_data->length > 0) {
- //~ fprintf(stderr, "ReceivedDrop other %p\n", static_cast<void *>(selection_data->type));
+ //~ fprintf(stderr, "ReceivedDrop other %p\n", static_cast<void *>(selection_data->type));
}
Redraw();
}
@@ -1577,13 +1623,13 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
//fprintf(stderr, "Copy to clipboard as UTF-8\n");
if (text->codePage != SC_CP_UTF8) {
// Convert to UTF-8
- //fprintf(stderr, "Convert to UTF-8 from %s\n", charSetBuffer);
+ //fprintf(stderr, "Convert to UTF-8 from %s\n", charSetBuffer);
tmputf = ConvertText(&len, selBuffer, len, "UTF-8", charSetBuffer, false);
selBuffer = tmputf;
}
} else if (info == TARGET_STRING) {
if (text->codePage == SC_CP_UTF8) {
- //fprintf(stderr, "Convert to locale %s\n", charSetBuffer);
+ //fprintf(stderr, "Convert to locale %s\n", charSetBuffer);
// Convert to locale
tmputf = ConvertText(&len, selBuffer, len, charSetBuffer, "UTF-8", true);
selBuffer = tmputf;
@@ -1597,7 +1643,7 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
// the terminating \0 is included in the length for rectangular clippings.
// All other tested aplications behave benignly by ignoring the \0.
// The #if is here because on Windows cfColumnSelect clip entry is used
- // instead as standard indicator of rectangularness (so no need to kludge)
+ // instead as standard indicator of rectangularness (so no need to kludge)
#if PLAT_GTK_WIN32 == 0
if (text->rectangular)
len++;
@@ -1651,14 +1697,18 @@ void ScintillaGTK::ClipboardClearSelection(GtkClipboard *, void *data) {
#endif
void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) {
- //Platform::DebugPrintf("UnclaimSelection\n");
- if (selection_event->selection == GDK_SELECTION_PRIMARY) {
- //Platform::DebugPrintf("UnclaimPrimarySelection\n");
- if (!OwnPrimarySelection()) {
- primary.Free();
- primarySelection = false;
- FullPaint();
+ try {
+ //Platform::DebugPrintf("UnclaimSelection\n");
+ if (selection_event->selection == GDK_SELECTION_PRIMARY) {
+ //Platform::DebugPrintf("UnclaimPrimarySelection\n");
+ if (!OwnPrimarySelection()) {
+ primary.Free();
+ primarySelection = false;
+ FullPaint();
+ }
}
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
}
@@ -1731,73 +1781,77 @@ static void SetAdjustmentValue(GtkObject *object, int value) {
}
gint ScintillaGTK::PressThis(GdkEventButton *event) {
- //Platform::DebugPrintf("Press %x time=%d state = %x button = %x\n",this,event->time, event->state, event->button);
- // Do not use GTK+ double click events as Scintilla has its own double click detection
- if (event->type != GDK_BUTTON_PRESS)
- return FALSE;
+ try {
+ //Platform::DebugPrintf("Press %x time=%d state = %x button = %x\n",this,event->time, event->state, event->button);
+ // Do not use GTK+ double click events as Scintilla has its own double click detection
+ if (event->type != GDK_BUTTON_PRESS)
+ return FALSE;
- evbtn = *event;
- Point pt;
- pt.x = int(event->x);
- pt.y = int(event->y);
- PRectangle rcClient = GetClientRectangle();
- //Platform::DebugPrintf("Press %0d,%0d in %0d,%0d %0d,%0d\n",
- // pt.x, pt.y, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
- if ((pt.x > rcClient.right) || (pt.y > rcClient.bottom)) {
- Platform::DebugPrintf("Bad location\n");
- return FALSE;
- }
+ evbtn = *event;
+ Point pt;
+ pt.x = int(event->x);
+ pt.y = int(event->y);
+ PRectangle rcClient = GetClientRectangle();
+ //Platform::DebugPrintf("Press %0d,%0d in %0d,%0d %0d,%0d\n",
+ // pt.x, pt.y, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
+ if ((pt.x > rcClient.right) || (pt.y > rcClient.bottom)) {
+ Platform::DebugPrintf("Bad location\n");
+ return FALSE;
+ }
- bool ctrl = (event->state & GDK_CONTROL_MASK) != 0;
+ bool ctrl = (event->state & GDK_CONTROL_MASK) != 0;
- gtk_widget_grab_focus(PWidget(wMain));
- if (event->button == 1) {
- // On X, instead of sending literal modifiers use control instead of alt
- // This is because most X window managers grab alt + click for moving
+ gtk_widget_grab_focus(PWidget(wMain));
+ if (event->button == 1) {
+ // On X, instead of sending literal modifiers use control instead of alt
+ // This is because most X window managers grab alt + click for moving
#if !PLAT_GTK_WIN32
- ButtonDown(pt, event->time,
- (event->state & GDK_SHIFT_MASK) != 0,
- (event->state & GDK_CONTROL_MASK) != 0,
- (event->state & GDK_CONTROL_MASK) != 0);
+ ButtonDown(pt, event->time,
+ (event->state & GDK_SHIFT_MASK) != 0,
+ (event->state & GDK_CONTROL_MASK) != 0,
+ (event->state & GDK_CONTROL_MASK) != 0);
#else
- ButtonDown(pt, event->time,
- (event->state & GDK_SHIFT_MASK) != 0,
- (event->state & GDK_CONTROL_MASK) != 0,
- (event->state & GDK_MOD1_MASK) != 0);
-#endif
- } else if (event->button == 2) {
- // Grab the primary selection if it exists
- Position pos = PositionFromLocation(pt);
- if (OwnPrimarySelection() && primary.s == NULL)
- CopySelectionRange(&primary);
-
- SetSelection(pos, pos);
- atomSought = atomUTF8;
- gtk_selection_convert(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY,
- atomSought, event->time);
- } else if (event->button == 3) {
- if (displayPopupMenu) {
- // PopUp menu
- // Convert to screen
- int ox = 0;
- int oy = 0;
- gdk_window_get_origin(PWidget(wMain)->window, &ox, &oy);
- ContextMenu(Point(pt.x + ox, pt.y + oy));
- } else {
- return FALSE;
+ ButtonDown(pt, event->time,
+ (event->state & GDK_SHIFT_MASK) != 0,
+ (event->state & GDK_CONTROL_MASK) != 0,
+ (event->state & GDK_MOD1_MASK) != 0);
+#endif
+ } else if (event->button == 2) {
+ // Grab the primary selection if it exists
+ Position pos = PositionFromLocation(pt);
+ if (OwnPrimarySelection() && primary.s == NULL)
+ CopySelectionRange(&primary);
+
+ SetSelection(pos, pos);
+ atomSought = atomUTF8;
+ gtk_selection_convert(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY,
+ atomSought, event->time);
+ } else if (event->button == 3) {
+ if (displayPopupMenu) {
+ // PopUp menu
+ // Convert to screen
+ int ox = 0;
+ int oy = 0;
+ gdk_window_get_origin(PWidget(wMain)->window, &ox, &oy);
+ ContextMenu(Point(pt.x + ox, pt.y + oy));
+ } else {
+ return FALSE;
+ }
+ } else if (event->button == 4) {
+ // Wheel scrolling up (only GTK 1.x does it this way)
+ if (ctrl)
+ SetAdjustmentValue(adjustmenth, (xOffset / 2) - 6);
+ else
+ SetAdjustmentValue(adjustmentv, topLine - 3);
+ } else if (event->button == 5) {
+ // Wheel scrolling down (only GTK 1.x does it this way)
+ if (ctrl)
+ SetAdjustmentValue(adjustmenth, (xOffset / 2) + 6);
+ else
+ SetAdjustmentValue(adjustmentv, topLine + 3);
}
- } else if (event->button == 4) {
- // Wheel scrolling up (only GTK 1.x does it this way)
- if (ctrl)
- SetAdjustmentValue(adjustmenth, (xOffset / 2) - 6);
- else
- SetAdjustmentValue(adjustmentv, topLine - 3);
- } else if (event->button == 5) {
- // Wheel scrolling down (only GTK 1.x does it this way)
- if (ctrl)
- SetAdjustmentValue(adjustmenth, (xOffset / 2) + 6);
- else
- SetAdjustmentValue(adjustmentv, topLine + 3);
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
#if GTK_MAJOR_VERSION >= 2
return TRUE;
@@ -1815,20 +1869,24 @@ gint ScintillaGTK::Press(GtkWidget *widget, GdkEventButton *event) {
gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- //Platform::DebugPrintf("Release %x %d %d\n",sciThis,event->time,event->state);
- if (!sciThis->HaveMouseCapture())
- return FALSE;
- if (event->button == 1) {
- Point pt;
- pt.x = int(event->x);
- pt.y = int(event->y);
- //Platform::DebugPrintf("Up %x %x %d %d %d\n",
- // sciThis,event->window,event->time, pt.x, pt.y);
- if (event->window != PWidget(sciThis->wMain)->window)
- // 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;
- sciThis->ButtonUp(pt, event->time, (event->state & 4) != 0);
+ try {
+ //Platform::DebugPrintf("Release %x %d %d\n",sciThis,event->time,event->state);
+ if (!sciThis->HaveMouseCapture())
+ return FALSE;
+ if (event->button == 1) {
+ Point pt;
+ pt.x = int(event->x);
+ pt.y = int(event->y);
+ //Platform::DebugPrintf("Up %x %x %d %d %d\n",
+ // sciThis,event->window,event->time, pt.x, pt.y);
+ if (event->window != PWidget(sciThis->wMain)->window)
+ // 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;
+ sciThis->ButtonUp(pt, event->time, (event->state & 4) != 0);
+ }
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
}
return FALSE;
}
@@ -1839,95 +1897,104 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) {
gint ScintillaGTK::ScrollEvent(GtkWidget *widget,
GdkEventScroll *event) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
+ try {
- if (widget == NULL || event == NULL)
- return FALSE;
+ if (widget == NULL || event == NULL)
+ return FALSE;
- // Compute amount and direction to scroll (even tho on win32 there is
- // intensity of scrolling info in the native message, gtk doesn't
- // support this so we simulate similarly adaptive scrolling)
- // Note that this is disabled on OS X (Darwin) where the X11 server already has
- // and adaptive scrolling algorithm that fights with this one
- int cLineScroll;
+ // Compute amount and direction to scroll (even tho on win32 there is
+ // intensity of scrolling info in the native message, gtk doesn't
+ // support this so we simulate similarly adaptive scrolling)
+ // Note that this is disabled on OS X (Darwin) where the X11 server already has
+ // and adaptive scrolling algorithm that fights with this one
+ int cLineScroll;
#if defined(__MWERKS__) || defined(__APPLE_CPP__) || defined(__APPLE_CC__)
- cLineScroll = sciThis->linesPerScroll;
- if (cLineScroll == 0)
- cLineScroll = 4;
- sciThis->wheelMouseIntensity = cLineScroll;
-#else
- int timeDelta = 1000000;
- GTimeVal curTime;
- g_get_current_time(&curTime);
- if (curTime.tv_sec == sciThis->lastWheelMouseTime.tv_sec)
- timeDelta = curTime.tv_usec - sciThis->lastWheelMouseTime.tv_usec;
- else if (curTime.tv_sec == sciThis->lastWheelMouseTime.tv_sec + 1)
- timeDelta = 1000000 + (curTime.tv_usec - sciThis->lastWheelMouseTime.tv_usec);
- if ((event->direction == sciThis->lastWheelMouseDirection) && (timeDelta < 250000)) {
- if (sciThis->wheelMouseIntensity < 12)
- sciThis->wheelMouseIntensity++;
- cLineScroll = sciThis->wheelMouseIntensity;
- } else {
cLineScroll = sciThis->linesPerScroll;
if (cLineScroll == 0)
cLineScroll = 4;
sciThis->wheelMouseIntensity = cLineScroll;
- }
+#else
+ int timeDelta = 1000000;
+ GTimeVal curTime;
+ g_get_current_time(&curTime);
+ if (curTime.tv_sec == sciThis->lastWheelMouseTime.tv_sec)
+ timeDelta = curTime.tv_usec - sciThis->lastWheelMouseTime.tv_usec;
+ else if (curTime.tv_sec == sciThis->lastWheelMouseTime.tv_sec + 1)
+ timeDelta = 1000000 + (curTime.tv_usec - sciThis->lastWheelMouseTime.tv_usec);
+ if ((event->direction == sciThis->lastWheelMouseDirection) && (timeDelta < 250000)) {
+ if (sciThis->wheelMouseIntensity < 12)
+ sciThis->wheelMouseIntensity++;
+ cLineScroll = sciThis->wheelMouseIntensity;
+ } else {
+ cLineScroll = sciThis->linesPerScroll;
+ if (cLineScroll == 0)
+ cLineScroll = 4;
+ sciThis->wheelMouseIntensity = cLineScroll;
+ }
#endif
- if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT) {
- cLineScroll *= -1;
- }
- g_get_current_time(&sciThis->lastWheelMouseTime);
- sciThis->lastWheelMouseDirection = event->direction;
+ if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT) {
+ cLineScroll *= -1;
+ }
+ g_get_current_time(&sciThis->lastWheelMouseTime);
+ sciThis->lastWheelMouseDirection = event->direction;
- // Note: Unpatched versions of win32gtk don't set the 'state' value so
- // only regular scrolling is supported there. Also, unpatched win32gtk
- // issues spurious button 2 mouse events during wheeling, which can cause
- // problems (a patch for both was submitted by archaeopteryx.com on 13Jun2001)
+ // Note: Unpatched versions of win32gtk don't set the 'state' value so
+ // only regular scrolling is supported there. Also, unpatched win32gtk
+ // issues spurious button 2 mouse events during wheeling, which can cause
+ // problems (a patch for both was submitted by archaeopteryx.com on 13Jun2001)
- // Data zoom not supported
- if (event->state & GDK_SHIFT_MASK) {
- return FALSE;
- }
+ // Data zoom not supported
+ if (event->state & GDK_SHIFT_MASK) {
+ return FALSE;
+ }
- // Horizontal scrolling
- if (event->direction == GDK_SCROLL_LEFT || event->direction == GDK_SCROLL_RIGHT) {
- sciThis->HorizontalScrollTo(sciThis->xOffset + cLineScroll);
+ // Horizontal scrolling
+ if (event->direction == GDK_SCROLL_LEFT || event->direction == GDK_SCROLL_RIGHT) {
+ sciThis->HorizontalScrollTo(sciThis->xOffset + cLineScroll);
- // Text font size zoom
- } else if (event->state & GDK_CONTROL_MASK) {
- if (cLineScroll < 0) {
- sciThis->KeyCommand(SCI_ZOOMIN);
+ // Text font size zoom
+ } else if (event->state & GDK_CONTROL_MASK) {
+ if (cLineScroll < 0) {
+ sciThis->KeyCommand(SCI_ZOOMIN);
+ } else {
+ sciThis->KeyCommand(SCI_ZOOMOUT);
+ }
+
+ // Regular scrolling
} else {
- sciThis->KeyCommand(SCI_ZOOMOUT);
+ sciThis->ScrollTo(sciThis->topLine + cLineScroll);
}
-
- // Regular scrolling
- } else {
- sciThis->ScrollTo(sciThis->topLine + cLineScroll);
+ return TRUE;
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
}
- return TRUE;
+ return FALSE;
}
#endif
gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- //Platform::DebugPrintf("Motion %x %d\n",sciThis,event->time);
- if (event->window != widget->window)
- return FALSE;
- int x = 0;
- int y = 0;
- GdkModifierType state;
- if (event->is_hint) {
- gdk_window_get_pointer(event->window, &x, &y, &state);
- } else {
- x = static_cast<int>(event->x);
- y = static_cast<int>(event->y);
- state = static_cast<GdkModifierType>(event->state);
- }
- //Platform::DebugPrintf("Move %x %x %d %c %d %d\n",
- // sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y);
- Point pt(x, y);
- sciThis->ButtonMove(pt);
+ try {
+ //Platform::DebugPrintf("Motion %x %d\n",sciThis,event->time);
+ if (event->window != widget->window)
+ return FALSE;
+ int x = 0;
+ int y = 0;
+ GdkModifierType state;
+ if (event->is_hint) {
+ gdk_window_get_pointer(event->window, &x, &y, &state);
+ } else {
+ x = static_cast<int>(event->x);
+ y = static_cast<int>(event->y);
+ state = static_cast<GdkModifierType>(event->state);
+ }
+ //Platform::DebugPrintf("Move %x %x %d %c %d %d\n",
+ // sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y);
+ Point pt(x, y);
+ sciThis->ButtonMove(pt);
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
return FALSE;
}
@@ -2005,46 +2072,51 @@ static int KeyTranslate(int keyIn) {
}
gboolean ScintillaGTK::KeyThis(GdkEventKey *event) {
- //fprintf(stderr, "SC-key: %d %x [%s]\n",
- // event->keyval, event->state, (event->length > 0) ? event->string : "empty");
+ try {
+ //fprintf(stderr, "SC-key: %d %x [%s]\n",
+ // event->keyval, event->state, (event->length > 0) ? event->string : "empty");
#if GTK_MAJOR_VERSION >= 2
- if (gtk_im_context_filter_keypress(im_context, event)) {
- return 1;
- }
-#endif
- if (!event->keyval) {
- return true;
- }
-
- bool shift = (event->state & GDK_SHIFT_MASK) != 0;
- bool ctrl = (event->state & GDK_CONTROL_MASK) != 0;
- bool alt = (event->state & GDK_MOD1_MASK) != 0;
- guint key = event->keyval;
- if (ctrl && (key < 128))
- key = toupper(key);
- else if (!ctrl && (key >= GDK_KP_Multiply && key <= GDK_KP_9))
- key &= 0x7F;
- // Hack for keys over 256 and below command keys but makes Hungarian work.
- // This will have to change for Unicode
- else if (key >= 0xFE00)
- key = KeyTranslate(key);
+ if (gtk_im_context_filter_keypress(im_context, event)) {
+ return 1;
+ }
+#endif
+ if (!event->keyval) {
+ return true;
+ }
+
+ bool shift = (event->state & GDK_SHIFT_MASK) != 0;
+ bool ctrl = (event->state & GDK_CONTROL_MASK) != 0;
+ bool alt = (event->state & GDK_MOD1_MASK) != 0;
+ guint key = event->keyval;
+ if (ctrl && (key < 128))
+ key = toupper(key);
+ else if (!ctrl && (key >= GDK_KP_Multiply && key <= GDK_KP_9))
+ key &= 0x7F;
+ // Hack for keys over 256 and below command keys but makes Hungarian work.
+ // This will have to change for Unicode
+ else if (key >= 0xFE00)
+ key = KeyTranslate(key);
#if GTK_MAJOR_VERSION < 2
- else if (!IsUnicodeMode() && (key >= 0x100) && (key < 0x1000))
- key &= 0xff;
-#endif
-
- bool consumed = false;
- bool added = KeyDown(key, shift, ctrl, alt, &consumed) != 0;
- if (!consumed)
- consumed = added;
- //fprintf(stderr, "SK-key: %d %x %x\n",event->keyval, event->state, consumed);
- if (event->keyval == 0xffffff && event->length > 0) {
- ClearSelection();
- if (pdoc->InsertCString(CurrentPosition(), event->string)) {
- MovePositionTo(CurrentPosition() + event->length);
+ else if (!IsUnicodeMode() && (key >= 0x100) && (key < 0x1000))
+ key &= 0xff;
+#endif
+
+ bool consumed = false;
+ bool added = KeyDown(key, shift, ctrl, alt, &consumed) != 0;
+ if (!consumed)
+ consumed = added;
+ //fprintf(stderr, "SK-key: %d %x %x\n",event->keyval, event->state, consumed);
+ if (event->keyval == 0xffffff && event->length > 0) {
+ ClearSelection();
+ if (pdoc->InsertCString(CurrentPosition(), event->string)) {
+ MovePositionTo(CurrentPosition() + event->length);
+ }
}
+ return consumed;
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
- return consumed;
+ return FALSE;
}
gboolean ScintillaGTK::KeyPress(GtkWidget *widget, GdkEventKey *event) {
@@ -2058,107 +2130,120 @@ gboolean ScintillaGTK::KeyRelease(GtkWidget *, GdkEventKey * /*event*/) {
}
#if GTK_MAJOR_VERSION >= 2
-gboolean ScintillaGTK::ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis) {
- return sciThis->ExposePreeditThis(widget, ose);
-}
-
gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) {
- gchar *str;
- gint cursor_pos;
- PangoAttrList *attrs;
+ try {
+ gchar *str;
+ gint cursor_pos;
+ PangoAttrList *attrs;
- gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
- PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
- pango_layout_set_attributes(layout, attrs);
+ gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
+ PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
+ pango_layout_set_attributes(layout, attrs);
- GdkGC *gc = gdk_gc_new(widget->window);
- GdkColor color[2] = { {0, 0x0000, 0x0000, 0x0000},
- {0, 0xffff, 0xffff, 0xffff}};
- gdk_color_alloc(gdk_colormap_get_system(), color);
- gdk_color_alloc(gdk_colormap_get_system(), color + 1);
+ GdkGC *gc = gdk_gc_new(widget->window);
+ GdkColor color[2] = { {0, 0x0000, 0x0000, 0x0000},
+ {0, 0xffff, 0xffff, 0xffff}
+ };
+ gdk_color_alloc(gdk_colormap_get_system(), color);
+ gdk_color_alloc(gdk_colormap_get_system(), color + 1);
- gdk_gc_set_foreground(gc, color + 1);
- gdk_draw_rectangle(widget->window, gc, TRUE, ose->area.x, ose->area.y,
- ose->area.width, ose->area.height);
+ gdk_gc_set_foreground(gc, color + 1);
+ gdk_draw_rectangle(widget->window, gc, TRUE, ose->area.x, ose->area.y,
+ ose->area.width, ose->area.height);
- gdk_gc_set_foreground(gc, color);
- gdk_gc_set_background(gc, color + 1);
- gdk_draw_layout(widget->window, gc, 0, 0, layout);
+ gdk_gc_set_foreground(gc, color);
+ gdk_gc_set_background(gc, color + 1);
+ gdk_draw_layout(widget->window, gc, 0, 0, layout);
- gdk_gc_unref(gc);
- g_free(str);
- pango_attr_list_unref(attrs);
- g_object_unref(layout);
+ gdk_gc_unref(gc);
+ g_free(str);
+ pango_attr_list_unref(attrs);
+ g_object_unref(layout);
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
return TRUE;
}
-void ScintillaGTK::Commit(GtkIMContext *, char *str, ScintillaGTK *sciThis) {
- sciThis->CommitThis(str);
+gboolean ScintillaGTK::ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis) {
+ return sciThis->ExposePreeditThis(widget, ose);
}
void ScintillaGTK::CommitThis(char *utfVal) {
- //~ fprintf(stderr, "Commit '%s'\n", utfVal);
- if (IsUnicodeMode()) {
- AddCharUTF(utfVal,strlen(utfVal));
- } else {
- const char *source = CharacterSetID();
- if (*source) {
- Converter conv(source, "UTF-8", true);
- if (conv) {
- char localeVal[4]="\0\0\0";
- char *pin = utfVal;
- size_t inLeft = strlen(utfVal);
- char *pout = localeVal;
- size_t outLeft = sizeof(localeVal);
- size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
- if (conversions != ((size_t)(-1))) {
- *pout = '\0';
- for (int i=0; localeVal[i]; i++) {
- AddChar(localeVal[i]);
+ try {
+ //~ fprintf(stderr, "Commit '%s'\n", utfVal);
+ if (IsUnicodeMode()) {
+ AddCharUTF(utfVal, strlen(utfVal));
+ } else {
+ const char *source = CharacterSetID();
+ if (*source) {
+ Converter conv(source, "UTF-8", true);
+ if (conv) {
+ char localeVal[4] = "\0\0\0";
+ char *pin = utfVal;
+ size_t inLeft = strlen(utfVal);
+ char *pout = localeVal;
+ size_t outLeft = sizeof(localeVal);
+ size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
+ if (conversions != ((size_t)(-1))) {
+ *pout = '\0';
+ for (int i = 0; localeVal[i]; i++) {
+ AddChar(localeVal[i]);
+ }
+ } else {
+ fprintf(stderr, "Conversion failed '%s'\n", utfVal);
}
- } else {
- fprintf(stderr, "Conversion failed '%s'\n", utfVal);
}
}
}
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
}
-void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) {
- sciThis->PreeditChangedThis();
+void ScintillaGTK::Commit(GtkIMContext *, char *str, ScintillaGTK *sciThis) {
+ sciThis->CommitThis(str);
}
void ScintillaGTK::PreeditChangedThis() {
- gchar *str;
- PangoAttrList *attrs;
- gint cursor_pos;
- gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
- if (strlen(str) > 0){
- PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
- pango_layout_set_attributes(layout, attrs);
-
- gint w, h;
- pango_layout_get_pixel_size(layout, &w, &h);
- g_object_unref(layout);
-
- gint x, y;
- gdk_window_get_origin((PWidget(wText))->window, &x, &y);
-
- Point pt = LocationFromPosition(currentPos);
- if (pt.x < 0)
- pt.x = 0;
- if (pt.y < 0)
- pt.y = 0;
-
- gtk_window_move(GTK_WINDOW(PWidget(wPreedit)), x+pt.x, y+pt.y);
- gtk_window_resize(GTK_WINDOW(PWidget(wPreedit)), w, h);
- gtk_widget_show(PWidget(wPreedit));
- gtk_widget_queue_draw_area(PWidget(wPreeditDraw), 0, 0, w, h);
- } else {
- gtk_widget_hide(PWidget(wPreedit));
+ try {
+ gchar *str;
+ PangoAttrList *attrs;
+ gint cursor_pos;
+ gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor_pos);
+ if (strlen(str) > 0) {
+ PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str);
+ pango_layout_set_attributes(layout, attrs);
+
+ gint w, h;
+ pango_layout_get_pixel_size(layout, &w, &h);
+ g_object_unref(layout);
+
+ gint x, y;
+ gdk_window_get_origin((PWidget(wText))->window, &x, &y);
+
+ Point pt = LocationFromPosition(currentPos);
+ if (pt.x < 0)
+ pt.x = 0;
+ if (pt.y < 0)
+ pt.y = 0;
+
+ gtk_window_move(GTK_WINDOW(PWidget(wPreedit)), x + pt.x, y + pt.y);
+ gtk_window_resize(GTK_WINDOW(PWidget(wPreedit)), w, h);
+ gtk_widget_show(PWidget(wPreedit));
+ gtk_widget_queue_draw_area(PWidget(wPreeditDraw), 0, 0, w, h);
+ } else {
+ gtk_widget_hide(PWidget(wPreedit));
+ }
+ g_free(str);
+ pango_attr_list_unref(attrs);
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
- g_free(str);
- pango_attr_list_unref(attrs);
+}
+
+void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) {
+ sciThis->PreeditChangedThis();
}
#endif
@@ -2180,23 +2265,27 @@ void ScintillaGTK::Destroy(GtkObject *object)
void ScintillaGTK::Destroy(GObject *object)
#endif
{
- ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object);
- // This avoids a double destruction
- if (!scio->pscin)
- return;
- ScintillaGTK *sciThis = reinterpret_cast<ScintillaGTK *>(scio->pscin);
- //Platform::DebugPrintf("Destroying %x %x\n", sciThis, object);
- sciThis->Finalise();
+ try {
+ ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object);
+ // This avoids a double destruction
+ if (!scio->pscin)
+ return;
+ ScintillaGTK *sciThis = reinterpret_cast<ScintillaGTK *>(scio->pscin);
+ //Platform::DebugPrintf("Destroying %x %x\n", sciThis, object);
+ sciThis->Finalise();
#if GLIB_MAJOR_VERSION < 2
- if (GTK_OBJECT_CLASS(parent_class)->destroy)
- (* GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ if (GTK_OBJECT_CLASS(parent_class)->destroy)
+ (* GTK_OBJECT_CLASS(parent_class)->destroy)(object);
#else
- // IS ANYTHING NEEDED ?
+ // IS ANYTHING NEEDED ?
#endif
- delete sciThis;
- scio->pscin = 0;
+ delete sciThis;
+ scio->pscin = 0;
+ } catch (...) {
+ // Its dead so nowhere to save the status
+ }
}
static void DrawChild(GtkWidget *widget, GdkRectangle *area) {
@@ -2210,54 +2299,62 @@ static void DrawChild(GtkWidget *widget, GdkRectangle *area) {
void ScintillaGTK::Draw(GtkWidget *widget, GdkRectangle *area) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- //Platform::DebugPrintf("Draw %p %0d,%0d %0d,%0d\n", widget, area->x, area->y, area->width, area->height);
- PRectangle rcPaint(area->x, area->y, area->x + area->width, area->y + area->height);
- sciThis->SyncPaint(rcPaint);
- if (GTK_WIDGET_DRAWABLE(PWidget(sciThis->wMain))) {
- DrawChild(PWidget(sciThis->scrollbarh), area);
- DrawChild(PWidget(sciThis->scrollbarv), area);
- }
+ try {
+ //Platform::DebugPrintf("Draw %p %0d,%0d %0d,%0d\n", widget, area->x, area->y, area->width, area->height);
+ PRectangle rcPaint(area->x, area->y, area->x + area->width, area->y + area->height);
+ sciThis->SyncPaint(rcPaint);
+ if (GTK_WIDGET_DRAWABLE(PWidget(sciThis->wMain))) {
+ DrawChild(PWidget(sciThis->scrollbarh), area);
+ DrawChild(PWidget(sciThis->scrollbarv), area);
+ }
#ifdef INTERNATIONAL_INPUT
- Point pt = sciThis->LocationFromPosition(sciThis->currentPos);
- pt.y += sciThis->vs.lineHeight - 2;
- if (pt.x < 0) pt.x = 0;
- if (pt.y < 0) pt.y = 0;
- CursorMoved(widget, pt.x, pt.y, sciThis);
+ Point pt = sciThis->LocationFromPosition(sciThis->currentPos);
+ pt.y += sciThis->vs.lineHeight - 2;
+ if (pt.x < 0) pt.x = 0;
+ if (pt.y < 0) pt.y = 0;
+ CursorMoved(widget, pt.x, pt.y, sciThis);
#endif
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
gint ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *ose) {
- paintState = painting;
+ try {
+ paintState = painting;
- rcPaint.left = ose->area.x;
- rcPaint.top = ose->area.y;
- rcPaint.right = ose->area.x + ose->area.width;
- rcPaint.bottom = ose->area.y + ose->area.height;
+ rcPaint.left = ose->area.x;
+ rcPaint.top = ose->area.y;
+ rcPaint.right = ose->area.x + ose->area.width;
+ rcPaint.bottom = ose->area.y + ose->area.height;
- PLATFORM_ASSERT(rgnUpdate == NULL);
+ PLATFORM_ASSERT(rgnUpdate == NULL);
#if GTK_MAJOR_VERSION >= 2
- rgnUpdate = gdk_region_copy(ose->region);
-#endif
- PRectangle rcClient = GetClientRectangle();
- paintingAllText = rcPaint.Contains(rcClient);
- Surface *surfaceWindow = Surface::Allocate();
- if (surfaceWindow) {
- surfaceWindow->Init(PWidget(wText)->window, PWidget(wText));
- Paint(surfaceWindow, rcPaint);
- surfaceWindow->Release();
- delete surfaceWindow;
- }
- if (paintState == paintAbandoned) {
- // Painting area was insufficient to cover new styling or brace highlight positions
- FullPaint();
- }
- paintState = notPainting;
+ rgnUpdate = gdk_region_copy(ose->region);
+#endif
+ PRectangle rcClient = GetClientRectangle();
+ paintingAllText = rcPaint.Contains(rcClient);
+ Surface *surfaceWindow = Surface::Allocate();
+ if (surfaceWindow) {
+ surfaceWindow->Init(PWidget(wText)->window, PWidget(wText));
+ Paint(surfaceWindow, rcPaint);
+ surfaceWindow->Release();
+ delete surfaceWindow;
+ }
+ if (paintState == paintAbandoned) {
+ // Painting area was insufficient to cover new styling or brace highlight positions
+ FullPaint();
+ }
+ paintState = notPainting;
- if (rgnUpdate) {
- gdk_region_destroy(rgnUpdate);
+ if (rgnUpdate) {
+ gdk_region_destroy(rgnUpdate);
+ }
+ rgnUpdate = 0;
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
- rgnUpdate = 0;
return FALSE;
}
@@ -2274,64 +2371,76 @@ gint ScintillaGTK::ExposeMain(GtkWidget *widget, GdkEventExpose *ose) {
}
gint ScintillaGTK::Expose(GtkWidget *, GdkEventExpose *ose) {
- //fprintf(stderr, "Expose %0d,%0d %0d,%0d\n",
- //ose->area.x, ose->area.y, ose->area.width, ose->area.height);
+ try {
+ //fprintf(stderr, "Expose %0d,%0d %0d,%0d\n",
+ //ose->area.x, ose->area.y, ose->area.width, ose->area.height);
#if GTK_MAJOR_VERSION < 2
- paintState = painting;
-
- rcPaint.left = ose->area.x;
- rcPaint.top = ose->area.y;
- rcPaint.right = ose->area.x + ose->area.width;
- rcPaint.bottom = ose->area.y + ose->area.height;
-
- PRectangle rcClient = GetClientRectangle();
- paintingAllText = rcPaint.Contains(rcClient);
- Surface *surfaceWindow = Surface::Allocate();
- if (surfaceWindow) {
- surfaceWindow->Init(PWidget(wMain)->window, PWidget(wMain));
-
- // Fill the corner between the scrollbars
- if (verticalScrollBarVisible) {
- if (horizontalScrollBarVisible && (wrapState == eWrapNone)) {
- PRectangle rcCorner = wMain.GetClientPosition();
- rcCorner.left = rcCorner.right - scrollBarWidth + 1;
- rcCorner.top = rcCorner.bottom - scrollBarHeight + 1;
- //fprintf(stderr, "Corner %0d,%0d %0d,%0d\n",
- //rcCorner.left, rcCorner.top, rcCorner.right, rcCorner.bottom);
- surfaceWindow->FillRectangle(rcCorner,
- vs.styles[STYLE_LINENUMBER].back.allocated);
+ paintState = painting;
+
+ rcPaint.left = ose->area.x;
+ rcPaint.top = ose->area.y;
+ rcPaint.right = ose->area.x + ose->area.width;
+ rcPaint.bottom = ose->area.y + ose->area.height;
+
+ PRectangle rcClient = GetClientRectangle();
+ paintingAllText = rcPaint.Contains(rcClient);
+ Surface *surfaceWindow = Surface::Allocate();
+ if (surfaceWindow) {
+ surfaceWindow->Init(PWidget(wMain)->window, PWidget(wMain));
+
+ // Fill the corner between the scrollbars
+ if (verticalScrollBarVisible) {
+ if (horizontalScrollBarVisible && (wrapState == eWrapNone)) {
+ PRectangle rcCorner = wMain.GetClientPosition();
+ rcCorner.left = rcCorner.right - scrollBarWidth + 1;
+ rcCorner.top = rcCorner.bottom - scrollBarHeight + 1;
+ //fprintf(stderr, "Corner %0d,%0d %0d,%0d\n",
+ //rcCorner.left, rcCorner.top, rcCorner.right, rcCorner.bottom);
+ surfaceWindow->FillRectangle(rcCorner,
+ vs.styles[STYLE_LINENUMBER].back.allocated);
+ }
}
- }
- //Paint(surfaceWindow, rcPaint);
- surfaceWindow->Release();
- delete surfaceWindow;
- }
- if (paintState == paintAbandoned) {
- // Painting area was insufficient to cover new styling or brace highlight positions
- FullPaint();
- }
- paintState = notPainting;
+ //Paint(surfaceWindow, rcPaint);
+ surfaceWindow->Release();
+ delete surfaceWindow;
+ }
+ if (paintState == paintAbandoned) {
+ // Painting area was insufficient to cover new styling or brace highlight positions
+ FullPaint();
+ }
+ paintState = notPainting;
#else
- // For GTK+ 2, the text is painted in ExposeText
- gtk_container_propagate_expose(
- GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarh), ose);
- gtk_container_propagate_expose(
- GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarv), ose);
+ // For GTK+ 2, the text is painted in ExposeText
+ gtk_container_propagate_expose(
+ GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarh), ose);
+ gtk_container_propagate_expose(
+ GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarv), ose);
#endif
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
return FALSE;
}
void ScintillaGTK::ScrollSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) {
- sciThis->ScrollTo(static_cast<int>(adj->value), false);
+ try {
+ sciThis->ScrollTo(static_cast<int>(adj->value), false);
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::ScrollHSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) {
- sciThis->HorizontalScrollTo(static_cast<int>(adj->value * 2));
+ try {
+ sciThis->HorizontalScrollTo(static_cast<int>(adj->value * 2));
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::SelectionReceived(GtkWidget *widget,
@@ -2344,18 +2453,22 @@ void ScintillaGTK::SelectionReceived(GtkWidget *widget,
void ScintillaGTK::SelectionGet(GtkWidget *widget,
GtkSelectionData *selection_data, guint info, guint) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- //Platform::DebugPrintf("Selection get\n");
- if (selection_data->selection == GDK_SELECTION_PRIMARY) {
- if (sciThis->primary.s == NULL) {
- sciThis->CopySelectionRange(&sciThis->primary);
+ try {
+ //Platform::DebugPrintf("Selection get\n");
+ if (selection_data->selection == GDK_SELECTION_PRIMARY) {
+ if (sciThis->primary.s == NULL) {
+ sciThis->CopySelectionRange(&sciThis->primary);
+ }
+ sciThis->GetSelection(selection_data, info, &sciThis->primary);
}
- sciThis->GetSelection(selection_data, info, &sciThis->primary);
- }
#ifndef USE_GTK_CLIPBOARD
- else {
- sciThis->GetSelection(selection_data, info, &sciThis->copyText);
- }
+ else {
+ sciThis->GetSelection(selection_data, info, &sciThis->copyText);
+ }
#endif
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
gint ScintillaGTK::SelectionClear(GtkWidget *widget, GdkEventSelection *selection_event) {
@@ -2378,19 +2491,23 @@ void ScintillaGTK::DragBegin(GtkWidget *, GdkDragContext *) {
gboolean ScintillaGTK::DragMotionThis(GdkDragContext *context,
gint x, gint y, guint dragtime) {
- Point npt(x, y);
- SetDragPosition(PositionFromLocation(npt));
- GdkDragAction preferredAction = context->suggested_action;
- int pos = PositionFromLocation(npt);
- if ((inDragDrop == ddDragging) && (0 == PositionInSelection(pos))) {
- // Avoid dragging selection onto itself as that produces a move
- // with no real effect but which creates undo actions.
- preferredAction = static_cast<GdkDragAction>(0);
- } else if (context->actions == static_cast<GdkDragAction>
- (GDK_ACTION_COPY | GDK_ACTION_MOVE)) {
- preferredAction = GDK_ACTION_MOVE;
- }
- gdk_drag_status(context, preferredAction, dragtime);
+ try {
+ Point npt(x, y);
+ SetDragPosition(PositionFromLocation(npt));
+ GdkDragAction preferredAction = context->suggested_action;
+ int pos = PositionFromLocation(npt);
+ if ((inDragDrop == ddDragging) && (0 == PositionInSelection(pos))) {
+ // Avoid dragging selection onto itself as that produces a move
+ // with no real effect but which creates undo actions.
+ preferredAction = static_cast<GdkDragAction>(0);
+ } else if (context->actions == static_cast<GdkDragAction>
+ (GDK_ACTION_COPY | GDK_ACTION_MOVE)) {
+ preferredAction = GDK_ACTION_MOVE;
+ }
+ gdk_drag_status(context, preferredAction, dragtime);
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
return FALSE;
}
@@ -2402,55 +2519,75 @@ gboolean ScintillaGTK::DragMotion(GtkWidget *widget, GdkDragContext *context,
void ScintillaGTK::DragLeave(GtkWidget *widget, GdkDragContext * /*context*/, guint) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- sciThis->SetDragPosition(invalidPosition);
- //Platform::DebugPrintf("DragLeave %x\n", sciThis);
+ try {
+ sciThis->SetDragPosition(invalidPosition);
+ //Platform::DebugPrintf("DragLeave %x\n", sciThis);
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::DragEnd(GtkWidget *widget, GdkDragContext * /*context*/) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- // If drag did not result in drop here or elsewhere
- if (!sciThis->dragWasDropped)
- sciThis->SetEmptySelection(sciThis->posDrag);
- sciThis->SetDragPosition(invalidPosition);
- //Platform::DebugPrintf("DragEnd %x %d\n", sciThis, sciThis->dragWasDropped);
- sciThis->inDragDrop = ddNone;
+ try {
+ // If drag did not result in drop here or elsewhere
+ if (!sciThis->dragWasDropped)
+ sciThis->SetEmptySelection(sciThis->posDrag);
+ sciThis->SetDragPosition(invalidPosition);
+ //Platform::DebugPrintf("DragEnd %x %d\n", sciThis, sciThis->dragWasDropped);
+ sciThis->inDragDrop = ddNone;
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
gboolean ScintillaGTK::Drop(GtkWidget *widget, GdkDragContext * /*context*/,
gint, gint, guint) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- //Platform::DebugPrintf("Drop %x\n", sciThis);
- sciThis->SetDragPosition(invalidPosition);
+ try {
+ //Platform::DebugPrintf("Drop %x\n", sciThis);
+ sciThis->SetDragPosition(invalidPosition);
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
return FALSE;
}
void ScintillaGTK::DragDataReceived(GtkWidget *widget, GdkDragContext * /*context*/,
gint, gint, GtkSelectionData *selection_data, guint /*info*/, guint) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- sciThis->ReceivedDrop(selection_data);
- sciThis->SetDragPosition(invalidPosition);
+ try {
+ sciThis->ReceivedDrop(selection_data);
+ sciThis->SetDragPosition(invalidPosition);
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
+ }
}
void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
GtkSelectionData *selection_data, guint info, guint) {
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
- sciThis->dragWasDropped = true;
- if (sciThis->currentPos != sciThis->anchor) {
- sciThis->GetSelection(selection_data, info, &sciThis->drag);
- }
- if (context->action == GDK_ACTION_MOVE) {
- int selStart = sciThis->SelectionStart();
- int selEnd = sciThis->SelectionEnd();
- if (sciThis->posDrop > selStart) {
- if (sciThis->posDrop > selEnd)
- sciThis->posDrop = sciThis->posDrop - (selEnd - selStart);
- else
- sciThis->posDrop = selStart;
- sciThis->posDrop = sciThis->pdoc->ClampPositionIntoDocument(sciThis->posDrop);
+ try {
+ sciThis->dragWasDropped = true;
+ if (sciThis->currentPos != sciThis->anchor) {
+ sciThis->GetSelection(selection_data, info, &sciThis->drag);
+ }
+ if (context->action == GDK_ACTION_MOVE) {
+ int selStart = sciThis->SelectionStart();
+ int selEnd = sciThis->SelectionEnd();
+ if (sciThis->posDrop > selStart) {
+ if (sciThis->posDrop > selEnd)
+ sciThis->posDrop = sciThis->posDrop - (selEnd - selStart);
+ else
+ sciThis->posDrop = selStart;
+ sciThis->posDrop = sciThis->pdoc->ClampPositionIntoDocument(sciThis->posDrop);
+ }
+ sciThis->ClearSelection();
}
- sciThis->ClearSelection();
+ sciThis->SetDragPosition(invalidPosition);
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
}
- sciThis->SetDragPosition(invalidPosition);
}
int ScintillaGTK::TimeOut(ScintillaGTK *sciThis) {
@@ -2478,15 +2615,18 @@ void ScintillaGTK::PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *) {
}
gint ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, ScintillaGTK *sciThis) {
- if (event->window != widget->window)
- return FALSE;
- if (event->type != GDK_BUTTON_PRESS)
- return FALSE;
- Point pt;
- pt.x = int(event->x);
- pt.y = int(event->y);
- sciThis->ct.MouseClick(pt);
- sciThis->CallTipClick();
+ try {
+ if (event->window != widget->window)
+ return FALSE;
+ if (event->type != GDK_BUTTON_PRESS)
+ return FALSE;
+ Point pt;
+ pt.x = int(event->x);
+ pt.y = int(event->y);
+ sciThis->ct.MouseClick(pt);
+ sciThis->CallTipClick();
+ } catch (...) {
+ }
#if GTK_MAJOR_VERSION >= 2
return TRUE;
#else
@@ -2495,14 +2635,18 @@ gint ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, ScintillaGT
}
gint ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) {
- Surface *surfaceWindow = Surface::Allocate();
- if (surfaceWindow) {
- surfaceWindow->Init(widget->window, widget);
- surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
- surfaceWindow->SetDBCSMode(ctip->codePage);
- ctip->PaintCT(surfaceWindow);
- surfaceWindow->Release();
- delete surfaceWindow;
+ try {
+ Surface *surfaceWindow = Surface::Allocate();
+ if (surfaceWindow) {
+ surfaceWindow->Init(widget->window, widget);
+ surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
+ surfaceWindow->SetDBCSMode(ctip->codePage);
+ ctip->PaintCT(surfaceWindow);
+ surfaceWindow->Release();
+ delete surfaceWindow;
+ }
+ } catch (...) {
+ // No pointer back to Scintilla to save status
}
return TRUE;
}
@@ -2526,50 +2670,56 @@ extern void Platform_Finalise();
#if GLIB_MAJOR_VERSION < 2
GtkType scintilla_get_type() {
static GtkType scintilla_type = 0;
+ try {
- if (!scintilla_type) {
- Platform_Initialise();
- static GtkTypeInfo scintilla_info = {
- "Scintilla",
- sizeof (ScintillaObject),
- sizeof (ScintillaClass),
- (GtkClassInitFunc) scintilla_class_init,
- (GtkObjectInitFunc) scintilla_init,
- (gpointer) NULL,
- (gpointer) NULL,
- 0
- };
+ if (!scintilla_type) {
+ Platform_Initialise();
+ static GtkTypeInfo scintilla_info = {
+ "Scintilla",
+ sizeof (ScintillaObject),
+ sizeof (ScintillaClass),
+ (GtkClassInitFunc) scintilla_class_init,
+ (GtkObjectInitFunc) scintilla_init,
+ (gpointer) NULL,
+ (gpointer) NULL,
+ 0
+ };
- scintilla_type = gtk_type_unique(gtk_container_get_type(), &scintilla_info);
- }
+ scintilla_type = gtk_type_unique(gtk_container_get_type(), &scintilla_info);
+ }
+ } catch (...) {
+ }
return scintilla_type;
}
#else
GType scintilla_get_type() {
static GType scintilla_type = 0;
+ try {
- if (!scintilla_type) {
- scintilla_type = g_type_from_name("Scintilla");
if (!scintilla_type) {
- static GTypeInfo scintilla_info = {
- (guint16) sizeof (ScintillaClass),
- NULL, //(GBaseInitFunc)
- NULL, //(GBaseFinalizeFunc)
- (GClassInitFunc) scintilla_class_init,
- NULL, //(GClassFinalizeFunc)
- NULL, //gconstpointer data
- (guint16) sizeof (ScintillaObject),
- 0, //n_preallocs
- (GInstanceInitFunc) scintilla_init,
- NULL //(GTypeValueTable*)
- };
-
- scintilla_type = g_type_register_static(
- GTK_TYPE_CONTAINER, "Scintilla", &scintilla_info, (GTypeFlags) 0);
+ scintilla_type = g_type_from_name("Scintilla");
+ if (!scintilla_type) {
+ static GTypeInfo scintilla_info = {
+ (guint16) sizeof (ScintillaClass),
+ NULL, //(GBaseInitFunc)
+ NULL, //(GBaseFinalizeFunc)
+ (GClassInitFunc) scintilla_class_init,
+ NULL, //(GClassFinalizeFunc)
+ NULL, //gconstpointer data
+ (guint16) sizeof (ScintillaObject),
+ 0, //n_preallocs
+ (GInstanceInitFunc) scintilla_init,
+ NULL //(GTypeValueTable*)
+ };
+
+ scintilla_type = g_type_register_static(
+ GTK_TYPE_CONTAINER, "Scintilla", &scintilla_info, (GTypeFlags) 0);
+ }
}
- }
+ } catch (...) {
+ }
return scintilla_type;
}
#endif
@@ -2641,65 +2791,71 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_
#endif
static void scintilla_class_init(ScintillaClass *klass) {
- OBJECT_CLASS *object_class = (OBJECT_CLASS*) klass;
- GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
- GtkContainerClass *container_class = (GtkContainerClass*) klass;
+ try {
+ OBJECT_CLASS *object_class = (OBJECT_CLASS*) klass;
+ GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
+ GtkContainerClass *container_class = (GtkContainerClass*) klass;
#if GLIB_MAJOR_VERSION < 2
- parent_class = (GtkWidgetClass*) gtk_type_class(gtk_container_get_type());
-
- scintilla_signals[COMMAND_SIGNAL] = gtk_signal_new(
- "command",
- GTK_RUN_LAST,
- GTK_CLASS_TYPE(object_class),
- GTK_SIGNAL_OFFSET(ScintillaClass, command),
- SIG_MARSHAL,
- GTK_TYPE_NONE,
- 2, MARSHAL_ARGUMENTS);
-
- scintilla_signals[NOTIFY_SIGNAL] = gtk_signal_new(
- SCINTILLA_NOTIFY,
- GTK_RUN_LAST,
- GTK_CLASS_TYPE(object_class),
- GTK_SIGNAL_OFFSET(ScintillaClass, notify),
- SIG_MARSHAL,
- GTK_TYPE_NONE,
- 2, MARSHAL_ARGUMENTS);
- gtk_object_class_add_signals(object_class,
- reinterpret_cast<unsigned int *>(scintilla_signals), LAST_SIGNAL);
+ parent_class = (GtkWidgetClass*) gtk_type_class(gtk_container_get_type());
+
+ scintilla_signals[COMMAND_SIGNAL] = gtk_signal_new(
+ "command",
+ GTK_RUN_LAST,
+ GTK_CLASS_TYPE(object_class),
+ GTK_SIGNAL_OFFSET(ScintillaClass, command),
+ SIG_MARSHAL,
+ GTK_TYPE_NONE,
+ 2, MARSHAL_ARGUMENTS);
+
+ scintilla_signals[NOTIFY_SIGNAL] = gtk_signal_new(
+ SCINTILLA_NOTIFY,
+ GTK_RUN_LAST,
+ GTK_CLASS_TYPE(object_class),
+ GTK_SIGNAL_OFFSET(ScintillaClass, notify),
+ SIG_MARSHAL,
+ GTK_TYPE_NONE,
+ 2, MARSHAL_ARGUMENTS);
+ gtk_object_class_add_signals(object_class,
+ reinterpret_cast<unsigned int *>(scintilla_signals), LAST_SIGNAL);
#else
- GSignalFlags sigflags = GSignalFlags(G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST);
- scintilla_signals[COMMAND_SIGNAL] = g_signal_new(
- "command",
- G_TYPE_FROM_CLASS(object_class),
- sigflags,
- G_STRUCT_OFFSET(ScintillaClass, command),
- NULL, //(GSignalAccumulator)
- NULL, //(gpointer)
- SIG_MARSHAL,
- G_TYPE_NONE,
- 2, MARSHAL_ARGUMENTS);
-
- 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,
- G_TYPE_NONE,
- 2, MARSHAL_ARGUMENTS);
-#endif
- klass->command = NULL;
- klass->notify = NULL;
-
- ScintillaGTK::ClassInit(object_class, widget_class, container_class);
+ GSignalFlags sigflags = GSignalFlags(G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST);
+ scintilla_signals[COMMAND_SIGNAL] = g_signal_new(
+ "command",
+ G_TYPE_FROM_CLASS(object_class),
+ sigflags,
+ G_STRUCT_OFFSET(ScintillaClass, command),
+ NULL, //(GSignalAccumulator)
+ NULL, //(gpointer)
+ SIG_MARSHAL,
+ G_TYPE_NONE,
+ 2, MARSHAL_ARGUMENTS);
+
+ 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,
+ G_TYPE_NONE,
+ 2, MARSHAL_ARGUMENTS);
+#endif
+ klass->command = NULL;
+ klass->notify = NULL;
+
+ ScintillaGTK::ClassInit(object_class, widget_class, container_class);
+ } catch (...) {
+ }
}
static void scintilla_init(ScintillaObject *sci) {
- GTK_WIDGET_SET_FLAGS(sci, GTK_CAN_FOCUS);
- sci->pscin = new ScintillaGTK(sci);
+ try {
+ GTK_WIDGET_SET_FLAGS(sci, GTK_CAN_FOCUS);
+ sci->pscin = new ScintillaGTK(sci);
+ } catch (...) {
+ }
}
GtkWidget* scintilla_new() {
@@ -2716,5 +2872,8 @@ void scintilla_set_id(ScintillaObject *sci, uptr_t id) {
}
void scintilla_release_resources(void) {
- Platform_Finalise();
+ try {
+ Platform_Finalise();
+ } catch (...) {
+ }
}
diff --git a/gtk/scintilla.mak b/gtk/scintilla.mak
index c4924ed6a..b993c6069 100644
--- a/gtk/scintilla.mak
+++ b/gtk/scintilla.mak
@@ -62,7 +62,7 @@ ALL_GTK_LIBS=$(GTK_TOP)/gtk+/gtk/gtk-1.3.lib \
!ENDIF
INCLUDEDIRS=-I ../include -I ../src $(GTK_INCLUDES)
-CXXFLAGS=/TP /W4 -DGTK -D_CRT_SECURE_NO_DEPRECATE=1
+CXXFLAGS=/TP /W4 -EHsc -DGTK -D_CRT_SECURE_NO_DEPRECATE=1
CFLAGS=/W4 -DGTK
# For something scary:/Wp64
CXXDEBUG=/Zi /Od /MDd -DDEBUG
@@ -90,7 +90,7 @@ LD=ilink32
INCLUDEDIRS=-I../include -I../src
CXXFLAGS = -v
-CXXFLAGS=-P -tWM -w -w-prc -w-inl -RT- -x-
+CXXFLAGS=-P -tWM -w -w-prc -w-inl -RT- -x
# Above turns off warnings for clarfying parentheses and inlines with for not expanded
CXXDEBUG=-v -DDEBUG
CXXNDEBUG=-O1 -DNDEBUG
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 3d61be26f..677cd0325 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -558,6 +558,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETMODEVENTMASK 2378
#define SCI_SETFOCUS 2380
#define SCI_GETFOCUS 2381
+#define SC_STATUS_OK 0
+#define SC_STATUS_FAILURE 1
+#define SC_STATUS_BADALLOC 2
#define SCI_SETSTATUS 2382
#define SCI_GETSTATUS 2383
#define SCI_SETMOUSEDOWNCAPTURES 2384
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 5860944de..a2c905fb7 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1476,6 +1476,11 @@ set void SetFocus=2380(bool focus,)
# Get internal focus flag.
get bool GetFocus=2381(,)
+enu Status=SC_STATUS_
+val SC_STATUS_OK=0
+val SC_STATUS_FAILURE=1
+val SC_STATUS_BADALLOC=2
+
# Change error status - 0 = OK.
set void SetStatus=2382(int statusCode,)
# Get error status.
diff --git a/src/Editor.h b/src/Editor.h
index 35564ca8c..3b15920ff 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -125,7 +125,6 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool hasFocus;
bool hideSelection;
bool inOverstrike;
- int errorStatus;
bool mouseDownCaptures;
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
@@ -478,6 +477,8 @@ public:
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
// Public so scintilla_set_id can use it.
int ctrlID;
+ // Public so COM methods for drag and drop can set it.
+ int errorStatus;
friend class AutoSurface;
friend class SelectionLineIterator;
};
diff --git a/vcbuild/SciLexer.dsp b/vcbuild/SciLexer.dsp
index e36d7b753..bea59eb45 100644
--- a/vcbuild/SciLexer.dsp
+++ b/vcbuild/SciLexer.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SciLexer_EXPORTS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /G6 /MT /W4 /O1 /I "..\include" /I "..\src" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SCI_LEXER" /FD /c
+# ADD CPP /nologo /G6 /MT /W4 /GX /O1 /I "..\include" /I "..\src" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SCI_LEXER" /FD /c
# SUBTRACT CPP /Fr /YX /Yc /Yu
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -418,11 +418,11 @@ SOURCE=..\src\LexSQL.cxx
# End Source File
# Begin Source File
-SOURCE=..\src\LexTADS3.cxx
+SOURCE=..\src\LexTACL.cxx
# End Source File
# Begin Source File
-SOURCE=..\src\LexTACL.cxx
+SOURCE=..\src\LexTADS3.cxx
# End Source File
# Begin Source File
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 7345fc8f2..012d8a9af 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1809,53 +1809,57 @@ void ListBoxX::Paint(HDC hDC) {
}
LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- switch (uMsg) {
- case WM_ERASEBKGND:
- return TRUE;
-
- case WM_PAINT: {
- PAINTSTRUCT ps;
- HDC hDC = ::BeginPaint(hWnd, &ps);
- ListBoxX *lbx = reinterpret_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd)));
- if (lbx)
- lbx->Paint(hDC);
- ::EndPaint(hWnd, &ps);
- }
- return 0;
-
- case WM_MOUSEACTIVATE:
- // This prevents the view activating when the scrollbar is clicked
- return MA_NOACTIVATE;
-
- case WM_LBUTTONDOWN: {
- // We must take control of selection to prevent the ListBox activating
- // the popup
- LRESULT lResult = ::SendMessage(hWnd, LB_ITEMFROMPOINT, 0, lParam);
- int item = LOWORD(lResult);
- if (HIWORD(lResult) == 0 && item >= 0) {
- ::SendMessage(hWnd, LB_SETCURSEL, item, 0);
+ try {
+ switch (uMsg) {
+ case WM_ERASEBKGND:
+ return TRUE;
+
+ case WM_PAINT: {
+ PAINTSTRUCT ps;
+ HDC hDC = ::BeginPaint(hWnd, &ps);
+ ListBoxX *lbx = reinterpret_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd)));
+ if (lbx)
+ lbx->Paint(hDC);
+ ::EndPaint(hWnd, &ps);
}
- }
- return 0;
+ return 0;
+
+ case WM_MOUSEACTIVATE:
+ // This prevents the view activating when the scrollbar is clicked
+ return MA_NOACTIVATE;
+
+ case WM_LBUTTONDOWN: {
+ // We must take control of selection to prevent the ListBox activating
+ // the popup
+ LRESULT lResult = ::SendMessage(hWnd, LB_ITEMFROMPOINT, 0, lParam);
+ int item = LOWORD(lResult);
+ if (HIWORD(lResult) == 0 && item >= 0) {
+ ::SendMessage(hWnd, LB_SETCURSEL, item, 0);
+ }
+ }
+ return 0;
- case WM_LBUTTONUP:
- return 0;
+ case WM_LBUTTONUP:
+ return 0;
- case WM_LBUTTONDBLCLK: {
- ListBoxX *lbx = reinterpret_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd)));
- if (lbx) {
- lbx->OnDoubleClick();
+ case WM_LBUTTONDBLCLK: {
+ ListBoxX *lbx = reinterpret_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd)));
+ if (lbx) {
+ lbx->OnDoubleClick();
+ }
}
+ return 0;
}
- return 0;
- }
- WNDPROC prevWndProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
- if (prevWndProc) {
- return ::CallWindowProc(prevWndProc, hWnd, uMsg, wParam, lParam);
- } else {
- return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
+ WNDPROC prevWndProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
+ if (prevWndProc) {
+ return ::CallWindowProc(prevWndProc, hWnd, uMsg, wParam, lParam);
+ } else {
+ return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
+ }
+ } catch (...) {
}
+ return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
}
LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index b4c5a825f..6ef6c0160 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -5,6 +5,7 @@
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#include <new>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -585,450 +586,456 @@ static UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) {
}
sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
- //Platform::DebugPrintf("S M:%x WP:%x L:%x\n", iMessage, wParam, lParam);
- iMessage = SciMessageFromEM(iMessage);
- switch (iMessage) {
-
- case WM_CREATE:
- ctrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(wMain.GetID()));
- // Get Intellimouse scroll line parameters
- GetIntelliMouseParameters();
- ::RegisterDragDrop(MainHWND(), reinterpret_cast<IDropTarget *>(&dt));
- break;
+ try {
+ //Platform::DebugPrintf("S M:%x WP:%x L:%x\n", iMessage, wParam, lParam);
+ iMessage = SciMessageFromEM(iMessage);
+ switch (iMessage) {
+
+ case WM_CREATE:
+ ctrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(wMain.GetID()));
+ // Get Intellimouse scroll line parameters
+ GetIntelliMouseParameters();
+ ::RegisterDragDrop(MainHWND(), reinterpret_cast<IDropTarget *>(&dt));
+ break;
- case WM_COMMAND:
+ case WM_COMMAND:
#ifdef TOTAL_CONTROL
- Command(LoWord(wParam));
+ Command(LoWord(wParam));
#endif
- break;
+ break;
- case WM_PAINT:
- return WndPaint(wParam);
+ case WM_PAINT:
+ return WndPaint(wParam);
- case WM_PRINTCLIENT: {
- HDC hdc = reinterpret_cast<HDC>(wParam);
- if (!IsCompatibleDC(hdc)) {
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_PRINTCLIENT: {
+ HDC hdc = reinterpret_cast<HDC>(wParam);
+ if (!IsCompatibleDC(hdc)) {
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ }
+ FullPaintDC(hdc);
}
- FullPaintDC(hdc);
- }
- break;
-
- case WM_VSCROLL:
- ScrollMessage(wParam);
- break;
+ break;
- case WM_HSCROLL:
- HorizontalScrollMessage(wParam);
- break;
+ case WM_VSCROLL:
+ ScrollMessage(wParam);
+ break;
- case WM_SIZE: {
- //Platform::DebugPrintf("Scintilla WM_SIZE %d %d\n", LoWord(lParam), HiWord(lParam));
- ChangeSize();
- }
- break;
+ case WM_HSCROLL:
+ HorizontalScrollMessage(wParam);
+ break;
- case WM_MOUSEWHEEL:
- // Don't handle datazoom.
- // (A good idea for datazoom would be to "fold" or "unfold" details.
- // i.e. if datazoomed out only class structures are visible, when datazooming in the control
- // structures appear, then eventually the individual statements...)
- if (wParam & MK_SHIFT) {
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- }
+ case WM_SIZE: {
+ //Platform::DebugPrintf("Scintilla WM_SIZE %d %d\n", LoWord(lParam), HiWord(lParam));
+ ChangeSize();
+ }
+ break;
- // Either SCROLL or ZOOM. We handle the wheel steppings calculation
- wheelDelta -= static_cast<short>(HiWord(wParam));
- if (abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) {
- int linesToScroll = linesPerScroll;
- if (linesPerScroll == WHEEL_PAGESCROLL)
- linesToScroll = LinesOnScreen() - 1;
- if (linesToScroll == 0) {
- linesToScroll = 1;
+ case WM_MOUSEWHEEL:
+ // Don't handle datazoom.
+ // (A good idea for datazoom would be to "fold" or "unfold" details.
+ // i.e. if datazoomed out only class structures are visible, when datazooming in the control
+ // structures appear, then eventually the individual statements...)
+ if (wParam & MK_SHIFT) {
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
- linesToScroll *= (wheelDelta / WHEEL_DELTA);
- if (wheelDelta >= 0)
- wheelDelta = wheelDelta % WHEEL_DELTA;
- else
- wheelDelta = - (-wheelDelta % WHEEL_DELTA);
-
- if (wParam & MK_CONTROL) {
- // Zoom! We play with the font sizes in the styles.
- // Number of steps/line is ignored, we just care if sizing up or down
- if (linesToScroll < 0) {
- KeyCommand(SCI_ZOOMIN);
+
+ // Either SCROLL or ZOOM. We handle the wheel steppings calculation
+ wheelDelta -= static_cast<short>(HiWord(wParam));
+ if (abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) {
+ int linesToScroll = linesPerScroll;
+ if (linesPerScroll == WHEEL_PAGESCROLL)
+ linesToScroll = LinesOnScreen() - 1;
+ if (linesToScroll == 0) {
+ linesToScroll = 1;
+ }
+ linesToScroll *= (wheelDelta / WHEEL_DELTA);
+ if (wheelDelta >= 0)
+ wheelDelta = wheelDelta % WHEEL_DELTA;
+ else
+ wheelDelta = - (-wheelDelta % WHEEL_DELTA);
+
+ if (wParam & MK_CONTROL) {
+ // Zoom! We play with the font sizes in the styles.
+ // Number of steps/line is ignored, we just care if sizing up or down
+ if (linesToScroll < 0) {
+ KeyCommand(SCI_ZOOMIN);
+ } else {
+ KeyCommand(SCI_ZOOMOUT);
+ }
} else {
- KeyCommand(SCI_ZOOMOUT);
+ // Scroll
+ ScrollTo(topLine + linesToScroll);
}
- } else {
- // Scroll
- ScrollTo(topLine + linesToScroll);
}
- }
- return 0;
-
- case WM_TIMER:
- if (wParam == standardTimerID && timer.ticking) {
- Tick();
- } else if (wParam == idleTimerID && idler.state) {
- SendMessage(MainHWND(), SC_WIN_IDLE, 0, 1);
- } else {
- return 1;
- }
- break;
-
- case SC_WIN_IDLE:
- // wParam=dwTickCountInitial, or 0 to initialize. lParam=bSkipUserInputTest
- if (idler.state) {
- if (lParam || (WAIT_TIMEOUT==MsgWaitForMultipleObjects(0,0,0,0, QS_INPUT|QS_HOTKEY))) {
- if (Idle()) {
- // User input was given priority above, but all events do get a turn. Other
- // messages, notifications, etc. will get interleaved with the idle messages.
-
- // However, some things like WM_PAINT are a lower priority, and will not fire
- // when there's a message posted. So, several times a second, we stop and let
- // the low priority events have a turn (after which the timer will fire again).
+ return 0;
- DWORD dwCurrent = GetTickCount();
- DWORD dwStart = wParam ? wParam : dwCurrent;
+ case WM_TIMER:
+ if (wParam == standardTimerID && timer.ticking) {
+ Tick();
+ } else if (wParam == idleTimerID && idler.state) {
+ SendMessage(MainHWND(), SC_WIN_IDLE, 0, 1);
+ } else {
+ return 1;
+ }
+ break;
- if (dwCurrent >= dwStart && dwCurrent > 200 && dwCurrent - 200 < dwStart)
- PostMessage(MainHWND(), SC_WIN_IDLE, dwStart, 0);
- } else {
- SetIdle(false);
+ case SC_WIN_IDLE:
+ // wParam=dwTickCountInitial, or 0 to initialize. lParam=bSkipUserInputTest
+ if (idler.state) {
+ if (lParam || (WAIT_TIMEOUT==MsgWaitForMultipleObjects(0,0,0,0, QS_INPUT|QS_HOTKEY))) {
+ if (Idle()) {
+ // User input was given priority above, but all events do get a turn. Other
+ // messages, notifications, etc. will get interleaved with the idle messages.
+
+ // However, some things like WM_PAINT are a lower priority, and will not fire
+ // when there's a message posted. So, several times a second, we stop and let
+ // the low priority events have a turn (after which the timer will fire again).
+
+ DWORD dwCurrent = GetTickCount();
+ DWORD dwStart = wParam ? wParam : dwCurrent;
+
+ if (dwCurrent >= dwStart && dwCurrent > 200 && dwCurrent - 200 < dwStart)
+ PostMessage(MainHWND(), SC_WIN_IDLE, dwStart, 0);
+ } else {
+ SetIdle(false);
+ }
}
}
- }
- break;
+ break;
- case WM_GETMINMAXINFO:
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_GETMINMAXINFO:
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case WM_LBUTTONDOWN: {
+ case WM_LBUTTONDOWN: {
#ifndef __DMC__
- // Digital Mars compiler does not include Imm library
- // For IME, set the composition string as the result string.
- HIMC hIMC = ::ImmGetContext(MainHWND());
- ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
- ::ImmReleaseContext(MainHWND(), hIMC);
+ // Digital Mars compiler does not include Imm library
+ // For IME, set the composition string as the result string.
+ HIMC hIMC = ::ImmGetContext(MainHWND());
+ ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
+ ::ImmReleaseContext(MainHWND(), hIMC);
#endif
- //
- //Platform::DebugPrintf("Buttdown %d %x %x %x %x %x\n",iMessage, wParam, lParam,
- // Platform::IsKeyDown(VK_SHIFT),
- // Platform::IsKeyDown(VK_CONTROL),
- // Platform::IsKeyDown(VK_MENU));
- ButtonDown(Point::FromLong(lParam), ::GetMessageTime(),
- (wParam & MK_SHIFT) != 0,
- (wParam & MK_CONTROL) != 0,
- Platform::IsKeyDown(VK_MENU));
- ::SetFocus(MainHWND());
- }
- break;
+ //
+ //Platform::DebugPrintf("Buttdown %d %x %x %x %x %x\n",iMessage, wParam, lParam,
+ // Platform::IsKeyDown(VK_SHIFT),
+ // Platform::IsKeyDown(VK_CONTROL),
+ // Platform::IsKeyDown(VK_MENU));
+ ButtonDown(Point::FromLong(lParam), ::GetMessageTime(),
+ (wParam & MK_SHIFT) != 0,
+ (wParam & MK_CONTROL) != 0,
+ Platform::IsKeyDown(VK_MENU));
+ ::SetFocus(MainHWND());
+ }
+ break;
- case WM_MOUSEMOVE:
- ButtonMove(Point::FromLong(lParam));
- break;
+ case WM_MOUSEMOVE:
+ ButtonMove(Point::FromLong(lParam));
+ break;
- case WM_LBUTTONUP:
- ButtonUp(Point::FromLong(lParam),
- ::GetMessageTime(),
- (wParam & MK_CONTROL) != 0);
- break;
+ case WM_LBUTTONUP:
+ ButtonUp(Point::FromLong(lParam),
+ ::GetMessageTime(),
+ (wParam & MK_CONTROL) != 0);
+ break;
- case WM_RBUTTONDOWN:
- if (!PointInSelection(Point::FromLong(lParam)))
- SetEmptySelection(PositionFromLocation(Point::FromLong(lParam)));
- break;
+ case WM_RBUTTONDOWN:
+ if (!PointInSelection(Point::FromLong(lParam)))
+ SetEmptySelection(PositionFromLocation(Point::FromLong(lParam)));
+ break;
- case WM_SETCURSOR:
- if (LoWord(lParam) == HTCLIENT) {
- if (inDragDrop == ddDragging) {
- DisplayCursor(Window::cursorUp);
+ case WM_SETCURSOR:
+ if (LoWord(lParam) == HTCLIENT) {
+ if (inDragDrop == ddDragging) {
+ DisplayCursor(Window::cursorUp);
+ } else {
+ // Display regular (drag) cursor over selection
+ POINT pt;
+ ::GetCursorPos(&pt);
+ ::ScreenToClient(MainHWND(), &pt);
+ if (PointInSelMargin(Point(pt.x, pt.y))) {
+ DisplayCursor(Window::cursorReverseArrow);
+ } else if (PointInSelection(Point(pt.x, pt.y)) && !SelectionEmpty()) {
+ DisplayCursor(Window::cursorArrow);
+ } else if (PointIsHotspot(Point(pt.x, pt.y))) {
+ DisplayCursor(Window::cursorHand);
+ } else {
+ DisplayCursor(Window::cursorText);
+ }
+ }
+ return TRUE;
} else {
- // Display regular (drag) cursor over selection
- POINT pt;
- ::GetCursorPos(&pt);
- ::ScreenToClient(MainHWND(), &pt);
- if (PointInSelMargin(Point(pt.x, pt.y))) {
- DisplayCursor(Window::cursorReverseArrow);
- } else if (PointInSelection(Point(pt.x, pt.y)) && !SelectionEmpty()) {
- DisplayCursor(Window::cursorArrow);
- } else if (PointIsHotspot(Point(pt.x, pt.y))) {
- DisplayCursor(Window::cursorHand);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ }
+
+ case WM_CHAR:
+ if (((wParam >= 128) || !iscntrl(wParam)) || !lastKeyDownConsumed) {
+ if (::IsWindowUnicode(MainHWND()) || keysAlwaysUnicode) {
+ wchar_t wcs[2] = {wParam, 0};
+ if (IsUnicodeMode()) {
+ // For a wide character version of the window:
+ char utfval[4];
+ unsigned int len = UTF8Length(wcs, 1);
+ UTF8FromUTF16(wcs, 1, utfval, len);
+ AddCharUTF(utfval, len);
+ } else {
+ UINT cpDest = CodePageFromCharSet(
+ vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
+ char inBufferCP[20];
+ int size = ::WideCharToMultiByte(cpDest,
+ 0, wcs, 1, inBufferCP, sizeof(inBufferCP) - 1, 0, 0);
+ AddCharUTF(inBufferCP, size);
+ }
} else {
- DisplayCursor(Window::cursorText);
+ if (IsUnicodeMode()) {
+ AddCharBytes('\0', LOBYTE(wParam));
+ } else {
+ AddChar(LOBYTE(wParam));
+ }
}
}
- return TRUE;
- } else {
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- }
+ return 0;
- case WM_CHAR:
- if (((wParam >= 128) || !iscntrl(wParam)) || !lastKeyDownConsumed) {
- if (::IsWindowUnicode(MainHWND()) || keysAlwaysUnicode) {
- wchar_t wcs[2] = {wParam, 0};
+ case WM_UNICHAR:
+ if (wParam == UNICODE_NOCHAR) {
+ return IsUnicodeMode() ? 1 : 0;
+ } else if (lastKeyDownConsumed) {
+ return 1;
+ } else {
if (IsUnicodeMode()) {
- // For a wide character version of the window:
char utfval[4];
+ wchar_t wcs[2] = {static_cast<wchar_t>(wParam), 0};
unsigned int len = UTF8Length(wcs, 1);
UTF8FromUTF16(wcs, 1, utfval, len);
AddCharUTF(utfval, len);
+ return 1;
} else {
- UINT cpDest = CodePageFromCharSet(
- vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
- char inBufferCP[20];
- int size = ::WideCharToMultiByte(cpDest,
- 0, wcs, 1, inBufferCP, sizeof(inBufferCP) - 1, 0, 0);
- AddCharUTF(inBufferCP, size);
- }
- } else {
- if (IsUnicodeMode()) {
- AddCharBytes('\0', LOBYTE(wParam));
- } else {
- AddChar(LOBYTE(wParam));
+ return 0;
}
}
- }
- return 0;
-
- case WM_UNICHAR:
- if (wParam == UNICODE_NOCHAR) {
- return IsUnicodeMode() ? 1 : 0;
- } else if (lastKeyDownConsumed) {
- return 1;
- } else {
- if (IsUnicodeMode()) {
- char utfval[4];
- wchar_t wcs[2] = {static_cast<wchar_t>(wParam), 0};
- unsigned int len = UTF8Length(wcs, 1);
- UTF8FromUTF16(wcs, 1, utfval, len);
- AddCharUTF(utfval, len);
- return 1;
- } else {
- return 0;
- }
- }
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN: {
- //Platform::DebugPrintf("S keydown %d %x %x %x %x\n",iMessage, wParam, lParam, ::IsKeyDown(VK_SHIFT), ::IsKeyDown(VK_CONTROL));
- lastKeyDownConsumed = false;
- int ret = KeyDown(KeyTranslate(wParam),
- Platform::IsKeyDown(VK_SHIFT),
- Platform::IsKeyDown(VK_CONTROL),
- Platform::IsKeyDown(VK_MENU),
- &lastKeyDownConsumed);
- if (!ret && !lastKeyDownConsumed) {
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN: {
+ //Platform::DebugPrintf("S keydown %d %x %x %x %x\n",iMessage, wParam, lParam, ::IsKeyDown(VK_SHIFT), ::IsKeyDown(VK_CONTROL));
+ lastKeyDownConsumed = false;
+ int ret = KeyDown(KeyTranslate(wParam),
+ Platform::IsKeyDown(VK_SHIFT),
+ Platform::IsKeyDown(VK_CONTROL),
+ Platform::IsKeyDown(VK_MENU),
+ &lastKeyDownConsumed);
+ if (!ret && !lastKeyDownConsumed) {
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ }
+ break;
}
- break;
- }
- case WM_IME_KEYDOWN:
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_IME_KEYDOWN:
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case WM_KEYUP:
- //Platform::DebugPrintf("S keyup %d %x %x\n",iMessage, wParam, lParam);
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_KEYUP:
+ //Platform::DebugPrintf("S keyup %d %x %x\n",iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case WM_SETTINGCHANGE:
- //Platform::DebugPrintf("Setting Changed\n");
- InvalidateStyleData();
- // Get Intellimouse scroll line parameters
- GetIntelliMouseParameters();
- break;
+ case WM_SETTINGCHANGE:
+ //Platform::DebugPrintf("Setting Changed\n");
+ InvalidateStyleData();
+ // Get Intellimouse scroll line parameters
+ GetIntelliMouseParameters();
+ break;
- case WM_GETDLGCODE:
- return DLGC_HASSETSEL | DLGC_WANTALLKEYS;
-
- case WM_KILLFOCUS: {
- HWND wOther = reinterpret_cast<HWND>(wParam);
- HWND wThis = MainHWND();
- HWND wCT = reinterpret_cast<HWND>(ct.wCallTip.GetID());
- if (!wParam ||
- !(::IsChild(wThis,wOther) || (wOther == wCT))) {
- SetFocusState(false);
- DestroySystemCaret();
+ case WM_GETDLGCODE:
+ return DLGC_HASSETSEL | DLGC_WANTALLKEYS;
+
+ case WM_KILLFOCUS: {
+ HWND wOther = reinterpret_cast<HWND>(wParam);
+ HWND wThis = MainHWND();
+ HWND wCT = reinterpret_cast<HWND>(ct.wCallTip.GetID());
+ if (!wParam ||
+ !(::IsChild(wThis,wOther) || (wOther == wCT))) {
+ SetFocusState(false);
+ DestroySystemCaret();
+ }
}
- }
- //RealizeWindowPalette(true);
- break;
+ //RealizeWindowPalette(true);
+ break;
- case WM_SETFOCUS:
- SetFocusState(true);
- RealizeWindowPalette(false);
- DestroySystemCaret();
- CreateSystemCaret();
- break;
+ case WM_SETFOCUS:
+ SetFocusState(true);
+ RealizeWindowPalette(false);
+ DestroySystemCaret();
+ CreateSystemCaret();
+ break;
- case WM_SYSCOLORCHANGE:
- //Platform::DebugPrintf("Setting Changed\n");
- InvalidateStyleData();
- break;
+ case WM_SYSCOLORCHANGE:
+ //Platform::DebugPrintf("Setting Changed\n");
+ InvalidateStyleData();
+ break;
- case WM_PALETTECHANGED:
- if (wParam != reinterpret_cast<uptr_t>(MainHWND())) {
- //Platform::DebugPrintf("** Palette Changed\n");
- RealizeWindowPalette(true);
- }
- break;
+ case WM_PALETTECHANGED:
+ if (wParam != reinterpret_cast<uptr_t>(MainHWND())) {
+ //Platform::DebugPrintf("** Palette Changed\n");
+ RealizeWindowPalette(true);
+ }
+ break;
- case WM_QUERYNEWPALETTE:
- //Platform::DebugPrintf("** Query palette\n");
- RealizeWindowPalette(false);
- break;
+ case WM_QUERYNEWPALETTE:
+ //Platform::DebugPrintf("** Query palette\n");
+ RealizeWindowPalette(false);
+ break;
- case WM_IME_STARTCOMPOSITION: // dbcs
- ImeStartComposition();
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_IME_STARTCOMPOSITION: // dbcs
+ ImeStartComposition();
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case WM_IME_ENDCOMPOSITION: // dbcs
- ImeEndComposition();
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ case WM_IME_ENDCOMPOSITION: // dbcs
+ ImeEndComposition();
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case WM_IME_COMPOSITION:
- return HandleComposition(wParam, lParam);
+ case WM_IME_COMPOSITION:
+ return HandleComposition(wParam, lParam);
- case WM_IME_CHAR: {
- AddCharBytes(HIBYTE(wParam), LOBYTE(wParam));
- return 0;
- }
+ case WM_IME_CHAR: {
+ AddCharBytes(HIBYTE(wParam), LOBYTE(wParam));
+ return 0;
+ }
- case WM_CONTEXTMENU:
+ case WM_CONTEXTMENU:
#ifdef TOTAL_CONTROL
- if (displayPopupMenu) {
- Point pt = Point::FromLong(lParam);
- if ((pt.x == -1) && (pt.y == -1)) {
- // Caused by keyboard so display menu near caret
- pt = LocationFromPosition(currentPos);
- POINT spt = {pt.x, pt.y};
- ::ClientToScreen(MainHWND(), &spt);
- pt = Point(spt.x, spt.y);
+ if (displayPopupMenu) {
+ Point pt = Point::FromLong(lParam);
+ if ((pt.x == -1) && (pt.y == -1)) {
+ // Caused by keyboard so display menu near caret
+ pt = LocationFromPosition(currentPos);
+ POINT spt = {pt.x, pt.y};
+ ::ClientToScreen(MainHWND(), &spt);
+ pt = Point(spt.x, spt.y);
+ }
+ ContextMenu(pt);
+ return 0;
}
- ContextMenu(pt);
- return 0;
- }
#endif
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
-
- case WM_INPUTLANGCHANGE:
- //::SetThreadLocale(LOWORD(lParam));
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
-
- case WM_INPUTLANGCHANGEREQUEST:
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case WM_ERASEBKGND:
- return 1; // Avoid any background erasure as whole window painted.
+ case WM_INPUTLANGCHANGE:
+ //::SetThreadLocale(LOWORD(lParam));
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case WM_CAPTURECHANGED:
- capturedMouse = false;
- return 0;
+ case WM_INPUTLANGCHANGEREQUEST:
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- // These are not handled in Scintilla and its faster to dispatch them here.
- // Also moves time out to here so profile doesn't count lots of empty message calls.
-
- case WM_MOVE:
- case WM_MOUSEACTIVATE:
- case WM_NCHITTEST:
- case WM_NCCALCSIZE:
- case WM_NCPAINT:
- case WM_NCMOUSEMOVE:
- case WM_NCLBUTTONDOWN:
- case WM_IME_SETCONTEXT:
- case WM_IME_NOTIFY:
- case WM_SYSCOMMAND:
- case WM_WINDOWPOSCHANGING:
- case WM_WINDOWPOSCHANGED:
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
-
- case EM_LINEFROMCHAR:
- if (static_cast<int>(wParam) < 0) {
- wParam = SelectionStart();
- }
- return pdoc->LineFromPosition(wParam);
+ case WM_ERASEBKGND:
+ return 1; // Avoid any background erasure as whole window painted.
- case EM_EXLINEFROMCHAR:
- return pdoc->LineFromPosition(lParam);
+ case WM_CAPTURECHANGED:
+ capturedMouse = false;
+ return 0;
- case EM_GETSEL:
- if (wParam) {
- *reinterpret_cast<int *>(wParam) = SelectionStart();
- }
- if (lParam) {
- *reinterpret_cast<int *>(lParam) = SelectionEnd();
- }
- return MAKELONG(SelectionStart(), SelectionEnd());
+ // These are not handled in Scintilla and its faster to dispatch them here.
+ // Also moves time out to here so profile doesn't count lots of empty message calls.
+
+ case WM_MOVE:
+ case WM_MOUSEACTIVATE:
+ case WM_NCHITTEST:
+ case WM_NCCALCSIZE:
+ case WM_NCPAINT:
+ case WM_NCMOUSEMOVE:
+ case WM_NCLBUTTONDOWN:
+ case WM_IME_SETCONTEXT:
+ case WM_IME_NOTIFY:
+ case WM_SYSCOMMAND:
+ case WM_WINDOWPOSCHANGING:
+ case WM_WINDOWPOSCHANGED:
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
- case EM_EXGETSEL: {
- if (lParam == 0) {
- return 0;
+ case EM_LINEFROMCHAR:
+ if (static_cast<int>(wParam) < 0) {
+ wParam = SelectionStart();
}
- CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
- pCR->cpMin = SelectionStart();
- pCR->cpMax = SelectionEnd();
- }
- break;
+ return pdoc->LineFromPosition(wParam);
- case EM_SETSEL: {
- int nStart = static_cast<int>(wParam);
- int nEnd = static_cast<int>(lParam);
- if (nStart == 0 && nEnd == -1) {
- nEnd = pdoc->Length();
+ case EM_EXLINEFROMCHAR:
+ return pdoc->LineFromPosition(lParam);
+
+ case EM_GETSEL:
+ if (wParam) {
+ *reinterpret_cast<int *>(wParam) = SelectionStart();
}
- if (nStart == -1) {
- nStart = nEnd; // Remove selection
+ if (lParam) {
+ *reinterpret_cast<int *>(lParam) = SelectionEnd();
}
- if (nStart > nEnd) {
- SetSelection(nEnd, nStart);
- } else {
- SetSelection(nStart, nEnd);
+ return MAKELONG(SelectionStart(), SelectionEnd());
+
+ case EM_EXGETSEL: {
+ if (lParam == 0) {
+ return 0;
+ }
+ CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
+ pCR->cpMin = SelectionStart();
+ pCR->cpMax = SelectionEnd();
}
- EnsureCaretVisible();
- }
- break;
+ break;
- case EM_EXSETSEL: {
- if (lParam == 0) {
- return 0;
+ case EM_SETSEL: {
+ int nStart = static_cast<int>(wParam);
+ int nEnd = static_cast<int>(lParam);
+ if (nStart == 0 && nEnd == -1) {
+ nEnd = pdoc->Length();
+ }
+ if (nStart == -1) {
+ nStart = nEnd; // Remove selection
+ }
+ if (nStart > nEnd) {
+ SetSelection(nEnd, nStart);
+ } else {
+ SetSelection(nStart, nEnd);
+ }
+ EnsureCaretVisible();
}
- CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
- selType = selStream;
- if (pCR->cpMin == 0 && pCR->cpMax == -1) {
- SetSelection(pCR->cpMin, pdoc->Length());
- } else {
- SetSelection(pCR->cpMin, pCR->cpMax);
+ break;
+
+ case EM_EXSETSEL: {
+ if (lParam == 0) {
+ return 0;
+ }
+ CharacterRange *pCR = reinterpret_cast<CharacterRange *>(lParam);
+ selType = selStream;
+ if (pCR->cpMin == 0 && pCR->cpMax == -1) {
+ SetSelection(pCR->cpMin, pdoc->Length());
+ } else {
+ SetSelection(pCR->cpMin, pCR->cpMax);
+ }
+ EnsureCaretVisible();
+ return pdoc->LineFromPosition(SelectionStart());
}
- EnsureCaretVisible();
- return pdoc->LineFromPosition(SelectionStart());
- }
- case SCI_GETDIRECTFUNCTION:
- return reinterpret_cast<sptr_t>(DirectFunction);
+ case SCI_GETDIRECTFUNCTION:
+ return reinterpret_cast<sptr_t>(DirectFunction);
- case SCI_GETDIRECTPOINTER:
- return reinterpret_cast<sptr_t>(this);
+ case SCI_GETDIRECTPOINTER:
+ return reinterpret_cast<sptr_t>(this);
- case SCI_GRABFOCUS:
- ::SetFocus(MainHWND());
- break;
+ case SCI_GRABFOCUS:
+ ::SetFocus(MainHWND());
+ break;
- case SCI_SETKEYSUNICODE:
- keysAlwaysUnicode = wParam != 0;
- break;
+ case SCI_SETKEYSUNICODE:
+ keysAlwaysUnicode = wParam != 0;
+ break;
- case SCI_GETKEYSUNICODE:
- return keysAlwaysUnicode;
+ case SCI_GETKEYSUNICODE:
+ return keysAlwaysUnicode;
#ifdef SCI_LEXER
- case SCI_LOADLEXERLIBRARY:
- LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(lParam));
- break;
+ case SCI_LOADLEXERLIBRARY:
+ LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(lParam));
+ break;
#endif
- default:
- return ScintillaBase::WndProc(iMessage, wParam, lParam);
+ default:
+ return ScintillaBase::WndProc(iMessage, wParam, lParam);
+ }
+ } catch (std::bad_alloc&) {
+ errorStatus = SC_STATUS_BADALLOC;
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
}
return 0l;
}
@@ -1544,7 +1551,12 @@ STDMETHODIMP FormatEnumerator_Reset(FormatEnumerator *fe) {
return S_OK;
}
STDMETHODIMP FormatEnumerator_Clone(FormatEnumerator *fe, IEnumFORMATETC **ppenum) {
- FormatEnumerator *pfe = new FormatEnumerator(fe->pos, fe->formats, fe->formatsLen);
+ FormatEnumerator *pfe;
+ try {
+ pfe = new FormatEnumerator(fe->pos, fe->formats, fe->formatsLen);
+ } catch (...) {
+ return E_OUTOFMEMORY;
+ }
return FormatEnumerator_QueryInterface(pfe, IID_IEnumFORMATETC,
reinterpret_cast<void **>(ppenum));
}
@@ -1671,21 +1683,29 @@ STDMETHODIMP DataObject_SetData(DataObject *, FORMATETC *, STGMEDIUM *, BOOL) {
}
STDMETHODIMP DataObject_EnumFormatEtc(DataObject *pd, DWORD dwDirection, IEnumFORMATETC **ppEnum) {
- //Platform::DebugPrintf("DOB EnumFormatEtc %d\n", dwDirection);
- if (dwDirection != DATADIR_GET) {
- *ppEnum = 0;
+ try {
+ //Platform::DebugPrintf("DOB EnumFormatEtc %d\n", dwDirection);
+ if (dwDirection != DATADIR_GET) {
+ *ppEnum = 0;
+ return E_FAIL;
+ }
+ FormatEnumerator *pfe;
+ if (pd->sci->IsUnicodeMode()) {
+ CLIPFORMAT formats[] = {CF_UNICODETEXT, CF_TEXT};
+ pfe = new FormatEnumerator(0, formats, 2);
+ } else {
+ CLIPFORMAT formats[] = {CF_TEXT};
+ pfe = new FormatEnumerator(0, formats, 1);
+ }
+ return FormatEnumerator_QueryInterface(pfe, IID_IEnumFORMATETC,
+ reinterpret_cast<void **>(ppEnum));
+ } catch (std::bad_alloc&) {
+ pd->sci->errorStatus = SC_STATUS_BADALLOC;
+ return E_OUTOFMEMORY;
+ } catch (...) {
+ pd->sci->errorStatus = SC_STATUS_FAILURE;
return E_FAIL;
}
- FormatEnumerator *pfe;
- if (pd->sci->IsUnicodeMode()) {
- CLIPFORMAT formats[] = {CF_UNICODETEXT, CF_TEXT};
- pfe = new FormatEnumerator(0, formats, 2);
- } else {
- CLIPFORMAT formats[] = {CF_TEXT};
- pfe = new FormatEnumerator(0, formats, 1);
- }
- return FormatEnumerator_QueryInterface(pfe, IID_IEnumFORMATETC,
- reinterpret_cast<void **>(ppEnum));
}
STDMETHODIMP DataObject_DAdvise(DataObject *, FORMATETC *, DWORD, IAdviseSink *, PDWORD) {
@@ -1738,17 +1758,37 @@ STDMETHODIMP_(ULONG)DropTarget_Release(DropTarget *dt) {
/// Implement IDropTarget by forwarding to Scintilla
STDMETHODIMP DropTarget_DragEnter(DropTarget *dt, LPDATAOBJECT pIDataSource, DWORD grfKeyState,
POINTL pt, PDWORD pdwEffect) {
- return dt->sci->DragEnter(pIDataSource, grfKeyState, pt, pdwEffect);
+ try {
+ return dt->sci->DragEnter(pIDataSource, grfKeyState, pt, pdwEffect);
+ } catch (...) {
+ dt->sci->errorStatus = SC_STATUS_FAILURE;
+ }
+ return E_FAIL;
}
STDMETHODIMP DropTarget_DragOver(DropTarget *dt, DWORD grfKeyState, POINTL pt, PDWORD pdwEffect) {
- return dt->sci->DragOver(grfKeyState, pt, pdwEffect);
+ try {
+ return dt->sci->DragOver(grfKeyState, pt, pdwEffect);
+ } catch (...) {
+ dt->sci->errorStatus = SC_STATUS_FAILURE;
+ }
+ return E_FAIL;
}
STDMETHODIMP DropTarget_DragLeave(DropTarget *dt) {
- return dt->sci->DragLeave();
+ try {
+ return dt->sci->DragLeave();
+ } catch (...) {
+ dt->sci->errorStatus = SC_STATUS_FAILURE;
+ }
+ return E_FAIL;
}
STDMETHODIMP DropTarget_Drop(DropTarget *dt, LPDATAOBJECT pIDataSource, DWORD grfKeyState,
POINTL pt, PDWORD pdwEffect) {
- return dt->sci->Drop(pIDataSource, grfKeyState, pt, pdwEffect);
+ try {
+ return dt->sci->Drop(pIDataSource, grfKeyState, pt, pdwEffect);
+ } catch (...) {
+ dt->sci->errorStatus = SC_STATUS_FAILURE;
+ }
+ return E_FAIL;
}
static void *vtDropTarget[] = {
@@ -2112,107 +2152,122 @@ STDMETHODIMP ScintillaWin::DragEnter(LPDATAOBJECT pIDataSource, DWORD grfKeyStat
}
STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffect) {
- if (!hasOKText || pdoc->IsReadOnly()) {
- *pdwEffect = DROPEFFECT_NONE;
- return S_OK;
- }
+ try {
+ if (!hasOKText || pdoc->IsReadOnly()) {
+ *pdwEffect = DROPEFFECT_NONE;
+ return S_OK;
+ }
- *pdwEffect = EffectFromState(grfKeyState);
+ *pdwEffect = EffectFromState(grfKeyState);
- // Update the cursor.
- POINT rpt = {pt.x, pt.y};
- ::ScreenToClient(MainHWND(), &rpt);
- SetDragPosition(PositionFromLocation(Point(rpt.x, rpt.y)));
+ // Update the cursor.
+ POINT rpt = {pt.x, pt.y};
+ ::ScreenToClient(MainHWND(), &rpt);
+ SetDragPosition(PositionFromLocation(Point(rpt.x, rpt.y)));
- return S_OK;
+ return S_OK;
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
+ return E_FAIL;
}
STDMETHODIMP ScintillaWin::DragLeave() {
- SetDragPosition(invalidPosition);
- return S_OK;
+ try {
+ SetDragPosition(invalidPosition);
+ return S_OK;
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
+ return E_FAIL;
}
STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
POINTL pt, PDWORD pdwEffect) {
- *pdwEffect = EffectFromState(grfKeyState);
+ try {
+ *pdwEffect = EffectFromState(grfKeyState);
- if (pIDataSource == NULL)
- return E_POINTER;
+ if (pIDataSource == NULL)
+ return E_POINTER;
- SetDragPosition(invalidPosition);
+ SetDragPosition(invalidPosition);
- STGMEDIUM medium={0,{0},0};
+ STGMEDIUM medium={0,{0},0};
- char *data = 0;
- bool dataAllocated = false;
+ char *data = 0;
+ bool dataAllocated = false;
- FORMATETC fmtu = {CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
- HRESULT hr = pIDataSource->GetData(&fmtu, &medium);
- if (SUCCEEDED(hr) && medium.hGlobal) {
- wchar_t *udata = static_cast<wchar_t *>(::GlobalLock(medium.hGlobal));
- if (IsUnicodeMode()) {
- int tlen = ::GlobalSize(medium.hGlobal);
- // Convert UTF-16 to UTF-8
- int dataLen = UTF8Length(udata, tlen/2);
- data = new char[dataLen+1];
- if (data) {
- UTF8FromUTF16(udata, tlen/2, data, dataLen);
- dataAllocated = true;
- }
- } else {
- // Convert UTF-16 to ANSI
- //
- // Default Scintilla behavior in Unicode mode
- // CF_UNICODETEXT available, but not in Unicode mode
- // Convert from Unicode to current Scintilla code page
- UINT cpDest = CodePageFromCharSet(
- vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
- int tlen = ::WideCharToMultiByte(cpDest, 0, udata, -1,
- NULL, 0, NULL, NULL) - 1; // subtract 0 terminator
- data = new char[tlen + 1];
- if (data) {
- memset(data, 0, (tlen+1));
- ::WideCharToMultiByte(cpDest, 0, udata, -1,
- data, tlen + 1, NULL, NULL);
- dataAllocated = true;
+ FORMATETC fmtu = {CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+ HRESULT hr = pIDataSource->GetData(&fmtu, &medium);
+ if (SUCCEEDED(hr) && medium.hGlobal) {
+ wchar_t *udata = static_cast<wchar_t *>(::GlobalLock(medium.hGlobal));
+ if (IsUnicodeMode()) {
+ int tlen = ::GlobalSize(medium.hGlobal);
+ // Convert UTF-16 to UTF-8
+ int dataLen = UTF8Length(udata, tlen/2);
+ data = new char[dataLen+1];
+ if (data) {
+ UTF8FromUTF16(udata, tlen/2, data, dataLen);
+ dataAllocated = true;
+ }
+ } else {
+ // Convert UTF-16 to ANSI
+ //
+ // Default Scintilla behavior in Unicode mode
+ // CF_UNICODETEXT available, but not in Unicode mode
+ // Convert from Unicode to current Scintilla code page
+ UINT cpDest = CodePageFromCharSet(
+ vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
+ int tlen = ::WideCharToMultiByte(cpDest, 0, udata, -1,
+ NULL, 0, NULL, NULL) - 1; // subtract 0 terminator
+ data = new char[tlen + 1];
+ if (data) {
+ memset(data, 0, (tlen+1));
+ ::WideCharToMultiByte(cpDest, 0, udata, -1,
+ data, tlen + 1, NULL, NULL);
+ dataAllocated = true;
+ }
}
}
- }
- if (!data) {
- FORMATETC fmte = {CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
- hr = pIDataSource->GetData(&fmte, &medium);
- if (SUCCEEDED(hr) && medium.hGlobal) {
- data = static_cast<char *>(::GlobalLock(medium.hGlobal));
+ if (!data) {
+ FORMATETC fmte = {CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
+ hr = pIDataSource->GetData(&fmte, &medium);
+ if (SUCCEEDED(hr) && medium.hGlobal) {
+ data = static_cast<char *>(::GlobalLock(medium.hGlobal));
+ }
}
- }
- if (!data) {
- //Platform::DebugPrintf("Bad data format: 0x%x\n", hres);
- return hr;
- }
+ if (!data) {
+ //Platform::DebugPrintf("Bad data format: 0x%x\n", hres);
+ return hr;
+ }
- FORMATETC fmtr = {cfColumnSelect, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- HRESULT hrRectangular = pIDataSource->QueryGetData(&fmtr);
+ FORMATETC fmtr = {cfColumnSelect, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
+ HRESULT hrRectangular = pIDataSource->QueryGetData(&fmtr);
- POINT rpt = {pt.x, pt.y};
- ::ScreenToClient(MainHWND(), &rpt);
- int movePos = PositionFromLocation(Point(rpt.x, rpt.y));
+ POINT rpt = {pt.x, pt.y};
+ ::ScreenToClient(MainHWND(), &rpt);
+ int movePos = PositionFromLocation(Point(rpt.x, rpt.y));
- DropAt(movePos, data, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);
+ DropAt(movePos, data, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);
- ::GlobalUnlock(medium.hGlobal);
+ ::GlobalUnlock(medium.hGlobal);
- // Free data
- if (medium.pUnkForRelease != NULL)
- medium.pUnkForRelease->Release();
- else
- ::GlobalFree(medium.hGlobal);
+ // Free data
+ if (medium.pUnkForRelease != NULL)
+ medium.pUnkForRelease->Release();
+ else
+ ::GlobalFree(medium.hGlobal);
- if (dataAllocated)
- delete []data;
+ if (dataAllocated)
+ delete []data;
- return S_OK;
+ return S_OK;
+ } catch (...) {
+ errorStatus = SC_STATUS_FAILURE;
+ }
+ return E_FAIL;
}
/// Implement important part of IDataObject
@@ -2379,59 +2434,63 @@ static void SetWindowPointer(HWND hWnd, void *ptr) {
sptr_t PASCAL ScintillaWin::CTWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, sptr_t lParam) {
-
// Find C++ object associated with window.
ScintillaWin *sciThis = reinterpret_cast<ScintillaWin *>(PointerFromWindow(hWnd));
- // ctp will be zero if WM_CREATE not seen yet
- if (sciThis == 0) {
- if (iMessage == WM_CREATE) {
- // Associate CallTip object with window
- CREATESTRUCT *pCreate = reinterpret_cast<CREATESTRUCT *>(lParam);
- SetWindowPointer(hWnd, pCreate->lpCreateParams);
- return 0;
- } else {
- return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
- }
- } else {
- if (iMessage == WM_NCDESTROY) {
- ::SetWindowLong(hWnd, 0, 0);
- return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
- } else if (iMessage == WM_PAINT) {
- PAINTSTRUCT ps;
- ::BeginPaint(hWnd, &ps);
- Surface *surfaceWindow = Surface::Allocate();
- if (surfaceWindow) {
- surfaceWindow->Init(ps.hdc, hWnd);
- surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == sciThis->ct.codePage);
- surfaceWindow->SetDBCSMode(sciThis->ct.codePage);
- sciThis->ct.PaintCT(surfaceWindow);
- surfaceWindow->Release();
- delete surfaceWindow;
+ try {
+ // ctp will be zero if WM_CREATE not seen yet
+ if (sciThis == 0) {
+ if (iMessage == WM_CREATE) {
+ // Associate CallTip object with window
+ CREATESTRUCT *pCreate = reinterpret_cast<CREATESTRUCT *>(lParam);
+ SetWindowPointer(hWnd, pCreate->lpCreateParams);
+ return 0;
+ } else {
+ return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
}
- ::EndPaint(hWnd, &ps);
- return 0;
- } else if ((iMessage == WM_NCLBUTTONDOWN) || (iMessage == WM_NCLBUTTONDBLCLK)) {
- POINT pt;
- pt.x = static_cast<short>(LOWORD(lParam));
- pt.y = static_cast<short>(HIWORD(lParam));
- ScreenToClient(hWnd, &pt);
- sciThis->ct.MouseClick(Point(pt.x, pt.y));
- sciThis->CallTipClick();
- return 0;
- } else if (iMessage == WM_LBUTTONDOWN) {
- // This does not fire due to the hit test code
- sciThis->ct.MouseClick(Point::FromLong(lParam));
- sciThis->CallTipClick();
- return 0;
- } else if (iMessage == WM_SETCURSOR) {
- ::SetCursor(::LoadCursor(NULL,IDC_ARROW));
- return 0;
- } else if (iMessage == WM_NCHITTEST) {
- return HTCAPTION;
} else {
- return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
+ if (iMessage == WM_NCDESTROY) {
+ ::SetWindowLong(hWnd, 0, 0);
+ return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
+ } else if (iMessage == WM_PAINT) {
+ PAINTSTRUCT ps;
+ ::BeginPaint(hWnd, &ps);
+ Surface *surfaceWindow = Surface::Allocate();
+ if (surfaceWindow) {
+ surfaceWindow->Init(ps.hdc, hWnd);
+ surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == sciThis->ct.codePage);
+ surfaceWindow->SetDBCSMode(sciThis->ct.codePage);
+ sciThis->ct.PaintCT(surfaceWindow);
+ surfaceWindow->Release();
+ delete surfaceWindow;
+ }
+ ::EndPaint(hWnd, &ps);
+ return 0;
+ } else if ((iMessage == WM_NCLBUTTONDOWN) || (iMessage == WM_NCLBUTTONDBLCLK)) {
+ POINT pt;
+ pt.x = static_cast<short>(LOWORD(lParam));
+ pt.y = static_cast<short>(HIWORD(lParam));
+ ScreenToClient(hWnd, &pt);
+ sciThis->ct.MouseClick(Point(pt.x, pt.y));
+ sciThis->CallTipClick();
+ return 0;
+ } else if (iMessage == WM_LBUTTONDOWN) {
+ // This does not fire due to the hit test code
+ sciThis->ct.MouseClick(Point::FromLong(lParam));
+ sciThis->CallTipClick();
+ return 0;
+ } else if (iMessage == WM_SETCURSOR) {
+ ::SetCursor(::LoadCursor(NULL,IDC_ARROW));
+ return 0;
+ } else if (iMessage == WM_NCHITTEST) {
+ return HTCAPTION;
+ } else {
+ return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
+ }
}
+ } catch (...) {
+ sciThis->errorStatus = SC_STATUS_FAILURE;
}
+ return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
}
sptr_t ScintillaWin::DirectFunction(
@@ -2457,18 +2516,23 @@ sptr_t PASCAL ScintillaWin::SWndProc(
ScintillaWin *sci = reinterpret_cast<ScintillaWin *>(PointerFromWindow(hWnd));
// sci will be zero if WM_CREATE not seen yet
if (sci == 0) {
- if (iMessage == WM_CREATE) {
- // Create C++ object associated with window
- sci = new ScintillaWin(hWnd);
- SetWindowPointer(hWnd, sci);
- return sci->WndProc(iMessage, wParam, lParam);
- } else {
- return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
+ try {
+ if (iMessage == WM_CREATE) {
+ // Create C++ object associated with window
+ sci = new ScintillaWin(hWnd);
+ SetWindowPointer(hWnd, sci);
+ return sci->WndProc(iMessage, wParam, lParam);
+ }
+ } catch (...) {
}
+ return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
} else {
if (iMessage == WM_NCDESTROY) {
- sci->Finalise();
- delete sci;
+ try {
+ sci->Finalise();
+ delete sci;
+ } catch (...) {
+ }
::SetWindowLong(hWnd, 0, 0);
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
} else {
diff --git a/win32/makefile b/win32/makefile
index e6fa49f47..143be32e0 100644
--- a/win32/makefile
+++ b/win32/makefile
@@ -29,7 +29,7 @@ LDFLAGS=-mwindows -lstdc++ -limm32 -lole32 -luuid -mno-cygwin
# Add -MMD to get dependencies
#CXXFLAGS = -g -pg -pedantic -Os -fno-exceptions -fvtable-thunks -fno-rtti
INCLUDEDIRS=-I ../include -I ../src
-CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -pedantic $(INCLUDEDIRS) -Os -fno-exceptions $(THUNKFLAGS) -fno-rtti -mno-cygwin
+CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -pedantic $(INCLUDEDIRS) -Os $(THUNKFLAGS) -fno-rtti -mno-cygwin
ifdef DEBUG
CXXFLAGS=-DDEBUG $(CXXBASEFLAGS)
diff --git a/win32/scintilla.mak b/win32/scintilla.mak
index f2f64a87f..ff8dc8f57 100644
--- a/win32/scintilla.mak
+++ b/win32/scintilla.mak
@@ -35,7 +35,7 @@ CC=cl
RC=rc
LD=link
-CXXFLAGS=-Zi -TP -W4 -Zc:forScope -Zc:wchar_t -D_CRT_SECURE_NO_DEPRECATE=1
+CXXFLAGS=-Zi -TP -W4 -EHsc -Zc:forScope -Zc:wchar_t -D_CRT_SECURE_NO_DEPRECATE=1
# For something scary:-Wp64
CXXDEBUG=-Od -MTd -DDEBUG
CXXNDEBUG=-O1 -MT -DNDEBUG -GL
@@ -52,7 +52,7 @@ CC=bcc32
RC=brcc32 -r
LD=ilink32
-CXXFLAGS=-P -tWM -w -w-prc -w-inl -w-pin -RT- -x-
+CXXFLAGS=-P -tWM -w -w-prc -w-inl -w-pin -RT-
# Above turns off warnings for clarfying parentheses and inlines with for not expanded
CXXDEBUG=-Od -v -DDEBUG
CXXNDEBUG=-O1 -DNDEBUG
diff --git a/win32/scintilla_vc6.mak b/win32/scintilla_vc6.mak
index 3d9191755..7a782af16 100644
--- a/win32/scintilla_vc6.mak
+++ b/win32/scintilla_vc6.mak
@@ -36,7 +36,7 @@ RC=rc
LD=link
#-Zc:forScope -Zc:wchar_t
-CXXFLAGS=-Zi -TP -W4
+CXXFLAGS=-Zi -TP -W4 -EHsc
# For something scary:-Wp64
CXXDEBUG=-Od -MTd -DDEBUG
CXXNDEBUG=-O1 -MT -DNDEBUG
@@ -54,7 +54,7 @@ CC=bcc32
RC=brcc32 -r
LD=ilink32
-CXXFLAGS=-P -tWM -w -w-prc -w-inl -RT- -x-
+CXXFLAGS=-P -tWM -w -w-prc -w-inl -RT-
# Above turns off warnings for clarfying parentheses and inlines with for not expanded
CXXDEBUG=-Od -v -DDEBUG
CXXNDEBUG=-O1 -DNDEBUG