public void RequestRedraw()
 {
     RemoveRedrawTimer();
     redrawTimeout = GLib.Timeout.Add(450, delegate {
         if (curUpdate != null)
         {
             curUpdate.RemoveHandler();
             curUpdate = null;
         }
         if (backgroundPixbuf != null)
         {
             curUpdate = new BgBufferUpdate(this);
         }
         redrawTimeout = 0;
         return(false);
     });
 }
            void CreateBgBuffer()
            {
                DestroyBgBuffer();
                curWidth  = Allocation.Width;
                curHeight = Math.Max(Allocation.Height, (int)(lineHeight * (TextEditor.GetTextEditorData().VisibleLineCount + TextEditor.EditorLineThreshold)));
                if (GdkWindow == null || curWidth < 1 || curHeight < 1)
                {
                    return;
                }
                backgroundPixbuf = new Pixmap(GdkWindow, curWidth, curHeight);
                backgroundBuffer = new Pixmap(GdkWindow, curWidth, curHeight);

                if (TextEditor.ColorStyle != null)
                {
                    using (var cr = Gdk.CairoHelper.Create(backgroundPixbuf)) {
                        cr.Rectangle(0, 0, curWidth, curHeight);
                        cr.Color = TextEditor.ColorStyle.Default.CairoBackgroundColor;
                        cr.Fill();
                    }
                }
                curUpdate = new BgBufferUpdate(this);
            }
            void CreateBgBuffer()
            {
                DestroyBgBuffer();
                curWidth  = Allocation.Width;
                curHeight = Math.Max(Allocation.Height, (int)(lineHeight * (TextEditor.GetTextEditorData().VisibleLineCount)));
                if (GdkWindow == null || curWidth < 1 || curHeight < 1)
                {
                    return;
                }
                var displayScale = Platform.IsWindows ? GtkWorkarounds.GetScaleFactor(this) : 1.0;

                backgroundPixbuf = new Pixmap(GdkWindow, (int)(curWidth * displayScale), (int)(curHeight * displayScale));
                backgroundBuffer = new Pixmap(GdkWindow, (int)(curWidth * displayScale), (int)(curHeight * displayScale));

                if (TextEditor.ColorStyle != null)
                {
                    using (var cr = Gdk.CairoHelper.Create(backgroundPixbuf)) {
                        cr.Rectangle(0, 0, curWidth * displayScale, curHeight * displayScale);
                        cr.SetSourceColor(TextEditor.ColorStyle.PlainText.Background);
                        cr.Fill();
                    }
                }
                curUpdate = new BgBufferUpdate(this);
            }
			void RequestRedraw ()
			{
				RemoveRedrawTimer ();
				redrawTimeout = GLib.Timeout.Add (450, delegate {
					if (curUpdate != null) {
						curUpdate.RemoveHandler ();
						curUpdate = null;
					}
					if (backgroundPixbuf != null)
						curUpdate = new BgBufferUpdate (this);
					redrawTimeout = 0;
					return false;
				});
			}
			void CreateBgBuffer ()
			{
				DestroyBgBuffer ();
				curWidth = Allocation.Width;
				curHeight = Math.Max (Allocation.Height, (int)(lineHeight * TextEditor.GetTextEditorData ().VisibleLineCount));
				if (GdkWindow == null || curWidth < 1 || curHeight < 1)
					return;
				backgroundPixbuf = new Pixmap (GdkWindow, curWidth, curHeight);
				backgroundBuffer = new Pixmap (GdkWindow, curWidth, curHeight);
				
				if (TextEditor.ColorStyle != null) {
					using (var cr = Gdk.CairoHelper.Create (backgroundPixbuf)) {
						cr.Rectangle (0, 0, curWidth, curHeight);
						cr.Color = TextEditor.ColorStyle.Default.CairoBackgroundColor;
						cr.Fill ();
					}
				}
				curUpdate = new BgBufferUpdate (this);
			}