Terminal#
Superclasses: Widget, InitiallyUnowned, Object
Implemented Interfaces: Accessible, AccessibleText, Buildable, ConstraintTarget, Scrollable
- Constructors:
Terminal(**properties)
new() -> Vte.Terminal
Constructors#
Methods#
- class Terminal
- check_hyperlink_at(x: float, y: float) str | None#
Returns a nonempty string: the target of the explicit hyperlink (printed using the OSC 8 escape sequence) at the position (x, y), or
None.Proper use of the escape sequence should result in URI-encoded URIs with a proper scheme like “http://”, “https://”, “file://”, “mailto:” etc. This is, however, not enforced by VTE. The caller must tolerate the returned string potentially not being a valid URI.
Added in version 0.70.
- Parameters:
x
y
- check_match_at(x: float, y: float) tuple[str | None, int]#
Checks if the text in and around the position (x, y) matches any of the regular expressions previously set using vte_terminal_match_add(). If a match exists, the text string is returned and if
tagis notNone, the number associated with the matched regular expression will be stored intag.If more than one regular expression has been set with vte_terminal_match_add(), then expressions are checked in the order in which they were added.
Added in version 0.70.
- Parameters:
x
y
- check_regex_simple_at(x: float, y: float, regexes: list[Regex], match_flags: int) list[str] | None#
Checks each regex in
regexesif the text in and around the position (x, y) matches the regular expressions. If a match exists, the matched text is stored inmatchesat the position of the regex inregexes; otherwiseNoneis stored there. Each non-Noneelement ofmatchesshould be freed withfree().Note that the regexes in
regexesshould have been created using the %PCRE2_MULTILINE flag.Added in version 0.70.
- Parameters:
x
y
regexes – an array of
Regexmatch_flags – PCRE2 match flags, or 0
- do_char_size_changed(self, char_width: int, char_height: int) None#
- Parameters:
char_width
char_height
- Parameters:
context
- dup_termprop_string(prop: str) tuple[str | None, int]#
- Returns the value of a
STRINGtermprop, orNoneif propis unset, orpropis not a registered property.
Added in version 0.78.
- Parameters:
prop – a termprop name
- Returns the value of a
- dup_termprop_string_by_id(prop: int) tuple[str | None, int]#
Like
dup_termprop_string()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- dup_termprop_uuid(prop: str) Uuid#
- Returns the value of a
UUIDtermprop as aUuid, orNoneif propis unset, orpropis not a registered property.
Added in version 0.78.
- Parameters:
prop – a termprop name
- Returns the value of a
- dup_termprop_uuid_by_id(prop: int) Uuid#
Like
dup_termprop_uuid()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- feed(data: list[int] | None = None) None#
Interprets
dataas if it were data received from a child process.- Parameters:
data – a string in the terminal’s current encoding
- feed_child(text: list[int] | None = None) None#
Sends a block of UTF-8 text to the child as if it were entered by the user at the keyboard.
- Parameters:
text – data to send to the child
- feed_child_binary(data: list[int] | None = None) None#
Sends a block of binary data to the child.
Deprecated since version 0.60:
- Don’t send binary data. Use
feed_child()instead to send UTF-8 text
- Parameters:
data – data to send to the child
- Don’t send binary data. Use
- get_allow_bold() bool#
Checks whether or not the terminal will attempt to draw bold text, by using a bold font variant.
Deprecated since version 0.60: There’s probably no reason for this feature to exist.
- get_allow_hyperlink() bool#
Checks whether or not hyperlinks (OSC 8 escape sequence) are allowed.
Added in version 0.50.
- get_audible_bell() bool#
Checks whether or not the terminal will beep when the child outputs the “bl” sequence.
- get_bold_is_bright() bool#
Checks whether the SGR 1 attribute also switches to the bright counterpart of the first 8 palette colors, in addition to making them bold (legacy behavior) or if SGR 1 only enables bold and leaves the color intact.
Added in version 0.52.
- get_cjk_ambiguous_width() int#
Returns whether ambiguous-width characters are narrow or wide. (Note that when using a non-UTF-8 encoding set via
set_encoding(), the width of ambiguous-width characters is fixed and determined by the encoding itself.)
- get_color_background_for_draw() RGBA#
Returns the background colour, as used by
terminalwhen drawing the background, which may be different from the color set byset_color_background().Note: you must only call this function while handling the GtkWidget::draw signal.
This function is rarely useful. One use for it is if you disable drawing the background (see
set_clear_background()) and then need to draw the background yourself.Added in version 0.54.
Added in version 0.76.
Added in version 0.76.
- get_current_directory_uri() str | None#
Deprecated since version 0.78: Use the %VTE_TERMPROP_CURRENT_FILE_URI_STRING termprop.
- get_current_file_uri() str | None#
Deprecated since version 0.78: Use the %VTE_TERMPROP_CURRENT_FILE_URI_STRING termprop.
- get_cursor_blink_mode() CursorBlinkMode#
Returns the currently set cursor blink mode.
- get_cursor_position() tuple[int, int]#
Reads the location of the insertion cursor and returns it. The row coordinate is absolute.
This method is unaware of BiDi. The returned column is logical column.
- get_cursor_shape() CursorShape#
Returns the currently set cursor shape.
- get_enable_a11y() bool#
Checks whether the terminal communicates with a11y backends
Added in version 0.78.
- get_enable_bidi() bool#
Checks whether the terminal performs bidirectional text rendering.
Added in version 0.58.
- get_encoding() str | None#
Determines the name of the encoding in which the terminal expects data to be encoded, or
Noneif UTF-8 is in use.Deprecated since version 0.54: Support for non-UTF-8 is deprecated.
- get_font() FontDescription#
Queries the terminal for information about the fonts which will be used to draw text in the terminal. The actual font takes the font scale into account, this is not reflected in the return value, the unscaled font is returned.
- get_has_selection() bool#
Checks if the terminal currently contains selected text. Note that this is different from determining if the terminal is the owner of any
GtkClipboarditems.
- get_icon_title() str | None#
Deprecated since version 0.54: Please do not use it in newly written code
- get_mouse_autohide() bool#
Determines the value of the terminal’s mouse autohide setting. When autohiding is enabled, the mouse cursor will be hidden when the user presses a key and shown when the user moves the mouse. This setting can be changed using
set_mouse_autohide().
- get_rewrap_on_resize() bool#
Checks whether or not the terminal will rewrap its contents upon resize.
Deprecated since version 0.58: Please do not use it in newly written code
- get_termprop_bool(prop: str) tuple[bool, bool]#
- For a
BOOLtermprop, setsvaluetoprop's value, or to
Falseifpropis unset, orpropis not a registered property.
Added in version 0.78.
- Parameters:
prop – a termprop name
- For a
- get_termprop_bool_by_id(prop: int) tuple[bool, bool]#
Like
get_termprop_bool()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_termprop_data(prop: str) list[int]#
- Returns the value of a
DATAtermprop, orNoneif propis unset, orpropis not a registered property.
Added in version 0.78.
- Parameters:
prop – a termprop name
- Returns the value of a
- get_termprop_data_by_id(prop: int) list[int]#
Like
get_termprop_data()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_termprop_double(prop: str) tuple[bool, float]#
- For a
DOUBLEtermprop, setsvaluetoprop's value, which is finite; or to 0.0 if
propis unset, orpropis not a registered property.
Added in version 0.78.
- Parameters:
prop – a termprop name
- For a
- get_termprop_double_by_id(prop: int) tuple[bool, float]#
Like
get_termprop_double()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_termprop_int(prop: str) tuple[bool, int]#
For a
INTtermprop, setsvaluetoprop's value, or to 0 ifpropis unset, or ifpropis not a registered property.If only a subset or range of values are acceptable for the given property, the caller must validate the returned value and treat any out-of-bounds value as if the termprop had no value; in particular it must not clamp the values to the expected range.
Added in version 0.78.
- Parameters:
prop – a termprop name
- get_termprop_int_by_id(prop: int) tuple[bool, int]#
Like
get_termprop_int()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_termprop_rgba(prop: str) tuple[bool, RGBA]#
Stores the value of a
RGBorRGBAtermprop incolorand returnsTrueif the termprop is set, or stores rgb(0,0,0) or rgba(0,0,0,1) incolorand returnsFalseif the termprop is unset.Added in version 0.78.
- Parameters:
prop – a termprop name
- get_termprop_rgba_by_id(prop: int) tuple[bool, RGBA]#
Like
get_termprop_rgba()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_termprop_string(prop: str) tuple[str | None, int]#
- Returns the value of a
STRINGtermprop, orNoneif propis unset, orpropis not a registered property.
Added in version 0.78.
- Parameters:
prop – a termprop name
- Returns the value of a
- get_termprop_string_by_id(prop: int) tuple[str | None, int]#
Like
get_termprop_string()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_termprop_uint(prop: str) tuple[bool, int]#
For a
UINTtermprop, setsvaluetoprop's value, or to 0 ifpropis unset, orpropis not a registered property.If only a subset or range of values are acceptable for the given property, the caller must validate the returned value and treat any out-of-bounds value as if the termprop had no value; in particular it must not clamp the values to the expected range.
Added in version 0.78.
- Parameters:
prop – a termprop name
- get_termprop_uint_by_id(prop: int) tuple[bool, int]#
Like
get_termprop_uint()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_termprop_value(prop: str) tuple[bool, Value]#
- Returns
Truewith the value ofpropstored invalue(if notNone) if, the termprop has a value, or
Falseifpropis unset, orpropis not a registered property; in that casevaluewill not be set.
The value type returned depends on the termprop type: * A
VALUELESStermprop stores no value, and returnsFalsefrom this function.
* A
BOOLtermprop stores aboolvalue. * AINTtermprop stores aintvalue. * AUINTtermprop stores a unsignedintvalue. * ADOUBLEtermprop stores afloatvalue. * ARGBtermprop stores a boxedRGBAvalue with alpha 1.0 on gtk3,and nothing on gtk4.
* A
STRINGtermprop stores astrvalue. * ADATAtermprop stores a boxedBytesvalue. * AUUIDtermprop stores a boxedUuidvalue. * AURItermprop stores a boxedUrivalue.Added in version 0.78.
- Parameters:
prop – a termprop name
- Returns
- get_termprop_value_by_id(prop: int) tuple[bool, Value]#
Like
get_termprop_value()except that it takes the termprop by ID. See that function for more information.Added in version 0.78.
- Parameters:
prop – a termprop ID
- get_text(is_selected: Callable[[Terminal, int, int, Any], bool] | None = None, user_data: Any = None) tuple[str | None, list[CharAttributes] | None]#
Extracts a view of the visible part of the terminal.
This method is unaware of BiDi. The columns returned in
attributesare logical columns.Note: since 0.68, passing a non-
Noneattributesparameter is deprecated. Starting with 0.72, passing a non-Noneattributesparameter will make this function itself returnNone. Since 0.72, passing a non-Noneis_selectedparameter will make this function itself returnNone.Deprecated since version 0.76: Use
get_text_format()instead- Parameters:
is_selected – a
SelectionFunccallback. Deprecated: 0.44: Always passNonehere.user_data – user data to be passed to the callback
- get_text_blink_mode() TextBlinkMode#
Checks whether or not the terminal will allow blinking text.
Added in version 0.52.
- get_text_format(format: Format) str | None#
Returns text from the visible part of the terminal in the specified format.
This method is unaware of BiDi. The columns returned in
attributesare logical columns.Added in version 0.76.
- Parameters:
format – the
Formatto use
- get_text_include_trailing_spaces(is_selected: Callable[[Terminal, int, int, Any], bool] | None = None, user_data: Any = None) tuple[str, list[CharAttributes] | None]#
Extracts a view of the visible part of the terminal.
This method is unaware of BiDi. The columns returned in
attributesare logical columns.Note: since 0.68, passing a non-
Nonearrayparameter is deprecated. Starting with 0.72, passing a non-Nonearrayparameter will make this function itself returnNone. Since 0.72, passing a non-Noneis_selectedparameter will make this function itself returnNone.Deprecated since version 0.56: Use
get_text_format()instead.- Parameters:
is_selected – a
SelectionFunccallback. Deprecated: 0.44: Always passNonehere.user_data – user data to be passed to the callback
- get_text_range(start_row: int, start_col: int, end_row: int, end_col: int, is_selected: Callable[[Terminal, int, int, Any], bool] | None = None, user_data: Any = None) tuple[str | None, list[CharAttributes] | None]#
Extracts a view of the visible part of the terminal. The entire scrollback buffer is scanned, so it is possible to read the entire contents of the buffer using this function.
This method is unaware of BiDi. The columns passed in
start_colandend_row, and returned inattributesare logical columns.Since 0.68, passing a non-
Nonearrayparameter is deprecated. Since 0.72, passing a non-Nonearrayparameter will make this functionitself return
None.- Since 0.72, passing a non-
Noneis_selectedfunction will make this function itself return
None.
Deprecated since version 0.76: Use
get_text_range_format()instead- Parameters:
start_row – first row to search for data
start_col – first column to search for data
end_row – last row to search for data
end_col – last column to search for data
is_selected – a
SelectionFunccallback. Deprecated: 0.44: Always passNonehereuser_data – user data to be passed to the callback
- Since 0.72, passing a non-
- get_text_range_format(format: Format, start_row: int, start_col: int, end_row: int, end_col: int) tuple[str | None, int]#
Returns the specified range of text in the specified format.
Added in version 0.72.
- Parameters:
format – the
Formatto usestart_row – the first row of the range
start_col – the first column of the range
end_row – the last row of the range
end_col – the last column of the range
- get_text_selected(format: Format) str | None#
Gets the currently selected text in the format specified by
format. Since 0.72, this function also supportsHTMLformat.Added in version 0.70.
- Parameters:
format – the
Formatto use
- get_text_selected_full(format: Format) tuple[str | None, int]#
Gets the currently selected text in the format specified by
format.Added in version 0.72.
- Parameters:
format – the
Formatto use
- get_window_title() str | None#
Deprecated since version 0.78: Use the
TERMPROP_XTERM_TITLEtermprop.
- get_word_char_exceptions() str | None#
Returns the set of characters which will be considered parts of a word when doing word-wise selection, in addition to the default which only considers alphanumeric characters part of a word.
If
None, a built-in set is used.Added in version 0.40.
- match_add_regex(regex: Regex, flags: int) int#
Adds the regular expression
regexto the list of matching expressions. When the user moves the mouse cursor over a section of displayed text which matches this expression, the text will be highlighted.Note that
regexshould have been created using thePCRE2_MULTILINEflag.Added in version 0.46.
- Parameters:
regex – a
Regexflags – PCRE2 match flags, or 0
- match_check(column: int, row: int) tuple[str | None, int]#
Checks if the text in and around the specified position matches any of the regular expressions previously set using vte_terminal_match_add(). If a match exists, the text string is returned and if
tagis notNone, the number associated with the matched regular expression will be stored intag.If more than one regular expression has been set with vte_terminal_match_add(), then expressions are checked in the order in which they were added.
Deprecated since version 0.46: Use vte_terminal_match_check_event() instead.
- Parameters:
column – the text column
row – the text row
- match_remove(tag: int) None#
Removes the regular expression which is associated with the given
tagfrom the list of expressions which the terminal will highlight when the user moves the mouse cursor over matching text.- Parameters:
tag – the tag of the regex to remove
- match_remove_all() None#
Clears the list of regular expressions the terminal uses to highlight text when the user moves the mouse cursor.
- match_set_cursor(tag: int, cursor: Cursor | None = None) None#
Sets which cursor the terminal will use if the pointer is over the pattern specified by
tag. The terminal keeps a reference tocursor.Deprecated since version 0.40: Use
match_set_cursor_name()instead.- Parameters:
tag – the tag of the regex which should use the specified cursor
cursor – the
Cursorwhich the terminal should use when the pattern is highlighted, orNoneto use the standard cursor
- match_set_cursor_name(tag: int, cursor_name: str) None#
Sets which cursor the terminal will use if the pointer is over the pattern specified by
tag.- Parameters:
tag – the tag of the regex which should use the specified cursor
cursor_name – the name of the cursor
- paste_clipboard() None#
Sends the contents of the
GDK_SELECTION_CLIPBOARDselection to the terminal’s child. It’s called on paste menu item, or when user presses Shift+Insert.
- paste_primary() None#
Sends the contents of the
GDK_SELECTION_PRIMARYselection to the terminal’s child. The terminal will call also paste theGDK_SELECTION_PRIMARYselection when the user clicks with the the second mouse button.
- paste_text(text: str) None#
Sends
textto the terminal’s child as if retrived from the clipboard, this differs fromfeed_child()in that it may processtextbefore passing it to the child (e.g. apply bracketed mode)Added in version 0.68.
- Parameters:
text – a string to paste
- pty_new_sync(flags: PtyFlags, cancellable: Cancellable | None = None) Pty#
Creates a new
Pty, sets the emulation property fromTerminal:emulation, and sets the size usingterminal's size.See vte_pty_new() for more information.
- Parameters:
flags – flags from
PtyFlagscancellable – a
Cancellable, orNone
- reset(clear_tabstops: bool, clear_history: bool) None#
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.
- Parameters:
clear_tabstops – whether to reset tabstops
clear_history – whether to empty the terminal’s scrollback buffer
- search_find_next() bool#
Searches the next string matching the search regex set with
search_set_regex().
- search_find_previous() bool#
Searches the previous string matching the search regex set with
search_set_regex().
- search_set_regex(regex: Regex | None, flags: int) None#
Sets the regex to search for. Unsets the search regex when passed
None.Note that
regexshould have been created using thePCRE2_MULTILINEflag.Added in version 0.46.
- Parameters:
regex – a
Regex, orNoneflags – PCRE2 match flags, or 0
- search_set_wrap_around(wrap_around: bool) None#
Sets whether search should wrap around to the beginning of the terminal content when reaching its end.
- Parameters:
wrap_around – whether search should wrap
- set_allow_bold(allow_bold: bool) None#
Controls whether or not the terminal will attempt to draw bold text, by using a bold font variant.
Deprecated since version 0.60: There’s probably no reason for this feature to exist.
- Parameters:
allow_bold –
Trueif the terminal should attempt to draw bold text
- set_allow_hyperlink(allow_hyperlink: bool) None#
Controls whether or not hyperlinks (OSC 8 escape sequence) are allowed.
Added in version 0.50.
- Parameters:
allow_hyperlink –
Trueif the terminal should allow hyperlinks
- set_audible_bell(is_audible: bool) None#
Controls whether or not the terminal will beep when the child outputs the “bl” sequence.
- Parameters:
is_audible –
Trueif the terminal should beep
- set_backspace_binding(binding: EraseBinding) None#
Modifies 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.
- Parameters:
binding – a
EraseBindingfor the backspace key
- set_bold_is_bright(bold_is_bright: bool) None#
Sets whether the SGR 1 attribute also switches to the bright counterpart of the first 8 palette colors, in addition to making them bold (legacy behavior) or if SGR 1 only enables bold and leaves the color intact.
Added in version 0.52.
- Parameters:
bold_is_bright –
Trueif bold should also enable bright
- set_cell_height_scale(scale: float) None#
Sets the terminal’s cell height scale to
scale.This can be used to increase the line spacing. (The font’s height is not affected.) Valid values go from 1.0 (default) to 2.0 (“double spacing”).
Added in version 0.52.
- Parameters:
scale – the cell height scale
- set_cell_width_scale(scale: float) None#
Sets the terminal’s cell width scale to
scale.This can be used to increase the letter spacing. (The font’s width is not affected.) Valid values go from 1.0 (default) to 2.0.
Added in version 0.52.
- Parameters:
scale – the cell width scale
- set_cjk_ambiguous_width(width: int) None#
This setting controls whether ambiguous-width characters are narrow or wide. (Note that when using a non-UTF-8 encoding set via
set_encoding(), the width of ambiguous-width characters is fixed and determined by the encoding itself.)- Parameters:
width – either 1 (narrow) or 2 (wide)
- set_clear_background(setting: bool) None#
Sets whether to paint the background with the background colour. The default is
True.This function is rarely useful. One use for it is to add a background image to the terminal.
Added in version 0.52.
- Parameters:
setting – whether to clear the background
- set_color_background(background: RGBA) None#
Sets the background color for text which does not have a specific background color assigned. Only has effect when no background image is set and when the terminal is not transparent.
- Parameters:
background – the new background color
- set_color_bold(bold: RGBA | None = None) None#
Sets the color used to draw bold text in the default foreground color. If
boldisNonethen the default color is used.- Parameters:
bold – the new bold color or
None
- set_color_cursor(cursor_background: RGBA | None = None) None#
Sets the background color for text which is under the cursor. If
None, text under the cursor will be drawn with foreground and background colors reversed.- Parameters:
cursor_background – the new color to use for the text cursor, or
None
- set_color_cursor_foreground(cursor_foreground: RGBA | None = None) None#
Sets the foreground color for text which is under the cursor. If
None, text under the cursor will be drawn with foreground and background colors reversed.Added in version 0.44.
- Parameters:
cursor_foreground – the new color to use for the text cursor, or
None
- set_color_foreground(foreground: RGBA) None#
Sets the foreground color used to draw normal text.
- Parameters:
foreground – the new foreground color
- set_color_highlight(highlight_background: RGBA | None = None) None#
Sets the background color for text which is highlighted. If
None, it is unset. If neither highlight background nor highlight foreground are set, highlighted text (which is usually highlighted because it is selected) will be drawn with foreground and background colors reversed.- Parameters:
highlight_background – the new color to use for highlighted text, or
None
- set_color_highlight_foreground(highlight_foreground: RGBA | None = None) None#
Sets the foreground color for text which is highlighted. If
None, it is unset. If neither highlight background nor highlight foreground are set, highlighted text (which is usually highlighted because it is selected) will be drawn with foreground and background colors reversed.- Parameters:
highlight_foreground – the new color to use for highlighted text, or
None
- set_colors(foreground: RGBA | None = None, background: RGBA | None = None, palette: list[RGBA] | None = None) None#
palettespecifies the new values for the 256 palette colors: 8 standard colors, their 8 bright counterparts, 6x6x6 color cube, and 24 grayscale colors. Omitted entries will default to a hardcoded value.palette_sizemust be 0, 8, 16, 232 or 256.If
foregroundisNoneandpalette_sizeis greater than 0, the new foreground color is taken frompalette[7]. IfbackgroundisNoneandpalette_sizeis greater than 0, the new background color is taken frompalette[0].- Parameters:
foreground – the new foreground color, or
Nonebackground – the new background color, or
Nonepalette – the color palette
Sets
menuas the context menu interminal. UseNoneto unset the current menu.Note that a menu model set with
set_context_menu_model()takes precedence over a menu set using this function.Added in version 0.76.
- Parameters:
menu – a menu
Sets
modelas the context menu model interminal. UseNoneto unset the current menu model.Added in version 0.76.
- Parameters:
model – a
MenuModel
- set_cursor_blink_mode(mode: CursorBlinkMode) None#
Sets whether or not the cursor will blink. Using
SYSTEMwill use theSettings::gtk-cursor-blink setting.- Parameters:
mode – the
CursorBlinkModeto use
- set_cursor_shape(shape: CursorShape) None#
Sets the shape of the cursor drawn.
- Parameters:
shape – the
CursorShapeto use
- set_delete_binding(binding: EraseBinding) None#
Modifies 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.
- Parameters:
binding – a
EraseBindingfor the delete key
- set_enable_a11y(enable_a11y: bool) None#
Controls whether or not the terminal will communicate with a11y backends.
Added in version 0.78.
- Parameters:
enable_a11y –
Trueto enable a11y support
- set_enable_bidi(enable_bidi: bool) None#
Controls whether or not the terminal will perform bidirectional text rendering.
Added in version 0.58.
- Parameters:
enable_bidi –
Trueto enable BiDi support
- set_enable_fallback_scrolling(enable: bool) None#
Controls whether the terminal uses scroll events to scroll the history if the event was not otherwise consumed by it.
This function is rarely useful, except when the terminal is added to a
ScrolledWindow, to perform kinetic scrolling (while vte itself does not, yet, implement kinetic scrolling by itself).Added in version 0.64.
- Parameters:
enable – whether to enable fallback scrolling
- set_enable_legacy_osc777(enable: bool) None#
Sets whether legacy OSC 777 sequences are translated to their corresponding termprops.
Added in version 0.78.
- Parameters:
enable – whether to enable legacy OSC 777
- set_enable_shaping(enable_shaping: bool) None#
Controls whether or not the terminal will shape Arabic text.
Added in version 0.58.
- Parameters:
enable_shaping –
Trueto enable Arabic shaping
- set_enable_sixel(enabled: bool) None#
Set whether to enable SIXEL images.
Added in version 0.62.
- Parameters:
enabled – whether to enable SIXEL images
- set_encoding(codeset: str | None = None) bool#
Changes the encoding the terminal will expect data from the child to be encoded with. For certain terminal types, applications executing in the terminal can change the encoding. If
codesetisNone, it uses “UTF-8”.Note: Support for non-UTF-8 is deprecated and may get removed altogether. Instead of this function, you should use a wrapper like luit(1) when spawning the child process.
Deprecated since version 0.54: Support for non-UTF-8 is deprecated.
- Parameters:
codeset – target charset, or
Noneto use UTF-8
- set_font(font_desc: FontDescription | None = None) None#
Sets the font used for rendering all text displayed by the terminal, overriding any fonts set using gtk_widget_modify_font(). The terminal will immediately attempt to load the desired font, retrieve its metrics, and attempt to resize itself to keep the same number of rows and columns. The font scale is applied to the specified font.
- Parameters:
font_desc – a
FontDescriptionfor the desired font, orNone
- set_font_options(font_options: FontOptions | None = None) None#
Sets the terminal’s font options to
options.Note that on GTK4, the terminal by default uses font options with %CAIRO_HINT_METRICS_ON set; to override that, use this function to set a
FontOptionsthat has %CAIRO_HINT_METRICS_OFF set.Added in version 0.74.
- Parameters:
font_options – the font options, or
None
- set_font_scale(scale: float) None#
Sets the terminal’s font scale to
scale.- Parameters:
scale – the font scale
- set_input_enabled(enabled: bool) None#
Enables or disables user input. When user input is disabled, the terminal’s child will not receive any key press, or mouse button press or motion events sent to it.
- Parameters:
enabled – whether to enable user input
- set_mouse_autohide(setting: bool) None#
Changes the value of the terminal’s mouse autohide setting. When autohiding is enabled, the mouse cursor will be hidden when the user presses a key and shown when the user moves the mouse. This setting can be read using
get_mouse_autohide().- Parameters:
setting – whether the mouse pointer should autohide
- set_pty(pty: Pty | None = None) None#
Sets
ptyas the PTY to use interminal. UseNoneto unset the PTY.- Parameters:
pty – a
Pty, orNone
- set_rewrap_on_resize(rewrap: bool) None#
Controls whether or not the terminal will rewrap its contents, including the scrollback history, whenever the terminal’s width changes.
Deprecated since version 0.58: Please do not use it in newly written code
- Parameters:
rewrap –
Trueif the terminal should rewrap on resize
- set_scroll_on_insert(scroll: bool) None#
Controls whether or not the terminal will forcibly scroll to the bottom of the viewable history when text is inserted, e.g. by a paste.
Added in version 0.76.
- Parameters:
scroll – whether the terminal should scroll on insert
- set_scroll_on_keystroke(scroll: bool) None#
Controls whether or not the terminal will forcibly scroll to the bottom of the viewable history when the user presses a key. Modifier keys do not trigger this behavior.
Added in version 0.52.
- Parameters:
scroll – whether the terminal should scroll on keystrokes
- set_scroll_on_output(scroll: bool) None#
Controls whether or not the terminal will forcibly scroll to the bottom of the viewable history when the new data is received from the child.
Added in version 0.52.
- Parameters:
scroll – whether the terminal should scroll on output
- set_scroll_unit_is_pixels(enable: bool) None#
Controls whether the terminal’s scroll unit is lines or pixels.
This function is rarely useful, except when the terminal is added to a
ScrolledWindow.Added in version 0.66.
- Parameters:
enable – whether to use pixels as scroll unit
- set_scrollback_lines(lines: int) None#
Sets the length of the scrollback buffer used by the terminal. The 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.
A negative value means “infinite scrollback”.
Using a large scrollback buffer (roughly 1M+ lines) may lead to performance degradation or exhaustion of system resources, and is therefore not recommended.
Note that this setting only affects the normal screen buffer. No scrollback is allowed on the alternate screen buffer.
- Parameters:
lines – the length of the history buffer
- set_size(columns: int, rows: int) None#
Attempts to change the terminal’s size in terms of rows and columns. If the attempt succeeds, the widget will resize itself to the proper size.
- Parameters:
columns – the desired number of columns
rows – the desired number of rows
- set_suppress_legacy_signals() None#
Suppress emissions of signals and property notifications that are deprecated.
Added in version 0.78.
- set_text_blink_mode(text_blink_mode: TextBlinkMode) None#
Controls whether or not the terminal will allow blinking text.
Added in version 0.52.
- Parameters:
text_blink_mode – the
TextBlinkModeto use
- set_word_char_exceptions(exceptions: str) None#
With this function you can provide a set of characters which will be considered parts of a word when doing word-wise selection, in addition to the default which only considers alphanumeric characters part of a word.
The characters in
exceptionsmust be non-alphanumeric, each character must occur only once, and ifexceptionscontains the character U+002D HYPHEN-MINUS, it must be at the start of the string.Use
Noneto reset the set of exception characters to the default.Added in version 0.40.
- Parameters:
exceptions – a string of ASCII punctuation characters, or
None
- set_xalign(align: Align) None#
Sets the horizontal alignment of
terminalwithin its allocation.- Note: %VTE_ALIGN_START_FILL is not supported, and will be treated
like
START.
Added in version 0.76.
- Parameters:
align – alignment value from
Align
- set_xfill(fill: bool) None#
Sets the horizontal fillment of
terminalwithin its allocation.- Note: %VTE_FILL_START_FILL is not supported, and will be treated
like %VTE_FILL_START.
Added in version 0.76.
- Parameters:
fill – fillment value from
VteFill
- set_yalign(align: Align) None#
Sets the vertical alignment of
terminalwithin its allocation.Added in version 0.76.
- Parameters:
align – alignment value from
Align
- set_yfill(fill: bool) None#
Sets the vertical fillment of
terminalwithin its allocation. Note that yfill is only supported with yalign set toSTART, and is ignored for all other yalign values.Added in version 0.76.
- Parameters:
fill – fillment value from
VteFill
- spawn_async(pty_flags: PtyFlags, working_directory: str | None, argv: list[str], envv: list[str] | None, spawn_flags: SpawnFlags, child_setup: Callable[[Any], None] | None, timeout: int, cancellable: Cancellable | None = None, callback: Callable[[Terminal, int, GError | None, Any], None] | None = None, user_data: Any = None) None#
A convenience function that wraps creating the
Ptyand spawning the child process on it. Likespawn_with_fds_async(), except that this function does not allow passing file descriptors to the child process. Seespawn_with_fds_async()for more information.Added in version 0.48.
- Parameters:
pty_flags – flags from
PtyFlagsworking_directory – the name of a directory the command should start in, or
Noneto use the current working directoryargv – child’s argument vector
envv – a list of environment variables to be added to the environment before starting the process, or
Nonespawn_flags – flags from
SpawnFlagschild_setup – an extra child setup function to run in the child just before exec(), or
Nonetimeout – a timeout value in ms, -1 for the default timeout, or G_MAXINT to wait indefinitely
cancellable – a
Cancellable, orNonecallback – a
TerminalSpawnAsyncCallback, orNoneuser_data – user data for
callback, orNone
- spawn_sync(pty_flags: PtyFlags, working_directory: str | None, argv: list[str], envv: list[str] | None, spawn_flags: SpawnFlags, child_setup: Callable[[Any], None] | None = None, child_setup_data: Any = None, cancellable: Cancellable | None = None) tuple[bool, int]#
Starts the specified command under a newly-allocated controlling pseudo-terminal. The
argvandenvvlists should beNone-terminated. The “TERM” environment variable is automatically set to a default value, but can be overridden fromenvv.pty_flagscontrols logging the session to the specified system log files.Note that %G_SPAWN_DO_NOT_REAP_CHILD will always be added to
spawn_flags.Note also that %G_SPAWN_STDOUT_TO_DEV_NULL, %G_SPAWN_STDERR_TO_DEV_NULL, and %G_SPAWN_CHILD_INHERITS_STDIN are not supported in
spawn_flags, since stdin, stdout and stderr of the child process will always be connected to the PTY.Note that all open file descriptors will be closed in the child. If you want to keep some file descriptor open for use in the child process, you need to use a child setup function that unsets the FD_CLOEXEC flag on that file descriptor.
See vte_pty_new(),
spawn_async()andwatch_child()for more information.Beginning with 0.52, sets PWD to
working_directoryin order to preserve symlink components. The caller should also make sure that symlinks were preserved while constructing the value ofworking_directory, e.g. by usingget_current_directory_uri(),get_current_dir()or get_current_dir_name().Deprecated since version 0.48: Use
spawn_async()instead.- Parameters:
pty_flags – flags from
PtyFlagsworking_directory – the name of a directory the command should start in, or
Noneto use the current working directoryargv – child’s argument vector
envv – a list of environment variables to be added to the environment before starting the process, or
Nonespawn_flags – flags from
SpawnFlagschild_setup – an extra child setup function to run in the child just before exec(), or
Nonechild_setup_data – user data for
child_setupcancellable – a
Cancellable, orNone
- spawn_with_fds_async(pty_flags: PtyFlags, working_directory: str | None, argv: list[str], envv: list[str] | None, fds: list[int] | None, map_fds: list[int] | None, spawn_flags: SpawnFlags, child_setup: Callable[[Any], None] | None, timeout: int, cancellable: Cancellable | None = None, callback: Callable[[Terminal, int, GError | None, Any], None] | None = None, user_data: Any = None) None#
A convenience function that wraps creating the
Ptyand spawning the child process on it. Seenew_sync(),spawn_with_fds_async(), andspawn_finish()for more information.When the operation is finished successfully,
callbackwill be called with the childPid, and aNoneError. The child PID will already be watched viawatch_child().When the operation fails,
callbackwill be called with a -1Pid, and a non-NoneErrorcontaining the error information.Note that %G_SPAWN_STDOUT_TO_DEV_NULL, %G_SPAWN_STDERR_TO_DEV_NULL, and %G_SPAWN_CHILD_INHERITS_STDIN are not supported in
spawn_flags, since stdin, stdout and stderr of the child process will always be connected to the PTY.If
fdsis notNone, the child process will map the file descriptors fromfdsaccording tomap_fds;n_map_fdsmust be less or equal ton_fds. This function will take ownership of the file descriptors infds; you must not use or close them after this call.Note that all open file descriptors apart from those mapped as above will be closed in the child. (If you want to keep some other file descriptor open for use in the child process, you need to use a child setup function that unsets the FD_CLOEXEC flag on that file descriptor manually.)
Beginning with 0.60, and on linux only, and unless
SPAWN_NO_SYSTEMD_SCOPEis passed inspawn_flags, the newly created child process will be moved to its own systemd user scope; and ifSPAWN_REQUIRE_SYSTEMD_SCOPEis passed, and creation of the systemd user scope fails, the whole spawn will fail. You can override the options used for the systemd user scope by providing a systemd override file for ‘vte-spawn-.scope’ unit. See man:systemd.unit(5) for further information.Note that if
terminalhas been destroyed before the operation is called,callbackwill be called with aNoneterminal; you must not do anything in the callback besides freeing any resources associated withuser_data, but taking care not to access the now-destroyedTerminal. Note that in this case, if spawning was successful, the child process will be aborted automatically.Beginning with 0.52, sets PWD to
working_directoryin order to preserve symlink components. The caller should also make sure that symlinks were preserved while constructing the value ofworking_directory, e.g. by usingget_current_directory_uri(),get_current_dir()or get_current_dir_name().Added in version 0.62.
- Parameters:
pty_flags – flags from
PtyFlagsworking_directory – the name of a directory the command should start in, or
Noneto use the current working directoryargv – child’s argument vector
envv – a list of environment variables to be added to the environment before starting the process, or
Nonefds – an array of file descriptors, or
Nonemap_fds – an array of integers, or
Nonespawn_flags – flags from
SpawnFlagschild_setup – an extra child setup function to run in the child just before exec(), or
Nonetimeout – a timeout value in ms, -1 for the default timeout, or G_MAXINT to wait indefinitely
cancellable – a
Cancellable, orNonecallback – a
TerminalSpawnAsyncCallback, orNoneuser_data – user data for
callback, orNone
- watch_child(child_pid: int) None#
Watches
child_pid. When the process exists, theTerminal::child-exited signal will be called with the child’s exit status.Prior to calling this function, a
Ptymust have been set interminalusingset_pty(). When the child exits, the terminal’sPtywill be set toNone.Note:
child_watch_add()orchild_watch_add_full()must not have been called forchild_pid, nor aSourcefor it been created withchild_watch_source_new().Note: when using the
spawn_async()family of functions, the %G_SPAWN_DO_NOT_REAP_CHILD flag MUST have been passed.- Parameters:
child_pid – a
Pid
- write_contents_sync(stream: OutputStream, flags: WriteFlags, cancellable: Cancellable | None = None) bool#
Write contents of the current contents of
terminal(including any scrollback history) tostreamaccording toflags.If
cancellableis notNone, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned inerror.This is a synchronous operation and will make the widget (and input processing) during the write operation, which may take a long time depending on scrollback history and
streamavailability for writing.- Parameters:
stream – a
OutputStreamto write toflags – a set of
WriteFlagscancellable – a
Cancellableobject, orNone
Properties#
- class Terminal
- props.allow_bold: bool#
The type of the None singleton.
Deprecated since version 0.60: There’s probably no reason for this feature to exist.
- props.backspace_binding: EraseBinding#
The type of the None singleton.
The type of the None singleton.
Added in version 0.76.
The type of the None singleton.
Added in version 0.76.
- props.current_directory_uri: str#
The type of the None singleton.
Deprecated since version 0.78: Use the
TERMPROP_CURRENT_DIRECTORY_URItermprop.
- props.current_file_uri: str#
The type of the None singleton.
Deprecated since version 0.78: Use the
TERMPROP_CURRENT_FILE_URItermprop.
- props.cursor_blink_mode: CursorBlinkMode#
The type of the None singleton.
- props.cursor_shape: CursorShape#
The type of the None singleton.
- props.delete_binding: EraseBinding#
The type of the None singleton.
- props.encoding: str#
The type of the None singleton.
Deprecated since version 0.54:
- Instead of using this, you should use a tool like
luit(1) when support for non-UTF-8 is required
- props.font_desc: FontDescription#
The type of the None singleton.
- props.font_options: FontOptions#
The type of the None singleton.
Added in version 0.74.
- props.icon_title: str#
The type of the None singleton.
Deprecated since version 0.54: This property is always
None.
- props.rewrap_on_resize: bool#
The type of the None singleton.
Deprecated since version 0.58: Please do not use it in newly written code
- props.text_blink_mode: TextBlinkMode#
The type of the None singleton.
Added in version 0.52.
- props.window_title: str#
The type of the None singleton.
Deprecated since version 0.78: Use the
TERMPROP_XTERM_TITLEtermprop.
Signals#
- class Terminal.signals
-
- char_size_changed(width: int, height: int) None#
The type of the None singleton.
- Parameters:
width – the new character cell width
height – the new character cell height
- child_exited(status: int) None#
The type of the None singleton.
- Parameters:
status – the child’s exit status
- commit(text: str, size: int) None#
The type of the None singleton.
- Parameters:
text – a string of text
size – the length of that string of text
- current_directory_uri_changed() None#
The type of the None singleton.
Deprecated since version 0.78:
- Use the
Terminal:termprop-changed signal for the
TERMPROP_CURRENT_DIRECTORY_URItermprop.
- Use the
- current_file_uri_changed() None#
The type of the None singleton.
Deprecated since version 0.78:
- Use the
Terminal:termprop-changed signal for the
TERMPROP_CURRENT_FILE_URItermprop.
- Use the
- deiconify_window() None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
- hyperlink_hover_uri_changed(uri: str, bbox: Rectangle) None#
The type of the None singleton.
Added in version 0.50.
- Parameters:
uri – the nonempty target URI under the mouse, or NULL
bbox – the bounding box of the hyperlink anchor text, or NULL
- icon_title_changed() None#
The type of the None singleton.
Deprecated since version 0.54: This signal is never emitted.
- iconify_window() None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
- lower_window() None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
- maximize_window() None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
- move_window(x: int, y: int) None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
- Parameters:
x – the terminal’s desired location, X coordinate
y – the terminal’s desired location, Y coordinate
- raise_window() None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
- refresh_window() None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
- resize_window(width: int, height: int) None#
The type of the None singleton.
- Parameters:
width – the desired number of columns
height – the desired number of rows
- restore_window() None#
The type of the None singleton.
Deprecated since version 0.60: Please do not use it in newly written code
The type of the None singleton.
- Parameters:
context – the context
- termprop_changed(name: str) None#
The type of the None singleton.
Added in version 0.78.
- Parameters:
name – the name of the changed property
- termprops_changed(props: list[int]) bool#
The type of the None singleton.
Added in version 0.78.
- Parameters:
props – an array of termprop IDs
- window_title_changed() None#
The type of the None singleton.
Deprecated since version 0.78:
- Use the
Terminal:termprop-changed signal for the
TERMPROP_XTERM_TITLEtermprop.
- Use the
Virtual Methods#
- class Terminal
-
- do_char_size_changed(char_width: int, char_height: int) None#
The type of the None singleton.
- Parameters:
char_width
char_height
- do_copy_clipboard() None#
Places the selected text in the terminal in the
GDK_SELECTION_CLIPBOARDselection.Deprecated since version 0.50:
- Use
copy_clipboard_format()withTEXT instead.
- Use
- do_paste_clipboard() None#
Sends the contents of the
GDK_SELECTION_CLIPBOARDselection to the terminal’s child. It’s called on paste menu item, or when user presses Shift+Insert.
- do_resize_window(width: int, height: int) None#
The type of the None singleton.
- Parameters:
width
height
- do_setup_context_menu(context: EventContext) None#
The type of the None singleton.
- Parameters:
context
Fields#
- class Terminal
- widget#