private void Append(ref TextIter iter, ArrayList plugins) { if (plugins.Count == 0) { InsertWithTagsByName(ref iter, Catalog.GetString("No plugins available.\n"), "description"); return; } foreach (IFactory p in plugins) { Append(ref iter, p); } }
public void SetCompletionText(CodeCompletionContext ctx, string partial_word, string complete_word, int offset) { int cursorOffset = Position - (ctx.TriggerOffset + partial_word.Length); TextIter start = Buffer.GetIterAtOffset(TokenBegin.Offset + ctx.TriggerOffset); TextIter end = Buffer.GetIterAtOffset(start.Offset + partial_word.Length); Buffer.Delete(ref start, ref end); Buffer.Insert(ref start, complete_word); TextIter cursor = Buffer.GetIterAtOffset(start.Offset + offset + cursorOffset); Buffer.PlaceCursor(cursor); }
string GetErrorInformationAt(TextIter iter) { ErrorInfo info; if (errors.TryGetValue(iter.Line, out info)) { return("<b>" + GettextCatalog.GetString("Parser Error:") + "</b> " + info.Message); } else { return(null); } }
void OnRowSelected(object s, EventArgs a) { UnitTest test = GetSelectedTest (); if (test != null) { int offset; if (outIters.TryGetValue (test, out offset)) { TextIter it = outputView.Buffer.GetIterAtOffset (offset); outputView.Buffer.MoveMark (outputView.Buffer.InsertMark, it); outputView.Buffer.MoveMark (outputView.Buffer.SelectionBound, it); outputView.ScrollToMark (outputView.Buffer.InsertMark, 0.0, true, 0.0, 0.0); } } }
void MarkAll(string exp) { TextIter start, end; start = m_Buffer.GetIterAtOffset(0); TextIter limit = m_Buffer.GetIterAtOffset(int.MaxValue); while (start.ForwardSearch(exp, TextSearchFlags.TextOnly, out start, out end, limit)) { m_Buffer.ApplyTag("bold", start, end); start.Offset++; } }
private void WriteMessage(LogLevel level, string message) { message = string.Format("{0} [{1}]: {2}\n", level.ToString(), DateTime.Now.ToString("u"), message); TextIter endIter = m_TextView.Buffer.EndIter; m_TextView.Buffer.InsertWithTagsByName(ref endIter, message, new string[] { level.ToString() }); var endMark = m_TextView.Buffer.GetMark("end"); if (endMark != null) { m_TextView.ScrollToMark(endMark, 0, true, 0, 1); } }
public void DropCompleteAhead() { if (GetIterAtMark(complete_end).Offset == 0) { return; } RemoveTag(complete_ahead, GetIterAtMark(InsertMark), GetIterAtMark(complete_end)); TextIter insertIter = GetIterAtMark(InsertMark); TextIter completionEnd = GetIterAtMark(complete_end); Delete(ref insertIter, ref completionEnd); MoveMark(complete_end, GetIterAtOffset(0)); }
public void Datos_Recibidos(IPEndPoint id) { TextIter iter = con_buffer.EndIter; con_buffer.Insert(ref iter, DateTime.Now.ToString() + "->"); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, svr.ObtenerNick(id) + ": "); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, svr.ObtenerDatos(id)); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, "\n"); //con_buffer.Text +=msg; }
private static void GetEndTags(TextIter currentIter, TextIter nextIter, TextTag [] tagArray, ArrayList endTags) { Array.Reverse(tagArray); foreach (TextTag tag in tagArray) { if (!DocumentUtils.TagEndsHere(tag, currentIter, nextIter)) { continue; } endTags.Add(tag); } }
/// <summary> /// Get the raw text in a cell. /// </summary> /// <param name="cell">The cell.</param> private string GetCellRawText(TableCell cell) { TextView tmpView = new TextView(); CreateStyles(tmpView); TextIter iter = tmpView.Buffer.StartIter; ProcessMarkdownBlocks(cell, ref iter, tmpView, 0, false); string result = tmpView.Buffer.Text; tmpView.Dispose(); return(result); }
public GASNViewerApp(string[] args) { Application.Init(); Glade.XML xml = new Glade.XML(null, "gui.glade", "gasnview", null); xml.Autoconnect(this); options = LoadConfig(config); UpdateOptions(); // load cache PrettyPrinter.Cache.Load(cache); // UI preparation fileexportimage.Pixbuf = new Pixbuf(null, "export.png"); file_export.Image = new Gtk.Image(new Pixbuf(null, "export-16.png")); textview1.Editable = false; textview1.GrabFocus(); Font = options.FontName; findfwd = textview1.Buffer.StartIter; findbck = textview1.Buffer.EndIter; findstart = -1; findend = -1; highlight_on = new Pixbuf(null, "text_hilight-16.png"); highlight_off = new Pixbuf(null, "text_lolight-16.png"); findhighlight = false; findnormalbasecolor = findentry.Style.Base(StateType.Normal); try { // GTK# bug - entry point was missing in early 1.0.x versions findnormaltextcolor = findentry.Style.Text(StateType.Normal); } catch (EntryPointNotFoundException) { findnormaltextcolor = new Gdk.Color(0x00, 0x00, 0x00); } finderrorbasecolor = new Gdk.Color(0xff, 0x00, 0x00); finderrortextcolor = new Gdk.Color(0xff, 0xff, 0xff); highlight = new TextTag("highlight"); highlight.BackgroundGdk = new Gdk.Color(0xff, 0xff, 0x00); textview1.Buffer.TagTable.Add(highlight); encapsulated = new TextTag("encapsulated"); encapsulated.ForegroundGdk = new Gdk.Color(0x00, 0x00, 0xff); textview1.Buffer.TagTable.Add(encapsulated); Highlight(false); // load any specified file and execute application if (args.Length > 0) { FileLoad(args[0]); } Application.Run(); }
public void Undo() { if (CanUndo) { CheckForEntryEvent(); UIEvent evnt = _undoEvents.Pop(); _redoEvents.Push(evnt); _updateInProgress = true; switch (evnt.Type) { case ControlType.TextView: { TextBuffer tb = (TextBuffer)evnt.Control; FocusOnTextView(tb); TextIter start = tb.GetIterAtOffset(evnt.StartOffset); if (evnt.Action == ActionType.Insert) { TextIter end = tb.GetIterAtOffset(evnt.StartOffset + evnt.Text.Length); tb.Delete(ref start, ref end); } else if (evnt.Action == ActionType.Delete) { tb.Insert(ref start, evnt.Text); } } break; case ControlType.Entry: { Entry en = (Entry)evnt.Control; if (en.Text == evnt.Text) { Undo(); } else { en.GrabFocus(); en.Text = evnt.Text; en.Position = evnt.StartOffset; } } break; } _updateInProgress = false; OnStatusChanged(EventArgs.Empty); } }
protected void SetHighlighting(Regex re, TextTag textTag) { string text = txtEditor.Buffer.Text; MatchCollection mc = re.Matches(text); foreach (Match m in mc) { TextIter start = txtEditor.Buffer.GetIterAtOffset(m.Index); TextIter end = txtEditor.Buffer.GetIterAtOffset(m.Index + m.Groups [0].Length); txtEditor.Buffer.ApplyTag(textTag, start, end); } }
public void AddDetails(string text, bool wrapped) { TextIter it = detailsTextView.Buffer.EndIter; if (wrapped) { detailsTextView.Buffer.InsertWithTags(ref it, text, tagWrap); } else { detailsTextView.Buffer.InsertWithTags(ref it, text, tagNoWrap); } expander.Visible = true; }
private void ShowLogging(string str) { Gtk.Application.Invoke(delegate { TextIter iter = console.Buffer.EndIter; console.Buffer.Insert(ref iter, str + "\n"); while (Application.EventsPending()) { Application.RunIteration(); } console.Buffer.MoveMark(console.Buffer.InsertMark, console.Buffer.EndIter); console.ScrollToMark(console.Buffer.InsertMark, 0.4, true, 0.0, 1.0); }); }
private void UpdateResults(List <string> results) { GtkScrolledWindowErrors.Visible = true; TextTagTable textResultTags = new TextTagTable(); var tagResult = new TextTag("blue"); tagResult.Foreground = "blue"; textResultTags.Add(tagResult); TextBuffer tempBuffer = new TextBuffer(textResultTags); TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, String.Join("\n", results), tagResult); textviewErrors.Buffer = tempBuffer; }
void Bt_conectar_Clicked(object sender, EventArgs e) { cl.ipSvr = tb_datos.Text; cl.Conectar(tb_nombre.Text); TextIter iter = con_buffer.EndIter; con_buffer.Insert(ref iter, DateTime.Now.ToString() + "->"); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, tb_nombre.Text + "->"); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, "Conectado"); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, "\n"); }
static void Draw(Gdk.Drawable drawable, TextView view, TextIter start, TextIter end) { if (HighlightSpacesEnabled || HighlightTabsEnabled || HighlightNewlinesEnabled) { Cairo.Context cntx = Gdk.CairoHelper.Create(drawable); //shift to pixel grid to reduce antialiasing cntx.Antialias = Cairo.Antialias.Default; cntx.LineCap = Cairo.LineCap.Square; cntx.LineWidth = 1; cntx.Translate(0.5, 0.5); TextIter iter = start; while (iter.Compare(end) <= 0) { switch (iter.Char) { case " ": if (HighlightSpacesEnabled) { DrawSpaceAtIter(cntx, view, iter); } break; case "\t": if (HighlightTabsEnabled) { DrawTabAtIter(cntx, view, iter); } break; case "\n": case "\r": if (HighlightNewlinesEnabled) { DrawLineEndAtIter(cntx, view, iter); } break; default: break; } if (!iter.ForwardChar()) { break; } } ((IDisposable)cntx).Dispose(); } }
private void Export(Export1cMode mode) { var dateStart = dateperiodpicker1.StartDate; var dateEnd = dateperiodpicker1.EndDate; using (var exportOperation = new ExportOperation(new OrderParametersProvider(new ParametersProvider()), mode, dateStart, dateEnd)) { this.exportInProgress = true; UpdateExportButtonSensitivity(); LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false); this.exportInProgress = false; UpdateExportButtonSensitivity(); exportData = exportOperation.Result; } this.labelTotalCounterparty.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceCounterparty) .ToString(); this.labelTotalNomenclature.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceNomenclature) .ToString(); this.labelTotalSales.Text = exportData.Objects .OfType <SalesDocumentNode>() .Count() .ToString(); this.labelTotalSum.Text = exportData.OrdersTotalSum.ToString("C"); this.labelExportedSum.Markup = String.Format("<span foreground=\"{1}\">{0:C}</span>", exportData.ExportedTotalSum, exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red"); this.labelTotalInvoices.Text = exportData.Objects .OfType <InvoiceDocumentNode>() .Count() .ToString(); GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0; if (exportData.Errors.Count > 0) { TextTagTable textTags = new TextTagTable(); var tag = new TextTag("Red"); tag.Foreground = "red"; textTags.Add(tag); TextBuffer tempBuffer = new TextBuffer(textTags); TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag); textviewErrors.Buffer = tempBuffer; } buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0; }
public static void AddStub(TextBuffer buffer, ref TextIter insertAt, string data, string suffix) { DocumentTagTable tagTable = (DocumentTagTable)buffer.TagTable; TextTag textTag = tagTable.Lookup("stub" + suffix + "#" + counter); if (textTag == null) { textTag = tagTable.CreateDynamicTag("stub" + suffix + "#" + counter); } counter++; buffer.InsertWithTags(ref insertAt, data, textTag); }
public void EvaluateInput() { Expression res; TextIter insertIter = Buffer.StartIter; if (InputView.Buffer.Text.Length == 0) { Buffer.InsertWithTagsByName(ref insertIter, "No input\n", "error"); return; } Eval.Parse(InputView.Buffer.Text); res = Eval.Evaluate(); if (res is Error) { Eval.SideEffects.Add(new ErrorData(res as Error)); } else if (!(res is Null)) { Buffer.Insert(ref insertIter, "ret: " + res.ToString() + "\n"); } foreach (var data in Eval.SideEffects) { if (data is PrintData) { Buffer.Insert(ref insertIter, data.ToString() + "\n"); } else if (data is ErrorData) { Buffer.InsertWithTagsByName(ref insertIter, data.ToString() + "\n", "error"); } else if (data is DebugData && Eval.GetBool("debug")) { Buffer.InsertWithTagsByName(ref insertIter, data.ToString() + "\n", "debug"); } else if (data is PlotData) { DrawView.Plot(data as PlotData); DrawView.Show(); } else if (data is WidgetData) { WidgetView.AddWidget(data as WidgetData); WidgetView.Show(); } } }
// File Menu public void OnFileNew(object sender, EventArgs args) { currentfile = null; savename = null; asn = null; pp = null; appbar1.Default = String.Empty; UpdateDisplay(); findfwd = textview1.Buffer.StartIter; findbck = textview1.Buffer.EndIter; findstart = -1; findend = -1; OnFindEntryChange(sender, args); }
private void InsertTextClip(string textToInsert) { int curpos = txtEditor.Buffer.CursorPosition; int offset = -1; // Check for certain tag types. if (Constants._reValueTag.IsMatch(textToInsert)) { offset = textToInsert.Length - 1; } if (offset < 0) { int idx = textToInsert.IndexOf("{", 2); if (idx > 0) { offset = idx - 1; } } string selectedText = txtEditor.Buffer.GetSelectedText(); if (selectedText.Length > 0 && offset >= 0) { // We have a selection to insert. textToInsert = string.Format("{0}{1}{2}", textToInsert.Substring(0, offset), selectedText, textToInsert.Substring(offset)); offset = textToInsert.Length; } if (offset < 0) { offset = textToInsert.Length; } if (selectedText.Length > 0) { txtEditor.Buffer.ReplaceSelection(textToInsert, false); } else { txtEditor.Buffer.InsertAtCursor(textToInsert); } curpos += offset; TextIter iter = txtEditor.Buffer.GetIterAtOffset(curpos); txtEditor.Buffer.PlaceCursor(iter); txtEditor.IsFocus = true; }
/// <summary> /// Logs the message broadcasted. /// Tracks the severity of the log message and assigns it an appropriate /// Indicator and Color. /// Appends the log message to the TextView. /// It should be coloring it, but it isn't right now. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> private void Log_MessageBroadcasted(object sender, MessageBroadcastedEventArgs e) { if (e.Severity == Severity.Trace) { return; } string severityIndicator; ConsoleColor color; TextTag logcolor = new TextTag("color"); switch (e.Severity) { case Severity.Trace: color = ConsoleColor.Blue; logcolor.Foreground = "blue"; severityIndicator = "T"; break; case Severity.Warning: color = ConsoleColor.Yellow; logcolor.Foreground = "yellow"; severityIndicator = "!"; break; case Severity.Error: color = ConsoleColor.Red; logcolor.Foreground = "red"; severityIndicator = "E"; break; case Severity.Fatal: color = ConsoleColor.Magenta; severityIndicator = "F"; break; default: color = ConsoleColor.White; logcolor.Foreground = "green"; severityIndicator = "I"; break; } TextIter logend = LogView.Buffer.EndIter; LogView.Buffer.Insert(ref logend, $"[{e.Channel.Name}]:{severityIndicator}: {e.Message}\n"); // LogView.Buffer.ApplyTag(logcolor, logend, LogView.Buffer.EndIter); Console.ForegroundColor = color; Console.WriteLine($"[{e.Channel.Name}]:{severityIndicator}: {e.Message}\n"); }
private static int InsertText(TextBuffer buffer, int offset, string data, Stack stack) { TagStart tagStart = (TagStart)stack.Peek(); TextIter insertAt = buffer.GetIterAtOffset(offset); TextTag textTag = DocumentUtils.GetAssociatedTextTag(buffer, tagStart.Tag); DocumentUtils.AddText(buffer, ref insertAt, data, textTag); // buffer.InsertWithTags (ref insertAt, data, textTag); #if DEBUG Console.WriteLine("Text: {0} Value: {1} Start: {2}", textTag.Name, data, offset); #endif return(insertAt.Offset); }
void Bt_enviar_Clicked(object sender, EventArgs e) { cl.EnviarDatos(tb_mensaje.Text); TextIter iter = con_buffer.EndIter; con_buffer.Insert(ref iter, DateTime.Now.ToString() + "->"); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, tb_nombre.Text + ": "); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, tb_mensaje.Text); iter = con_buffer.EndIter; con_buffer.Insert(ref iter, "\n"); tb_mensaje.Text = ""; }
private void AddButtonToStatusWindow(string buttonName, int buttonID) { TextIter iter = StatusWindow.Buffer.EndIter; TextChildAnchor anchor = StatusWindow.Buffer.CreateChildAnchor(ref iter); EventBox box = new EventBox(); ApsimNG.Classes.CustomButton moreInfo = new ApsimNG.Classes.CustomButton(buttonName, buttonID); moreInfo.Clicked += ShowDetailedErrorMessage; box.Add(moreInfo); StatusWindow.AddChildAtAnchor(box, anchor); box.ShowAll(); box.Realize(); box.ShowAll(); moreInfo.ParentWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Arrow); }
private void LogLineSimple(string message) { TextIter endIter = txtLog.Buffer.EndIter; txtLog.Buffer.Insert(ref endIter, message + "\n"); #if DEBUG Console.WriteLine("Log: " + message); #endif if (follow) { txtLogScroll.Vadjustment.Value = txtLogScroll.Vadjustment.Upper; } }
public void TagEndsHereSimple() { DocumentEditor editor = new DocumentEditor(); TextBuffer buffer = editor.Buffer; TextIter insertIter = buffer.StartIter; buffer.InsertWithTagsByName(ref insertIter, "Example Region", "Type"); TextIter endIter = buffer.GetIterAtOffset(insertIter.Offset - 1); TextIter nextIter = buffer.GetIterAtOffset(insertIter.Offset); bool endsTag = DocumentUtils.TagEndsHere(buffer.TagTable.Lookup("Type"), endIter, nextIter); Assert.IsTrue(endsTag, "TEH01"); }
void SetupTimer(Note note, TextIter start, TextIter end) { if (!start.StartsLine()) { start.BackwardLine(); } if (!end.EndsLine()) { end.ForwardToLineEnd(); } Buffer.RemoveTag("reminder", start, end); //Buffer.RemoveAllTags(start, end); // This breaks stuff - what purpose does it serve? SetupTimer(Note, start.GetSlice(end), start.Line); }
void FollowIfLink(TextView view, TextIter iter) { foreach (TextTag tag in iter.Tags) { object move = tag_links[tag]; if (move is int) { if (ShowNthMove != null) ShowNthMove (this, new MoveEventArgs ((int) move)); } } }
private void PrintTitle(TextBuffer buffer, ref TextIter iter) { if (game == null) return; string title = String.Format ("{0} vs {1}", game.White, game.Black); buffer.CreateMark ("-1", iter, true); buffer.InsertWithTagsByName (ref iter, title, HEADING_TAG); buffer.Insert (ref iter, "\n"); Widget tagdetails = GetTagDetailsWidget (); TextChildAnchor anchor = buffer.CreateChildAnchor (ref iter); view.AddChildAtAnchor (tagdetails, anchor); buffer.Insert (ref iter, "\n\n"); }
private void UpdateGameDetails(TextBuffer buffer, ref TextIter iter) { PrintTitle (buffer, ref iter); if (game == null) return; if (game.Comment != null) { buffer.InsertWithTags (ref iter, game.Comment, commentTag); buffer.Insert (ref iter, "\n"); } int i = 0; int moveno = 1; foreach (PGNChessMove move in game.Moves) { if (i % 2 == 0) { buffer.InsertWithTags (ref iter, moveno. ToString (), movenumberTag); moveno++; buffer.Insert (ref iter, ". "); } string markstr = i.ToString (); string text = move.DetailedMove; buffer.CreateMark (markstr, iter, true); // left gravity TextTag link_tag = new TextTag (null); tag_links[link_tag] = i; taglinks.Add (link_tag); buffer.TagTable.Add (link_tag); buffer.InsertWithTags (ref iter, text, moveTag, link_tag); marks[markstr] = text.Length; buffer.Insert (ref iter, " "); if (move.comment != null) { buffer.Insert (ref iter, "\n"); buffer.InsertWithTags (ref iter, FormatComment (move. comment), commentTag); buffer.Insert (ref iter, "\n"); } i++; } }
private void GetItersForMove(int idx, TextBuffer buffer, out TextIter start, out TextIter end) { string markstr = idx.ToString (); int len = (int) marks[markstr]; start = buffer.GetIterAtMark (buffer. GetMark (markstr)); end = start; end.ForwardChars (len); }