Exemple #1
0
        public static bool ReplaceSelection(this Gtk.TextBuffer buffer, string newText, bool keepSelection = true)
        {
            bool     retval = false;
            TextIter start;
            TextIter end;

            if (buffer.GetSelectionBounds(out start, out end))
            {
                TextMark startMark = buffer.CreateMark("start", start, false);
                TextMark endMark   = buffer.CreateMark("end", end, true);

                buffer.DeleteSelection(true, true);

                TextIter start2 = buffer.GetIterAtMark(startMark);
                buffer.Insert(ref start2, newText);

                if (keepSelection)
                {
                    TextIter start3 = buffer.GetIterAtMark(startMark);
                    TextIter end3   = buffer.GetIterAtMark(endMark);

                    buffer.SelectRange(start3, end3);
                }
                retval = true;
            }
            return(retval);
        }
Exemple #2
0
        public void Append(string s)
        {
            TextMark tm = stb.GetMark("insert");

            stb.InsertAtCursor(String.Concat(s, "\n"));
            stv.ScrollMarkOnscreen(tm);
        }
Exemple #3
0
        public LogView()
        {
            buffer                     = new Gtk.TextBuffer(new Gtk.TextTagTable());
            textEditorControl          = new LogTextView(buffer);
            textEditorControl.Editable = false;

            ShadowType = ShadowType.None;
            Add(textEditorControl);

            bold        = new TextTag("bold");
            bold.Weight = Pango.Weight.Bold;
            buffer.TagTable.Add(bold);

            errorTag            = new TextTag("error");
            errorTag.Foreground = "red";
            errorTag.Weight     = Pango.Weight.Bold;
            buffer.TagTable.Add(errorTag);

            consoleLogTag            = new TextTag("consoleLog");
            consoleLogTag.Foreground = "darkgrey";
            buffer.TagTable.Add(consoleLogTag);

            tag            = new TextTag("0");
            tag.LeftMargin = 10;
            buffer.TagTable.Add(tag);
            tags.Add(tag);

            endMark = buffer.CreateMark("end-mark", buffer.EndIter, false);

            UpdateCustomFont();
            IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomFontChanged;

            outputDispatcher = new GLib.TimeoutHandler(outputDispatchHandler);
        }
Exemple #4
0
        protected void OnItemtreeRowActivated(object o, RowActivatedArgs args)
        {
            var rec = treeManager.GetItem(args.Path, 0);

            if (rec != null)
            {
                if (rec.SourceFile != null)
                {
                    var toopen = from r in records where r.SourceFile == rec.SourceFile select r;
                    var tmp    = new List <CodeRecord> (toopen);
                    OpenSourceFile(tmp);
                    SourceView sv = null;

                    string localfile = null;
                    if (fsmap.SourceMap.TryGetValue(rec.SourceFile, out localfile))
                    {
                        // assuming it is open, scroll to the thing we clicked
                        if (sourceviews.TryGetValue(localfile, out sv))
                        {
                            var tm   = new TextMark(rec.FullMethodName, true);
                            var iter = sv.Buffer.GetIterAtLine(rec.GetLines()[0] - 1);

                            sv.Buffer.AddMark(tm, iter);
                            sv.ScrollToMark(tm, 0.3, true, 0.2, 0.2);
                            sv.ScrollMarkOnscreen(tm);
                            sv.Buffer.PlaceCursor(iter);
                        }
                    }
                }
            }
        }
        private void ScrollToEnd()
        {
            TextIter ti = ytextviewProgressStatus.Buffer.GetIterAtLine(ytextviewProgressStatus.Buffer.LineCount - 1);
            TextMark tm = ytextviewProgressStatus.Buffer.CreateMark("eot", ti, false);

            ytextviewProgressStatus.ScrollToMark(tm, 0, false, 0, 0);
        }
        private void HighlightSearchTerms(string highlight)
        {
            TextBuffer buffer = conversation.Buffer;
            string     text   = buffer.GetText(buffer.StartIter, buffer.EndIter, false).ToLower();

            string [] words    = highlight.Split(' ');
            bool      scrolled = false;

            foreach (string word in words)
            {
                int idx = 0;

                if (word == String.Empty)
                {
                    continue;
                }

                while ((idx = text.IndexOf(word.ToLower(), idx)) != -1)
                {
                    Gtk.TextIter start = buffer.GetIterAtOffset(idx);
                    Gtk.TextIter end   = start;
                    end.ForwardChars(word.Length);
                    if (!scrolled)
                    {
                        scrolled = true;
                        TextMark mark = buffer.CreateMark(null, start, false);
                        conversation.ScrollMarkOnscreen(mark);
                    }
                    buffer.ApplyTag("highlight", start, end);

                    idx += word.Length;
                }
            }
        }
Exemple #7
0
        private void ShowPrompt(bool newline, bool continuation)
        {
            TextIter end_iter = Buffer.EndIter;

            if (newline)
            {
                Buffer.Insert(ref end_iter, "\n");
            }

            string prompt = continuation ? InteractiveBase.ContinuationPrompt : InteractiveBase.Prompt;

            Buffer.Insert(ref end_iter, prompt);

            Buffer.PlaceCursor(Buffer.EndIter);
            ScrollMarkOnscreen(Buffer.InsertMark);

            end_of_last_processing = Buffer.CreateMark(null, Buffer.EndIter, true);
            Buffer.ApplyTag(Buffer.TagTable.Lookup("Freezer"), Buffer.StartIter, InputLineBegin);

            TextIter prompt_start_iter = InputLineBegin;

            prompt_start_iter.LineIndex -= prompt.Length;

            TextIter prompt_end_iter = InputLineBegin;

            prompt_end_iter.LineIndex -= 1;

            Buffer.ApplyTag(Buffer.TagTable.Lookup(continuation ? "PromptContinuation" : "Prompt"),
                            prompt_start_iter, prompt_end_iter);
        }
        public SourceEditorBuffer() : base(new TextTagTable())
        {
            markup            = new TextTag("breakpoint");
            markup.Background = "yellow";
            TagTable.Add(markup);

            complete_ahead            = new TextTag("complete_ahead");
            complete_ahead.Foreground = "grey";
            TagTable.Add(complete_ahead);

            compilation_error           = new TextTag("compilation_error");
            compilation_error.Underline = Pango.Underline.Error;
            TagTable.Add(compilation_error);

            complete_end                = CreateMark(null, StartIter, true);
            highlightLineTag            = new TextTag("highlightLine");
            highlightLineTag.Background = "lightgrey";
            TagTable.Add(highlightLineTag);

            MaxUndoLevels = 1000;

            base.InsertText  += OnInsertText;
            base.DeleteRange += onDeleteRangeAfter;
            base.DeleteRange += onDeleteRangeBefore;
        }
Exemple #9
0
        public void Prompt(bool newLine, bool multiline)
        {
            lock (m_Lock)
            {
                TextIter end = Buffer.EndIter;
                if (newLine)
                {
                    Buffer.Insert(ref end, "\n");
                }
                if (multiline)
                {
                    Buffer.Insert(ref end, PromptMultiLineString);
                }
                else
                {
                    Buffer.Insert(ref end, PromptString);
                }

                Buffer.PlaceCursor(Buffer.EndIter);
                textView.ScrollMarkOnscreen(Buffer.InsertMark);

                // Record the end of where we processed, used to calculate start
                // of next input line
                endOfLastProcessing = Buffer.CreateMark(null, Buffer.EndIter, true);

                // Freeze all the text except our input line
                Buffer.ApplyTag(Buffer.TagTable.Lookup("Freezer"), Buffer.StartIter, InputLineBegin);
            }
        }
Exemple #10
0
        private void scrollToEnd()
        {
            TextIter ti = textViewChat.Buffer.GetIterAtLine(textViewChat.Buffer.LineCount - 1);
            TextMark tm = textViewChat.Buffer.CreateMark("eot", ti, false);

            textViewChat.ScrollToMark(tm, 0, false, 0, 0);
        }
Exemple #11
0
        public void async_update_status()
        {
            string s;

            if (Settings.TransmitAgent == "efax")
            {
                s = Fax.async_get_server_status();
                if (s != null)
                {
                    TextMark tm = StatusTextBuffer.GetMark("insert");
                    StatusTextBuffer.InsertAtCursor(String.Concat(s, "\n"));
                    StatusText.ScrollMarkOnscreen(tm);
                }
            }

            if (Settings.TransmitAgent == "hylafax")
            {
                // Progressbar pulser - add this when we have async comms
                GLib.Timeout.Add((uint)(100), new TimeoutHandler(queue_progress));

                // update status bar
                Appbar.ClearStack();
                Appbar.Push(Catalog.GetString("Refreshing server status..."));
                Appbar.Refresh();
                //GLib.MainContext.Iteration ();
                while (Gtk.Application.EventsPending())
                {
                    Gtk.Application.RunIteration();
                }

                s = Fax.async_get_server_status();
            }
        }
Exemple #12
0
        private void ScrollToBottom()
        {
            TextMark EndMark = chatTextView.Buffer.CreateMark("end", chatTextView.Buffer.EndIter, false);

            chatTextView.ScrollToMark(EndMark, 0.4, true, 0.0, 1.0);
            chatTextView.Buffer.DeleteMark(EndMark);
            chatTextView.QueueDraw();
        }
        public AddLogEntryDialog(Dictionary <string, ChangeLogEntry> entries)
        {
            Build();

            Pango.FontDescription font = Pango.FontDescription.FromString(DesktopService.DefaultMonospaceFont);
            textview.ModifyFont(font);
            textview.WrapMode   = WrapMode.None;
            textview.AcceptsTab = true;
            Pango.TabArray tabs = new Pango.TabArray(1, true);
            tabs.SetTab(0, Pango.TabAlign.Left, GetStringWidth(" ") * 4);
            textview.Tabs           = tabs;
            textview.SizeRequested += delegate(object o, SizeRequestedArgs args)
            {
                textview.WidthRequest = GetStringWidth(string.Empty.PadRight(80));
            };
            font.Dispose();

            store          = new ListStore(typeof(ChangeLogEntry), typeof(Gdk.Pixbuf), typeof(string));
            fileList.Model = store;

            fileList.AppendColumn(string.Empty, new CellRendererPixbuf(), "pixbuf", 1);
            fileList.AppendColumn(string.Empty, new CellRendererText(), "text", 2);

            foreach (ChangeLogEntry ce in entries.Values)
            {
                Gdk.Pixbuf pic;
                if (ce.CantGenerate)
                {
                    pic = ImageService.GetPixbuf(Gtk.Stock.DialogWarning, Gtk.IconSize.Menu);
                }
                else if (ce.IsNew)
                {
                    pic = ImageService.GetPixbuf(Gtk.Stock.New, Gtk.IconSize.Menu);
                }
                else
                {
                    pic = null;
                }
                store.AppendValues(ce, pic, ce.File);
            }
            fileList.Selection.Changed += OnSelectionChanged;
            textview.Buffer.Changed    += OnTextChanged;
            TreeIter it;

            editMark              = textview.Buffer.CreateMark(null, textview.Buffer.EndIter, false);
            oldTextTag            = new Gtk.TextTag("readonly");
            oldTextTag.Foreground = "gray";
            oldTextTag.Editable   = false;
            textview.Buffer.TagTable.Add(oldTextTag);

            if (store.GetIterFirst(out it))
            {
                fileList.Selection.SelectIter(it);
            }
        }
Exemple #14
0
 internal void OnUpdateInputLineBegin()
 {
     if (tokenBeginMark == null)
     {
         tokenBeginMark = Buffer.CreateMark(null, Buffer.EndIter, true);
     }
     else
     {
         Buffer.MoveMark(tokenBeginMark, Buffer.EndIter);
     }
 }
Exemple #15
0
        public void ConsoleWrite(string message)
        {
            TextIter end = this.console_textview.Buffer.EndIter;

            this.console_textview.Buffer.Insert
                (ref end, message);
            TextMark m = this.console_textview.Buffer.CreateMark
                             (null, end, false);

            this.console_textview.ScrollMarkOnscreen(m);
        }
Exemple #16
0
        public TextRange(TextIter start, TextIter end)
        {
            if (start.Buffer != end.Buffer)
            {
                throw new Exception("Start buffer and end buffer do not match");
            }

            buffer     = start.Buffer;
            start_mark = buffer.CreateMark(null, start, true);
            end_mark   = buffer.CreateMark(null, end, true);
        }
        public AddLogEntryDialog(Dictionary <string, ChangeLogEntry> entries)
        {
            Build();

            textview.ModifyFont(FontService.MonospaceFont);
            textview.WrapMode   = WrapMode.None;
            textview.AcceptsTab = true;
            Pango.TabArray tabs = new Pango.TabArray(1, true);
            tabs.SetTab(0, Pango.TabAlign.Left, GetStringWidth(" ") * 4);
            textview.Tabs           = tabs;
            textview.SizeRequested += delegate {
                textview.WidthRequest = GetStringWidth(String.Empty.PadRight(80));
            };

            store          = new ListStore(typeof(ChangeLogEntry), typeof(Xwt.Drawing.Image), typeof(string));
            fileList.Model = store;

            fileList.AppendColumn(string.Empty, new CellRendererImage(), "image", 1);
            fileList.AppendColumn(string.Empty, new CellRendererText(), "text", 2);

            foreach (ChangeLogEntry ce in entries.Values)
            {
                Xwt.Drawing.Image pic;
                if (ce.CantGenerate)
                {
                    pic = ImageService.GetIcon(Ide.Gui.Stock.Warning, IconSize.Menu);
                }
                else if (ce.IsNew)
                {
                    pic = ImageService.GetIcon(Stock.New, IconSize.Menu);
                }
                else
                {
                    pic = null;
                }
                store.AppendValues(ce, pic, ce.File);
            }
            fileList.Selection.Changed += OnSelectionChanged;
            textview.Buffer.Changed    += OnTextChanged;
            TreeIter it;

            editMark              = textview.Buffer.CreateMark(null, textview.Buffer.EndIter, false);
            oldTextTag            = new TextTag("readonly");
            oldTextTag.Foreground = "gray";
            oldTextTag.Editable   = false;
            textview.Buffer.TagTable.Add(oldTextTag);

            if (store.GetIterFirst(out it))
            {
                fileList.Selection.SelectIter(it);
            }
        }
Exemple #18
0
        // Updates the status text widget
        // only used for Efax
        public void update_status(string s)
        {
            if (s == null)
            {
                return;
            }

            if (Settings.TransmitAgent == "efax")
            {
                TextMark tm = StatusTextBuffer.GetMark("insert");
                StatusTextBuffer.InsertAtCursor(String.Concat(s, "\n"));
                StatusText.ScrollMarkOnscreen(tm);
            }
        }
        public bool ReceiveUpdates()
        {
            string newOutput = debuggerService.GetNewConsoleOutput();

            if (newOutput.Length > 0)
            {
                // Append new text
                consoleOut.Buffer.Text += newOutput;

                // Scroll the window to the end
                TextMark endMark = consoleOut.Buffer.CreateMark(null, consoleOut.Buffer.EndIter, false);
                consoleOut.ScrollToMark(endMark, 0, false, 0, 0);
            }

            return(true);
        }
        public void UpdateDisplay(SourceCodeLocation[] breakpoints)
        {
            string filename = mdbGui.DebuggerService.GetCurrentFilename();

            if (filename == null)
            {
                this.Buffer.Text          = "No source code";
                currentlyLoadedSourceFile = null;
                return;
            }

            // Load the source file if neccessary
            if (currentlyLoadedSourceFile != filename)
            {
                string[] sourceCode = mdbGui.DebuggerService.ReadFile(filename);
                this.Buffer.Text          = string.Join("\n", sourceCode);
                currentlyLoadedSourceFile = filename;
            }

            // Remove all current tags
            TextIter bufferBegin, bufferEnd;

            this.Buffer.GetBounds(out bufferBegin, out bufferEnd);
            this.Buffer.RemoveAllTags(bufferBegin, bufferEnd);

            // Add tag to show current line
            int      currentLine     = mdbGui.DebuggerService.GetCurrentLine();
            TextIter currentLineIter = AddSourceViewTag("currentLine", currentLine);

            // Add tags for breakpoints
            foreach (SourceCodeLocation breakpoint in breakpoints)
            {
                if (breakpoint.Filename == currentlyLoadedSourceFile)
                {
                    // If it is current line, do not retag it
                    if (breakpoint.Line != currentLine)
                    {
                        AddSourceViewTag("breakpoint", breakpoint.Line);
                    }
                }
            }

            // Scroll to current line
            TextMark mark = this.Buffer.CreateMark(null, currentLineIter, false);

            this.ScrollToMark(mark, 0, false, 0, 0);
        }
        public LogView()
        {
            buffer                     = new TextBuffer(new TextTagTable());
            textEditorControl          = new LogTextView(buffer);
            textEditorControl.Editable = false;

            scrollView.ShadowType = ShadowType.None;
            scrollView.Add(textEditorControl);
            PackEnd(scrollView, true, true, 0);

            bold        = new TextTag("bold");
            bold.Weight = Weight.Bold;
            buffer.TagTable.Add(bold);

            errorTag            = new TextTag("error");
            errorTag.Foreground = Styles.ErrorForegroundColor.ToHexString(false);
            errorTag.Weight     = Weight.Bold;
            buffer.TagTable.Add(errorTag);

            warningTag            = new TextTag("warning");
            warningTag.Foreground = Styles.WarningForegroundColor.ToHexString(false);
            buffer.TagTable.Add(warningTag);

            debugTag            = new TextTag("debug");
            debugTag.Foreground = Styles.InformationForegroundColor.ToHexString(false);
            buffer.TagTable.Add(debugTag);

            consoleLogTag            = new TextTag("consoleLog");
            consoleLogTag.Foreground = Styles.SecondaryTextColor.ToHexString(false);
            buffer.TagTable.Add(consoleLogTag);

            normalTag            = new TextTag("0");
            normalTag.LeftMargin = 10;
            buffer.TagTable.Add(normalTag);
            tags.Add(normalTag);

            endMark = buffer.CreateMark("end-mark", buffer.EndIter, false);

            UpdateCustomFont();
            IdeApp.Preferences.CustomOutputPadFont.Changed += HandleCustomFontChanged;

            outputDispatcher = new GLib.TimeoutHandler(outputDispatchHandler);

            InitSearchWidget();
        }
        public void UncommentCode()
        {
            string commentTag = "//";             // as default

            commentTag = Services.Languages.GetBindingPerFileName(IdeApp.Workbench.ActiveDocument.FileName).CommentTag;

            TextIter textStart;
            TextIter textEnd;

            GetSelectionBounds(out textStart, out textEnd);

            int      numberOfLines = textStart.Line == textEnd.Line ? 1 : textEnd.Line - textStart.Line + 1;
            TextMark mTextStart    = CreateMark(null, textStart, true);
            TextMark mTextTmp      = mTextStart;

            using (new AtomicUndo(this)) {
                for (int i = 0; i < numberOfLines; i++)
                {
                    TextIter textTmp = GetIterAtMark(mTextTmp);
                    // delete the comment tag
                    textTmp.LineOffset = 0;

                    // the user can have spaces at start of line, handling that
                    TextIter textLineEnd = textTmp;
                    textLineEnd.ForwardToLineEnd();
                    string trimmedText, fullText;
                    int    spaces;
                    fullText    = textTmp.GetText(textLineEnd);
                    trimmedText = fullText.TrimStart();
                    spaces      = fullText.Length - trimmedText.Length;
                    if (trimmedText.StartsWith(commentTag))
                    {
                        textTmp.ForwardChars(spaces);
                        textEnd = textTmp;
                        textEnd.ForwardChars(commentTag.Length);
                        Delete(ref textTmp, ref textEnd);
                    }

                    // setup a mark on next line
                    textTmp = GetIterAtMark(mTextTmp);
                    textTmp.ForwardLine();
                    mTextTmp = CreateMark(null, textTmp, true);
                }
            }
        }
        public TalkView() : base(new TextBuffer(null))
        {
            CursorVisible = false;
            Editable      = false;
            WrapMode      = WrapMode.WordChar;

            lastMessage = DateTime.MinValue;

            normalCursor = new Gdk.Cursor(Gdk.CursorType.Xterm);
            handCursor   = new Gdk.Cursor(Gdk.CursorType.Hand2);

            TextTag tag;

            tag            = new TextTag("status");
            tag.Foreground = "darkgrey";
            tag.Weight     = Pango.Weight.Bold;
            Buffer.TagTable.Add(tag);

            tag            = new TextTag("error");
            tag.Foreground = "dark red";
            Buffer.TagTable.Add(tag);

            tag               = new TextTag("time");
            tag.Foreground    = "darkgrey";
            tag.Justification = Justification.Center;
            Buffer.TagTable.Add(tag);

            linkTag            = new TextTag("link");
            linkTag.Foreground = "blue";
            linkTag.Underline  = Pango.Underline.Single;
            Buffer.TagTable.Add(linkTag);

            tag            = new TextTag("nick-self");
            tag.Foreground = "sea green";
            tag.Weight     = Pango.Weight.Bold;
            Buffer.TagTable.Add(tag);

            tag            = new TextTag("nick-other");
            tag.Foreground = "skyblue4";
            tag.Weight     = Pango.Weight.Bold;
            Buffer.TagTable.Add(tag);

            endIter = Buffer.GetIterAtOffset(0);
            endMark = Buffer.CreateMark("end", endIter, true);
        }
Exemple #24
0
        protected void UnsafeAddText(TextMark mark, string text, TextTag indentTag, TextTag extraTag)
        {
            //don't allow the pad to hold more than MAX_BUFFER_LENGTH chars
            int overrun = (buffer.CharCount + text.Length) - MAX_BUFFER_LENGTH;

            if (overrun > 0)
            {
                TextIter start = buffer.StartIter;
                TextIter end   = buffer.GetIterAtOffset(overrun);
                buffer.Delete(ref start, ref end);
            }

            bool scrollToEnd = ShouldAutoScroll();

            TextIter it;

            if (mark != null)
            {
                it = buffer.GetIterAtMark(mark);
            }
            else
            {
                it = buffer.EndIter;
            }

            if (extraTag != null)
            {
                buffer.InsertWithTags(ref it, text, indentTag ?? normalTag, extraTag);
            }
            else
            {
                buffer.InsertWithTags(ref it, text, indentTag ?? normalTag);
            }

            if (scrollToEnd)
            {
                it.LineOffset = 0;
                buffer.MoveMark(endMark, it);
                textEditorControl.ScrollToMark(endMark, 0, false, 0, 0);
            }
        }
Exemple #25
0
        public LogView()
        {
            buffer                     = new TextBuffer(new TextTagTable());
            textEditorControl          = new LogTextView(buffer);
            textEditorControl.Editable = false;

            scrollView.ShadowType = ShadowType.None;
            scrollView.Add(textEditorControl);
            PackEnd(scrollView, true, true, 0);

            bold        = new TextTag("bold");
            bold.Weight = Weight.Bold;
            buffer.TagTable.Add(bold);

            errorTag            = new TextTag("error");
            errorTag.Foreground = "#dc3122";
            errorTag.Weight     = Weight.Bold;
            buffer.TagTable.Add(errorTag);

            debugTag            = new TextTag("debug");
            debugTag.Foreground = "#256ada";
            buffer.TagTable.Add(debugTag);

            consoleLogTag            = new TextTag("consoleLog");
            consoleLogTag.Foreground = "darkgrey";
            buffer.TagTable.Add(consoleLogTag);

            tag            = new TextTag("0");
            tag.LeftMargin = 10;
            buffer.TagTable.Add(tag);
            tags.Add(tag);

            endMark = buffer.CreateMark("end-mark", buffer.EndIter, false);

            UpdateCustomFont();
            IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomFontChanged;

            outputDispatcher = new GLib.TimeoutHandler(outputDispatchHandler);

            InitSearchWidget();
        }
        public ConsoleView2()
        {
            PromptString          = "> ";
            PromptMultiLineString = ">> ";

            textView = new TextView();
            Add(textView);
            ShowAll();

            textView.WrapMode       = Gtk.WrapMode.Word;
            textView.KeyPressEvent += TextViewKeyPressEvent;
            textView.PopulatePopup += TextViewPopulatePopup;

            inputBeginMark = Buffer.CreateMark(null, Buffer.EndIter, true);

            // The 'Freezer' tag is used to keep everything except
            // the input line from being editable
            TextTag tag = new TextTag("Freezer");

            tag.Editable = false;
            Buffer.TagTable.Add(tag);

            errorTag            = new TextTag("error");
            errorTag.Background = "#dc3122";
            errorTag.Foreground = "white";
            errorTag.Weight     = Weight.Bold;
            Buffer.TagTable.Add(errorTag);

            warningTag            = new TextTag("warning");
            warningTag.Foreground = "black";
            warningTag.Background = "yellow";
            Buffer.TagTable.Add(warningTag);

            debugTag            = new TextTag("debug");
            debugTag.Foreground = "darkgrey";
            Buffer.TagTable.Add(debugTag);

            Prompt(false);
        }
Exemple #27
0
        public OutputFilterWidget()
        {
            this.Build();
            this.ShowAll();

            //Environment.SetEnvironmentVariable("MONODEVELOP_CONSOLE_LOG_USE_COLOUR", "true");

            //internalLogger.TextWritten += WriteConsoleLogText;
            //console = new LogViewProgressConsole (this);

            debugTag = new TextTag("debug")
            {
                Foreground = Styles.InformationForegroundColor.ToHexString(false),
            };
            DestinationBuffer.TagTable.Add(debugTag);

            endMark = DestinationBuffer.CreateMark("end-mark", DestinationBuffer.EndIter, false);

            textview1.ModifyFont(IdeApp.Preferences.CustomOutputPadFont ?? IdeServices.FontService.MonospaceFont);

            RegisterEvents();
        }
Exemple #28
0
        public ConsoleView()
        {
            PromptString          = "> ";
            PromptMultiLineString = ">> ";

            textView = new TextView();
            Add(textView);
            ShowAll();

            textView.WrapMode       = Gtk.WrapMode.Word;
            textView.KeyPressEvent += TextViewKeyPressEvent;
            textView.PopulatePopup += TextViewPopulatePopup;

            inputBeginMark = Buffer.CreateMark(null, Buffer.EndIter, true);

            // The 'Freezer' tag is used to keep everything except
            // the input line from being editable
            TextTag tag = new TextTag("Freezer");

            tag.Editable = false;
            Buffer.TagTable.Add(tag);
            Prompt(false);
        }
Exemple #29
0
        /// Walk through the message and add TextTag objects as needed
        private void FormatTextBuffer(TextBuffer textBuffer, XmlNode linkTextNode)
        {
            XmlNodeList childNodes = linkTextNode.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                if (childNode.Name.Equals("a"))
                {
                    XmlAttribute href = childNode.Attributes["href"];
                    if (href != null)
                    {
                        string textTagName = href.Value;

                        TextTag textTag = textBuffer.TagTable.Lookup(textTagName);
                        if (textTag != null)
                        {
                            TextMark startTagMark = textBuffer.CreateMark(textTagName, textBuffer.EndIter, true);
                            textBuffer.InsertAtCursor(childNode.InnerText);
                            TextIter startTagIter = textBuffer.GetIterAtMark(startTagMark);
                            TextIter endTagIter   = textBuffer.EndIter;
                            textBuffer.ApplyTag(textTag, startTagIter, endTagIter);
                        }
                    }
                    else
                    {
                        textBuffer.InsertAtCursor(childNode.InnerText);
                    }
                }
                else
                {
                    textBuffer.InsertAtCursor(childNode.InnerText);
                }
            }

            // Make the font size smaller
            textBuffer.ApplyTag("small-font", textBuffer.StartIter, textBuffer.EndIter);
        }
		// Remove a mark.
		private void RemoveMark(TextMark mark)
				{
					if(mark.LeftGravity)
					{
						// remove the mark
						leftMarks.Remove(leftMarks.MarkSearch(mark), 1);
					}
					else
					{
						// remove the mark
						rightMarks.Remove(rightMarks.MarkSearch(mark), 1);
					}
				}
			// Insert a mark at the given position.
			public void Insert(int pos, TextMark mark)
					{
						// enforce position bounds limits
						if(pos < 0 || pos >= MarkCount)
						{
							throw new ArgumentOutOfRangeException("pos");
						}

						// adjust the gap as needed
						ExpandGap(1);
						ShiftGap(gapStart - pos);

						// add the new mark to the buffer
						((TextMark[])array)[gapStart++] = mark;
					}
		// Move a mark.
		private void MoveMark(TextMark mark, int pos)
				{
					// enforce position bounds limits
					if(pos < 0 || pos > CharCount)
					{
						throw new ArgumentOutOfRangeException("pos");
					}

					if(mark.LeftGravity)
					{
						// adjust the mark index for the gap
						if(pos > gapStart) { pos += (gapEnd - gapStart); }

						// move the mark
						leftMarks.MoveMark(mark, pos);
					}
					else
					{
						// adjust the mark index for the gap
						if(pos >= gapStart) { pos += (gapEnd - gapStart); }

						// move the mark
						rightMarks.MoveMark(mark, pos);
					}
				}
			// Search for the position of the given mark.
			public int MarkSearch(TextMark mark)
					{
						// search for the mark position
						int index = MarkSearch(mark.index);

						// return minus one if there's no match
						if(index < 0) { return -1; }

						// return the index if it's a match
						if(this[index] == mark) { return index; }

						// get the marks count
						int markCount = MarkCount;

						// find and return the removal position, forward search
						for(int i = (index + 1); i < markCount; ++i)
						{
							// get the current mark
							TextMark curr = this[i];

							// compare the current mark against the removal mark
							if(curr == mark) { return i; }

							// break if there are no more forward candidates
							if(curr.index != mark.index) { break; }
						}

						// find and return the removal position, backward search
						for(--index; index >= 0; --index)
						{
							// get the current mark
							TextMark curr = this[index];

							// compare the current mark against the removal mark
							if(curr == mark) { return index; }

							// break if there are no more backward candidates
							if(curr.index != mark.index) { break; }
						}

						// return minus one if there's no match
						return -1;
					}
			// Move a mark to a new position.
			public void MoveMark(TextMark mark, int newPos)
					{
						// bail out now if there's no movement required
						if(mark.index == newPos) { return; }

						// get the mark position
						int i = MarkSearch(mark);

						// remove the mark from the old position
						Remove(i, 1);

						// get the mark insertion index
						i = MarkInsertionSearch(newPos);

						// insert the mark at the new position
						Insert(i, mark);

						// set the mark index to the new position
						mark.index = newPos;
					}
Exemple #35
0
 void Clear()
 {
     textview1.Buffer.Clear();
     m_Scroll2EndMark = textview1.Buffer.CreateMark("Scroll2End", textview1.Buffer.EndIter, true);
 }