33
33
using MonoDevelop.Core.ProgressMonitoring;
34
34
using MonoDevelop.Core.Execution;
36
using System.Text.RegularExpressions;
37
using MonoDevelop.Ide.Fonts;
38
using MonoDevelop.Components.Commands;
37
40
namespace MonoDevelop.Ide.Gui.Components
59
61
const int MAX_BUFFER_LENGTH = 4000 * 1024;
64
/// The log text view allows the user to jump to the source of an error/warning
65
/// by double clicking on the line in the text view.
67
public class LogTextView : TextView
69
public LogTextView (Gtk.TextBuffer buf) : base (buf)
77
static Regex lineRegex = new Regex ("\\b.*\\s(?<file>[/\\\\].*):(line\\s)?(?<line>\\d+)\\s*$", RegexOptions.Compiled);
78
protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
80
if (evnt.Type == Gdk.EventType.TwoButtonPress) {
81
var cursorPos = base.Buffer.GetIterAtOffset (this.Buffer.CursorPosition);
87
iterStart = Buffer.GetIterAtLine (cursorPos.Line);
88
iterEnd = Buffer.GetIterAtOffset (iterStart.Offset + iterStart.CharsInLine);
90
lineText = Buffer.GetText (iterStart, iterEnd, true);
91
} catch (Exception e) {
92
LoggingService.LogError ("Error in getting text of the current line.", e);
93
return base.OnButtonPressEvent (evnt);
96
var match = lineRegex.Match (lineText);
98
string file = match.Groups["file"].Value;
99
string line = match.Groups["line"].Value;
100
if (!string.IsNullOrEmpty (file) && !string.IsNullOrEmpty (line)) {
103
fileExists = File.Exists (file);
110
lineNumber = int.Parse (line);
111
} catch (Exception) {
114
IdeApp.Workbench.OpenDocument (file, lineNumber, 1);
119
return base.OnButtonPressEvent (evnt);
63
125
buffer = new Gtk.TextBuffer (new Gtk.TextTagTable ());
64
textEditorControl = new Gtk.TextView (buffer);
126
textEditorControl = new LogTextView (buffer);
65
127
textEditorControl.Editable = false;
67
129
ShadowType = ShadowType.None;
88
150
endMark = buffer.CreateMark ("end-mark", buffer.EndIter, false);
90
UpdateCustomFont (IdeApp.Preferences.CustomOutputPadFont);
91
153
IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomFontChanged;
93
155
outputDispatcher = new GLib.TimeoutHandler (outputDispatchHandler);
158
[CommandHandler (Ide.Commands.EditCommands.Copy)]
163
if (buffer.HasSelection && buffer.GetSelectionBounds (out start, out end)) {
164
var text = buffer.GetText (start, end, false);
165
var clipboard = Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
166
clipboard.Text = text;
168
clipboard = Clipboard.Get (Gdk.Atom.Intern ("PRIMARY", false));
169
clipboard.Text = text;
96
173
public LogViewProgressMonitor GetProgressMonitor ()
112
void HandleCustomFontChanged (object sender, PropertyChangedEventArgs e)
189
void HandleCustomFontChanged (object sender, EventArgs e)
114
UpdateCustomFont ((string)e.NewValue);
117
void UpdateCustomFont (string name)
194
void UpdateCustomFont ()
119
if (customFont != null) {
120
customFont.Dispose ();
123
if (!string.IsNullOrEmpty (name)) {
124
customFont = Pango.FontDescription.FromString (name);
126
textEditorControl.ModifyFont (customFont);
196
textEditorControl.ModifyFont (IdeApp.Preferences.CustomOutputPadFont ?? FontService.DefaultMonospaceFontDescription);
129
199
//mechanism to to batch copy text when large amounts are being dumped
448
514
userWarned = true;
449
515
string title = GettextCatalog.GetString ("Console input not supported");
450
string desc = GettextCatalog.GetString ("Console input is not supported when using the MonoDevelop output console. If your applications needs to read data from the standard input, please set the 'Run in External Console' option in the project options.");
516
string desc = GettextCatalog.GetString (
517
"Console input is not supported when using the {0} output console. If your application needs to read " +
518
"data from the standard input, please set the 'Run in External Console' option in the project options.",
519
BrandingService.ApplicationName
451
521
MessageService.ShowWarning (title, desc);