public bool IsMarked(int linenum, SourceMarkerType type) { TextIter insert = GetIterAtLine (linenum); TextIter begin_line = insert, end_line = insert; begin_line.LineOffset = 0; while (! end_line.EndsLine ()) end_line.ForwardChar (); IntPtr lst = gtk_source_buffer_get_markers_in_region (Handle, ref begin_line, ref end_line); bool fnd_marker = false; IntPtr current = lst; while (current != IntPtr.Zero) { IntPtr data = gtksharp_slist_get_data (current); IntPtr nm = gtk_source_marker_get_marker_type (data); string name = GLib.Marshaller.PtrToStringGFree (nm); if (name == type.ToString ()) { fnd_marker = true; break; } current = gtksharp_slist_get_next (current); } if (lst != IntPtr.Zero) g_slist_free (lst); return fnd_marker; }
public void ToggleMark(int linenum, SourceMarkerType type) { TextIter insert = GetIterAtLine (linenum); TextIter begin_line = insert, end_line = insert; begin_line.LineOffset = 0; while (! end_line.EndsLine ()) end_line.ForwardChar (); IntPtr lst = gtk_source_buffer_get_markers_in_region (Handle, ref begin_line, ref end_line); bool found_marker = false; // // The problem is that the buffer owns the // reference to the marker. So, if we use the nice Gtk# stuff, we get // a problem when we dispose it later. Thus we must basically write this // in C. // FIXME: Is there a bug# for this? IntPtr current = lst; while (current != IntPtr.Zero) { IntPtr data = gtksharp_slist_get_data (current); IntPtr nm = gtk_source_marker_get_marker_type (data); string name = GLib.Marshaller.PtrToStringGFree (nm); if (name == type.ToString ()) { gtk_source_buffer_delete_marker (Handle, data); found_marker = true; } current = gtksharp_slist_get_next (current); } if (lst != IntPtr.Zero) g_slist_free (lst); if (found_marker) return; switch (type.ToString ()) { case "ExecutionMark": begin_line.LineOffset = 2; break; case "BreakpointMark": begin_line.LineOffset = 1; break; } gtk_source_buffer_create_marker (Handle, null, type.ToString (), ref begin_line); }
public void ClearMarks(SourceMarkerType type) { TextIter begin = StartIter; TextIter end = EndIter; IntPtr lst = gtk_source_buffer_get_markers_in_region (Handle, ref begin, ref end); IntPtr current = lst; while (current != IntPtr.Zero) { IntPtr data = gtksharp_slist_get_data (current); IntPtr nm = gtk_source_marker_get_marker_type (data); string name = GLib.Marshaller.PtrToStringGFree (nm); if (name == type.ToString ()) gtk_source_buffer_delete_marker (Handle, data); current = gtksharp_slist_get_next (current); } if (lst != IntPtr.Zero) g_slist_free (lst); }