本文整理汇总了C#中Gtk.TextBuffer类的典型用法代码示例。如果您正苦于以下问题:C# TextBuffer类的具体用法?C# TextBuffer怎么用?C# TextBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextBuffer类属于Gtk命名空间,在下文中一共展示了TextBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertLink
// Inserts a piece of text into the buffer, giving it the usual
// appearance of a hyperlink in a web browser: blue and underlined.
// Additionally, attaches some data on the tag, to make it recognizable
// as a link.
void InsertLink (TextBuffer buffer, ref TextIter iter, string text, int page)
{
TextTag tag = new TextTag (null);
tag.Foreground = "blue";
tag.Underline = Pango.Underline.Single;
tag_pages [tag] = page;
buffer.TagTable.Add (tag);
buffer.InsertWithTags (ref iter, text, tag);
}
示例2: ConsoleGtk
public ConsoleGtk ()
{
Window win = new Window ("MonoLOGO");
win.DeleteEvent += new EventHandler (Window_Delete);
win.BorderWidth = 4;
win.DefaultSize = new Size (450, 300);
VBox vbox = new VBox (false, 4);
win.EmitAdd (vbox);
ScrolledWindow swin = new ScrolledWindow (new Adjustment (0.0, 0.0, 0.0, 0.0, 0.0, 0.0), new Adjustment (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
swin.HscrollbarPolicy = Gtk.PolicyType.Automatic;
swin.VscrollbarPolicy = Gtk.PolicyType.Automatic;
swin.ShadowType = Gtk.ShadowType.In;
vbox.PackStart (swin, true, true, 0);
TextBuffer buf = new TextBuffer (new TextTagTable ());
Out = new TextWriterGtk (buf);
TextView text = new TextView (buf);
text.Editable = false;
swin.EmitAdd (text);
Entry entry = new Entry ();
entry.Activate += new EventHandler (Entry_Activate);
vbox.PackStart (entry, false, false, 0);
win.ShowAll ();
}
示例3: AddPaddingEmpty
public static int AddPaddingEmpty (TextBuffer buffer, int offset, string suffix)
{
TextIter insertAt = buffer.GetIterAtOffset (offset);
AddPaddingEmpty (buffer, ref insertAt, suffix);
return insertAt.Offset;
}
示例4: LogView
public LogView ()
{
buffer = new Gtk.TextBuffer (new Gtk.TextTagTable ());
textEditorControl = new Gtk.TextView (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);
}
示例5: ShowPage
// Fills the buffer with text and interspersed links. In any real
// hypertext app, this method would parse a file to identify the links.
void ShowPage (TextBuffer buffer, int page)
{
buffer.Text = "";
TextIter iter = buffer.StartIter;
if (page == 1) {
buffer.Insert (ref iter, "Some text to show that simple ");
InsertLink (buffer, ref iter, "hypertext", 3);
buffer.Insert (ref iter, " can easily be realized with ");
InsertLink (buffer, ref iter, "tags", 2);
buffer.Insert (ref iter, ".");
} else if (page == 2) {
buffer.Insert (ref iter,
"A tag is an attribute that can be applied to some range of text. " +
"For example, a tag might be called \"bold\" and make the text inside " +
"the tag bold. However, the tag concept is more general than that; " +
"tags don't have to affect appearance. They can instead affect the " +
"behavior of mouse and key presses, \"lock\" a range of text so the " +
"user can't edit it, or countless other things.\n");
InsertLink (buffer, ref iter, "Go back", 1);
} else if (page == 3) {
TextTag tag = buffer.TagTable.Lookup ("bold");
if (tag == null) {
tag = new TextTag ("bold");
tag.Weight = Pango.Weight.Bold;
buffer.TagTable.Add (tag);
}
buffer.InsertWithTags (ref iter, "hypertext:\n", tag);
buffer.Insert (ref iter,
"machine-readable text that is not sequential but is organized " +
"so that related items of information are connected.\n");
InsertLink (buffer, ref iter, "Go back", 1);
}
}
示例6: CreateText
private ScrolledWindow CreateText(TextBuffer buffer, bool IsSource)
{
ScrolledWindow scrolledWindow = new ScrolledWindow ();
scrolledWindow.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
scrolledWindow.ShadowType = ShadowType.In;
TextView textView = new TextView (buffer);
textView.Editable = false;
textView.CursorVisible = false;
scrolledWindow.Add (textView);
if (IsSource) {
FontDescription fontDescription = FontDescription.FromString ("monospace");
textView.OverrideFont (fontDescription);
textView.WrapMode = Gtk.WrapMode.None;
} else {
// Make it a bit nicer for text
textView.WrapMode = Gtk.WrapMode.Word;
textView.PixelsAboveLines = 2;
textView.PixelsBelowLines = 2;
}
return scrolledWindow;
}
示例7: Redo
public override void Redo (TextBuffer buffer)
{
TextIter insertIter = buffer.GetIterAtOffset (index);
buffer.InsertRange (ref insertIter, chop.Start, chop.End);
buffer.MoveMark (buffer.SelectionBound, buffer.GetIterAtOffset (index));
buffer.MoveMark (buffer.InsertMark, buffer.GetIterAtOffset (index + chop.Length));
}
示例8: Indexing
public Indexing()
{
this.Build();
this.Hide(); // not show the on creation, since we can add text before we show the screen
buffer = new Gtk.TextBuffer(new TextTagTable());
log_text_view.Buffer = buffer;
}
示例9: StyleWindow
public StyleWindow()
: base(Gtk.WindowType.Toplevel)
{
SetSizeRequest(800, 800);
var box = new VBox();
Add(box);
var tab = new TextTagTable();
buf = new TextBuffer(tab);
buf.Text = System.IO.File.ReadAllText("res/theme/gtk.css");
var en = new TextView(buf);
sv = new ScrolledWindow();
sv.Add(en);
box.PackStart(sv, true, true, 0);
var cssProvider = new CssProvider();
StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, uint.MaxValue - 10);
var isDefault = true;
var but = new Button();
but.Label = "Save";
but.HeightRequest = 30;
box.PackEnd(but, false, false, 0);
but.Clicked += (s, e) => {
System.IO.File.WriteAllText("res/theme/gtk.css", buf.Text);
};
buf.Changed += (s, e) => {
bool error = false;
try {
//StyleContext.RemoveProviderForScreen(Gdk.Screen.Default, cssProvider);
cssProvider.LoadFromData(buf.Text);
//StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, uint.MaxValue - 10);
} catch (Exception ex) {
error = true;
}
if (error) {
if (!isDefault) {
StyleContext.RemoveProviderForScreen(Gdk.Screen.Default, cssProvider);
StyleContext.AddProviderForScreen(Gdk.Screen.Default, AppLib.GlobalCssProvider, uint.MaxValue);
isDefault = true;
}
} else {
if (isDefault) {
StyleContext.RemoveProviderForScreen(Gdk.Screen.Default, AppLib.GlobalCssProvider);
StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, uint.MaxValue);
isDefault = false;
}
}
};
ShowAll();
}
示例10: CheckDependenciesDialog
public CheckDependenciesDialog(Project project)
: base("CheckDependenciesDialog.ui", "dependencies")
{
text_buffer = new Gtk.TextBuffer (new Gtk.TextTagTable ());
capabilitiesview.Buffer = text_buffer;
Gtk.TextBuffer buffer_intro = new Gtk.TextBuffer (new Gtk.TextTagTable ());
textview_intro.Buffer = buffer_intro;
buffer_intro.Text = Catalog.GetString ("Mistelix uses a set of external components. Their availability determines Mistelix's capabilities. The following list shows the level of support of your system for Mistelix and if there are actions required.");
}
示例11: TextView
public TextView (TextBuffer buffer) : base (IntPtr.Zero)
{
if (GetType() != typeof (TextView)) {
CreateNativeObject (new string [0], new GLib.Value [0]);
Buffer = buffer;
return;
}
Raw = gtk_text_view_new_with_buffer (buffer.Handle);
}
示例12: Serialize
public static string Serialize (TextBuffer buffer, TextIter start, TextIter end)
{
StringWriter stream = new StringWriter ();
XmlTextWriter xmlWriter = new XmlTextWriter (stream);
xmlWriter.Formatting = Formatting.Indented;
Serialize (buffer, start, end, xmlWriter);
xmlWriter.Close ();
return stream.ToString ();
}
示例13: MapWindow
private TextView textView; // Textview to hold landmark information.
#endregion Fields
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="SLAM.MapWindow"/> class.
/// </summary>
/// <param name="mapView">Map view contained in this window.</param>
public MapWindow(MapView mapView)
: base("Map")
{
robot = mapView.RobotView.Robot;
this.mapView = mapView;
// Subscribe to events.
mapView.MapModel.MapUpdated += new EventHandler<MapUpdateEventArgs> (Map_Update);
mapView.RobotView.Robot.RobotUpdated += new EventHandler<RobotUpdateEventArgs> (Robot_Update);
SetPosition (WindowPosition.Center);
Resizable = false;
DeleteEvent += delegate
{
Application.Quit ();
};
TextBuffer textBuffer = new TextBuffer (new TextTagTable ());
textView = new TextView ();
textView.Indent = 10;
textView.Editable = false;
textView.Buffer = textBuffer;
textView.CursorVisible = false;
textView.SetSizeRequest (mapView.ViewWidth, 150);
foreach (Landmark landmark in mapView.MapModel.Landmarks)
{
this.textView.Buffer.Text += landmark.ToString ();
}
ScrolledWindow scrolledWindow = new ScrolledWindow ();
scrolledWindow.Add (textView);
commandEntry = new Entry ();
commandEntry.Activated += CommandEntry_OnActivated;
sendButton = new Button ("Send");
sendButton.Clicked += SendButton_OnClick;
HBox hbox = new HBox (false, 0);
hbox.Add (commandEntry);
hbox.Add (sendButton);
VBox vbox = new VBox (false, 0);
vbox.Add (this.mapView);
vbox.Add (scrolledWindow);
vbox.Add (hbox);
Add (vbox);
Shown += OnShown;
}
示例14: NotesWidget
public NotesWidget()
{
this.Build ();
this.buf = textview1.Buffer;
buf.Changed += new EventHandler (OnEdition);
App.Current.EventsBroker.Subscribe<EventLoadedEvent> (HandlePlayLoaded);
}
示例15: ProgressDialog
public ProgressDialog (Window parent, bool allowCancel, bool showDetails)
{
this.Build ();
HasSeparator = false;
ActionArea.Hide ();
DefaultHeight = 5;
TransientFor = parent;
btnCancel.Visible = allowCancel;
expander.Visible = showDetails;
buffer = detailsTextView.Buffer;
detailsTextView.Editable = false;
bold = new TextTag ("bold");
bold.Weight = Pango.Weight.Bold;
buffer.TagTable.Add (bold);
tag = new TextTag ("0");
tag.Indent = 10;
buffer.TagTable.Add (tag);
tags.Add (tag);
}