diff options
author | culler <culler> | 2019-01-02 01:21:48 (GMT) |
---|---|---|
committer | culler <culler> | 2019-01-02 01:21:48 (GMT) |
commit | dac8c5e71bad36669aaecfc25e3e82cefef6c1ed (patch) | |
tree | aef73c2a0977a53bea0ef730806f2097659b7407 | |
parent | 27d71c8a9216f3fd97537b0f3aaa6a7650aca3e1 (diff) | |
download | tk-dac8c5e71bad36669aaecfc25e3e82cefef6c1ed.zip tk-dac8c5e71bad36669aaecfc25e3e82cefef6c1ed.tar.gz tk-dac8c5e71bad36669aaecfc25e3e82cefef6c1ed.tar.bz2 |
Use a flag bit instead of an int to store the sync state. Avoid running idle
tasks in the sync command if possible.
-rw-r--r-- | generic/tkText.c | 2 | ||||
-rw-r--r-- | generic/tkText.h | 3 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 18 |
3 files changed, 15 insertions, 8 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index 5f248a8..2dabe4c 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -533,7 +533,6 @@ CreateWidget( textPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(textPtr->tkwin), TextWidgetObjCmd, textPtr, TextCmdDeletedProc); - textPtr->inSync = 1; if (sharedPtr == NULL) { sharedPtr = ckalloc(sizeof(TkSharedText)); @@ -1560,7 +1559,6 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; diff --git a/generic/tkText.h b/generic/tkText.h index 91abb73..5d88784 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -785,8 +785,7 @@ typedef struct TkText { * refering to us. */ int insertCursorType; /* 0 = standard insertion cursor, 1 = block * cursor. */ - int inSync; /* The last value sent as a <<WidgetViewSync>> - event. Initialized to 1.*/ + /* * Copies of information from the shared section relating to the undo/redo * functonality diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4ff9307..ae452c5 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -497,13 +497,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL; * different character might be under the mouse * cursor now). Need to recompute the current * character before the next redisplay. + * OUT_OF_SYNC 1 means that the last <<WidgetViewSync>> event had + * value 0, indicating that the widget is out of sync. */ #define DINFO_OUT_OF_DATE 1 #define REDRAW_PENDING 2 #define REDRAW_BORDERS 4 #define REPICK_NEEDED 8 - +#define OUT_OF_SYNC 16 /* * Action values for FreeDLines: * @@ -3152,8 +3154,12 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - if (InSync != textPtr->inSync) { - textPtr->inSync = InSync; + if (InSync == !!(textPtr->dInfoPtr->flags & OUT_OF_SYNC)) { + if (InSync) { + textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; + } else { + textPtr->dInfoPtr->flags |= OUT_OF_SYNC; + } TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", Tcl_NewBooleanObj(InSync)); } @@ -3202,7 +3208,11 @@ TkTextUpdateLineMetrics( int fullUpdateRequested = (lineNum == 0 && endLine == totalLines && doThisMuch == -1); - + + if (fullUpdateRequested && (textPtr->dInfoPtr->flags & REDRAW_PENDING)) { + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + } + if (totalLines == 0) { /* * Empty peer widget. |