public override Control GetVisualizerWidget (ObjectValue val) { string value = val.Value; Gdk.Color col = new Gdk.Color (85, 85, 85); if (!val.IsNull && (val.TypeName == "string" || val.TypeName == "char[]")) value = '"' + GetString (val) + '"'; if (DebuggingService.HasInlineVisualizer (val)) value = DebuggingService.GetInlineVisualizer (val).InlineVisualize (val); var label = new Gtk.Label (); label.Text = value; var font = label.Style.FontDescription.Copy (); if (font.SizeIsAbsolute) { font.AbsoluteSize = font.Size - 1; } else { font.Size -= (int)(Pango.Scale.PangoScale); } label.ModifyFont (font); label.ModifyFg (StateType.Normal, col); label.SetPadding (4, 4); if (label.SizeRequest ().Width > 500) { label.WidthRequest = 500; label.Wrap = true; label.LineWrapMode = Pango.WrapMode.WordChar; } else { label.Justify = Gtk.Justification.Center; } if (label.Layout.GetLine (1) != null) { label.Justify = Gtk.Justification.Left; var line15 = label.Layout.GetLine (15); if (line15 != null) { label.Text = value.Substring (0, line15.StartIndex).TrimEnd ('\r', '\n') + "\n…"; } } label.Show (); return label; }
void HandleExceptionValueChanged (object sender, EventArgs e) { frames = null; if (exception.IsEvaluatingGroup) exception = exception.GetArrayItem (0); NotifyChanged (); }
public override Gtk.Widget GetVisualizerWidget (ObjectValue val) { var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone (); string file = Path.GetTempFileName (); Gdk.Pixbuf pixbuf; ops.AllowTargetInvoke = true; try { var pix = (RawValue) val.GetRawValue (ops); pix.CallMethod ("Save", file, "png"); pixbuf = new Gdk.Pixbuf (file); } finally { File.Delete (file); } var sc = new Gtk.ScrolledWindow (); sc.ShadowType = Gtk.ShadowType.In; sc.HscrollbarPolicy = Gtk.PolicyType.Automatic; sc.VscrollbarPolicy = Gtk.PolicyType.Automatic; var image = new Gtk.Image (pixbuf); sc.AddWithViewport (image); sc.ShowAll (); return sc; }
public PinnedWatchWidget (TextEditor editor, PinnedWatch watch) { objectValue = watch.Value; Editor = editor; Watch = watch; valueTree = new ObjectValueTreeView (); valueTree.AllowAdding = false; valueTree.AllowEditing = true; valueTree.AllowPinning = true; valueTree.HeadersVisible = false; valueTree.CompactView = true; valueTree.PinnedWatch = watch; if (objectValue != null) valueTree.AddValue (objectValue); valueTree.ButtonPressEvent += HandleValueTreeButtonPressEvent; valueTree.ButtonReleaseEvent += HandleValueTreeButtonReleaseEvent; valueTree.MotionNotifyEvent += HandleValueTreeMotionNotifyEvent; Gtk.Frame fr = new Gtk.Frame (); fr.ShadowType = Gtk.ShadowType.Out; fr.Add (valueTree); Add (fr); HandleEditorOptionsChanged (null, null); ShowAll (); //unpin.Hide (); Editor.EditorOptionsChanged += HandleEditorOptionsChanged; DebuggingService.PausedEvent += HandleDebuggingServicePausedEvent; DebuggingService.ResumedEvent += HandleDebuggingServiceResumedEvent; }
/// <summary> /// The provided value can have the following members: /// Type of the object: type of the exception /// Message: Message of the exception /// Instance: Raw instance of the exception /// StackTrace: an array of frames. Each frame must have: /// Value of the object: display text of the frame /// File: name of the file /// Line: line /// Col: column /// InnerException: inner exception, following the same format described above. /// </summary> public ExceptionInfo (ObjectValue exception) { this.exception = exception; if (exception.IsEvaluating || exception.IsEvaluatingGroup) exception.ValueChanged += HandleExceptionValueChanged; }
public void Show (ObjectValue val) { value = val; visualizers = new List<ValueVisualizer> (DebuggingService.GetValueVisualizers (val)); visualizers.Sort ((v1, v2) => string.Compare (v1.Name, v2.Name, StringComparison.CurrentCultureIgnoreCase)); buttons = new List<ToggleButton> (); Gtk.Button defaultVis = null; for (int i = 0; i < visualizers.Count; i++) { var button = new ToggleButton (); button.Label = visualizers [i].Name; button.Toggled += OnComboVisualizersChanged; if (visualizers [i].IsDefaultVisualizer (val)) defaultVis = button; hbox1.PackStart (button, false, false, 0); buttons.Add (button); button.CanFocus = false; button.Show (); } if (defaultVis != null) defaultVis.Click (); else if (buttons.Count > 0) buttons [0].Click (); if (val.IsReadOnly || !visualizers.Any (v => v.CanEdit (val))) { buttonCancel.Label = Gtk.Stock.Close; buttonSave.Hide (); } }
string GetString (ObjectValue val) { var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone (); ops.AllowTargetInvoke = true; ops.ChunkRawStrings = true; if (val.TypeName == "string") { var rawString = val.GetRawValue (ops) as RawValueString; var length = rawString.Length; if (length > 0) { return rawString.Substring (0, Math.Min (length, 4096)); } else { return ""; } } else if (val.TypeName == "char[]") { var rawArray = val.GetRawValue (ops) as RawValueArray; var length = rawArray.Length; if (length > 0) { return new string (rawArray.GetValues (0, Math.Min (length, 4096)) as char[]); } else { return ""; } } else { throw new InvalidOperationException (); } }
public void UpdateValue (ObjectValue newValue) { try { callback.UpdateValue (newValue); } catch { // Ignore } }
static ObjectValue Create (IObjectValueSource source, ObjectPath path, string typeName) { ObjectValue ob = new ObjectValue (); ob.source = source; ob.path = path; ob.typeName = typeName; return ob; }
void LoadMessage () { if (messageObject == null) { messageObject = exception.GetChild ("Message"); if (messageObject != null && messageObject.IsEvaluating) messageObject.ValueChanged += HandleMessageValueChanged; } }
public override bool CanVisualize (ObjectValue val) { switch (val.TypeName) { case "char[]": return true; case "string": return true; default: return false; } }
static ObjectValue Create (IObjectValueSource source, ObjectPath path, string typeName) { var val = new ObjectValue (); val.typeName = typeName; val.source = source; val.path = path; return val; }
public static void Show (ObjectValue val, Control widget, Gdk.Rectangle previewButtonArea) { DestroyWindow (); wnd = new PreviewVisualizerWindow (val, widget); wnd.ShowPopup (widget, previewButtonArea, PopupPosition.Left); wnd.Destroyed += HandleDestroyed; OnWindowShown (EventArgs.Empty); }
// PinWindow pinWindow; // TreeIter currentPinIter; public DebugValueWindow (Mono.TextEditor.TextEditor editor, int offset, StackFrame frame, ObjectValue value, PinnedWatch watch): base (Gtk.WindowType.Toplevel) { this.TypeHint = WindowTypeHint.PopupMenu; this.AllowShrink = false; this.AllowGrow = false; this.Decorated = false; TransientFor = (Gtk.Window) editor.Toplevel; // Avoid getting the focus when the window is shown. We'll get it when the mouse enters the window AcceptFocus = false; sw = new ScrolledWindow (); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Never; tree = new ObjectValueTreeView (); sw.Add (tree); ContentBox.Add (sw); tree.Frame = frame; tree.CompactView = true; tree.AllowAdding = false; tree.AllowEditing = true; tree.HeadersVisible = false; tree.AllowPinning = true; tree.RootPinAlwaysVisible = true; tree.PinnedWatch = watch; DocumentLocation location = editor.Document.OffsetToLocation (offset); tree.PinnedWatchLine = location.Line; tree.PinnedWatchFile = ((ExtensibleTextEditor)editor).View.ContentName; tree.AddValue (value); tree.Selection.UnselectAll (); tree.SizeAllocated += OnTreeSizeChanged; tree.PinStatusChanged += delegate { Destroy (); }; // tree.MotionNotifyEvent += HandleTreeMotionNotifyEvent; sw.ShowAll (); // pinWindow = new PinWindow (this); // pinWindow.SetPinned (false); // pinWindow.ButtonPressEvent += HandlePinWindowButtonPressEvent; tree.StartEditing += delegate { Modal = true; }; tree.EndEditing += delegate { Modal = false; }; ShowArrow = true; Theme.CornerRadius = 3; }
public bool StoreValue (ObjectValue val) { try { val.SetRawValue (textView.Buffer.Text); } catch { MonoDevelop.Ide.MessageService.ShowError ("Unable to set text"); } return true; }
internal void Evaluate (bool notify) { if (DebuggingService.CurrentFrame != null) { evaluated = true; value = DebuggingService.CurrentFrame.GetExpressionValue (expression, true); value.Name = expression; if (notify) NotifyChanged (); } }
public void Show (ObjectValue val) { value = val; visualizers = new List<IValueVisualizer> (DebuggingService.GetValueVisualizers (val)); visualizers.Sort (delegate (IValueVisualizer v1, IValueVisualizer v2) { return v1.Name.CompareTo (v2.Name); }); foreach (IValueVisualizer vis in visualizers) comboVisualizers.AppendText (vis.Name); comboVisualizers.Active = 0; }
public override bool CanVisualize (ObjectValue val) { switch (val.TypeName) { case "System.IO.MemoryStream": case "Foundation.NSData": case "sbyte[]": case "byte[]": return true; default: return false; } }
void PrintValue (ObjectValue val) { string result = val.Value; if (string.IsNullOrEmpty (result)) { if (val.IsNotSupported) result = GettextCatalog.GetString ("Expression not supported."); else if (val.IsError || val.IsUnknown) result = GettextCatalog.GetString ("Evaluation failed."); else result = string.Empty; } view.WriteOutput (result); }
public static ObjectValue CreateObject (IObjectValueSource source, ObjectPath path, string typeName, EvaluationResult value, ObjectValueFlags flags, ObjectValue[] children) { ObjectValue ob = Create (source, path, typeName); ob.path = path; ob.flags = flags | ObjectValueFlags.Object; ob.value = value.Value; ob.displayValue = value.DisplayValue; if (children != null) { ob.children = new List<ObjectValue> (); ob.children.AddRange (children); } return ob; }
public void Show (ObjectValue val) { value = val; visualizers = new List<IValueVisualizer> (DebuggingService.GetValueVisualizers (val)); visualizers.Sort (delegate (IValueVisualizer v1, IValueVisualizer v2) { return v1.Name.CompareTo (v2.Name); }); foreach (IValueVisualizer vis in visualizers) comboVisualizers.AppendText (vis.Name); comboVisualizers.Active = 0; if (val.IsReadOnly || visualizers.Count == 0) { buttonCancel.Hide (); buttonOk.Label = Gtk.Stock.Close; } }
public override bool IsDefaultVisualizer (ObjectValue val) { switch (val.TypeName) { case "MonoTouch.Foundation.NSData": case "MonoMac.Foundation.NSData": case "System.IO.MemoryStream": case "Foundation.NSData": case "sbyte[]": case "byte[]": return true; case "char[]": case "string": default: return false; } }
public DebugValueWindow (TextEditor editor, int offset, StackFrame frame, ObjectValue value, PinnedWatch watch) : base (Gtk.WindowType.Toplevel) { this.TypeHint = WindowTypeHint.PopupMenu; this.AllowShrink = false; this.AllowGrow = false; this.Decorated = false; TransientFor = (Gtk.Window) ((Gtk.Widget)editor).Toplevel; // Avoid getting the focus when the window is shown. We'll get it when the mouse enters the window AcceptFocus = false; sw = new ScrolledWindow (); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Never; tree = new ObjectValueTreeView (); sw.Add (tree); ContentBox.Add (sw); tree.Frame = frame; tree.CompactView = true; tree.AllowAdding = false; tree.AllowEditing = true; tree.HeadersVisible = false; tree.AllowPinning = true; tree.RootPinAlwaysVisible = true; tree.PinnedWatch = watch; var location = editor.OffsetToLocation (offset); tree.PinnedWatchLine = location.Line; tree.PinnedWatchFile = editor.FileName; tree.AddValue (value); tree.Selection.UnselectAll (); tree.SizeAllocated += OnTreeSizeChanged; tree.PinStatusChanged += OnPinStatusChanged; sw.ShowAll (); tree.StartEditing += OnStartEditing; tree.EndEditing += OnEndEditing; ShowArrow = true; Theme.CornerRadius = 3; }
public DebugValueWindow (Mono.TextEditor.TextEditor editor, int offset, StackFrame frame, ObjectValue value, PinnedWatch watch) { TransientFor = (Gtk.Window) editor.Toplevel; // Avoid getting the focus when the window is shown. We'll get it when the mouse enters the window AcceptFocus = false; sw = new ScrolledWindow (); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Never; tree = new ObjectValueTreeView (); sw.Add (tree); Add (sw); tree.Frame = frame; tree.CompactView = true; tree.AllowAdding = false; tree.AllowEditing = true; tree.HeadersVisible = false; tree.AllowPinning = true; tree.PinnedWatch = watch; DocumentLocation location = editor.Document.OffsetToLocation (offset); tree.PinnedWatchLine = location.Line + 1; tree.PinnedWatchFile = ((ExtensibleTextEditor)editor).View.ContentName; tree.AddValue (value); tree.Selection.UnselectAll (); tree.SizeAllocated += OnTreeSizeChanged; tree.PinStatusChanged += delegate { Destroy (); }; sw.ShowAll (); tree.StartEditing += delegate { Modal = true; }; tree.EndEditing += delegate { Modal = false; }; }
public override Widget GetVisualizerWidget (ObjectValue val) { hexEditor = new Mono.MHex.HexEditor (); byte[] buf = null; if (val.TypeName != "string") { var raw = val.GetRawValue () as RawValueArray; sbyte[] sbuf; switch (val.TypeName) { case "sbyte[]": sbuf = raw.ToArray () as sbyte[]; buf = new byte[sbuf.Length]; for (int i = 0; i < sbuf.Length; i++) buf[i] = (byte) sbuf[i]; break; case "char[]": buf = Encoding.Unicode.GetBytes (new string (raw.ToArray () as char[])); break; case "byte[]": buf = raw.ToArray () as byte[]; break; } } else { var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone (); ops.ChunkRawStrings = true; var raw = val.GetRawValue (ops) as RawValueString; buf = Encoding.Unicode.GetBytes (raw.Value); } hexEditor.HexEditorData.Buffer = new ArrayBuffer (buf); hexEditor.Sensitive = CanEdit (val); var xwtScrollView = new Xwt.ScrollView (hexEditor); var scrollWidget = (Widget) Xwt.Toolkit.CurrentEngine.GetNativeWidget (xwtScrollView); SetHexEditorOptions (); hexEditor.SetFocus (); return scrollWidget; }
public override Gtk.Widget GetVisualizerWidget (ObjectValue val) { Gdk.Pixbuf pixbuf; string file = Path.GetTempFileName (); try { RawValue pix = (RawValue) val.GetRawValue (); pix.CallMethod ("Save", file, "png"); pixbuf = new Gdk.Pixbuf (file); } finally { File.Delete (file); } Gtk.ScrolledWindow sc = new Gtk.ScrolledWindow (); sc.ShadowType = Gtk.ShadowType.In; sc.HscrollbarPolicy = Gtk.PolicyType.Automatic; sc.VscrollbarPolicy = Gtk.PolicyType.Automatic; Gtk.Image image = new Gtk.Image (pixbuf); sc.AddWithViewport (image); sc.ShowAll (); return sc; }
public Gtk.Widget GetVisualizerWidget (ObjectValue val) { VBox box = new VBox (false, 6); textView = new TextView () { WrapMode = WrapMode.Char }; Gtk.ScrolledWindow scrolled = new Gtk.ScrolledWindow (); scrolled.HscrollbarPolicy = PolicyType.Automatic; scrolled.VscrollbarPolicy = PolicyType.Automatic; scrolled.ShadowType = ShadowType.In; scrolled.Add (textView); box.PackStart (scrolled, true, true, 0); CheckButton cb = new CheckButton (GettextCatalog.GetString ("Wrap text")); cb.Active = true; cb.Toggled += delegate { if (cb.Active) textView.WrapMode = WrapMode.Char; else textView.WrapMode = WrapMode.None; }; box.PackStart (cb, false, false, 0); box.ShowAll (); EvaluationOptions ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone (); ops.ChunkRawStrings = true; this.raw = val.GetRawValue (ops) as RawValueString; this.length = raw.Length; this.offset = 0; this.val = val; if (this.length > 0) { idle_id = GLib.Idle.Add (GetNextStringChunk); textView.Destroyed += delegate { if (idle_id != 0) { GLib.Source.Remove (idle_id); idle_id = 0; } }; } return box; }
public void Show (ObjectValue val) { value = val; visualizers = new List<ValueVisualizer> (DebuggingService.GetValueVisualizers (val)); visualizers.Sort ((v1, v2) => string.Compare (v1.Name, v2.Name, StringComparison.CurrentCultureIgnoreCase)); int defaultVis = 0; int n = 0; foreach (ValueVisualizer vis in visualizers) { comboVisualizers.AppendText (vis.Name); if (vis.IsDefaultVisualizer (val)) defaultVis = n; n++; } comboVisualizers.Active = defaultVis; if (val.IsReadOnly || !visualizers.Any (v => v.CanEdit (val))) { buttonCancel.Label = Gtk.Stock.Close; buttonSave.Hide (); } }
public override Control GetVisualizerWidget (ObjectValue val) { var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone (); ops.AllowTargetInvoke = true; ops.ChunkRawStrings = true; ops.EllipsizedLength = 5000;//Preview window can hold aprox. 4700 chars val.Refresh (ops);//Refresh DebuggerDisplay/String value with full length instead of ellipsized string value = val.Value; Gdk.Color col = Styles.PreviewVisualizerTextColor.ToGdkColor (); if (DebuggingService.HasInlineVisualizer (val)) value = DebuggingService.GetInlineVisualizer (val).InlineVisualize (val); var label = new Gtk.Label (); label.Text = value; label.ModifyFont (FontService.SansFont.CopyModified (Ide.Gui.Styles.FontScale11)); label.ModifyFg (StateType.Normal, col); label.SetPadding (4, 4); if (label.SizeRequest ().Width > 500) { label.WidthRequest = 500; label.Wrap = true; label.LineWrapMode = Pango.WrapMode.WordChar; } else { label.Justify = Gtk.Justification.Center; } if (label.Layout.GetLine (1) != null) { label.Justify = Gtk.Justification.Left; var trimmedLine = label.Layout.GetLine (50); if (trimmedLine != null) { label.Text = value.Substring (0, trimmedLine.StartIndex).TrimEnd ('\r', '\n') + "\n…"; } } label.Show (); return label; }
public void Show (ObjectValue val) { value = val; visualizers = new List<ValueVisualizer> (DebuggingService.GetValueVisualizers (val)); visualizers.Sort (delegate (ValueVisualizer v1, ValueVisualizer v2) { return v1.Name.CompareTo (v2.Name); }); int defaultVis = 0; int n = 0; foreach (ValueVisualizer vis in visualizers) { comboVisualizers.AppendText (vis.Name); if (vis.IsDefaultVisualizer (val)) defaultVis = n; n++; } comboVisualizers.Active = defaultVis; if (val.IsReadOnly || !visualizers.Where (v => v.CanEdit (val)).Any ()) { buttonCancel.Hide (); buttonOk.Label = Gtk.Stock.Close; } }
internal void ConnectCallback(StackFrame parentFrame) { ObjectValue.ConnectCallbacks(parentFrame, exception); }
/// <summary> /// The provided value must have a specific structure. /// The Value property is the display text. /// A child "File" member must be the name of the file. /// A child "Line" member must be the line. /// A child "Col" member must be the column. /// </summary> public ExceptionStackFrame(ObjectValue value) { frame = value; }
public UpdateCallbackProxy(ObjectValue val) { valRef = new WeakReference(val); }