void DocumentChanged(object sender, DocumentEventArgs e)
 {
     if (e.Text == null) {
         Remove(e.Offset, e.Length);
     } else {
         if (e.Length < 0) {
             Insert(e.Offset, e.Text);
         } else {
             Replace(e.Offset, e.Length, e.Text);
         }
     }
 }
 // KSL End
 void TextAreaChangedEvent(object sender, DocumentEventArgs e)
 {
     IsDirty = true;
 }
        public void AdjustScrollBars(object sender, DocumentEventArgs e)
        {
            double v_curval = vScrollBar.Adjustment.Value;
            int v_min = 0;
            int v_max = (Document.TotalNumberOfLines + textArea.TextView.VisibleLineCount - 2) * textArea.TextView.FontHeight;
            int v_lc = Math.Max(0, textArea.TextView.DrawingPosition.Height);
            int v_sc = Math.Max(0, textArea.TextView.FontHeight);

            double h_curval = hScrollBar.Adjustment.Value;
            int h_min = 0;
            int h_max = (int)(1000 * textArea.TextView.GetWidth(' ')) ; //Math.Max(0, max + textArea.TextView.VisibleColumnCount - 1);
            int h_lc = Math.Max(0, textArea.TextView.DrawingPosition.Width);
            int h_sc = Math.Max(0, (int)textArea.TextView.GetWidth(' '));

            Gtk.Adjustment ha = new Gtk.Adjustment(h_curval, h_min, h_max, h_sc, h_lc, 100);
            Gtk.Adjustment va = new Gtk.Adjustment(v_curval, v_min, v_max, v_sc, v_lc, 100);

            hScrollBar.Adjustment = ha;
            vScrollBar.Adjustment = va;
        }
 protected void OnDocumentChanged(DocumentEventArgs e)
 {
     if (DocumentChanged != null) {
         DocumentChanged(this, e);
     }
 }