vte-sharp2.0.0.0Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.A terminal widget implementation.
A is a terminal emulator implemented as a .
using System;
using System.Collections;
using Gtk;
using Gnome;
using Vte;
class T
{
static void Main (string[] args)
{
new T (args);
}
T (string[] args)
{
Program program = new Program ("vte-sharp-test", "0.0", Modules.UI, args);
App app = new App ("vte-sharp-test", "Test for vte widget");
app.SetDefaultSize (600, 450);
app.DeleteEvent += new DeleteEventHandler (OnAppDelete);
HBox hbox = new HBox ();
Terminal term = new Terminal ();
term.EncodingChanged += new EventHandler (OnEncodingChanged);
term.CursorBlinks = true;
term.MouseAutohide = true;
term.ScrollOnKeystroke = true;
term.DeleteBinding = TerminalEraseBinding.Auto;
term.BackspaceBinding = TerminalEraseBinding.Auto;
term.Encoding = "UTF-8";
term.FontFromString = "Monospace 12";
term.TextDeleted += new EventHandler (OnTextDeleted);
term.ChildExited += new EventHandler (OnChildExited);
VScrollbar vscroll = new VScrollbar (term.Adjustment);
hbox.PackStart (term);
hbox.PackStart (vscroll);
Gdk.Color white = new Gdk.Color ();
Gdk.Color.Parse ("white", ref white);
Gdk.Color black = new Gdk.Color ();
Gdk.Color.Parse ("black", ref black);
term.SetColors (black, white, white, 16);
string[] argv = Environment.GetCommandLineArgs ();
// wants an array of "variable=value"
string[] envv = new string [Environment.GetEnvironmentVariables ().Count];
int i = 0;
foreach (DictionaryEntry e in Environment.GetEnvironmentVariables ())
{
if (e.Key == "" || e.Value == "")
continue;
string tmp = String.Format ("{0}={1}", e.Key, e.Value);
envv[i] = tmp;
i ++;
}
int pid = term.ForkCommand (
Environment.GetEnvironmentVariable ("SHELL"),
argv,
envv,
Environment.CurrentDirectory,
false,
true,
true);
Console.WriteLine ("Child pid: {0}", pid);
app.Contents = hbox;
app.ShowAll ();
program.Run ();
}
private void OnTextDeleted (object o, EventArgs args)
{
Console.WriteLine ("text deleted");
}
private void OnEncodingChanged (object o, EventArgs args)
{
Console.WriteLine ("encoding changed");
}
private void OnTextInserted (object o, EventArgs args)
{
Console.WriteLine ("text inserted");
}
private void OnChildExited (object o, EventArgs args)
{
// optionally we could just reset instead of quitting
Console.WriteLine ("child exited");
Application.Quit ();
}
private void OnAppDelete (object o, DeleteEventArgs args)
{
Application.Quit ();
}
}
Gtk.WidgetMethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidTo be added
a
a To be addedMethodSystem.VoidAppends menu items for various input methods to the given menu.
a The user can select one of these items to modify the input method used by the terminal.MethodSystem.VoidResets as much of the terminal's internal state as possible. to reset tabstops
to empty the terminal's scrollback buffer
Resets as much of the terminal's internal state as possible, discarding any unprocessed input data, resetting character attributes, cursor state, national character set state, status line, terminal modes (insert/delete), selection state, and encoding.MethodSystem.StringExtracts a view of the visible part of the terminal.
a callback
user data to be passed to the callback
location for storing text attributes
a If is not , characters will only be read if returns after being passed the column and row, respectively. A structure is added to attributes for each byte added to the returned string detailing the character's position, colors, and other characteristics.MethodSystem.VoidTo be added
a
a To be addedMethodSystem.VoidPlaces the selected text in the terminal in the GDK_SELECTION_PRIMARY selection.MethodSystem.VoidChange the colors of the
the new foreground color, or
the new background color, or
the color palette
the number of entries in
The terminal widget uses a 28-color model comprised of the default foreground and background colors, the bold foreground color, the dim foreground color, an eight color palette, and bold versions of the eight color palette, and a dim version of the the eight color palette.
must be either 0, 8, 16, or 24. If is and is greater than 0, the new foreground color is taken from palette[7]. If is and is greater than 0, the new background color is taken from palette[0]. If is 8 or 16, the third (dim) and possibly second (bold) 8-color palette is extrapolated from the new background color and the items in palette.
MethodSystem.VoidReads the location of the insertion cursor and returns it.
long which will hold the column
long which will hold the row
The row coordinate is absolute.MethodSystem.VoidDetermines the amount of additional space the widget is using to pad the edges of its visible area.
a in which to store left/right-edge padding
a in which to store top/bottom-edge ypadding
This is necessary for cases where characters in the selected font do not themselves include a padding area and the text itself would be contiguous with the window border. Applications which use the widget's row_count, column_count, char_height, and char_width fields to set geometry hints using gtk_window_set_geometry_hints() will need to add this value to the base size. The values returned in xpad and ypad are the total padding used in each direction, and do not need to be doubled.MethodSystem.VoidPlaces the selected text in the terminal in the GDK_SELECTION_CLIPBOARD selection.MethodSystem.StringChecks if the text in and around the specified position matches any of the regular expressions previously set using .
the text column
the text row
pointer to an integer
a string which matches one of the previously set regular expressionsIf a match exists, the text string is returned and if is not , the number associated with the matched regular expression will be stored in tag. If more than one regular expression has been set with , then expressions are checked in the order in which they were added.MethodSystem.StringExtracts a view of the visible part of the string.
first row to search for data
first column to search for data
last row to search for data
last column to search for data
a callback
user data to be passed to the callback
location for storing text attributes
a If is not , characters will only be read if returns after being passed the column and row, respectively. A structure is added to attributes for each byte added to the returned string detailing the character's position, colors, and other characteristics. The entire scrollback buffer is scanned, so it is possible to read the entire contents of the buffer using this function.MethodSystem.VoidClears the list of regular expressions the terminal uses to highlight text when the user moves the mouse cursor.MethodSystem.Int32Adds a regular expression to the list of matching expressions.
a regular expression
an integer associated with this expressionWhen the user moves the mouse cursor over a section of displayed text which matches this expression, the text will be highlighted.MethodSystem.VoidSends a block of UTF-8 text to the child as if it were entered by the user at the keyboard.
a MethodSystem.VoidRemoves the regular expression which is associated with the given from the list of expressions which the terminal will highlight when the user moves the mouse cursor over matching text.
the tag of the regex to remove
MethodSystem.VoidReset the terminal palette to reasonable compiled-in defaults.MethodSystem.VoidAttempts to change the terminal's size in terms of rows and columns.
the desired number of columns
the desired number of rows
If the attempt succeeds, the widget will resize itself to the proper size.MethodSystem.VoidSends the contents of the GDK_SELECTION_CLIPBOARD selection to the terminal's child.If necessary, the data is converted from UTF-8 to the terminal's current encoding.MethodSystem.VoidSends the contents of the GDK_SELECTION_PRIMARY selection to the terminal's child.If necessary, the data is converted from UTF-8 to the terminal's current encoding. The terminal will call also paste the GDK_SELECTION_PRIMARY selection when the user clicks with the the second mouse button.MethodSystem.VoidInterprets as if it were data received from a child process.
a This can either be used to drive the terminal without a child process, or just to mess with your users.ConstructorInternal Constructor.
a This should not be called by normal applications.System.Obsolete(Message=null, IsError=False)ConstructorInternal Constructor.
a This should not be called by normal user code.ConstructorDefault ConstructorPropertyGLib.GTypeGType Property.a Returns the native value for .PropertySystem.Int64An accessor function provided for the benefit of language bindings. the contents of terminal's char_ascent fieldPropertyGtk.AdjustmentAn accessor function provided for the benefit of language bindings. the contents of terminal's adjustment fieldPropertySystem.Int64An accessor function provided for the benefit of language bindings. the contents of terminal's column_count fieldPropertyGdk.ColorSets the background color for text which does not have a specific background color assigned. the new background colorOnly has effect when no background image is set and when the terminal is not transparent.PropertySystem.BooleanControls whether or not the terminal will forcibly scroll to the bottom of the viewable history when the user presses a key. if the terminal should scroll on keystrokesModifier keys do not trigger this behavior.PropertySystem.Int64An accessor function provided for the benefit of language bindings.a the contents of terminal's char_width fieldPropertySystem.Int64An accessor function provided for the benefit of language bindings.the contents of terminal's char_descent fieldPropertySystem.BooleanControls whether or not the terminal will present a visible bell to the user when the child outputs the "bl" sequence. if visible bell is enabled, if notThe terminal will clear itself to the default foreground color and then repaint itself.PropertySystem.BooleanSets whether or not the cursor will blink. if the cursor should blinkThe length of the blinking cycle is controlled by the "gtk-cursor-blink-time" GTK+ setting.PropertySystem.StringA convenience function which converts name into a PangoFontDescription and passes it to . A string describing the font.PropertySystem.StringSets what type of terminal the widget attempts to emulate by scanning for control sequences defined in the system's termcap file. the name of a terminal descriptionUnless you are interested in this feature, always use "xterm".PropertySystem.BooleanWhether a is using Xft to draw text. if the terminal is using Xft to render, if the terminal is using Pango or Xlib.This function allows an application to determine which mode the widget is in. This setting cannot be changed by the caller, but in practice usually matches the behavior of Gtk itself.PropertyVte.TerminalEraseBindingModifies the terminal's backspace key binding, which controls what string or control sequence the terminal sends to its child when the user presses the backspace key. a for the backspace keyPropertySystem.StringAn accessor function provided for the benefit of language bindings. the contents of terminal's icon_title fieldPropertySystem.BooleanControls whether or not the terminal will forcibly scroll to the bottom of the viewable history when the new data is received from the child. if the terminal should scroll on outputPropertySystem.BooleanSets the terminal's background image to the pixmap stored in the root window, adjusted so that if there are no windows below your application, the widget will appear to be transparent. if the terminal should fake transparencyPropertyGdk.ColorTo be addeda To be addedPropertyVte.TerminalEraseBindingModifies the terminal's delete key binding, which controls what string or control sequence the terminal sends to its child when the user presses the delete key.a for the delete keyPropertySystem.StringThe encoding the terminal will expect data from the child to be encoded with. a valid gconv targetFor certain terminal types, applications executing in the terminal can change the encoding. The default encoding is defined by the application's locale settings.PropertySystem.BooleanControls whether or not the terminal will attempt to draw bold text by repainting text with a different offset. if the terminal should attempt to draw bold textPropertyGdk.PixbufSets a background image for the widget. to use, or to cancelText which would otherwise be drawn using the default background color will instead be drawn over the specified image. If necessary, the image will be tiled to cover the widget's entire visible area.PropertySystem.StringWhen the user double-clicks to start selection, the terminal will extend the selection on word boundaries. a specificationWhen the user double-clicks to start selection, the terminal will extend the selection on word boundaries. It will treat characters passed in as parts of words, and all other characters as word separators. Ranges of characters can be specified by separating them with a hyphen.
As a special case, if set to or the empty string, the terminal will treat all graphic non-punctuation characters as word characters.
PropertySystem.Int64An accessor function provided for the benefit of language bindings. the contents of terminal's row_count fieldPropertySystem.StringSome terminal emulations specify a status line which is separate from the main display area, and define a means for applications to move the cursor to the status line and back.The current contents of the terminal's status line. For terminals like "xterm", this will usually be the empty string. The string must not be modified or freed by the caller.PropertySystem.BooleanTo be addeda To be addedPropertyGdk.ColorSets the color used to draw dim text in the default foreground color. the new dim colorPropertySystem.Int64Sets the length of the scrollback buffer used by the terminal.the length of the history bufferThe size of the scrollback buffer will be set to the larger of this value and the number of visible rows the widget can display, so 0 can safely be used to disable scrollback. Note that this setting only affects the normal screen buffer. For terminal types which have an alternate screen buffer, no scrollback is allowed.PropertySystem.Int64An accessor function provided for the benefit of language bindings. the contents of terminal's char_height fieldPropertySystem.StringSets a background image for the widget.a If specified by , the terminal will make its in-memory copy of the image darker for its own use.
This is a convenience wrapper for . If your application intends to create multiple terminal widgets using the same background, performing this step yourself and just using will reduce memory consumption.
PropertyGdk.ColorSets the color used to draw bold text in the default foreground color. the new bold colorPropertySystem.DoubleAdjust the brightness of the background image.a If a background image has been set using , , or , the terminal will adjust the brightness of the image before drawing the image. To do so, the terminal will create a copy of the background image (or snapshot of the root window) and modify its pixel values.
If your application intends to create multiple terminal widgets with the same settings, performing this step yourself and just using will save memory.
PropertySystem.StringAn accessor function provided for the benefit of language bindings. the contents of terminal's window_title field the contents of terminal's window_title fieldPropertySystem.BooleanThe value of the terminal's mouse autohide setting. if the autohide should be enabledWhen autohiding is enabled, the mouse cursor will be hidden when the user presses a key and shown when the user moves the mouse.PropertyGdk.ColorSets the foreground color used to draw normal text the new foreground colorPropertySystem.BooleanControls whether or not the terminal will beep when the child outputs the "bl" sequence.a if the terminal should beepPropertySystem.BooleanChecks if the terminal currently contains selected text. if part of the text in the terminal is selected.Note that this is different from determining if the terminal is the owner of any items.EventSystem.EventHandlerEmitted at the child application's request.GLib.Signal(CName="restore-window")EventSystem.EventHandlerEmitted at the child application's request.GLib.Signal(CName="lower-window")EventSystem.EventHandlerEmitted at the child application's request.GLib.Signal(CName="maximize-window")EventSystem.EventHandlerEmitted when the user hits the '+' key while holding the Control key.GLib.Signal(CName="increase-font-size")EventSystem.EventHandlerAn internal signal used for communication between the terminal and its accessibility peer.May not be emitted under certain circumstances.GLib.Signal(CName="text-modified")EventSystem.EventHandlerEmitted at the child application's request.GLib.Signal(CName="raise-window")EventSystem.EventHandlerAn internal signal used for communication between the terminal and its accessibility peer.May not be emitted under certain circumstances.GLib.Signal(CName="text-inserted")EventSystem.EventHandlerEmitted whenever the contents of the status line are modified or cleared.GLib.Signal(CName="status-line-changed")EventSystem.EventHandlerEmitted at the child application's request.GLib.Signal(CName="iconify-window")EventSystem.EventHandlerThis signal is emitted when the terminal detects that a child started using has exited.GLib.Signal(CName="child-exited")EventSystem.EventHandlerAn internal signal used for communication between the terminal and its accessibility peer.May not be emitted under certain circumstances.GLib.Signal(CName="text-deleted")EventVte.MoveWindowHandlerEmitted at the child application's request.GLib.Signal(CName="move-window")EventSystem.EventHandlerEmitted at the child application's request.GLib.Signal(CName="refresh-window")EventSystem.EventHandlerEmitted at the child application's request.GLib.Signal(CName="deiconify-window")EventSystem.EventHandlerEmitted when the terminal's icon_title field is modified.GLib.Signal(CName="icon-title-changed")EventSystem.EventHandlerEmitted when the user hits the '-' key while holding the Control key.GLib.Signal(CName="decrease-font-size")EventVte.TextScrolledHandlerAn internal signal used for communication between the terminal and its accessibility peer.May not be emitted under certain circumstances.GLib.Signal(CName="text-scrolled")EventVte.CharSizeChangedHandlerEmitted whenever selection of a new font causes the values of the char_width or char_height fields to change.GLib.Signal(CName="char-size-changed")EventSystem.EventHandlerEmitted when the terminals encoding type is changed.GLib.Signal(CName="encoding-changed")EventSystem.EventHandlerEmitted when the terminal's window_title field is modified.GLib.Signal(CName="window-title-changed")EventSystem.EventHandlerEmitted whenever the visible appearance of the terminal has changed.Used primarily by .GLib.Signal(CName="contents-changed")EventSystem.EventHandlerEmitted whenever the cursor moves to a new character cell.Used primarily by .GLib.Signal(CName="cursor-moved")EventSystem.EventHandlerEmitted whenever the contents of terminal's selection changes.GLib.Signal(CName="selection-changed")EventSystem.EventHandlerTo be addedGLib.Signal(CName="eof")EventSystem.EventHandlerEmitted when the terminal emulation type is changed.GLib.Signal(CName="emulation-changed")EventVte.ResizeWindowHandlerEmitted at the child application's request.GLib.Signal(CName="resize-window")EventVte.CommitHandlerEmitted whenever the terminal receives input from the user and prepares to send it to the child process.The signal is emitted even when there is no child process.GLib.Signal(CName="commit")PropertyPango.FontDescriptionThe font used for rendering all text displayed by the terminal, overriding any fonts set using .The of the desired font.The terminal will immediately attempt to load the desired font, retrieve its metrics, and attempts to resize itself to keep the same number of rows and columns.MethodSystem.Int32Starts the specified command under a newly-allocated control pseudo-terminal.
the name of a binary to run
the argument list to be passed to
a list of environment variables to be added to the environment before starting
the name of a directory the command should start in, or if the session should be logged to the lastlog
if the session should be logged to the utmp/utmpx log
if the session should be logged to the wtmp/wtmpx log
the ID of the new processTERM is automatically set to reflect the terminal widget's emulation setting. If lastlog, utmp, or wtmp are , logs the session to the specified system log files.MethodSystem.BooleanDetermines if a character is considered to be part of a word
a if is considered to be a word character according to the current value of .