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); }
/// <summary>Función para actualizar el texto de la barra de estado /// cuando cambia la posición del cursor en el cuadro de edición de /// texto ensamblador.</summary> /// <param name="o">El objeto que provoca la llamada.</param> /// <param name="args">Los argumentos.</param> private void ActualizadaPosicionCursor (object o, Gtk.MarkSetArgs args) { Gtk.TextMark mark = textoCodigo.InsertMark; Gtk.TextIter iter = textoCodigo.GetIterAtMark(mark); int lineasTotales = textoCodigo.LineCount; int caractTotales = textoCodigo.CharCount; int lineaActual = iter.Line + 1; int columnaActual = iter.LineOffset + 1; int offset = iter.Offset; int porc = (caractTotales < 1) ? 0 : (100 * offset) / caractTotales; String mensaje = String.Format( GetText("Ventana_Statusbar_Texto"), lineaActual, lineasTotales, columnaActual, offset, porc); if (textoCodigo.Modified) { mensaje += " *"; } PonerMensajeStatusbar(mensaje); }
public void NewLine() { var startIter = Buffer.GetIterAtMark(promptStart); Buffer.InsertWithTagsByName(ref startIter, "\n", "history"); Buffer.InsertWithTagsByName(ref startIter, "> ", "prompt"); promptStart = Buffer.CreateMark(null, startIter, true); Buffer.PlaceCursor(startIter); this.sourceHighlighter = new IncrementalHighlighter(new GtkHighlighter(Buffer)); column = 0; }
public ReadEvalPrintLoopView(Action<string> evaluator) : base(new TextBuffer(new TextTagTable())) { this.evaluator = evaluator; var startIter = Buffer.StartIter; promptStart = Buffer.CreateMark(null, startIter, true); Buffer.TagTable.Add(new TextTag("prompt") { Editable = false, Weight = Weight.Bold }); Buffer.TagTable.Add(new TextTag("history") { Editable = false }); Buffer.TagTable.Add(new TextTag("string") { Foreground ="red" }); Buffer.TagTable.Add(new TextTag("number") { Foreground ="green" }); Buffer.InsertWithTagsByName(ref startIter, "> ", "prompt"); promptStart = Buffer.CreateMark(null, startIter, true); this.sourceHighlighter = new IncrementalHighlighter(new GtkHighlighter(Buffer)); }
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); }
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); }
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); }
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); }
void FinalizeLine(bool move_cursor=true) { if (this.blockText == "") this.blockText += InputLine; else this.blockText += Environment.NewLine + InputLine; // Everything but the last item (which was input), //in the future stack needs to get put back into the // past stack while (commandHistoryFuture.Count > 1) commandHistoryPast.Push (commandHistoryFuture.Pop()); // Clear the pesky junk input line commandHistoryFuture.Clear(); // Record our input line commandHistoryPast.Push(InputLine); if (scriptLines == "") scriptLines += InputLine; else scriptLines += Environment.NewLine + InputLine; var end = Buffer.EndIter; Buffer.Insert(ref end, Environment.NewLine); startOfPrompt = Buffer.CreateMark(null, Buffer.EndIter, true); endOfLastProcessing = Buffer.CreateMark (null, Buffer.EndIter, true); promptState = PromptState.None; Buffer.ApplyTag(Buffer.TagTable.Lookup("Freezer"), Buffer.StartIter, InputLineBegin); if (move_cursor) { Buffer.PlaceCursor (Buffer.EndIter); textView.ScrollMarkOnscreen (Buffer.InsertMark); // Freeze all the text except our input line } }
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; }
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); } }
void PrepareCompletionDetails(TextIter iter) { Gdk.Rectangle rect = GetIterLocation (Buffer.GetIterAtMark (Buffer.InsertMark)); int wx, wy; BufferToWindowCoords (Gtk.TextWindowType.Widget, rect.X, rect.Y + rect.Height, out wx, out wy); int tx, ty; GdkWindow.GetOrigin (out tx, out ty); this.completionX = tx + wx; this.completionY = ty + wy; this.textHeight = rect.Height; this.triggerMark = buf.CreateMark (null, iter, true); }
protected override bool OnKeyPressEvent(EventKey evnt) { if(evnt.Key == Gdk.Key.Return) { var startIter = Buffer.GetIterAtMark(promptStart); var endIter = Buffer.EndIter; var text = Buffer.GetText(startIter, endIter, true); Buffer.ApplyTag("history", startIter, endIter); promptStart = Buffer.CreateMark(null, endIter, true); evaluator(text); NewLine(); return true; } else if(evnt.Key == Gdk.Key.Shift_L) { return base.OnKeyPressEvent(evnt); } var result = base.OnKeyPressEvent(evnt); sourceHighlighter.Tokenize(new Character((char)evnt.KeyValue, new Location(null, 0, column))); column++; return result; }
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.CustomOutputPadFont); IdeApp.Preferences.CustomOutputPadFontChanged += HandleCustomFontChanged; outputDispatcher = new GLib.TimeoutHandler (outputDispatchHandler); }
public OutputConsole() { buffer = new Gtk.TextBuffer(new Gtk.TextTagTable()); textEditorControl = new Gtk.TextView(buffer); textEditorControl.Editable = true; sw = new ScrolledWindow(); sw.ShadowType = ShadowType.Out; sw.Add(textEditorControl); this.PackStart(sw, true, true, 0); vbt = new VBox(); Gdk.Pixbuf clear_pixbuf = MainClass.Tools.GetIconFromStock("file-new.png", IconSize.SmallToolbar); Button btnClear = new Button(new Gtk.Image(clear_pixbuf)); btnClear.TooltipText = MainClass.Languages.Translate("clear"); btnClear.Relief = ReliefStyle.None; btnClear.CanFocus = false; btnClear.WidthRequest = btnClear.HeightRequest = 24; btnClear.Clicked += delegate(object sender, EventArgs e) { Clear(); }; Gdk.Pixbuf save_pixbuf = MainClass.Tools.GetIconFromStock("save.png", IconSize.SmallToolbar); Button btnSave = new Button(new Gtk.Image(save_pixbuf)); btnSave.TooltipText = MainClass.Languages.Translate("save"); btnSave.Relief = ReliefStyle.None; btnSave.CanFocus = false; btnSave.WidthRequest = btnSave.HeightRequest = 24; btnSave.Clicked += delegate(object sender, EventArgs e) { Save(); }; vbt.WidthRequest = 24; vbt.PackStart(btnClear, false, false, 0); vbt.PackStart(btnSave, false, false, 0); this.PackEnd(vbt, false, false, 0); bold = new TextTag("bold"); bold.Weight = Pango.Weight.Bold; buffer.TagTable.Add(bold); errorTag = new TextTag("error"); errorTag.Foreground = "red"; 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); outputDispatcher = new GLib.TimeoutHandler(OutputDispatchHandler); customFont = Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont); textEditorControl.ModifyFont(customFont); textEditorControl.KeyPressEvent += HandleTextEditorControlKeyPressEvent; this.ShowAll(); }
public GtkHighlighter(TextBuffer buffer) { this.buffer = buffer; lineStart = buffer.CreateMark(null, buffer.EndIter, true); }
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 SourceEditorBuffer() : base(new SourceTagTable ()) { 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); }
void InternalPrompt(bool multiline, bool move_cursor=true) { promptState = multiline ? PromptState.Multiline : PromptState.Regular; if (!multiline) blockText = ""; startOfPrompt = Buffer.CreateMark(null, Buffer.EndIter, true); TextIter end = Buffer.EndIter; if (multiline) Buffer.Insert (ref end, PromptMultiLineString); else Buffer.Insert (ref end, PromptString); // 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); if (move_cursor) { Buffer.PlaceCursor (Buffer.EndIter); textView.ScrollMarkOnscreen (Buffer.InsertMark); } }
void Clear() { textview1.Buffer.Clear(); m_Scroll2EndMark = textview1.Buffer.CreateMark("Scroll2End", textview1.Buffer.EndIter, true); }
public void Print(string text) { var startIter = Buffer.GetIterAtMark(promptStart); Buffer.InsertWithTagsByName(ref startIter, "\n", "history"); Buffer.InsertWithTagsByName(ref startIter, "> ", "prompt"); Buffer.InsertWithTagsByName(ref startIter, text, "history"); promptStart = Buffer.CreateMark(null, startIter, true); Buffer.PlaceCursor(startIter); }
public void Initialize(TextIter iter, AttributedTaskTag tag) { //this.Buffer = buffer; this.Position = Buffer.CreateMark (null, iter, true); this.Tag = tag; Tag.AttributedTask = this; utils = new TaskNoteUtilities (Buffer); }
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.CustomOutputPadFont.Changed += HandleCustomFontChanged; outputDispatcher = new GLib.TimeoutHandler (outputDispatchHandler); InitSearchWidget (); }
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); } } } } }