Skip to content

Commit

Permalink
Merge branch 'scintilla-update-342'
Browse files Browse the repository at this point in the history
This fixes flickering under GTK >= 3.10.
  • Loading branch information
b4n committed May 17, 2014
2 parents f3d96ef + 67329f2 commit e566435
Show file tree
Hide file tree
Showing 34 changed files with 1,390 additions and 949 deletions.
2 changes: 2 additions & 0 deletions data/filetypes.c
Expand Up @@ -28,6 +28,8 @@ globalclass=class
# """verbatim"""
tripleverbatim=string_2
hashquotedstring=string_2
taskmarker=comment
escapesequence=string_1

[keywords]
# all items must be in one line
Expand Down
65 changes: 44 additions & 21 deletions scintilla/gtk/ScintillaGTK.cxx
Expand Up @@ -160,6 +160,7 @@ class ScintillaGTK : public ScintillaBase {
#else
GdkRegion *rgnUpdate;
#endif
bool repaintFullWindow;

// Private so ScintillaGTK objects can not be copied
ScintillaGTK(const ScintillaGTK &);
Expand All @@ -172,6 +173,7 @@ class ScintillaGTK : public ScintillaBase {
private:
virtual void Initialise();
virtual void Finalise();
virtual bool AbandonPaint();
virtual void DisplayCursor(Window::Cursor c);
virtual bool DragThreshold(Point ptStart, Point ptNow);
virtual void StartDrag();
Expand Down Expand Up @@ -309,7 +311,7 @@ class ScintillaGTK : public ScintillaBase {
#endif
static gboolean PressCT(GtkWidget *widget, GdkEventButton *event, ScintillaGTK *sciThis);

static sptr_t DirectFunction(ScintillaGTK *sciThis,
static sptr_t DirectFunction(sptr_t ptr,
unsigned int iMessage, uptr_t wParam, sptr_t lParam);
};

Expand Down Expand Up @@ -365,7 +367,8 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
im_context(NULL),
lastWheelMouseDirection(0),
wheelMouseIntensity(0),
rgnUpdate(0) {
rgnUpdate(0),
repaintFullWindow(false) {
sci = sci_;
wMain = GTK_WIDGET(sci);

Expand Down Expand Up @@ -756,10 +759,10 @@ void ScintillaGTK::Initialise() {
#else
g_signal_connect(G_OBJECT(widtxt), "expose_event",
G_CALLBACK(ScintillaGTK::ExposeText), this);
#endif
gtk_widget_set_events(widtxt, GDK_EXPOSURE_MASK);
// Avoid background drawing flash
gtk_widget_set_double_buffered(widtxt, FALSE);
#endif
gtk_widget_set_events(widtxt, GDK_EXPOSURE_MASK);
gtk_widget_set_size_request(widtxt, 100, 100);
adjustmentv = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 201.0, 1.0, 20.0, 20.0));
#if GTK_CHECK_VERSION(3,0,0)
Expand Down Expand Up @@ -825,6 +828,13 @@ void ScintillaGTK::Finalise() {
ScintillaBase::Finalise();
}

bool ScintillaGTK::AbandonPaint() {
if ((paintState == painting) && !paintingAllText) {
repaintFullWindow = true;
}
return false;
}

void ScintillaGTK::DisplayCursor(Window::Cursor c) {
if (cursorMode == SC_CURSORNORMAL)
wText.SetCursor(c);
Expand All @@ -842,11 +852,20 @@ void ScintillaGTK::StartDrag() {
dragWasDropped = false;
inDragDrop = ddDragging;
GtkTargetList *tl = gtk_target_list_new(clipboardCopyTargets, nClipboardCopyTargets);
#if GTK_CHECK_VERSION(3,10,0)
gtk_drag_begin_with_coordinates(GTK_WIDGET(PWidget(wMain)),
tl,
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE),
evbtn->button,
reinterpret_cast<GdkEvent *>(evbtn),
-1, -1);
#else
gtk_drag_begin(GTK_WIDGET(PWidget(wMain)),
tl,
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE),
evbtn->button,
reinterpret_cast<GdkEvent *>(evbtn));
#endif
}

static std::string ConvertText(const char *s, size_t len, const char *charSetDest,
Expand Down Expand Up @@ -1189,7 +1208,7 @@ bool ScintillaGTK::ModifyScrollBars(int nMax, int nPage) {
}
#endif
if (modified && (paintState == painting)) {
paintState = paintAbandoned;
repaintFullWindow = true;
}

return modified;
Expand Down Expand Up @@ -1487,7 +1506,7 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio
len--; // Forget the extra '\0'
#endif

std::string dest = Document::TransformLineEnds(data, len, pdoc->eolMode);
std::string dest(data, len);
if (selectionTypeData == GDK_TARGET_STRING) {
if (IsUnicodeMode()) {
// Unknown encoding so assume in Latin1
Expand Down Expand Up @@ -1528,15 +1547,9 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) {
if (SelectionOfGSD(selection_data) != GDK_SELECTION_PRIMARY) {
ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH);
}
SelectionPosition selStart = sel.IsRectangular() ?
sel.Rectangular().Start() :
sel.Range(sel.Main()).Start();

if (selText.rectangular) {
PasteRectangular(selStart, selText.Data(), selText.Length());
} else {
InsertPaste(selStart, selText.Data(), selText.Length());
}
InsertPasteShape(selText.Data(), selText.Length(),
selText.rectangular ? pasteRectangular : pasteStream);
EnsureCaretVisible();
}
}
Expand Down Expand Up @@ -1667,9 +1680,9 @@ void ScintillaGTK::Resize(int width, int height) {
// Not always needed, but some themes can have different sizes of scrollbars
#if GTK_CHECK_VERSION(3,0,0)
GtkRequisition requisition;
gtk_widget_get_requisition(PWidget(scrollbarv), &requisition);
gtk_widget_get_preferred_size(PWidget(scrollbarv), NULL, &requisition);
verticalScrollBarWidth = requisition.width;
gtk_widget_get_requisition(PWidget(scrollbarh), &requisition);
gtk_widget_get_preferred_size(PWidget(scrollbarh), NULL, &requisition);
horizontalScrollBarHeight = requisition.height;
#else
verticalScrollBarWidth = GTK_WIDGET(PWidget(scrollbarv))->requisition.width;
Expand Down Expand Up @@ -2168,8 +2181,9 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) {
//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);
const int lengthInserted = pdoc->InsertString(CurrentPosition(), event->string, strlen(event->string));
if (lengthInserted > 0) {
MovePositionTo(CurrentPosition() + lengthInserted);
}
}
return consumed;
Expand Down Expand Up @@ -2370,6 +2384,7 @@ void ScintillaGTK::Destroy(GObject *object) {
gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) {
try {
paintState = painting;
repaintFullWindow = false;

rcPaint = GetClientRectangle();

Expand Down Expand Up @@ -2397,11 +2412,12 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) {
surfaceWindow->Release();
delete surfaceWindow;
}
if (paintState == paintAbandoned) {
if ((paintState == paintAbandoned) || repaintFullWindow) {
// Painting area was insufficient to cover new styling or brace highlight positions
FullPaint();
}
paintState = notPainting;
repaintFullWindow = false;

if (rgnUpdate) {
cairo_rectangle_list_destroy(rgnUpdate);
Expand All @@ -2425,6 +2441,13 @@ gboolean ScintillaGTK::DrawThis(cairo_t *cr) {
GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarh), cr);
gtk_container_propagate_draw(
GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarv), cr);
// Starting from the following version, the expose event are not propagated
// for double buffered non native windows, so we need to call it ourselves
// or keep the default handler
#if GTK_CHECK_VERSION(3,9,2)
gtk_container_propagate_draw(
GTK_CONTAINER(PWidget(wMain)), PWidget(wText), cr);
#endif
} catch (...) {
errorStatus = SC_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2788,8 +2811,8 @@ gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, Cal
#endif

sptr_t ScintillaGTK::DirectFunction(
ScintillaGTK *sciThis, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sciThis->WndProc(iMessage, wParam, lParam);
sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return reinterpret_cast<ScintillaGTK *>(ptr)->WndProc(iMessage, wParam, lParam);
}

sptr_t scintilla_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
Expand Down
24 changes: 15 additions & 9 deletions scintilla/include/Platform.h
Expand Up @@ -77,7 +77,9 @@ namespace Scintilla {

typedef float XYPOSITION;
typedef double XYACCUMULATOR;
//#define XYPOSITION int
inline int RoundXYPosition(XYPOSITION xyPos) {
return int(xyPos + 0.5);
}

// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
Expand All @@ -92,7 +94,7 @@ typedef void *IdlerID;

/**
* A geometric point class.
* Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably.
* Point is similar to the Win32 POINT and GTK+ GdkPoint types.
*/
class Point {
public:
Expand All @@ -102,14 +104,18 @@ class Point {
explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) {
}

static Point FromInts(int x_, int y_) {
return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_));
}

// Other automatically defined methods (assignment, copy constructor, destructor) are fine

static Point FromLong(long lpoint);
};

/**
* A geometric rectangle class.
* PRectangle is exactly the same as the Win32 RECT so can be used interchangeably.
* PRectangle is similar to the Win32 RECT.
* PRectangles contain their top and left sides, but not their right and bottom sides.
*/
class PRectangle {
Expand All @@ -119,10 +125,15 @@ class PRectangle {
XYPOSITION right;
XYPOSITION bottom;

PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
left(left_), top(top_), right(right_), bottom(bottom_) {
}

static PRectangle FromInts(int left_, int top_, int right_, int bottom_) {
return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_),
static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_));
}

// Other automatically defined methods (assignment, copy constructor, destructor) are fine

bool operator==(PRectangle &rc) const {
Expand Down Expand Up @@ -516,11 +527,6 @@ class Platform {
}
#endif

// Shut up annoying Visual C++ warnings:
#ifdef _MSC_VER
#pragma warning(disable: 4244 4309 4514 4710)
#endif

#if defined(__GNUC__) && defined(SCINTILLA_QT)
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
Expand Down
13 changes: 13 additions & 0 deletions scintilla/include/SciLexer.h
Expand Up @@ -126,6 +126,7 @@
#define SCLEX_RUST 111
#define SCLEX_DMAP 112
#define SCLEX_AS 113
#define SCLEX_DMIS 114
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
Expand Down Expand Up @@ -169,6 +170,8 @@
#define SCE_C_PREPROCESSORCOMMENT 23
#define SCE_C_PREPROCESSORCOMMENTDOC 24
#define SCE_C_USERLITERAL 25
#define SCE_C_TASKMARKER 26
#define SCE_C_ESCAPESEQUENCE 27
#define SCE_D_DEFAULT 0
#define SCE_D_COMMENT 1
#define SCE_D_COMMENTLINE 2
Expand Down Expand Up @@ -1700,6 +1703,16 @@
#define SCE_DMAP_WORD 8
#define SCE_DMAP_WORD2 9
#define SCE_DMAP_WORD3 10
#define SCE_DMIS_DEFAULT 0
#define SCE_DMIS_COMMENT 1
#define SCE_DMIS_STRING 2
#define SCE_DMIS_NUMBER 3
#define SCE_DMIS_KEYWORD 4
#define SCE_DMIS_MAJORWORD 5
#define SCE_DMIS_MINORWORD 6
#define SCE_DMIS_UNSUPPORTED_MAJOR 7
#define SCE_DMIS_UNSUPPORTED_MINOR 8
#define SCE_DMIS_LABEL 9
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */

#endif
5 changes: 4 additions & 1 deletion scintilla/include/Scintilla.h
Expand Up @@ -50,6 +50,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_ADDTEXT 2001
#define SCI_ADDSTYLEDTEXT 2002
#define SCI_INSERTTEXT 2003
#define SCI_CHANGEINSERTION 2672
#define SCI_CLEARALL 2004
#define SCI_DELETERANGE 2645
#define SCI_CLEARDOCUMENTSTYLE 2005
Expand Down Expand Up @@ -461,6 +462,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008
#define SC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010
#define SC_FOLDFLAG_LEVELNUMBERS 0x0040
#define SC_FOLDFLAG_LINESTATE 0x0080
#define SCI_SETFOLDFLAGS 2233
#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234
#define SCI_SETTABINDENTS 2260
Expand Down Expand Up @@ -945,7 +947,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_MOD_CHANGEANNOTATION 0x20000
#define SC_MOD_CONTAINER 0x40000
#define SC_MOD_LEXERSTATE 0x80000
#define SC_MODEVENTMASKALL 0xFFFFF
#define SC_MOD_INSERTCHECK 0x100000
#define SC_MODEVENTMASKALL 0x1FFFFF
#define SC_UPDATE_CONTENT 0x1
#define SC_UPDATE_SELECTION 0x2
#define SC_UPDATE_V_SCROLL 0x4
Expand Down
22 changes: 21 additions & 1 deletion scintilla/include/Scintilla.iface
Expand Up @@ -98,6 +98,9 @@ fun void AddStyledText=2002(int length, cells c)
# Insert string at a position.
fun void InsertText=2003(position pos, string text)

# Change the text that is being inserted in response to SC_MOD_INSERTCHECK
fun void ChangeInsertion=2672(int length, string text)

# Delete all text in the document.
fun void ClearAll=2004(,)

Expand Down Expand Up @@ -1151,6 +1154,7 @@ val SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004
val SC_FOLDFLAG_LINEAFTER_EXPANDED=0x0008
val SC_FOLDFLAG_LINEAFTER_CONTRACTED=0x0010
val SC_FOLDFLAG_LEVELNUMBERS=0x0040
val SC_FOLDFLAG_LINESTATE=0x0080

# Set some style options for folding.
set void SetFoldFlags=2233(int flags,)
Expand Down Expand Up @@ -2494,7 +2498,8 @@ val SC_MOD_CHANGEMARGIN=0x10000
val SC_MOD_CHANGEANNOTATION=0x20000
val SC_MOD_CONTAINER=0x40000
val SC_MOD_LEXERSTATE=0x80000
val SC_MODEVENTMASKALL=0xFFFFF
val SC_MOD_INSERTCHECK=0x100000
val SC_MODEVENTMASKALL=0x1FFFFF

enu Update=SC_UPDATE_
val SC_UPDATE_CONTENT=0x1
Expand Down Expand Up @@ -2659,6 +2664,7 @@ val SCLEX_KVIRC=110
val SCLEX_RUST=111
val SCLEX_DMAP=112
val SCLEX_AS=113
val SCLEX_DMIS=114

# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
Expand Down Expand Up @@ -2711,6 +2717,8 @@ val SCE_C_HASHQUOTEDSTRING=22
val SCE_C_PREPROCESSORCOMMENT=23
val SCE_C_PREPROCESSORCOMMENTDOC=24
val SCE_C_USERLITERAL=25
val SCE_C_TASKMARKER=26
val SCE_C_ESCAPESEQUENCE=27
# Lexical states for SCLEX_D
lex D=SCLEX_D SCE_D_
val SCE_D_DEFAULT=0
Expand Down Expand Up @@ -4438,6 +4446,18 @@ val SCE_DMAP_IDENTIFIER=7
val SCE_DMAP_WORD=8
val SCE_DMAP_WORD2=9
val SCE_DMAP_WORD3=10
# Lexical states for SCLEX_DMIS
lex DMIS=SCLEX_DMIS SCE_DMIS_
val SCE_DMIS_DEFAULT=0
val SCE_DMIS_COMMENT=1
val SCE_DMIS_STRING=2
val SCE_DMIS_NUMBER=3
val SCE_DMIS_KEYWORD=4
val SCE_DMIS_MAJORWORD=5
val SCE_DMIS_MINORWORD=6
val SCE_DMIS_UNSUPPORTED_MAJOR=7
val SCE_DMIS_UNSUPPORTED_MINOR=8
val SCE_DMIS_LABEL=9

# Events

Expand Down

0 comments on commit e566435

Please sign in to comment.