static void DrawLineEndAtIter (Cairo.Context cntx, TextView view, TextIter iter) { Gdk.Rectangle rect = view.GetIterLocation (iter); int x, y; view.BufferToWindowCoords (TextWindowType.Text, rect.X, rect.Y + rect.Height / 2, out x, out y); cntx.Save (); cntx.Color = GetDrawingColorForIter (view, iter); double arrowSize = 3; cntx.MoveTo (x + 10, y); cntx.RelLineTo (new Cairo.Distance (0, -arrowSize)); cntx.RelMoveTo (new Cairo.Distance (0, arrowSize)); cntx.RelLineTo (new Cairo.Distance (-8, 0)); cntx.RelLineTo (new Cairo.Distance (arrowSize, arrowSize)); cntx.RelMoveTo (new Cairo.Distance (-arrowSize, -arrowSize)); cntx.RelLineTo (new Cairo.Distance (arrowSize, -arrowSize)); cntx.Stroke (); cntx.Restore (); }
private void GetCharCountDrawInfo (TextView textView, out int[,] info) { if (textView.Buffer.LineCount == 0) { info = null; return; //shouldn't happen, but just to make sure } /* Get visible coordinates */ int minVisibleY = textView.VisibleRect.Top; int maxVisibleY = textView.VisibleRect.Bottom; /* Get visible start and end iters */ TextIter startIter, endIter; int lineTop; textView.GetLineAtY(out startIter, minVisibleY, out lineTop); textView.GetLineAtY(out endIter, maxVisibleY, out lineTop); int lineCount = endIter.Line - startIter.Line + 1; int startLine = startIter.Line; int endLine = endIter.Line; /* Initializations */ info = new int[lineCount, 2]; /* Process start iter */ int startLineCharCount = startIter.CharsInLine - (lineCount > 1 ? 1 : 0); //subtract 1 for newline if there are >1 lines info[0, 0] = startLineCharCount; //Char Count Gdk.Rectangle startIterLocation = textView.GetIterLocation(startIter); info[0, 1] = startIterLocation.Bottom - (startIterLocation.Height/2) - minVisibleY; //Y /* If only 1 line, return */ if (lineCount == 1) { return; } /* Process middle iters */ for (int i = 1, line = startLine + 1 ; line < endLine ; i++, line++) { TextIter iter = textView.Buffer.GetIterAtLine(line); int charCount = iter.CharsInLine - 1; //subtract 1 for newline info[i, 0] = charCount; Gdk.Rectangle iterLocation = textView.GetIterLocation(iter); info[i, 1] = iterLocation.Bottom - (iterLocation.Height/2) - minVisibleY; //Y } /* Process end iter */ int endLineCharCount = endIter.CharsInLine - (endLine == textView.Buffer.LineCount - 1 ? 0 : 1); //subtract newline if this isn't the last line in the buffer info[lineCount-1, 0] = endLineCharCount; Gdk.Rectangle endIterLocation = textView.GetIterLocation(endIter); info[lineCount-1, 1] = endIterLocation.Bottom - (endIterLocation.Height/2) - minVisibleY; //Y }
static void DrawSpaceAtIter (Cairo.Context cntx, TextView view, TextIter iter) { Gdk.Rectangle rect = view.GetIterLocation (iter); int x, y; view.BufferToWindowCoords (TextWindowType.Text, rect.X + rect.Width / 2, rect.Y + rect.Height / 2, out x, out y); cntx.Save (); cntx.Color = GetDrawingColorForIter (view, iter); //no overlap on the circle, even if context is set to LineCap.Square cntx.LineCap = Cairo.LineCap.Butt; cntx.MoveTo (x, y); cntx.Arc (x, y, 0.5, 0, 2 * Math.PI); cntx.Stroke (); cntx.Restore (); }