1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module vte.Terminal; 26 27 private import gdk.Cursor; 28 private import gdk.Event; 29 private import gdk.RGBA; 30 private import gio.Cancellable; 31 private import gio.OutputStream; 32 private import glib.ArrayG; 33 private import glib.ConstructionException; 34 private import glib.ErrorG; 35 private import glib.GException; 36 private import glib.MemorySlice; 37 private import glib.Regex; 38 private import glib.Str; 39 private import gobject.ObjectG; 40 private import gobject.Signals; 41 private import gtk.BuildableIF; 42 private import gtk.BuildableT; 43 private import gtk.ScrollableIF; 44 private import gtk.ScrollableT; 45 private import gtk.Widget; 46 private import gtk.Window; 47 private import pango.PgFontDescription; 48 private import std.algorithm; 49 private import vte.Pty; 50 private import vte.Regex : RegexVte = Regex; 51 private import vte.c.functions; 52 public import vte.c.types; 53 public import vtec.vtetypes; 54 55 56 /** */ 57 public class Terminal : Widget, ScrollableIF 58 { 59 /** the main Gtk struct */ 60 protected VteTerminal* vteTerminal; 61 62 /** Get the main Gtk struct */ 63 public VteTerminal* getTerminalStruct(bool transferOwnership = false) 64 { 65 if (transferOwnership) 66 ownedRef = false; 67 return vteTerminal; 68 } 69 70 /** the main Gtk struct as a void* */ 71 protected override void* getStruct() 72 { 73 return cast(void*)vteTerminal; 74 } 75 76 protected override void setStruct(GObject* obj) 77 { 78 vteTerminal = cast(VteTerminal*)obj; 79 super.setStruct(obj); 80 } 81 82 /** 83 * Sets our main struct and passes it to the parent class. 84 */ 85 public this (VteTerminal* vteTerminal, bool ownedRef = false) 86 { 87 this.vteTerminal = vteTerminal; 88 super(cast(GtkWidget*)vteTerminal, ownedRef); 89 } 90 91 // add the Scrollable capabilities 92 mixin ScrollableT!(VteTerminal); 93 94 95 /** */ 96 public static GType getType() 97 { 98 return vte_terminal_get_type(); 99 } 100 101 /** 102 * Creates a new terminal widget. 103 * 104 * Returns: a new #VteTerminal object 105 * 106 * Throws: ConstructionException GTK+ fails to create the object. 107 */ 108 public this() 109 { 110 auto p = vte_terminal_new(); 111 112 if(p is null) 113 { 114 throw new ConstructionException("null returned by new"); 115 } 116 117 this(cast(VteTerminal*) p); 118 } 119 120 /** 121 * Places the selected text in the terminal in the #GDK_SELECTION_CLIPBOARD 122 * selection. 123 * 124 * Deprecated: Use vte_terminal_copy_clipboard_format() with %VTE_FORMAT_TEXT 125 * instead. 126 */ 127 public void copyClipboard() 128 { 129 vte_terminal_copy_clipboard(vteTerminal); 130 } 131 132 /** 133 * Places the selected text in the terminal in the #GDK_SELECTION_CLIPBOARD 134 * selection in the form specified by @format. 135 * 136 * For all formats, the selection data (see #GtkSelectionData) will include the 137 * text targets (see gtk_target_list_add_text_targets() and 138 * gtk_selection_data_targets_includes_text()). For %VTE_FORMAT_HTML, 139 * the selection will also include the "text/html" target, which when requested, 140 * returns the HTML data in UTF-16 with a U+FEFF BYTE ORDER MARK character at 141 * the start. 142 * 143 * Params: 144 * format = a #VteFormat 145 * 146 * Since: 0.50 147 */ 148 public void copyClipboardFormat(VteFormat format) 149 { 150 vte_terminal_copy_clipboard_format(vteTerminal, format); 151 } 152 153 /** 154 * Places the selected text in the terminal in the #GDK_SELECTION_PRIMARY 155 * selection. 156 */ 157 public void copyPrimary() 158 { 159 vte_terminal_copy_primary(vteTerminal); 160 } 161 162 /** 163 * This function does nothing. 164 * 165 * Deprecated: Use vte_terminal_event_check_regex_simple() instead. 166 * 167 * Params: 168 * event = a #GdkEvent 169 * regexes = an array of #GRegex 170 * matchFlags = the #GRegexMatchFlags to use when matching the regexes 171 * matches = a location to store the matches 172 * 173 * Returns: %FALSE 174 * 175 * Since: 0.44 176 */ 177 public bool eventCheckGregexSimple(Event event, Regex[] regexes, GRegexMatchFlags matchFlags, string[] matches) 178 { 179 GRegex*[] regexesArray = new GRegex*[regexes.length]; 180 for ( int i = 0; i < regexes.length; i++ ) 181 { 182 regexesArray[i] = regexes[i].getRegexStruct(); 183 } 184 185 return vte_terminal_event_check_gregex_simple(vteTerminal, (event is null) ? null : event.getEventStruct(), regexesArray.ptr, cast(size_t)matches.length, matchFlags, Str.toStringzArray(matches)) != 0; 186 } 187 188 /** 189 * Checks each regex in @regexes if the text in and around the position of 190 * the event matches the regular expressions. If a match exists, the matched 191 * text is stored in @matches at the position of the regex in @regexes; otherwise 192 * %NULL is stored there. 193 * 194 * Params: 195 * event = a #GdkEvent 196 * regexes = an array of #VteRegex 197 * matchFlags = PCRE2 match flags, or 0 198 * matches = a location to store the matches 199 * 200 * Returns: %TRUE iff any of the regexes produced a match 201 * 202 * Since: 0.46 203 */ 204 public bool eventCheckRegexSimple(Event event, RegexVte[] regexes, uint matchFlags, string[] matches) 205 { 206 VteRegex*[] regexesArray = new VteRegex*[regexes.length]; 207 for ( int i = 0; i < regexes.length; i++ ) 208 { 209 regexesArray[i] = regexes[i].getRegexStruct(); 210 } 211 212 return vte_terminal_event_check_regex_simple(vteTerminal, (event is null) ? null : event.getEventStruct(), regexesArray.ptr, cast(size_t)matches.length, matchFlags, Str.toStringzArray(matches)) != 0; 213 } 214 215 /** 216 * Interprets @data as if it were data received from a child process. This 217 * can either be used to drive the terminal without a child process, or just 218 * to mess with your users. 219 * 220 * Params: 221 * data = a string in the terminal's current encoding 222 */ 223 public void feed(string data) 224 { 225 vte_terminal_feed(vteTerminal, Str.toStringz(data), cast(ptrdiff_t)data.length); 226 } 227 228 /** 229 * Sends a block of UTF-8 text to the child as if it were entered by the user 230 * at the keyboard. 231 * 232 * Params: 233 * text = data to send to the child 234 * length = length of @text in bytes, or -1 if @text is NUL-terminated 235 */ 236 public void feedChild(string text, ptrdiff_t length) 237 { 238 vte_terminal_feed_child(vteTerminal, Str.toStringz(text), length); 239 } 240 241 /** 242 * Sends a block of binary data to the child. 243 * 244 * Params: 245 * data = data to send to the child 246 */ 247 public void feedChildBinary(ubyte[] data) 248 { 249 vte_terminal_feed_child_binary(vteTerminal, data.ptr, cast(size_t)data.length); 250 } 251 252 /** 253 * Checks whether or not the terminal will attempt to draw bold text by 254 * repainting text with a one-pixel offset. 255 * 256 * Returns: %TRUE if bolding is enabled, %FALSE if not 257 */ 258 public bool getAllowBold() 259 { 260 return vte_terminal_get_allow_bold(vteTerminal) != 0; 261 } 262 263 /** 264 * Checks whether or not hyperlinks (OSC 8 escape sequence) are allowed. 265 * 266 * Returns: %TRUE if hyperlinks are enabled, %FALSE if not 267 * 268 * Since: 0.50 269 */ 270 public bool getAllowHyperlink() 271 { 272 return vte_terminal_get_allow_hyperlink(vteTerminal) != 0; 273 } 274 275 /** 276 * Checks whether or not the terminal will beep when the child outputs the 277 * "bl" sequence. 278 * 279 * Returns: %TRUE if audible bell is enabled, %FALSE if not 280 */ 281 public bool getAudibleBell() 282 { 283 return vte_terminal_get_audible_bell(vteTerminal) != 0; 284 } 285 286 /** 287 * Returns: the height of a character cell 288 */ 289 public glong getCharHeight() 290 { 291 return vte_terminal_get_char_height(vteTerminal); 292 } 293 294 /** 295 * Returns: the width of a character cell 296 */ 297 public glong getCharWidth() 298 { 299 return vte_terminal_get_char_width(vteTerminal); 300 } 301 302 /** 303 * Returns whether ambiguous-width characters are narrow or wide when using 304 * the UTF-8 encoding (vte_terminal_set_encoding()). 305 * 306 * Returns: 1 if ambiguous-width characters are narrow, or 2 if they are wide 307 */ 308 public int getCjkAmbiguousWidth() 309 { 310 return vte_terminal_get_cjk_ambiguous_width(vteTerminal); 311 } 312 313 /** 314 * Returns: the number of columns 315 */ 316 public glong getColumnCount() 317 { 318 return vte_terminal_get_column_count(vteTerminal); 319 } 320 321 /** 322 * Returns: the URI of the current directory of the 323 * process running in the terminal, or %NULL 324 */ 325 public string getCurrentDirectoryUri() 326 { 327 return Str.toString(vte_terminal_get_current_directory_uri(vteTerminal)); 328 } 329 330 /** 331 * Returns: the URI of the current file the 332 * process running in the terminal is operating on, or %NULL if 333 * not set 334 */ 335 public string getCurrentFileUri() 336 { 337 return Str.toString(vte_terminal_get_current_file_uri(vteTerminal)); 338 } 339 340 /** 341 * Returns the currently set cursor blink mode. 342 * 343 * Returns: cursor blink mode. 344 */ 345 public VteCursorBlinkMode getCursorBlinkMode() 346 { 347 return vte_terminal_get_cursor_blink_mode(vteTerminal); 348 } 349 350 /** 351 * Reads the location of the insertion cursor and returns it. The row 352 * coordinate is absolute. 353 * 354 * Params: 355 * column = a location to store the column, or %NULL 356 * row = a location to store the row, or %NULL 357 */ 358 public void getCursorPosition(out glong column, out glong row) 359 { 360 vte_terminal_get_cursor_position(vteTerminal, &column, &row); 361 } 362 363 /** 364 * Returns the currently set cursor shape. 365 * 366 * Returns: cursor shape. 367 */ 368 public VteCursorShape getCursorShape() 369 { 370 return vte_terminal_get_cursor_shape(vteTerminal); 371 } 372 373 /** 374 * Determines the name of the encoding in which the terminal expects data to be 375 * encoded. 376 * 377 * Returns: the current encoding for the terminal 378 */ 379 public string getEncoding() 380 { 381 return Str.toString(vte_terminal_get_encoding(vteTerminal)); 382 } 383 384 /** 385 * Queries the terminal for information about the fonts which will be 386 * used to draw text in the terminal. The actual font takes the font scale 387 * into account, this is not reflected in the return value, the unscaled 388 * font is returned. 389 * 390 * Returns: a #PangoFontDescription describing the font the 391 * terminal uses to render text at the default font scale of 1.0. 392 */ 393 public PgFontDescription getFont() 394 { 395 auto p = vte_terminal_get_font(vteTerminal); 396 397 if(p is null) 398 { 399 return null; 400 } 401 402 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 403 } 404 405 /** 406 * Returns: the terminal's font scale 407 */ 408 public double getFontScale() 409 { 410 return vte_terminal_get_font_scale(vteTerminal); 411 } 412 413 /** 414 * Fills in some @hints from @terminal's geometry. The hints 415 * filled are those covered by the %GDK_HINT_RESIZE_INC, 416 * %GDK_HINT_MIN_SIZE and %GDK_HINT_BASE_SIZE flags. 417 * 418 * See gtk_window_set_geometry_hints() for more information. 419 * 420 * @terminal must be realized (see gtk_widget_get_realized()). 421 * 422 * Params: 423 * hints = a #GdkGeometry to fill in 424 * minRows = the minimum number of rows to request 425 * minColumns = the minimum number of columns to request 426 */ 427 public void getGeometryHints(out GdkGeometry hints, int minRows, int minColumns) 428 { 429 vte_terminal_get_geometry_hints(vteTerminal, &hints, minRows, minColumns); 430 } 431 432 /** 433 * Checks if the terminal currently contains selected text. Note that this 434 * is different from determining if the terminal is the owner of any 435 * #GtkClipboard items. 436 * 437 * Returns: %TRUE if part of the text in the terminal is selected. 438 */ 439 public bool getHasSelection() 440 { 441 return vte_terminal_get_has_selection(vteTerminal) != 0; 442 } 443 444 /** 445 * Returns: the icon title 446 */ 447 public string getIconTitle() 448 { 449 return Str.toString(vte_terminal_get_icon_title(vteTerminal)); 450 } 451 452 /** 453 * Returns whether the terminal allow user input. 454 */ 455 public bool getInputEnabled() 456 { 457 return vte_terminal_get_input_enabled(vteTerminal) != 0; 458 } 459 460 /** 461 * Determines the value of the terminal's mouse autohide setting. When 462 * autohiding is enabled, the mouse cursor will be hidden when the user presses 463 * a key and shown when the user moves the mouse. This setting can be changed 464 * using vte_terminal_set_mouse_autohide(). 465 * 466 * Returns: %TRUE if autohiding is enabled, %FALSE if not 467 */ 468 public bool getMouseAutohide() 469 { 470 return vte_terminal_get_mouse_autohide(vteTerminal) != 0; 471 } 472 473 /** 474 * Returns the #VtePty of @terminal. 475 * 476 * Returns: a #VtePty, or %NULL 477 */ 478 public Pty getPty() 479 { 480 auto p = vte_terminal_get_pty(vteTerminal); 481 482 if(p is null) 483 { 484 return null; 485 } 486 487 return ObjectG.getDObject!(Pty)(cast(VtePty*) p); 488 } 489 490 /** 491 * Checks whether or not the terminal will rewrap its contents upon resize. 492 * 493 * Returns: %TRUE if rewrapping is enabled, %FALSE if not 494 */ 495 public bool getRewrapOnResize() 496 { 497 return vte_terminal_get_rewrap_on_resize(vteTerminal) != 0; 498 } 499 500 /** 501 * Returns: the number of rows 502 */ 503 public glong getRowCount() 504 { 505 return vte_terminal_get_row_count(vteTerminal); 506 } 507 508 /** 509 * Extracts a view of the visible part of the terminal. If @is_selected is not 510 * %NULL, characters will only be read if @is_selected returns %TRUE after being 511 * passed the column and row, respectively. A #VteCharAttributes structure 512 * is added to @attributes for each byte added to the returned string detailing 513 * the character's position, colors, and other characteristics. 514 * 515 * Params: 516 * isSelected = a #VteSelectionFunc callback 517 * userData = user data to be passed to the callback 518 * attributes = location for storing text attributes 519 * 520 * Returns: a newly allocated text string, or %NULL. 521 */ 522 public string getText(VteSelectionFunc isSelected, void* userData, out ArrayG attributes) 523 { 524 GArray* outattributes = sliceNew!GArray(); 525 526 auto retStr = vte_terminal_get_text(vteTerminal, isSelected, userData, outattributes); 527 528 attributes = new ArrayG(outattributes, true); 529 530 scope(exit) Str.freeString(retStr); 531 return Str.toString(retStr); 532 } 533 534 /** 535 * Extracts a view of the visible part of the terminal. If @is_selected is not 536 * %NULL, characters will only be read if @is_selected returns %TRUE after being 537 * passed the column and row, respectively. A #VteCharAttributes structure 538 * is added to @attributes for each byte added to the returned string detailing 539 * the character's position, colors, and other characteristics. This function 540 * differs from vte_terminal_get_text() in that trailing spaces at the end of 541 * lines are included. 542 * 543 * Params: 544 * isSelected = a #VteSelectionFunc callback 545 * userData = user data to be passed to the callback 546 * attributes = location for storing text attributes 547 * 548 * Returns: a newly allocated text string, or %NULL. 549 */ 550 public string getTextIncludeTrailingSpaces(VteSelectionFunc isSelected, void* userData, out ArrayG attributes) 551 { 552 GArray* outattributes = sliceNew!GArray(); 553 554 auto retStr = vte_terminal_get_text_include_trailing_spaces(vteTerminal, isSelected, userData, outattributes); 555 556 attributes = new ArrayG(outattributes, true); 557 558 scope(exit) Str.freeString(retStr); 559 return Str.toString(retStr); 560 } 561 562 /** 563 * Extracts a view of the visible part of the terminal. If @is_selected is not 564 * %NULL, characters will only be read if @is_selected returns %TRUE after being 565 * passed the column and row, respectively. A #VteCharAttributes structure 566 * is added to @attributes for each byte added to the returned string detailing 567 * the character's position, colors, and other characteristics. The 568 * entire scrollback buffer is scanned, so it is possible to read the entire 569 * contents of the buffer using this function. 570 * 571 * Params: 572 * startRow = first row to search for data 573 * startCol = first column to search for data 574 * endRow = last row to search for data 575 * endCol = last column to search for data 576 * isSelected = a #VteSelectionFunc callback 577 * userData = user data to be passed to the callback 578 * attributes = location for storing text attributes 579 * 580 * Returns: a newly allocated text string, or %NULL. 581 */ 582 public string getTextRange(glong startRow, glong startCol, glong endRow, glong endCol, VteSelectionFunc isSelected, void* userData, out ArrayG attributes) 583 { 584 GArray* outattributes = sliceNew!GArray(); 585 586 auto retStr = vte_terminal_get_text_range(vteTerminal, startRow, startCol, endRow, endCol, isSelected, userData, outattributes); 587 588 attributes = new ArrayG(outattributes, true); 589 590 scope(exit) Str.freeString(retStr); 591 return Str.toString(retStr); 592 } 593 594 /** 595 * Returns: the window title 596 */ 597 public string getWindowTitle() 598 { 599 return Str.toString(vte_terminal_get_window_title(vteTerminal)); 600 } 601 602 /** 603 * Returns the set of characters which will be considered parts of a word 604 * when doing word-wise selection, in addition to the default which only 605 * considers alphanumeric characters part of a word. 606 * 607 * If %NULL, a built-in set is used. 608 * 609 * Returns: a string, or %NULL 610 * 611 * Since: 0.40 612 */ 613 public string getWordCharExceptions() 614 { 615 return Str.toString(vte_terminal_get_word_char_exceptions(vteTerminal)); 616 } 617 618 /** 619 * Returns a nonempty string: the target of the explicit hyperlink (printed using the OSC 8 620 * escape sequence) at the position of the event, or %NULL. 621 * 622 * Proper use of the escape sequence should result in URI-encoded URIs with a proper scheme 623 * like "http://", "https://", "file://", "mailto:" etc. This is, however, not enforced by VTE. 624 * The caller must tolerate the returned string potentially not being a valid URI. 625 * 626 * Params: 627 * event = a #GdkEvent 628 * 629 * Returns: a newly allocated string containing the target of the hyperlink 630 * 631 * Since: 0.50 632 */ 633 public string hyperlinkCheckEvent(Event event) 634 { 635 auto retStr = vte_terminal_hyperlink_check_event(vteTerminal, (event is null) ? null : event.getEventStruct()); 636 637 scope(exit) Str.freeString(retStr); 638 return Str.toString(retStr); 639 } 640 641 /** 642 * Adds the regular expression @regex to the list of matching expressions. When the 643 * user moves the mouse cursor over a section of displayed text which matches 644 * this expression, the text will be highlighted. 645 * 646 * Deprecated: Use vte_terminal_match_add_regex() or vte_terminal_match_add_regex_full() instead. 647 * 648 * Params: 649 * gregex = a #GRegex 650 * gflags = the #GRegexMatchFlags to use when matching the regex 651 * 652 * Returns: an integer associated with this expression, or -1 if @gregex could not be 653 * transformed into a #VteRegex or @gflags were incompatible 654 */ 655 public int matchAddGregex(Regex gregex, GRegexMatchFlags gflags) 656 { 657 return vte_terminal_match_add_gregex(vteTerminal, (gregex is null) ? null : gregex.getRegexStruct(), gflags); 658 } 659 660 /** 661 * Adds the regular expression @regex to the list of matching expressions. When the 662 * user moves the mouse cursor over a section of displayed text which matches 663 * this expression, the text will be highlighted. 664 * 665 * Params: 666 * regex = a #VteRegex 667 * flags = PCRE2 match flags, or 0 668 * 669 * Returns: an integer associated with this expression 670 * 671 * Since: 0.46 672 */ 673 public int matchAddRegex(RegexVte regex, uint flags) 674 { 675 return vte_terminal_match_add_regex(vteTerminal, (regex is null) ? null : regex.getRegexStruct(), flags); 676 } 677 678 /** 679 * Checks if the text in and around the specified position matches any of the 680 * regular expressions previously set using vte_terminal_match_add(). If a 681 * match exists, the text string is returned and if @tag is not %NULL, the number 682 * associated with the matched regular expression will be stored in @tag. 683 * 684 * If more than one regular expression has been set with 685 * vte_terminal_match_add(), then expressions are checked in the order in 686 * which they were added. 687 * 688 * Deprecated: Use vte_terminal_match_check_event() instead. 689 * 690 * Params: 691 * column = the text column 692 * row = the text row 693 * tag = a location to store the tag, or %NULL 694 * 695 * Returns: a newly allocated string which matches one of the previously 696 * set regular expressions 697 */ 698 public string matchCheck(glong column, glong row, out int tag) 699 { 700 auto retStr = vte_terminal_match_check(vteTerminal, column, row, &tag); 701 702 scope(exit) Str.freeString(retStr); 703 return Str.toString(retStr); 704 } 705 706 /** 707 * Checks if the text in and around the position of the event matches any of the 708 * regular expressions previously set using vte_terminal_match_add(). If a 709 * match exists, the text string is returned and if @tag is not %NULL, the number 710 * associated with the matched regular expression will be stored in @tag. 711 * 712 * If more than one regular expression has been set with 713 * vte_terminal_match_add(), then expressions are checked in the order in 714 * which they were added. 715 * 716 * Params: 717 * event = a #GdkEvent 718 * tag = a location to store the tag, or %NULL 719 * 720 * Returns: a newly allocated string which matches one of the previously 721 * set regular expressions 722 */ 723 public string matchCheckEvent(Event event, out int tag) 724 { 725 auto retStr = vte_terminal_match_check_event(vteTerminal, (event is null) ? null : event.getEventStruct(), &tag); 726 727 scope(exit) Str.freeString(retStr); 728 return Str.toString(retStr); 729 } 730 731 /** 732 * Removes the regular expression which is associated with the given @tag from 733 * the list of expressions which the terminal will highlight when the user 734 * moves the mouse cursor over matching text. 735 * 736 * Params: 737 * tag = the tag of the regex to remove 738 */ 739 public void matchRemove(int tag) 740 { 741 vte_terminal_match_remove(vteTerminal, tag); 742 } 743 744 /** 745 * Clears the list of regular expressions the terminal uses to highlight text 746 * when the user moves the mouse cursor. 747 */ 748 public void matchRemoveAll() 749 { 750 vte_terminal_match_remove_all(vteTerminal); 751 } 752 753 /** 754 * Sets which cursor the terminal will use if the pointer is over the pattern 755 * specified by @tag. The terminal keeps a reference to @cursor. 756 * 757 * Deprecated: Use vte_terminal_match_set_cursor_type() or vte_terminal_match_set_cursor_named() instead. 758 * 759 * Params: 760 * tag = the tag of the regex which should use the specified cursor 761 * cursor = the #GdkCursor which the terminal should use when the pattern is 762 * highlighted, or %NULL to use the standard cursor 763 */ 764 public void matchSetCursor(int tag, Cursor cursor) 765 { 766 vte_terminal_match_set_cursor(vteTerminal, tag, (cursor is null) ? null : cursor.getCursorStruct()); 767 } 768 769 /** 770 * Sets which cursor the terminal will use if the pointer is over the pattern 771 * specified by @tag. 772 * 773 * Params: 774 * tag = the tag of the regex which should use the specified cursor 775 * cursorName = the name of the cursor 776 */ 777 public void matchSetCursorName(int tag, string cursorName) 778 { 779 vte_terminal_match_set_cursor_name(vteTerminal, tag, Str.toStringz(cursorName)); 780 } 781 782 /** 783 * Sets which cursor the terminal will use if the pointer is over the pattern 784 * specified by @tag. 785 * 786 * Params: 787 * tag = the tag of the regex which should use the specified cursor 788 * cursorType = a #GdkCursorType 789 */ 790 public void matchSetCursorType(int tag, GdkCursorType cursorType) 791 { 792 vte_terminal_match_set_cursor_type(vteTerminal, tag, cursorType); 793 } 794 795 /** 796 * Sends the contents of the #GDK_SELECTION_CLIPBOARD selection to the 797 * terminal's child. If necessary, the data is converted from UTF-8 to the 798 * terminal's current encoding. It's called on paste menu item, or when 799 * user presses Shift+Insert. 800 */ 801 public void pasteClipboard() 802 { 803 vte_terminal_paste_clipboard(vteTerminal); 804 } 805 806 /** 807 * Sends the contents of the #GDK_SELECTION_PRIMARY selection to the terminal's 808 * child. If necessary, the data is converted from UTF-8 to the terminal's 809 * current encoding. The terminal will call also paste the 810 * #GDK_SELECTION_PRIMARY selection when the user clicks with the the second 811 * mouse button. 812 */ 813 public void pastePrimary() 814 { 815 vte_terminal_paste_primary(vteTerminal); 816 } 817 818 /** 819 * Creates a new #VtePty, and sets the emulation property 820 * from #VteTerminal:emulation. 821 * 822 * See vte_pty_new() for more information. 823 * 824 * Params: 825 * flags = flags from #VtePtyFlags 826 * cancellable = a #GCancellable, or %NULL 827 * 828 * Returns: a new #VtePty 829 * 830 * Throws: GException on failure. 831 */ 832 public Pty ptyNewSync(VtePtyFlags flags, Cancellable cancellable) 833 { 834 GError* err = null; 835 836 auto p = vte_terminal_pty_new_sync(vteTerminal, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 837 838 if (err !is null) 839 { 840 throw new GException( new ErrorG(err) ); 841 } 842 843 if(p is null) 844 { 845 return null; 846 } 847 848 return ObjectG.getDObject!(Pty)(cast(VtePty*) p, true); 849 } 850 851 /** 852 * Resets as much of the terminal's internal state as possible, discarding any 853 * unprocessed input data, resetting character attributes, cursor state, 854 * national character set state, status line, terminal modes (insert/delete), 855 * selection state, and encoding. 856 * 857 * Params: 858 * clearTabstops = whether to reset tabstops 859 * clearHistory = whether to empty the terminal's scrollback buffer 860 */ 861 public void reset(bool clearTabstops, bool clearHistory) 862 { 863 vte_terminal_reset(vteTerminal, clearTabstops, clearHistory); 864 } 865 866 /** 867 * Searches the next string matching the search regex set with 868 * vte_terminal_search_set_regex(). 869 * 870 * Returns: %TRUE if a match was found 871 */ 872 public bool searchFindNext() 873 { 874 return vte_terminal_search_find_next(vteTerminal) != 0; 875 } 876 877 /** 878 * Searches the previous string matching the search regex set with 879 * vte_terminal_search_set_regex(). 880 * 881 * Returns: %TRUE if a match was found 882 */ 883 public bool searchFindPrevious() 884 { 885 return vte_terminal_search_find_previous(vteTerminal) != 0; 886 } 887 888 /** 889 * 890 * 891 * Deprecated: use vte_terminal_search_get_regex() instead. 892 * 893 * Returns: %NULL 894 */ 895 public Regex searchGetGregex() 896 { 897 auto p = vte_terminal_search_get_gregex(vteTerminal); 898 899 if(p is null) 900 { 901 return null; 902 } 903 904 return new Regex(cast(GRegex*) p); 905 } 906 907 /** 908 * Returns: the search #VteRegex regex set in @terminal, or %NULL 909 * 910 * Since: 0.46 911 */ 912 public RegexVte searchGetRegex() 913 { 914 auto p = vte_terminal_search_get_regex(vteTerminal); 915 916 if(p is null) 917 { 918 return null; 919 } 920 921 return ObjectG.getDObject!(RegexVte)(cast(VteRegex*) p); 922 } 923 924 /** 925 * Returns: whether searching will wrap around 926 */ 927 public bool searchGetWrapAround() 928 { 929 return vte_terminal_search_get_wrap_around(vteTerminal) != 0; 930 } 931 932 /** 933 * Sets the #GRegex regex to search for. Unsets the search regex when passed %NULL. 934 * 935 * Deprecated: use vte_terminal_search_set_regex() instead. 936 * 937 * Params: 938 * gregex = a #GRegex, or %NULL 939 * gflags = flags from #GRegexMatchFlags 940 */ 941 public void searchSetGregex(Regex gregex, GRegexMatchFlags gflags) 942 { 943 vte_terminal_search_set_gregex(vteTerminal, (gregex is null) ? null : gregex.getRegexStruct(), gflags); 944 } 945 946 /** 947 * Sets the regex to search for. Unsets the search regex when passed %NULL. 948 * 949 * Params: 950 * regex = a #VteRegex, or %NULL 951 * flags = PCRE2 match flags, or 0 952 * 953 * Since: 0.46 954 */ 955 public void searchSetRegex(RegexVte regex, uint flags) 956 { 957 vte_terminal_search_set_regex(vteTerminal, (regex is null) ? null : regex.getRegexStruct(), flags); 958 } 959 960 /** 961 * Sets whether search should wrap around to the beginning of the 962 * terminal content when reaching its end. 963 * 964 * Params: 965 * wrapAround = whether search should wrap 966 */ 967 public void searchSetWrapAround(bool wrapAround) 968 { 969 vte_terminal_search_set_wrap_around(vteTerminal, wrapAround); 970 } 971 972 /** 973 * Selects all text within the terminal (including the scrollback buffer). 974 */ 975 public void selectAll() 976 { 977 vte_terminal_select_all(vteTerminal); 978 } 979 980 /** 981 * Controls whether or not the terminal will attempt to draw bold text, 982 * either by using a bold font variant or by repainting text with a different 983 * offset. 984 * 985 * Params: 986 * allowBold = %TRUE if the terminal should attempt to draw bold text 987 */ 988 public void setAllowBold(bool allowBold) 989 { 990 vte_terminal_set_allow_bold(vteTerminal, allowBold); 991 } 992 993 /** 994 * Controls whether or not hyperlinks (OSC 8 escape sequence) are allowed. 995 * 996 * Params: 997 * allowHyperlink = %TRUE if the terminal should allow hyperlinks 998 * 999 * Since: 0.50 1000 */ 1001 public void setAllowHyperlink(bool allowHyperlink) 1002 { 1003 vte_terminal_set_allow_hyperlink(vteTerminal, allowHyperlink); 1004 } 1005 1006 /** 1007 * Controls whether or not the terminal will beep when the child outputs the 1008 * "bl" sequence. 1009 * 1010 * Params: 1011 * isAudible = %TRUE if the terminal should beep 1012 */ 1013 public void setAudibleBell(bool isAudible) 1014 { 1015 vte_terminal_set_audible_bell(vteTerminal, isAudible); 1016 } 1017 1018 /** 1019 * Modifies the terminal's backspace key binding, which controls what 1020 * string or control sequence the terminal sends to its child when the user 1021 * presses the backspace key. 1022 * 1023 * Params: 1024 * binding = a #VteEraseBinding for the backspace key 1025 */ 1026 public void setBackspaceBinding(VteEraseBinding binding) 1027 { 1028 vte_terminal_set_backspace_binding(vteTerminal, binding); 1029 } 1030 1031 /** 1032 * This setting controls whether ambiguous-width characters are narrow or wide 1033 * when using the UTF-8 encoding (vte_terminal_set_encoding()). In all other encodings, 1034 * the width of ambiguous-width characters is fixed. 1035 * 1036 * Params: 1037 * width = either 1 (narrow) or 2 (wide) 1038 */ 1039 public void setCjkAmbiguousWidth(int width) 1040 { 1041 vte_terminal_set_cjk_ambiguous_width(vteTerminal, width); 1042 } 1043 1044 /** 1045 * Sets the background color for text which does not have a specific background 1046 * color assigned. Only has effect when no background image is set and when 1047 * the terminal is not transparent. 1048 * 1049 * Params: 1050 * background = the new background color 1051 */ 1052 public void setColorBackground(RGBA background) 1053 { 1054 vte_terminal_set_color_background(vteTerminal, (background is null) ? null : background.getRGBAStruct()); 1055 } 1056 1057 /** 1058 * Sets the color used to draw bold text in the default foreground color. 1059 * If @bold is %NULL then the default color is used. 1060 * 1061 * Params: 1062 * bold = the new bold color or %NULL 1063 */ 1064 public void setColorBold(RGBA bold) 1065 { 1066 vte_terminal_set_color_bold(vteTerminal, (bold is null) ? null : bold.getRGBAStruct()); 1067 } 1068 1069 /** 1070 * Sets the background color for text which is under the cursor. If %NULL, text 1071 * under the cursor will be drawn with foreground and background colors 1072 * reversed. 1073 * 1074 * Params: 1075 * cursorBackground = the new color to use for the text cursor, or %NULL 1076 */ 1077 public void setColorCursor(RGBA cursorBackground) 1078 { 1079 vte_terminal_set_color_cursor(vteTerminal, (cursorBackground is null) ? null : cursorBackground.getRGBAStruct()); 1080 } 1081 1082 /** 1083 * Sets the foreground color for text which is under the cursor. If %NULL, text 1084 * under the cursor will be drawn with foreground and background colors 1085 * reversed. 1086 * 1087 * Params: 1088 * cursorForeground = the new color to use for the text cursor, or %NULL 1089 * 1090 * Since: 0.44 1091 */ 1092 public void setColorCursorForeground(RGBA cursorForeground) 1093 { 1094 vte_terminal_set_color_cursor_foreground(vteTerminal, (cursorForeground is null) ? null : cursorForeground.getRGBAStruct()); 1095 } 1096 1097 /** 1098 * Sets the foreground color used to draw normal text. 1099 * 1100 * Params: 1101 * foreground = the new foreground color 1102 */ 1103 public void setColorForeground(RGBA foreground) 1104 { 1105 vte_terminal_set_color_foreground(vteTerminal, (foreground is null) ? null : foreground.getRGBAStruct()); 1106 } 1107 1108 /** 1109 * Sets the background color for text which is highlighted. If %NULL, 1110 * it is unset. If neither highlight background nor highlight foreground are set, 1111 * highlighted text (which is usually highlighted because it is selected) will 1112 * be drawn with foreground and background colors reversed. 1113 * 1114 * Params: 1115 * highlightBackground = the new color to use for highlighted text, or %NULL 1116 */ 1117 public void setColorHighlight(RGBA highlightBackground) 1118 { 1119 vte_terminal_set_color_highlight(vteTerminal, (highlightBackground is null) ? null : highlightBackground.getRGBAStruct()); 1120 } 1121 1122 /** 1123 * Sets the foreground color for text which is highlighted. If %NULL, 1124 * it is unset. If neither highlight background nor highlight foreground are set, 1125 * highlighted text (which is usually highlighted because it is selected) will 1126 * be drawn with foreground and background colors reversed. 1127 * 1128 * Params: 1129 * highlightForeground = the new color to use for highlighted text, or %NULL 1130 */ 1131 public void setColorHighlightForeground(RGBA highlightForeground) 1132 { 1133 vte_terminal_set_color_highlight_foreground(vteTerminal, (highlightForeground is null) ? null : highlightForeground.getRGBAStruct()); 1134 } 1135 1136 /** 1137 * @palette specifies the new values for the 256 palette colors: 8 standard colors, 1138 * their 8 bright counterparts, 6x6x6 color cube, and 24 grayscale colors. 1139 * Omitted entries will default to a hardcoded value. 1140 * 1141 * @palette_size must be 0, 8, 16, 232 or 256. 1142 * 1143 * If @foreground is %NULL and @palette_size is greater than 0, the new foreground 1144 * color is taken from @palette[7]. If @background is %NULL and @palette_size is 1145 * greater than 0, the new background color is taken from @palette[0]. 1146 * 1147 * Params: 1148 * foreground = the new foreground color, or %NULL 1149 * background = the new background color, or %NULL 1150 * palette = the color palette 1151 */ 1152 public void setColors(RGBA foreground, RGBA background, RGBA[] palette) 1153 { 1154 GdkRGBA[] paletteArray = new GdkRGBA[palette.length]; 1155 for ( int i = 0; i < palette.length; i++ ) 1156 { 1157 paletteArray[i] = *(palette[i].getRGBAStruct()); 1158 } 1159 1160 vte_terminal_set_colors(vteTerminal, (foreground is null) ? null : foreground.getRGBAStruct(), (background is null) ? null : background.getRGBAStruct(), paletteArray.ptr, cast(size_t)palette.length); 1161 } 1162 1163 /** 1164 * Sets whether or not the cursor will blink. Using %VTE_CURSOR_BLINK_SYSTEM 1165 * will use the #GtkSettings::gtk-cursor-blink setting. 1166 * 1167 * Params: 1168 * mode = the #VteCursorBlinkMode to use 1169 */ 1170 public void setCursorBlinkMode(VteCursorBlinkMode mode) 1171 { 1172 vte_terminal_set_cursor_blink_mode(vteTerminal, mode); 1173 } 1174 1175 /** 1176 * Sets the shape of the cursor drawn. 1177 * 1178 * Params: 1179 * shape = the #VteCursorShape to use 1180 */ 1181 public void setCursorShape(VteCursorShape shape) 1182 { 1183 vte_terminal_set_cursor_shape(vteTerminal, shape); 1184 } 1185 1186 /** 1187 * Reset the terminal palette to reasonable compiled-in default color. 1188 */ 1189 public void setDefaultColors() 1190 { 1191 vte_terminal_set_default_colors(vteTerminal); 1192 } 1193 1194 /** 1195 * Modifies the terminal's delete key binding, which controls what 1196 * string or control sequence the terminal sends to its child when the user 1197 * presses the delete key. 1198 * 1199 * Params: 1200 * binding = a #VteEraseBinding for the delete key 1201 */ 1202 public void setDeleteBinding(VteEraseBinding binding) 1203 { 1204 vte_terminal_set_delete_binding(vteTerminal, binding); 1205 } 1206 1207 /** 1208 * Changes the encoding the terminal will expect data from the child to 1209 * be encoded with. For certain terminal types, applications executing in the 1210 * terminal can change the encoding. If @codeset is %NULL, it uses "UTF-8". 1211 * 1212 * Params: 1213 * codeset = a valid #GIConv target, or %NULL to use UTF-8 1214 * 1215 * Returns: %TRUE if the encoding could be changed to the specified one, 1216 * or %FALSE with @error set to %G_CONVERT_ERROR_NO_CONVERSION. 1217 * 1218 * Throws: GException on failure. 1219 */ 1220 public bool setEncoding(string codeset) 1221 { 1222 GError* err = null; 1223 1224 auto p = vte_terminal_set_encoding(vteTerminal, Str.toStringz(codeset), &err) != 0; 1225 1226 if (err !is null) 1227 { 1228 throw new GException( new ErrorG(err) ); 1229 } 1230 1231 return p; 1232 } 1233 1234 /** 1235 * Sets the font used for rendering all text displayed by the terminal, 1236 * overriding any fonts set using gtk_widget_modify_font(). The terminal 1237 * will immediately attempt to load the desired font, retrieve its 1238 * metrics, and attempt to resize itself to keep the same number of rows 1239 * and columns. The font scale is applied to the specified font. 1240 * 1241 * Params: 1242 * fontDesc = a #PangoFontDescription for the desired font, or %NULL 1243 */ 1244 public void setFont(PgFontDescription fontDesc) 1245 { 1246 vte_terminal_set_font(vteTerminal, (fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 1247 } 1248 1249 /** 1250 * Sets the terminal's font scale to @scale. 1251 * 1252 * Params: 1253 * scale = the font scale 1254 */ 1255 public void setFontScale(double scale) 1256 { 1257 vte_terminal_set_font_scale(vteTerminal, scale); 1258 } 1259 1260 /** 1261 * Sets @terminal as @window's geometry widget. See 1262 * gtk_window_set_geometry_hints() for more information. 1263 * 1264 * @terminal must be realized (see gtk_widget_get_realized()). 1265 * 1266 * Params: 1267 * window = a #GtkWindow 1268 */ 1269 public void setGeometryHintsForWindow(Window window) 1270 { 1271 vte_terminal_set_geometry_hints_for_window(vteTerminal, (window is null) ? null : window.getWindowStruct()); 1272 } 1273 1274 /** 1275 * Enables or disables user input. When user input is disabled, 1276 * the terminal's child will not receive any key press, or mouse button 1277 * press or motion events sent to it. 1278 * 1279 * Params: 1280 * enabled = whether to enable user input 1281 */ 1282 public void setInputEnabled(bool enabled) 1283 { 1284 vte_terminal_set_input_enabled(vteTerminal, enabled); 1285 } 1286 1287 /** 1288 * Changes the value of the terminal's mouse autohide setting. When autohiding 1289 * is enabled, the mouse cursor will be hidden when the user presses a key and 1290 * shown when the user moves the mouse. This setting can be read using 1291 * vte_terminal_get_mouse_autohide(). 1292 * 1293 * Params: 1294 * setting = whether the mouse pointer should autohide 1295 */ 1296 public void setMouseAutohide(bool setting) 1297 { 1298 vte_terminal_set_mouse_autohide(vteTerminal, setting); 1299 } 1300 1301 /** 1302 * Sets @pty as the PTY to use in @terminal. 1303 * Use %NULL to unset the PTY. 1304 * 1305 * Params: 1306 * pty = a #VtePty, or %NULL 1307 */ 1308 public void setPty(Pty pty) 1309 { 1310 vte_terminal_set_pty(vteTerminal, (pty is null) ? null : pty.getPtyStruct()); 1311 } 1312 1313 /** 1314 * Controls whether or not the terminal will rewrap its contents, including 1315 * the scrollback history, whenever the terminal's width changes. 1316 * 1317 * Params: 1318 * rewrap = %TRUE if the terminal should rewrap on resize 1319 */ 1320 public void setRewrapOnResize(bool rewrap) 1321 { 1322 vte_terminal_set_rewrap_on_resize(vteTerminal, rewrap); 1323 } 1324 1325 /** 1326 * Controls whether or not the terminal will forcibly scroll to the bottom of 1327 * the viewable history when the user presses a key. Modifier keys do not 1328 * trigger this behavior. 1329 * 1330 * Params: 1331 * scroll = whether the terminal should scroll on keystrokes 1332 */ 1333 public void setScrollOnKeystroke(bool scroll) 1334 { 1335 vte_terminal_set_scroll_on_keystroke(vteTerminal, scroll); 1336 } 1337 1338 /** 1339 * Controls whether or not the terminal will forcibly scroll to the bottom of 1340 * the viewable history when the new data is received from the child. 1341 * 1342 * Params: 1343 * scroll = whether the terminal should scroll on output 1344 */ 1345 public void setScrollOnOutput(bool scroll) 1346 { 1347 vte_terminal_set_scroll_on_output(vteTerminal, scroll); 1348 } 1349 1350 /** 1351 * Sets the length of the scrollback buffer used by the terminal. The size of 1352 * the scrollback buffer will be set to the larger of this value and the number 1353 * of visible rows the widget can display, so 0 can safely be used to disable 1354 * scrollback. 1355 * 1356 * A negative value means "infinite scrollback". 1357 * 1358 * Note that this setting only affects the normal screen buffer. 1359 * No scrollback is allowed on the alternate screen buffer. 1360 * 1361 * Params: 1362 * lines = the length of the history buffer 1363 */ 1364 public void setScrollbackLines(glong lines) 1365 { 1366 vte_terminal_set_scrollback_lines(vteTerminal, lines); 1367 } 1368 1369 /** 1370 * Attempts to change the terminal's size in terms of rows and columns. If 1371 * the attempt succeeds, the widget will resize itself to the proper size. 1372 * 1373 * Params: 1374 * columns = the desired number of columns 1375 * rows = the desired number of rows 1376 */ 1377 public void setSize(glong columns, glong rows) 1378 { 1379 vte_terminal_set_size(vteTerminal, columns, rows); 1380 } 1381 1382 /** 1383 * With this function you can provide a set of characters which will 1384 * be considered parts of a word when doing word-wise selection, in 1385 * addition to the default which only considers alphanumeric characters 1386 * part of a word. 1387 * 1388 * The characters in @exceptions must be non-alphanumeric, each character 1389 * must occur only once, and if @exceptions contains the character 1390 * U+002D HYPHEN-MINUS, it must be at the start of the string. 1391 * 1392 * Use %NULL to reset the set of exception characters to the default. 1393 * 1394 * Params: 1395 * exceptions = a string of ASCII punctuation characters, or %NULL 1396 * 1397 * Since: 0.40 1398 */ 1399 public void setWordCharExceptions(string exceptions) 1400 { 1401 vte_terminal_set_word_char_exceptions(vteTerminal, Str.toStringz(exceptions)); 1402 } 1403 1404 /** 1405 * A convenience function that wraps creating the #VtePty and spawning 1406 * the child process on it. See vte_pty_new_sync(), vte_pty_spawn_async(), 1407 * and vte_pty_spawn_finish() for more information. 1408 * 1409 * When the operation is finished successfully, @callback will be called 1410 * with the child #GPid, and a %NULL #GError. The child PID will already be 1411 * watched via vte_terminal_watch_child(). 1412 * 1413 * When the operation fails, @callback will be called with a -1 #GPid, 1414 * and a non-%NULL #GError containing the error information. 1415 * 1416 * Note that if @terminal has been destroyed before the operation is called, 1417 * @callback will be called with a %NULL @terminal; you must not do anything 1418 * in the callback besides freeing any resources associated with @user_data, 1419 * but taking care not to access the now-destroyed #VteTerminal. Note that 1420 * in this case, if spawning was successful, the child process will be aborted 1421 * automatically. 1422 * 1423 * Params: 1424 * ptyFlags = flags from #VtePtyFlags 1425 * workingDirectory = the name of a directory the command should start 1426 * in, or %NULL to use the current working directory 1427 * argv = child's argument vector 1428 * envv = a list of environment 1429 * variables to be added to the environment before starting the process, or %NULL 1430 * spawnFlags = flags from #GSpawnFlags 1431 * childSetup = an extra child setup function to run in the child just before exec(), or %NULL 1432 * childSetupData = user data for @child_setup, or %NULL 1433 * childSetupDataDestroy = a #GDestroyNotify for @child_setup_data, or %NULL 1434 * timeout = a timeout value in ms, or -1 to wait indefinitely 1435 * cancellable = a #GCancellable, or %NULL 1436 * callback = a #VteTerminalSpawnAsyncCallback, or %NULL 1437 * userData = user data for @callback, or %NULL 1438 * 1439 * Since: 0.48 1440 */ 1441 public void spawnAsync(VtePtyFlags ptyFlags, string workingDirectory, string[] argv, string[] envv, GSpawnFlags spawnFlags, GSpawnChildSetupFunc childSetup, void* childSetupData, GDestroyNotify childSetupDataDestroy, int timeout, Cancellable cancellable, VteTerminalSpawnAsyncCallback callback, void* userData) 1442 { 1443 vte_terminal_spawn_async(vteTerminal, ptyFlags, Str.toStringz(workingDirectory), Str.toStringzArray(argv), Str.toStringzArray(envv), spawnFlags, childSetup, childSetupData, childSetupDataDestroy, timeout, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1444 } 1445 1446 /** 1447 * Starts the specified command under a newly-allocated controlling 1448 * pseudo-terminal. The @argv and @envv lists should be %NULL-terminated. 1449 * The "TERM" environment variable is automatically set to a default value, 1450 * but can be overridden from @envv. 1451 * @pty_flags controls logging the session to the specified system log files. 1452 * 1453 * Note that %G_SPAWN_DO_NOT_REAP_CHILD will always be added to @spawn_flags. 1454 * 1455 * Note that all open file descriptors will be closed in the child. If you want 1456 * to keep some file descriptor open for use in the child process, you need to 1457 * use a child setup function that unsets the FD_CLOEXEC flag on that file 1458 * descriptor. 1459 * 1460 * See vte_pty_new(), g_spawn_async() and vte_terminal_watch_child() for more information. 1461 * 1462 * Deprecated: Use vte_terminal_spawn_async() instead. 1463 * 1464 * Params: 1465 * ptyFlags = flags from #VtePtyFlags 1466 * workingDirectory = the name of a directory the command should start 1467 * in, or %NULL to use the current working directory 1468 * argv = child's argument vector 1469 * envv = a list of environment 1470 * variables to be added to the environment before starting the process, or %NULL 1471 * spawnFlags = flags from #GSpawnFlags 1472 * childSetup = an extra child setup function to run in the child just before exec(), or %NULL 1473 * childSetupData = user data for @child_setup 1474 * childPid = a location to store the child PID, or %NULL 1475 * cancellable = a #GCancellable, or %NULL 1476 * 1477 * Returns: %TRUE on success, or %FALSE on error with @error filled in 1478 * 1479 * Throws: GException on failure. 1480 */ 1481 public bool spawnSync(VtePtyFlags ptyFlags, string workingDirectory, string[] argv, string[] envv, GSpawnFlags spawnFlags, GSpawnChildSetupFunc childSetup, void* childSetupData, out GPid childPid, Cancellable cancellable) 1482 { 1483 GError* err = null; 1484 1485 auto p = vte_terminal_spawn_sync(vteTerminal, ptyFlags, Str.toStringz(workingDirectory), Str.toStringzArray(argv), Str.toStringzArray(envv), spawnFlags, childSetup, childSetupData, &childPid, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1486 1487 if (err !is null) 1488 { 1489 throw new GException( new ErrorG(err) ); 1490 } 1491 1492 return p; 1493 } 1494 1495 /** 1496 * Clears the current selection. 1497 */ 1498 public void unselectAll() 1499 { 1500 vte_terminal_unselect_all(vteTerminal); 1501 } 1502 1503 /** 1504 * Watches @child_pid. When the process exists, the #VteTerminal::child-exited 1505 * signal will be called with the child's exit status. 1506 * 1507 * Prior to calling this function, a #VtePty must have been set in @terminal 1508 * using vte_terminal_set_pty(). 1509 * When the child exits, the terminal's #VtePty will be set to %NULL. 1510 * 1511 * Note: g_child_watch_add() or g_child_watch_add_full() must not have 1512 * been called for @child_pid, nor a #GSource for it been created with 1513 * g_child_watch_source_new(). 1514 * 1515 * Note: when using the g_spawn_async() family of functions, 1516 * the %G_SPAWN_DO_NOT_REAP_CHILD flag MUST have been passed. 1517 * 1518 * Params: 1519 * childPid = a #GPid 1520 */ 1521 public void watchChild(GPid childPid) 1522 { 1523 vte_terminal_watch_child(vteTerminal, childPid); 1524 } 1525 1526 /** 1527 * Write contents of the current contents of @terminal (including any 1528 * scrollback history) to @stream according to @flags. 1529 * 1530 * If @cancellable is not %NULL, then the operation can be cancelled by triggering 1531 * the cancellable object from another thread. If the operation was cancelled, 1532 * the error %G_IO_ERROR_CANCELLED will be returned in @error. 1533 * 1534 * This is a synchronous operation and will make the widget (and input 1535 * processing) during the write operation, which may take a long time 1536 * depending on scrollback history and @stream availability for writing. 1537 * 1538 * Params: 1539 * stream = a #GOutputStream to write to 1540 * flags = a set of #VteWriteFlags 1541 * cancellable = a #GCancellable object, or %NULL 1542 * 1543 * Returns: %TRUE on success, %FALSE if there was an error 1544 * 1545 * Throws: GException on failure. 1546 */ 1547 public bool writeContentsSync(OutputStream stream, VteWriteFlags flags, Cancellable cancellable) 1548 { 1549 GError* err = null; 1550 1551 auto p = vte_terminal_write_contents_sync(vteTerminal, (stream is null) ? null : stream.getOutputStreamStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1552 1553 if (err !is null) 1554 { 1555 throw new GException( new ErrorG(err) ); 1556 } 1557 1558 return p; 1559 } 1560 1561 protected class OnBellDelegateWrapper 1562 { 1563 void delegate(Terminal) dlg; 1564 gulong handlerId; 1565 1566 this(void delegate(Terminal) dlg) 1567 { 1568 this.dlg = dlg; 1569 onBellListeners ~= this; 1570 } 1571 1572 void remove(OnBellDelegateWrapper source) 1573 { 1574 foreach(index, wrapper; onBellListeners) 1575 { 1576 if (wrapper.handlerId == source.handlerId) 1577 { 1578 onBellListeners[index] = null; 1579 onBellListeners = std.algorithm.remove(onBellListeners, index); 1580 break; 1581 } 1582 } 1583 } 1584 } 1585 OnBellDelegateWrapper[] onBellListeners; 1586 1587 /** 1588 * This signal is emitted when the a child sends a bell request to the 1589 * terminal. 1590 */ 1591 gulong addOnBell(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1592 { 1593 auto wrapper = new OnBellDelegateWrapper(dlg); 1594 wrapper.handlerId = Signals.connectData( 1595 this, 1596 "bell", 1597 cast(GCallback)&callBackBell, 1598 cast(void*)wrapper, 1599 cast(GClosureNotify)&callBackBellDestroy, 1600 connectFlags); 1601 return wrapper.handlerId; 1602 } 1603 1604 extern(C) static void callBackBell(VteTerminal* terminalStruct, OnBellDelegateWrapper wrapper) 1605 { 1606 wrapper.dlg(wrapper.outer); 1607 } 1608 1609 extern(C) static void callBackBellDestroy(OnBellDelegateWrapper wrapper, GClosure* closure) 1610 { 1611 wrapper.remove(wrapper); 1612 } 1613 1614 protected class OnCharSizeChangedDelegateWrapper 1615 { 1616 void delegate(uint, uint, Terminal) dlg; 1617 gulong handlerId; 1618 1619 this(void delegate(uint, uint, Terminal) dlg) 1620 { 1621 this.dlg = dlg; 1622 onCharSizeChangedListeners ~= this; 1623 } 1624 1625 void remove(OnCharSizeChangedDelegateWrapper source) 1626 { 1627 foreach(index, wrapper; onCharSizeChangedListeners) 1628 { 1629 if (wrapper.handlerId == source.handlerId) 1630 { 1631 onCharSizeChangedListeners[index] = null; 1632 onCharSizeChangedListeners = std.algorithm.remove(onCharSizeChangedListeners, index); 1633 break; 1634 } 1635 } 1636 } 1637 } 1638 OnCharSizeChangedDelegateWrapper[] onCharSizeChangedListeners; 1639 1640 /** 1641 * Emitted whenever selection of a new font causes the values of the 1642 * %char_width or %char_height fields to change. 1643 * 1644 * Params: 1645 * width = the new character cell width 1646 * height = the new character cell height 1647 */ 1648 gulong addOnCharSizeChanged(void delegate(uint, uint, Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1649 { 1650 auto wrapper = new OnCharSizeChangedDelegateWrapper(dlg); 1651 wrapper.handlerId = Signals.connectData( 1652 this, 1653 "char-size-changed", 1654 cast(GCallback)&callBackCharSizeChanged, 1655 cast(void*)wrapper, 1656 cast(GClosureNotify)&callBackCharSizeChangedDestroy, 1657 connectFlags); 1658 return wrapper.handlerId; 1659 } 1660 1661 extern(C) static void callBackCharSizeChanged(VteTerminal* terminalStruct, uint width, uint height, OnCharSizeChangedDelegateWrapper wrapper) 1662 { 1663 wrapper.dlg(width, height, wrapper.outer); 1664 } 1665 1666 extern(C) static void callBackCharSizeChangedDestroy(OnCharSizeChangedDelegateWrapper wrapper, GClosure* closure) 1667 { 1668 wrapper.remove(wrapper); 1669 } 1670 1671 protected class OnChildExitedDelegateWrapper 1672 { 1673 void delegate(int, Terminal) dlg; 1674 gulong handlerId; 1675 1676 this(void delegate(int, Terminal) dlg) 1677 { 1678 this.dlg = dlg; 1679 onChildExitedListeners ~= this; 1680 } 1681 1682 void remove(OnChildExitedDelegateWrapper source) 1683 { 1684 foreach(index, wrapper; onChildExitedListeners) 1685 { 1686 if (wrapper.handlerId == source.handlerId) 1687 { 1688 onChildExitedListeners[index] = null; 1689 onChildExitedListeners = std.algorithm.remove(onChildExitedListeners, index); 1690 break; 1691 } 1692 } 1693 } 1694 } 1695 OnChildExitedDelegateWrapper[] onChildExitedListeners; 1696 1697 /** 1698 * This signal is emitted when the terminal detects that a child 1699 * watched using vte_terminal_watch_child() has exited. 1700 * 1701 * Params: 1702 * status = the child's exit status 1703 */ 1704 gulong addOnChildExited(void delegate(int, Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1705 { 1706 auto wrapper = new OnChildExitedDelegateWrapper(dlg); 1707 wrapper.handlerId = Signals.connectData( 1708 this, 1709 "child-exited", 1710 cast(GCallback)&callBackChildExited, 1711 cast(void*)wrapper, 1712 cast(GClosureNotify)&callBackChildExitedDestroy, 1713 connectFlags); 1714 return wrapper.handlerId; 1715 } 1716 1717 extern(C) static void callBackChildExited(VteTerminal* terminalStruct, int status, OnChildExitedDelegateWrapper wrapper) 1718 { 1719 wrapper.dlg(status, wrapper.outer); 1720 } 1721 1722 extern(C) static void callBackChildExitedDestroy(OnChildExitedDelegateWrapper wrapper, GClosure* closure) 1723 { 1724 wrapper.remove(wrapper); 1725 } 1726 1727 protected class OnCommitDelegateWrapper 1728 { 1729 void delegate(string, uint, Terminal) dlg; 1730 gulong handlerId; 1731 1732 this(void delegate(string, uint, Terminal) dlg) 1733 { 1734 this.dlg = dlg; 1735 onCommitListeners ~= this; 1736 } 1737 1738 void remove(OnCommitDelegateWrapper source) 1739 { 1740 foreach(index, wrapper; onCommitListeners) 1741 { 1742 if (wrapper.handlerId == source.handlerId) 1743 { 1744 onCommitListeners[index] = null; 1745 onCommitListeners = std.algorithm.remove(onCommitListeners, index); 1746 break; 1747 } 1748 } 1749 } 1750 } 1751 OnCommitDelegateWrapper[] onCommitListeners; 1752 1753 /** 1754 * Emitted whenever the terminal receives input from the user and 1755 * prepares to send it to the child process. The signal is emitted even 1756 * when there is no child process. 1757 * 1758 * Params: 1759 * text = a string of text 1760 * size = the length of that string of text 1761 */ 1762 gulong addOnCommit(void delegate(string, uint, Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1763 { 1764 auto wrapper = new OnCommitDelegateWrapper(dlg); 1765 wrapper.handlerId = Signals.connectData( 1766 this, 1767 "commit", 1768 cast(GCallback)&callBackCommit, 1769 cast(void*)wrapper, 1770 cast(GClosureNotify)&callBackCommitDestroy, 1771 connectFlags); 1772 return wrapper.handlerId; 1773 } 1774 1775 extern(C) static void callBackCommit(VteTerminal* terminalStruct, char* text, uint size, OnCommitDelegateWrapper wrapper) 1776 { 1777 wrapper.dlg(Str.toString(text), size, wrapper.outer); 1778 } 1779 1780 extern(C) static void callBackCommitDestroy(OnCommitDelegateWrapper wrapper, GClosure* closure) 1781 { 1782 wrapper.remove(wrapper); 1783 } 1784 1785 protected class OnContentsChangedDelegateWrapper 1786 { 1787 void delegate(Terminal) dlg; 1788 gulong handlerId; 1789 1790 this(void delegate(Terminal) dlg) 1791 { 1792 this.dlg = dlg; 1793 onContentsChangedListeners ~= this; 1794 } 1795 1796 void remove(OnContentsChangedDelegateWrapper source) 1797 { 1798 foreach(index, wrapper; onContentsChangedListeners) 1799 { 1800 if (wrapper.handlerId == source.handlerId) 1801 { 1802 onContentsChangedListeners[index] = null; 1803 onContentsChangedListeners = std.algorithm.remove(onContentsChangedListeners, index); 1804 break; 1805 } 1806 } 1807 } 1808 } 1809 OnContentsChangedDelegateWrapper[] onContentsChangedListeners; 1810 1811 /** 1812 * Emitted whenever the visible appearance of the terminal has changed. 1813 * Used primarily by #VteTerminalAccessible. 1814 */ 1815 gulong addOnContentsChanged(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1816 { 1817 auto wrapper = new OnContentsChangedDelegateWrapper(dlg); 1818 wrapper.handlerId = Signals.connectData( 1819 this, 1820 "contents-changed", 1821 cast(GCallback)&callBackContentsChanged, 1822 cast(void*)wrapper, 1823 cast(GClosureNotify)&callBackContentsChangedDestroy, 1824 connectFlags); 1825 return wrapper.handlerId; 1826 } 1827 1828 extern(C) static void callBackContentsChanged(VteTerminal* terminalStruct, OnContentsChangedDelegateWrapper wrapper) 1829 { 1830 wrapper.dlg(wrapper.outer); 1831 } 1832 1833 extern(C) static void callBackContentsChangedDestroy(OnContentsChangedDelegateWrapper wrapper, GClosure* closure) 1834 { 1835 wrapper.remove(wrapper); 1836 } 1837 1838 protected class OnCopyClipboardDelegateWrapper 1839 { 1840 void delegate(Terminal) dlg; 1841 gulong handlerId; 1842 1843 this(void delegate(Terminal) dlg) 1844 { 1845 this.dlg = dlg; 1846 onCopyClipboardListeners ~= this; 1847 } 1848 1849 void remove(OnCopyClipboardDelegateWrapper source) 1850 { 1851 foreach(index, wrapper; onCopyClipboardListeners) 1852 { 1853 if (wrapper.handlerId == source.handlerId) 1854 { 1855 onCopyClipboardListeners[index] = null; 1856 onCopyClipboardListeners = std.algorithm.remove(onCopyClipboardListeners, index); 1857 break; 1858 } 1859 } 1860 } 1861 } 1862 OnCopyClipboardDelegateWrapper[] onCopyClipboardListeners; 1863 1864 /** 1865 * Emitted whenever vte_terminal_copy_clipboard() is called. 1866 */ 1867 gulong addOnCopyClipboard(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1868 { 1869 auto wrapper = new OnCopyClipboardDelegateWrapper(dlg); 1870 wrapper.handlerId = Signals.connectData( 1871 this, 1872 "copy-clipboard", 1873 cast(GCallback)&callBackCopyClipboard, 1874 cast(void*)wrapper, 1875 cast(GClosureNotify)&callBackCopyClipboardDestroy, 1876 connectFlags); 1877 return wrapper.handlerId; 1878 } 1879 1880 extern(C) static void callBackCopyClipboard(VteTerminal* terminalStruct, OnCopyClipboardDelegateWrapper wrapper) 1881 { 1882 wrapper.dlg(wrapper.outer); 1883 } 1884 1885 extern(C) static void callBackCopyClipboardDestroy(OnCopyClipboardDelegateWrapper wrapper, GClosure* closure) 1886 { 1887 wrapper.remove(wrapper); 1888 } 1889 1890 protected class OnCurrentDirectoryUriChangedDelegateWrapper 1891 { 1892 void delegate(Terminal) dlg; 1893 gulong handlerId; 1894 1895 this(void delegate(Terminal) dlg) 1896 { 1897 this.dlg = dlg; 1898 onCurrentDirectoryUriChangedListeners ~= this; 1899 } 1900 1901 void remove(OnCurrentDirectoryUriChangedDelegateWrapper source) 1902 { 1903 foreach(index, wrapper; onCurrentDirectoryUriChangedListeners) 1904 { 1905 if (wrapper.handlerId == source.handlerId) 1906 { 1907 onCurrentDirectoryUriChangedListeners[index] = null; 1908 onCurrentDirectoryUriChangedListeners = std.algorithm.remove(onCurrentDirectoryUriChangedListeners, index); 1909 break; 1910 } 1911 } 1912 } 1913 } 1914 OnCurrentDirectoryUriChangedDelegateWrapper[] onCurrentDirectoryUriChangedListeners; 1915 1916 /** 1917 * Emitted when the current directory URI is modified. 1918 */ 1919 gulong addOnCurrentDirectoryUriChanged(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1920 { 1921 auto wrapper = new OnCurrentDirectoryUriChangedDelegateWrapper(dlg); 1922 wrapper.handlerId = Signals.connectData( 1923 this, 1924 "current-directory-uri-changed", 1925 cast(GCallback)&callBackCurrentDirectoryUriChanged, 1926 cast(void*)wrapper, 1927 cast(GClosureNotify)&callBackCurrentDirectoryUriChangedDestroy, 1928 connectFlags); 1929 return wrapper.handlerId; 1930 } 1931 1932 extern(C) static void callBackCurrentDirectoryUriChanged(VteTerminal* terminalStruct, OnCurrentDirectoryUriChangedDelegateWrapper wrapper) 1933 { 1934 wrapper.dlg(wrapper.outer); 1935 } 1936 1937 extern(C) static void callBackCurrentDirectoryUriChangedDestroy(OnCurrentDirectoryUriChangedDelegateWrapper wrapper, GClosure* closure) 1938 { 1939 wrapper.remove(wrapper); 1940 } 1941 1942 protected class OnCurrentFileUriChangedDelegateWrapper 1943 { 1944 void delegate(Terminal) dlg; 1945 gulong handlerId; 1946 1947 this(void delegate(Terminal) dlg) 1948 { 1949 this.dlg = dlg; 1950 onCurrentFileUriChangedListeners ~= this; 1951 } 1952 1953 void remove(OnCurrentFileUriChangedDelegateWrapper source) 1954 { 1955 foreach(index, wrapper; onCurrentFileUriChangedListeners) 1956 { 1957 if (wrapper.handlerId == source.handlerId) 1958 { 1959 onCurrentFileUriChangedListeners[index] = null; 1960 onCurrentFileUriChangedListeners = std.algorithm.remove(onCurrentFileUriChangedListeners, index); 1961 break; 1962 } 1963 } 1964 } 1965 } 1966 OnCurrentFileUriChangedDelegateWrapper[] onCurrentFileUriChangedListeners; 1967 1968 /** 1969 * Emitted when the current file URI is modified. 1970 */ 1971 gulong addOnCurrentFileUriChanged(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1972 { 1973 auto wrapper = new OnCurrentFileUriChangedDelegateWrapper(dlg); 1974 wrapper.handlerId = Signals.connectData( 1975 this, 1976 "current-file-uri-changed", 1977 cast(GCallback)&callBackCurrentFileUriChanged, 1978 cast(void*)wrapper, 1979 cast(GClosureNotify)&callBackCurrentFileUriChangedDestroy, 1980 connectFlags); 1981 return wrapper.handlerId; 1982 } 1983 1984 extern(C) static void callBackCurrentFileUriChanged(VteTerminal* terminalStruct, OnCurrentFileUriChangedDelegateWrapper wrapper) 1985 { 1986 wrapper.dlg(wrapper.outer); 1987 } 1988 1989 extern(C) static void callBackCurrentFileUriChangedDestroy(OnCurrentFileUriChangedDelegateWrapper wrapper, GClosure* closure) 1990 { 1991 wrapper.remove(wrapper); 1992 } 1993 1994 protected class OnCursorMovedDelegateWrapper 1995 { 1996 void delegate(Terminal) dlg; 1997 gulong handlerId; 1998 1999 this(void delegate(Terminal) dlg) 2000 { 2001 this.dlg = dlg; 2002 onCursorMovedListeners ~= this; 2003 } 2004 2005 void remove(OnCursorMovedDelegateWrapper source) 2006 { 2007 foreach(index, wrapper; onCursorMovedListeners) 2008 { 2009 if (wrapper.handlerId == source.handlerId) 2010 { 2011 onCursorMovedListeners[index] = null; 2012 onCursorMovedListeners = std.algorithm.remove(onCursorMovedListeners, index); 2013 break; 2014 } 2015 } 2016 } 2017 } 2018 OnCursorMovedDelegateWrapper[] onCursorMovedListeners; 2019 2020 /** 2021 * Emitted whenever the cursor moves to a new character cell. Used 2022 * primarily by #VteTerminalAccessible. 2023 */ 2024 gulong addOnCursorMoved(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2025 { 2026 auto wrapper = new OnCursorMovedDelegateWrapper(dlg); 2027 wrapper.handlerId = Signals.connectData( 2028 this, 2029 "cursor-moved", 2030 cast(GCallback)&callBackCursorMoved, 2031 cast(void*)wrapper, 2032 cast(GClosureNotify)&callBackCursorMovedDestroy, 2033 connectFlags); 2034 return wrapper.handlerId; 2035 } 2036 2037 extern(C) static void callBackCursorMoved(VteTerminal* terminalStruct, OnCursorMovedDelegateWrapper wrapper) 2038 { 2039 wrapper.dlg(wrapper.outer); 2040 } 2041 2042 extern(C) static void callBackCursorMovedDestroy(OnCursorMovedDelegateWrapper wrapper, GClosure* closure) 2043 { 2044 wrapper.remove(wrapper); 2045 } 2046 2047 protected class OnDecreaseFontSizeDelegateWrapper 2048 { 2049 void delegate(Terminal) dlg; 2050 gulong handlerId; 2051 2052 this(void delegate(Terminal) dlg) 2053 { 2054 this.dlg = dlg; 2055 onDecreaseFontSizeListeners ~= this; 2056 } 2057 2058 void remove(OnDecreaseFontSizeDelegateWrapper source) 2059 { 2060 foreach(index, wrapper; onDecreaseFontSizeListeners) 2061 { 2062 if (wrapper.handlerId == source.handlerId) 2063 { 2064 onDecreaseFontSizeListeners[index] = null; 2065 onDecreaseFontSizeListeners = std.algorithm.remove(onDecreaseFontSizeListeners, index); 2066 break; 2067 } 2068 } 2069 } 2070 } 2071 OnDecreaseFontSizeDelegateWrapper[] onDecreaseFontSizeListeners; 2072 2073 /** 2074 * Emitted when the user hits the '-' key while holding the Control key. 2075 */ 2076 gulong addOnDecreaseFontSize(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2077 { 2078 auto wrapper = new OnDecreaseFontSizeDelegateWrapper(dlg); 2079 wrapper.handlerId = Signals.connectData( 2080 this, 2081 "decrease-font-size", 2082 cast(GCallback)&callBackDecreaseFontSize, 2083 cast(void*)wrapper, 2084 cast(GClosureNotify)&callBackDecreaseFontSizeDestroy, 2085 connectFlags); 2086 return wrapper.handlerId; 2087 } 2088 2089 extern(C) static void callBackDecreaseFontSize(VteTerminal* terminalStruct, OnDecreaseFontSizeDelegateWrapper wrapper) 2090 { 2091 wrapper.dlg(wrapper.outer); 2092 } 2093 2094 extern(C) static void callBackDecreaseFontSizeDestroy(OnDecreaseFontSizeDelegateWrapper wrapper, GClosure* closure) 2095 { 2096 wrapper.remove(wrapper); 2097 } 2098 2099 protected class OnDeiconifyWindowDelegateWrapper 2100 { 2101 void delegate(Terminal) dlg; 2102 gulong handlerId; 2103 2104 this(void delegate(Terminal) dlg) 2105 { 2106 this.dlg = dlg; 2107 onDeiconifyWindowListeners ~= this; 2108 } 2109 2110 void remove(OnDeiconifyWindowDelegateWrapper source) 2111 { 2112 foreach(index, wrapper; onDeiconifyWindowListeners) 2113 { 2114 if (wrapper.handlerId == source.handlerId) 2115 { 2116 onDeiconifyWindowListeners[index] = null; 2117 onDeiconifyWindowListeners = std.algorithm.remove(onDeiconifyWindowListeners, index); 2118 break; 2119 } 2120 } 2121 } 2122 } 2123 OnDeiconifyWindowDelegateWrapper[] onDeiconifyWindowListeners; 2124 2125 /** 2126 * Emitted at the child application's request. 2127 */ 2128 gulong addOnDeiconifyWindow(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2129 { 2130 auto wrapper = new OnDeiconifyWindowDelegateWrapper(dlg); 2131 wrapper.handlerId = Signals.connectData( 2132 this, 2133 "deiconify-window", 2134 cast(GCallback)&callBackDeiconifyWindow, 2135 cast(void*)wrapper, 2136 cast(GClosureNotify)&callBackDeiconifyWindowDestroy, 2137 connectFlags); 2138 return wrapper.handlerId; 2139 } 2140 2141 extern(C) static void callBackDeiconifyWindow(VteTerminal* terminalStruct, OnDeiconifyWindowDelegateWrapper wrapper) 2142 { 2143 wrapper.dlg(wrapper.outer); 2144 } 2145 2146 extern(C) static void callBackDeiconifyWindowDestroy(OnDeiconifyWindowDelegateWrapper wrapper, GClosure* closure) 2147 { 2148 wrapper.remove(wrapper); 2149 } 2150 2151 protected class OnEncodingChangedDelegateWrapper 2152 { 2153 void delegate(Terminal) dlg; 2154 gulong handlerId; 2155 2156 this(void delegate(Terminal) dlg) 2157 { 2158 this.dlg = dlg; 2159 onEncodingChangedListeners ~= this; 2160 } 2161 2162 void remove(OnEncodingChangedDelegateWrapper source) 2163 { 2164 foreach(index, wrapper; onEncodingChangedListeners) 2165 { 2166 if (wrapper.handlerId == source.handlerId) 2167 { 2168 onEncodingChangedListeners[index] = null; 2169 onEncodingChangedListeners = std.algorithm.remove(onEncodingChangedListeners, index); 2170 break; 2171 } 2172 } 2173 } 2174 } 2175 OnEncodingChangedDelegateWrapper[] onEncodingChangedListeners; 2176 2177 /** 2178 * Emitted whenever the terminal's current encoding has changed, either 2179 * as a result of receiving a control sequence which toggled between the 2180 * local and UTF-8 encodings, or at the parent application's request. 2181 */ 2182 gulong addOnEncodingChanged(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2183 { 2184 auto wrapper = new OnEncodingChangedDelegateWrapper(dlg); 2185 wrapper.handlerId = Signals.connectData( 2186 this, 2187 "encoding-changed", 2188 cast(GCallback)&callBackEncodingChanged, 2189 cast(void*)wrapper, 2190 cast(GClosureNotify)&callBackEncodingChangedDestroy, 2191 connectFlags); 2192 return wrapper.handlerId; 2193 } 2194 2195 extern(C) static void callBackEncodingChanged(VteTerminal* terminalStruct, OnEncodingChangedDelegateWrapper wrapper) 2196 { 2197 wrapper.dlg(wrapper.outer); 2198 } 2199 2200 extern(C) static void callBackEncodingChangedDestroy(OnEncodingChangedDelegateWrapper wrapper, GClosure* closure) 2201 { 2202 wrapper.remove(wrapper); 2203 } 2204 2205 protected class OnEofDelegateWrapper 2206 { 2207 void delegate(Terminal) dlg; 2208 gulong handlerId; 2209 2210 this(void delegate(Terminal) dlg) 2211 { 2212 this.dlg = dlg; 2213 onEofListeners ~= this; 2214 } 2215 2216 void remove(OnEofDelegateWrapper source) 2217 { 2218 foreach(index, wrapper; onEofListeners) 2219 { 2220 if (wrapper.handlerId == source.handlerId) 2221 { 2222 onEofListeners[index] = null; 2223 onEofListeners = std.algorithm.remove(onEofListeners, index); 2224 break; 2225 } 2226 } 2227 } 2228 } 2229 OnEofDelegateWrapper[] onEofListeners; 2230 2231 /** 2232 * Emitted when the terminal receives an end-of-file from a child which 2233 * is running in the terminal. This signal is frequently (but not 2234 * always) emitted with a #VteTerminal::child-exited signal. 2235 */ 2236 gulong addOnEof(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2237 { 2238 auto wrapper = new OnEofDelegateWrapper(dlg); 2239 wrapper.handlerId = Signals.connectData( 2240 this, 2241 "eof", 2242 cast(GCallback)&callBackEof, 2243 cast(void*)wrapper, 2244 cast(GClosureNotify)&callBackEofDestroy, 2245 connectFlags); 2246 return wrapper.handlerId; 2247 } 2248 2249 extern(C) static void callBackEof(VteTerminal* terminalStruct, OnEofDelegateWrapper wrapper) 2250 { 2251 wrapper.dlg(wrapper.outer); 2252 } 2253 2254 extern(C) static void callBackEofDestroy(OnEofDelegateWrapper wrapper, GClosure* closure) 2255 { 2256 wrapper.remove(wrapper); 2257 } 2258 2259 protected class OnHyperlinkHoverUriChangedDelegateWrapper 2260 { 2261 void delegate(string, GdkRectangle*, Terminal) dlg; 2262 gulong handlerId; 2263 2264 this(void delegate(string, GdkRectangle*, Terminal) dlg) 2265 { 2266 this.dlg = dlg; 2267 onHyperlinkHoverUriChangedListeners ~= this; 2268 } 2269 2270 void remove(OnHyperlinkHoverUriChangedDelegateWrapper source) 2271 { 2272 foreach(index, wrapper; onHyperlinkHoverUriChangedListeners) 2273 { 2274 if (wrapper.handlerId == source.handlerId) 2275 { 2276 onHyperlinkHoverUriChangedListeners[index] = null; 2277 onHyperlinkHoverUriChangedListeners = std.algorithm.remove(onHyperlinkHoverUriChangedListeners, index); 2278 break; 2279 } 2280 } 2281 } 2282 } 2283 OnHyperlinkHoverUriChangedDelegateWrapper[] onHyperlinkHoverUriChangedListeners; 2284 2285 /** 2286 * Emitted when the hovered hyperlink changes. 2287 * 2288 * @uri and @bbox are owned by VTE, must not be modified, and might 2289 * change after the signal handlers returns. 2290 * 2291 * The signal is not re-emitted when the bounding box changes for the 2292 * same hyperlink. This might change in a future VTE version without notice. 2293 * 2294 * Params: 2295 * uri = the nonempty target URI under the mouse, or NULL 2296 * bbox = the bounding box of the hyperlink anchor text, or NULL 2297 * 2298 * Since: 0.50 2299 */ 2300 gulong addOnHyperlinkHoverUriChanged(void delegate(string, GdkRectangle*, Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2301 { 2302 auto wrapper = new OnHyperlinkHoverUriChangedDelegateWrapper(dlg); 2303 wrapper.handlerId = Signals.connectData( 2304 this, 2305 "hyperlink-hover-uri-changed", 2306 cast(GCallback)&callBackHyperlinkHoverUriChanged, 2307 cast(void*)wrapper, 2308 cast(GClosureNotify)&callBackHyperlinkHoverUriChangedDestroy, 2309 connectFlags); 2310 return wrapper.handlerId; 2311 } 2312 2313 extern(C) static void callBackHyperlinkHoverUriChanged(VteTerminal* terminalStruct, char* uri, GdkRectangle* bbox, OnHyperlinkHoverUriChangedDelegateWrapper wrapper) 2314 { 2315 wrapper.dlg(Str.toString(uri), bbox, wrapper.outer); 2316 } 2317 2318 extern(C) static void callBackHyperlinkHoverUriChangedDestroy(OnHyperlinkHoverUriChangedDelegateWrapper wrapper, GClosure* closure) 2319 { 2320 wrapper.remove(wrapper); 2321 } 2322 2323 protected class OnIconTitleChangedDelegateWrapper 2324 { 2325 void delegate(Terminal) dlg; 2326 gulong handlerId; 2327 2328 this(void delegate(Terminal) dlg) 2329 { 2330 this.dlg = dlg; 2331 onIconTitleChangedListeners ~= this; 2332 } 2333 2334 void remove(OnIconTitleChangedDelegateWrapper source) 2335 { 2336 foreach(index, wrapper; onIconTitleChangedListeners) 2337 { 2338 if (wrapper.handlerId == source.handlerId) 2339 { 2340 onIconTitleChangedListeners[index] = null; 2341 onIconTitleChangedListeners = std.algorithm.remove(onIconTitleChangedListeners, index); 2342 break; 2343 } 2344 } 2345 } 2346 } 2347 OnIconTitleChangedDelegateWrapper[] onIconTitleChangedListeners; 2348 2349 /** 2350 * Emitted when the terminal's %icon_title field is modified. 2351 */ 2352 gulong addOnIconTitleChanged(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2353 { 2354 auto wrapper = new OnIconTitleChangedDelegateWrapper(dlg); 2355 wrapper.handlerId = Signals.connectData( 2356 this, 2357 "icon-title-changed", 2358 cast(GCallback)&callBackIconTitleChanged, 2359 cast(void*)wrapper, 2360 cast(GClosureNotify)&callBackIconTitleChangedDestroy, 2361 connectFlags); 2362 return wrapper.handlerId; 2363 } 2364 2365 extern(C) static void callBackIconTitleChanged(VteTerminal* terminalStruct, OnIconTitleChangedDelegateWrapper wrapper) 2366 { 2367 wrapper.dlg(wrapper.outer); 2368 } 2369 2370 extern(C) static void callBackIconTitleChangedDestroy(OnIconTitleChangedDelegateWrapper wrapper, GClosure* closure) 2371 { 2372 wrapper.remove(wrapper); 2373 } 2374 2375 protected class OnIconifyWindowDelegateWrapper 2376 { 2377 void delegate(Terminal) dlg; 2378 gulong handlerId; 2379 2380 this(void delegate(Terminal) dlg) 2381 { 2382 this.dlg = dlg; 2383 onIconifyWindowListeners ~= this; 2384 } 2385 2386 void remove(OnIconifyWindowDelegateWrapper source) 2387 { 2388 foreach(index, wrapper; onIconifyWindowListeners) 2389 { 2390 if (wrapper.handlerId == source.handlerId) 2391 { 2392 onIconifyWindowListeners[index] = null; 2393 onIconifyWindowListeners = std.algorithm.remove(onIconifyWindowListeners, index); 2394 break; 2395 } 2396 } 2397 } 2398 } 2399 OnIconifyWindowDelegateWrapper[] onIconifyWindowListeners; 2400 2401 /** 2402 * Emitted at the child application's request. 2403 */ 2404 gulong addOnIconifyWindow(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2405 { 2406 auto wrapper = new OnIconifyWindowDelegateWrapper(dlg); 2407 wrapper.handlerId = Signals.connectData( 2408 this, 2409 "iconify-window", 2410 cast(GCallback)&callBackIconifyWindow, 2411 cast(void*)wrapper, 2412 cast(GClosureNotify)&callBackIconifyWindowDestroy, 2413 connectFlags); 2414 return wrapper.handlerId; 2415 } 2416 2417 extern(C) static void callBackIconifyWindow(VteTerminal* terminalStruct, OnIconifyWindowDelegateWrapper wrapper) 2418 { 2419 wrapper.dlg(wrapper.outer); 2420 } 2421 2422 extern(C) static void callBackIconifyWindowDestroy(OnIconifyWindowDelegateWrapper wrapper, GClosure* closure) 2423 { 2424 wrapper.remove(wrapper); 2425 } 2426 2427 protected class OnIncreaseFontSizeDelegateWrapper 2428 { 2429 void delegate(Terminal) dlg; 2430 gulong handlerId; 2431 2432 this(void delegate(Terminal) dlg) 2433 { 2434 this.dlg = dlg; 2435 onIncreaseFontSizeListeners ~= this; 2436 } 2437 2438 void remove(OnIncreaseFontSizeDelegateWrapper source) 2439 { 2440 foreach(index, wrapper; onIncreaseFontSizeListeners) 2441 { 2442 if (wrapper.handlerId == source.handlerId) 2443 { 2444 onIncreaseFontSizeListeners[index] = null; 2445 onIncreaseFontSizeListeners = std.algorithm.remove(onIncreaseFontSizeListeners, index); 2446 break; 2447 } 2448 } 2449 } 2450 } 2451 OnIncreaseFontSizeDelegateWrapper[] onIncreaseFontSizeListeners; 2452 2453 /** 2454 * Emitted when the user hits the '+' key while holding the Control key. 2455 */ 2456 gulong addOnIncreaseFontSize(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2457 { 2458 auto wrapper = new OnIncreaseFontSizeDelegateWrapper(dlg); 2459 wrapper.handlerId = Signals.connectData( 2460 this, 2461 "increase-font-size", 2462 cast(GCallback)&callBackIncreaseFontSize, 2463 cast(void*)wrapper, 2464 cast(GClosureNotify)&callBackIncreaseFontSizeDestroy, 2465 connectFlags); 2466 return wrapper.handlerId; 2467 } 2468 2469 extern(C) static void callBackIncreaseFontSize(VteTerminal* terminalStruct, OnIncreaseFontSizeDelegateWrapper wrapper) 2470 { 2471 wrapper.dlg(wrapper.outer); 2472 } 2473 2474 extern(C) static void callBackIncreaseFontSizeDestroy(OnIncreaseFontSizeDelegateWrapper wrapper, GClosure* closure) 2475 { 2476 wrapper.remove(wrapper); 2477 } 2478 2479 protected class OnLowerWindowDelegateWrapper 2480 { 2481 void delegate(Terminal) dlg; 2482 gulong handlerId; 2483 2484 this(void delegate(Terminal) dlg) 2485 { 2486 this.dlg = dlg; 2487 onLowerWindowListeners ~= this; 2488 } 2489 2490 void remove(OnLowerWindowDelegateWrapper source) 2491 { 2492 foreach(index, wrapper; onLowerWindowListeners) 2493 { 2494 if (wrapper.handlerId == source.handlerId) 2495 { 2496 onLowerWindowListeners[index] = null; 2497 onLowerWindowListeners = std.algorithm.remove(onLowerWindowListeners, index); 2498 break; 2499 } 2500 } 2501 } 2502 } 2503 OnLowerWindowDelegateWrapper[] onLowerWindowListeners; 2504 2505 /** 2506 * Emitted at the child application's request. 2507 */ 2508 gulong addOnLowerWindow(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2509 { 2510 auto wrapper = new OnLowerWindowDelegateWrapper(dlg); 2511 wrapper.handlerId = Signals.connectData( 2512 this, 2513 "lower-window", 2514 cast(GCallback)&callBackLowerWindow, 2515 cast(void*)wrapper, 2516 cast(GClosureNotify)&callBackLowerWindowDestroy, 2517 connectFlags); 2518 return wrapper.handlerId; 2519 } 2520 2521 extern(C) static void callBackLowerWindow(VteTerminal* terminalStruct, OnLowerWindowDelegateWrapper wrapper) 2522 { 2523 wrapper.dlg(wrapper.outer); 2524 } 2525 2526 extern(C) static void callBackLowerWindowDestroy(OnLowerWindowDelegateWrapper wrapper, GClosure* closure) 2527 { 2528 wrapper.remove(wrapper); 2529 } 2530 2531 protected class OnMaximizeWindowDelegateWrapper 2532 { 2533 void delegate(Terminal) dlg; 2534 gulong handlerId; 2535 2536 this(void delegate(Terminal) dlg) 2537 { 2538 this.dlg = dlg; 2539 onMaximizeWindowListeners ~= this; 2540 } 2541 2542 void remove(OnMaximizeWindowDelegateWrapper source) 2543 { 2544 foreach(index, wrapper; onMaximizeWindowListeners) 2545 { 2546 if (wrapper.handlerId == source.handlerId) 2547 { 2548 onMaximizeWindowListeners[index] = null; 2549 onMaximizeWindowListeners = std.algorithm.remove(onMaximizeWindowListeners, index); 2550 break; 2551 } 2552 } 2553 } 2554 } 2555 OnMaximizeWindowDelegateWrapper[] onMaximizeWindowListeners; 2556 2557 /** 2558 * Emitted at the child application's request. 2559 */ 2560 gulong addOnMaximizeWindow(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2561 { 2562 auto wrapper = new OnMaximizeWindowDelegateWrapper(dlg); 2563 wrapper.handlerId = Signals.connectData( 2564 this, 2565 "maximize-window", 2566 cast(GCallback)&callBackMaximizeWindow, 2567 cast(void*)wrapper, 2568 cast(GClosureNotify)&callBackMaximizeWindowDestroy, 2569 connectFlags); 2570 return wrapper.handlerId; 2571 } 2572 2573 extern(C) static void callBackMaximizeWindow(VteTerminal* terminalStruct, OnMaximizeWindowDelegateWrapper wrapper) 2574 { 2575 wrapper.dlg(wrapper.outer); 2576 } 2577 2578 extern(C) static void callBackMaximizeWindowDestroy(OnMaximizeWindowDelegateWrapper wrapper, GClosure* closure) 2579 { 2580 wrapper.remove(wrapper); 2581 } 2582 2583 protected class OnMoveWindowDelegateWrapper 2584 { 2585 void delegate(uint, uint, Terminal) dlg; 2586 gulong handlerId; 2587 2588 this(void delegate(uint, uint, Terminal) dlg) 2589 { 2590 this.dlg = dlg; 2591 onMoveWindowListeners ~= this; 2592 } 2593 2594 void remove(OnMoveWindowDelegateWrapper source) 2595 { 2596 foreach(index, wrapper; onMoveWindowListeners) 2597 { 2598 if (wrapper.handlerId == source.handlerId) 2599 { 2600 onMoveWindowListeners[index] = null; 2601 onMoveWindowListeners = std.algorithm.remove(onMoveWindowListeners, index); 2602 break; 2603 } 2604 } 2605 } 2606 } 2607 OnMoveWindowDelegateWrapper[] onMoveWindowListeners; 2608 2609 /** 2610 * Emitted at the child application's request. 2611 * 2612 * Params: 2613 * x = the terminal's desired location, X coordinate 2614 * y = the terminal's desired location, Y coordinate 2615 */ 2616 gulong addOnMoveWindow(void delegate(uint, uint, Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2617 { 2618 auto wrapper = new OnMoveWindowDelegateWrapper(dlg); 2619 wrapper.handlerId = Signals.connectData( 2620 this, 2621 "move-window", 2622 cast(GCallback)&callBackMoveWindow, 2623 cast(void*)wrapper, 2624 cast(GClosureNotify)&callBackMoveWindowDestroy, 2625 connectFlags); 2626 return wrapper.handlerId; 2627 } 2628 2629 extern(C) static void callBackMoveWindow(VteTerminal* terminalStruct, uint x, uint y, OnMoveWindowDelegateWrapper wrapper) 2630 { 2631 wrapper.dlg(x, y, wrapper.outer); 2632 } 2633 2634 extern(C) static void callBackMoveWindowDestroy(OnMoveWindowDelegateWrapper wrapper, GClosure* closure) 2635 { 2636 wrapper.remove(wrapper); 2637 } 2638 2639 protected class OnPasteClipboardDelegateWrapper 2640 { 2641 void delegate(Terminal) dlg; 2642 gulong handlerId; 2643 2644 this(void delegate(Terminal) dlg) 2645 { 2646 this.dlg = dlg; 2647 onPasteClipboardListeners ~= this; 2648 } 2649 2650 void remove(OnPasteClipboardDelegateWrapper source) 2651 { 2652 foreach(index, wrapper; onPasteClipboardListeners) 2653 { 2654 if (wrapper.handlerId == source.handlerId) 2655 { 2656 onPasteClipboardListeners[index] = null; 2657 onPasteClipboardListeners = std.algorithm.remove(onPasteClipboardListeners, index); 2658 break; 2659 } 2660 } 2661 } 2662 } 2663 OnPasteClipboardDelegateWrapper[] onPasteClipboardListeners; 2664 2665 /** 2666 * Emitted whenever vte_terminal_paste_clipboard() is called. 2667 */ 2668 gulong addOnPasteClipboard(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2669 { 2670 auto wrapper = new OnPasteClipboardDelegateWrapper(dlg); 2671 wrapper.handlerId = Signals.connectData( 2672 this, 2673 "paste-clipboard", 2674 cast(GCallback)&callBackPasteClipboard, 2675 cast(void*)wrapper, 2676 cast(GClosureNotify)&callBackPasteClipboardDestroy, 2677 connectFlags); 2678 return wrapper.handlerId; 2679 } 2680 2681 extern(C) static void callBackPasteClipboard(VteTerminal* terminalStruct, OnPasteClipboardDelegateWrapper wrapper) 2682 { 2683 wrapper.dlg(wrapper.outer); 2684 } 2685 2686 extern(C) static void callBackPasteClipboardDestroy(OnPasteClipboardDelegateWrapper wrapper, GClosure* closure) 2687 { 2688 wrapper.remove(wrapper); 2689 } 2690 2691 protected class OnRaiseWindowDelegateWrapper 2692 { 2693 void delegate(Terminal) dlg; 2694 gulong handlerId; 2695 2696 this(void delegate(Terminal) dlg) 2697 { 2698 this.dlg = dlg; 2699 onRaiseWindowListeners ~= this; 2700 } 2701 2702 void remove(OnRaiseWindowDelegateWrapper source) 2703 { 2704 foreach(index, wrapper; onRaiseWindowListeners) 2705 { 2706 if (wrapper.handlerId == source.handlerId) 2707 { 2708 onRaiseWindowListeners[index] = null; 2709 onRaiseWindowListeners = std.algorithm.remove(onRaiseWindowListeners, index); 2710 break; 2711 } 2712 } 2713 } 2714 } 2715 OnRaiseWindowDelegateWrapper[] onRaiseWindowListeners; 2716 2717 /** 2718 * Emitted at the child application's request. 2719 */ 2720 gulong addOnRaiseWindow(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2721 { 2722 auto wrapper = new OnRaiseWindowDelegateWrapper(dlg); 2723 wrapper.handlerId = Signals.connectData( 2724 this, 2725 "raise-window", 2726 cast(GCallback)&callBackRaiseWindow, 2727 cast(void*)wrapper, 2728 cast(GClosureNotify)&callBackRaiseWindowDestroy, 2729 connectFlags); 2730 return wrapper.handlerId; 2731 } 2732 2733 extern(C) static void callBackRaiseWindow(VteTerminal* terminalStruct, OnRaiseWindowDelegateWrapper wrapper) 2734 { 2735 wrapper.dlg(wrapper.outer); 2736 } 2737 2738 extern(C) static void callBackRaiseWindowDestroy(OnRaiseWindowDelegateWrapper wrapper, GClosure* closure) 2739 { 2740 wrapper.remove(wrapper); 2741 } 2742 2743 protected class OnRefreshWindowDelegateWrapper 2744 { 2745 void delegate(Terminal) dlg; 2746 gulong handlerId; 2747 2748 this(void delegate(Terminal) dlg) 2749 { 2750 this.dlg = dlg; 2751 onRefreshWindowListeners ~= this; 2752 } 2753 2754 void remove(OnRefreshWindowDelegateWrapper source) 2755 { 2756 foreach(index, wrapper; onRefreshWindowListeners) 2757 { 2758 if (wrapper.handlerId == source.handlerId) 2759 { 2760 onRefreshWindowListeners[index] = null; 2761 onRefreshWindowListeners = std.algorithm.remove(onRefreshWindowListeners, index); 2762 break; 2763 } 2764 } 2765 } 2766 } 2767 OnRefreshWindowDelegateWrapper[] onRefreshWindowListeners; 2768 2769 /** 2770 * Emitted at the child application's request. 2771 */ 2772 gulong addOnRefreshWindow(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2773 { 2774 auto wrapper = new OnRefreshWindowDelegateWrapper(dlg); 2775 wrapper.handlerId = Signals.connectData( 2776 this, 2777 "refresh-window", 2778 cast(GCallback)&callBackRefreshWindow, 2779 cast(void*)wrapper, 2780 cast(GClosureNotify)&callBackRefreshWindowDestroy, 2781 connectFlags); 2782 return wrapper.handlerId; 2783 } 2784 2785 extern(C) static void callBackRefreshWindow(VteTerminal* terminalStruct, OnRefreshWindowDelegateWrapper wrapper) 2786 { 2787 wrapper.dlg(wrapper.outer); 2788 } 2789 2790 extern(C) static void callBackRefreshWindowDestroy(OnRefreshWindowDelegateWrapper wrapper, GClosure* closure) 2791 { 2792 wrapper.remove(wrapper); 2793 } 2794 2795 protected class OnResizeWindowDelegateWrapper 2796 { 2797 void delegate(uint, uint, Terminal) dlg; 2798 gulong handlerId; 2799 2800 this(void delegate(uint, uint, Terminal) dlg) 2801 { 2802 this.dlg = dlg; 2803 onResizeWindowListeners ~= this; 2804 } 2805 2806 void remove(OnResizeWindowDelegateWrapper source) 2807 { 2808 foreach(index, wrapper; onResizeWindowListeners) 2809 { 2810 if (wrapper.handlerId == source.handlerId) 2811 { 2812 onResizeWindowListeners[index] = null; 2813 onResizeWindowListeners = std.algorithm.remove(onResizeWindowListeners, index); 2814 break; 2815 } 2816 } 2817 } 2818 } 2819 OnResizeWindowDelegateWrapper[] onResizeWindowListeners; 2820 2821 /** 2822 * Emitted at the child application's request. 2823 * 2824 * Params: 2825 * width = the desired number of columns 2826 * height = the desired number of rows 2827 */ 2828 gulong addOnResizeWindow(void delegate(uint, uint, Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2829 { 2830 auto wrapper = new OnResizeWindowDelegateWrapper(dlg); 2831 wrapper.handlerId = Signals.connectData( 2832 this, 2833 "resize-window", 2834 cast(GCallback)&callBackResizeWindow, 2835 cast(void*)wrapper, 2836 cast(GClosureNotify)&callBackResizeWindowDestroy, 2837 connectFlags); 2838 return wrapper.handlerId; 2839 } 2840 2841 extern(C) static void callBackResizeWindow(VteTerminal* terminalStruct, uint width, uint height, OnResizeWindowDelegateWrapper wrapper) 2842 { 2843 wrapper.dlg(width, height, wrapper.outer); 2844 } 2845 2846 extern(C) static void callBackResizeWindowDestroy(OnResizeWindowDelegateWrapper wrapper, GClosure* closure) 2847 { 2848 wrapper.remove(wrapper); 2849 } 2850 2851 protected class OnRestoreWindowDelegateWrapper 2852 { 2853 void delegate(Terminal) dlg; 2854 gulong handlerId; 2855 2856 this(void delegate(Terminal) dlg) 2857 { 2858 this.dlg = dlg; 2859 onRestoreWindowListeners ~= this; 2860 } 2861 2862 void remove(OnRestoreWindowDelegateWrapper source) 2863 { 2864 foreach(index, wrapper; onRestoreWindowListeners) 2865 { 2866 if (wrapper.handlerId == source.handlerId) 2867 { 2868 onRestoreWindowListeners[index] = null; 2869 onRestoreWindowListeners = std.algorithm.remove(onRestoreWindowListeners, index); 2870 break; 2871 } 2872 } 2873 } 2874 } 2875 OnRestoreWindowDelegateWrapper[] onRestoreWindowListeners; 2876 2877 /** 2878 * Emitted at the child application's request. 2879 */ 2880 gulong addOnRestoreWindow(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2881 { 2882 auto wrapper = new OnRestoreWindowDelegateWrapper(dlg); 2883 wrapper.handlerId = Signals.connectData( 2884 this, 2885 "restore-window", 2886 cast(GCallback)&callBackRestoreWindow, 2887 cast(void*)wrapper, 2888 cast(GClosureNotify)&callBackRestoreWindowDestroy, 2889 connectFlags); 2890 return wrapper.handlerId; 2891 } 2892 2893 extern(C) static void callBackRestoreWindow(VteTerminal* terminalStruct, OnRestoreWindowDelegateWrapper wrapper) 2894 { 2895 wrapper.dlg(wrapper.outer); 2896 } 2897 2898 extern(C) static void callBackRestoreWindowDestroy(OnRestoreWindowDelegateWrapper wrapper, GClosure* closure) 2899 { 2900 wrapper.remove(wrapper); 2901 } 2902 2903 protected class OnSelectionChangedDelegateWrapper 2904 { 2905 void delegate(Terminal) dlg; 2906 gulong handlerId; 2907 2908 this(void delegate(Terminal) dlg) 2909 { 2910 this.dlg = dlg; 2911 onSelectionChangedListeners ~= this; 2912 } 2913 2914 void remove(OnSelectionChangedDelegateWrapper source) 2915 { 2916 foreach(index, wrapper; onSelectionChangedListeners) 2917 { 2918 if (wrapper.handlerId == source.handlerId) 2919 { 2920 onSelectionChangedListeners[index] = null; 2921 onSelectionChangedListeners = std.algorithm.remove(onSelectionChangedListeners, index); 2922 break; 2923 } 2924 } 2925 } 2926 } 2927 OnSelectionChangedDelegateWrapper[] onSelectionChangedListeners; 2928 2929 /** 2930 * Emitted whenever the contents of terminal's selection changes. 2931 */ 2932 gulong addOnSelectionChanged(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2933 { 2934 auto wrapper = new OnSelectionChangedDelegateWrapper(dlg); 2935 wrapper.handlerId = Signals.connectData( 2936 this, 2937 "selection-changed", 2938 cast(GCallback)&callBackSelectionChanged, 2939 cast(void*)wrapper, 2940 cast(GClosureNotify)&callBackSelectionChangedDestroy, 2941 connectFlags); 2942 return wrapper.handlerId; 2943 } 2944 2945 extern(C) static void callBackSelectionChanged(VteTerminal* terminalStruct, OnSelectionChangedDelegateWrapper wrapper) 2946 { 2947 wrapper.dlg(wrapper.outer); 2948 } 2949 2950 extern(C) static void callBackSelectionChangedDestroy(OnSelectionChangedDelegateWrapper wrapper, GClosure* closure) 2951 { 2952 wrapper.remove(wrapper); 2953 } 2954 2955 protected class OnTextDeletedDelegateWrapper 2956 { 2957 void delegate(Terminal) dlg; 2958 gulong handlerId; 2959 2960 this(void delegate(Terminal) dlg) 2961 { 2962 this.dlg = dlg; 2963 onTextDeletedListeners ~= this; 2964 } 2965 2966 void remove(OnTextDeletedDelegateWrapper source) 2967 { 2968 foreach(index, wrapper; onTextDeletedListeners) 2969 { 2970 if (wrapper.handlerId == source.handlerId) 2971 { 2972 onTextDeletedListeners[index] = null; 2973 onTextDeletedListeners = std.algorithm.remove(onTextDeletedListeners, index); 2974 break; 2975 } 2976 } 2977 } 2978 } 2979 OnTextDeletedDelegateWrapper[] onTextDeletedListeners; 2980 2981 /** 2982 * An internal signal used for communication between the terminal and 2983 * its accessibility peer. May not be emitted under certain 2984 * circumstances. 2985 */ 2986 gulong addOnTextDeleted(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2987 { 2988 auto wrapper = new OnTextDeletedDelegateWrapper(dlg); 2989 wrapper.handlerId = Signals.connectData( 2990 this, 2991 "text-deleted", 2992 cast(GCallback)&callBackTextDeleted, 2993 cast(void*)wrapper, 2994 cast(GClosureNotify)&callBackTextDeletedDestroy, 2995 connectFlags); 2996 return wrapper.handlerId; 2997 } 2998 2999 extern(C) static void callBackTextDeleted(VteTerminal* terminalStruct, OnTextDeletedDelegateWrapper wrapper) 3000 { 3001 wrapper.dlg(wrapper.outer); 3002 } 3003 3004 extern(C) static void callBackTextDeletedDestroy(OnTextDeletedDelegateWrapper wrapper, GClosure* closure) 3005 { 3006 wrapper.remove(wrapper); 3007 } 3008 3009 protected class OnTextInsertedDelegateWrapper 3010 { 3011 void delegate(Terminal) dlg; 3012 gulong handlerId; 3013 3014 this(void delegate(Terminal) dlg) 3015 { 3016 this.dlg = dlg; 3017 onTextInsertedListeners ~= this; 3018 } 3019 3020 void remove(OnTextInsertedDelegateWrapper source) 3021 { 3022 foreach(index, wrapper; onTextInsertedListeners) 3023 { 3024 if (wrapper.handlerId == source.handlerId) 3025 { 3026 onTextInsertedListeners[index] = null; 3027 onTextInsertedListeners = std.algorithm.remove(onTextInsertedListeners, index); 3028 break; 3029 } 3030 } 3031 } 3032 } 3033 OnTextInsertedDelegateWrapper[] onTextInsertedListeners; 3034 3035 /** 3036 * An internal signal used for communication between the terminal and 3037 * its accessibility peer. May not be emitted under certain 3038 * circumstances. 3039 */ 3040 gulong addOnTextInserted(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 3041 { 3042 auto wrapper = new OnTextInsertedDelegateWrapper(dlg); 3043 wrapper.handlerId = Signals.connectData( 3044 this, 3045 "text-inserted", 3046 cast(GCallback)&callBackTextInserted, 3047 cast(void*)wrapper, 3048 cast(GClosureNotify)&callBackTextInsertedDestroy, 3049 connectFlags); 3050 return wrapper.handlerId; 3051 } 3052 3053 extern(C) static void callBackTextInserted(VteTerminal* terminalStruct, OnTextInsertedDelegateWrapper wrapper) 3054 { 3055 wrapper.dlg(wrapper.outer); 3056 } 3057 3058 extern(C) static void callBackTextInsertedDestroy(OnTextInsertedDelegateWrapper wrapper, GClosure* closure) 3059 { 3060 wrapper.remove(wrapper); 3061 } 3062 3063 protected class OnTextModifiedDelegateWrapper 3064 { 3065 void delegate(Terminal) dlg; 3066 gulong handlerId; 3067 3068 this(void delegate(Terminal) dlg) 3069 { 3070 this.dlg = dlg; 3071 onTextModifiedListeners ~= this; 3072 } 3073 3074 void remove(OnTextModifiedDelegateWrapper source) 3075 { 3076 foreach(index, wrapper; onTextModifiedListeners) 3077 { 3078 if (wrapper.handlerId == source.handlerId) 3079 { 3080 onTextModifiedListeners[index] = null; 3081 onTextModifiedListeners = std.algorithm.remove(onTextModifiedListeners, index); 3082 break; 3083 } 3084 } 3085 } 3086 } 3087 OnTextModifiedDelegateWrapper[] onTextModifiedListeners; 3088 3089 /** 3090 * An internal signal used for communication between the terminal and 3091 * its accessibility peer. May not be emitted under certain 3092 * circumstances. 3093 */ 3094 gulong addOnTextModified(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 3095 { 3096 auto wrapper = new OnTextModifiedDelegateWrapper(dlg); 3097 wrapper.handlerId = Signals.connectData( 3098 this, 3099 "text-modified", 3100 cast(GCallback)&callBackTextModified, 3101 cast(void*)wrapper, 3102 cast(GClosureNotify)&callBackTextModifiedDestroy, 3103 connectFlags); 3104 return wrapper.handlerId; 3105 } 3106 3107 extern(C) static void callBackTextModified(VteTerminal* terminalStruct, OnTextModifiedDelegateWrapper wrapper) 3108 { 3109 wrapper.dlg(wrapper.outer); 3110 } 3111 3112 extern(C) static void callBackTextModifiedDestroy(OnTextModifiedDelegateWrapper wrapper, GClosure* closure) 3113 { 3114 wrapper.remove(wrapper); 3115 } 3116 3117 protected class OnTextScrolledDelegateWrapper 3118 { 3119 void delegate(int, Terminal) dlg; 3120 gulong handlerId; 3121 3122 this(void delegate(int, Terminal) dlg) 3123 { 3124 this.dlg = dlg; 3125 onTextScrolledListeners ~= this; 3126 } 3127 3128 void remove(OnTextScrolledDelegateWrapper source) 3129 { 3130 foreach(index, wrapper; onTextScrolledListeners) 3131 { 3132 if (wrapper.handlerId == source.handlerId) 3133 { 3134 onTextScrolledListeners[index] = null; 3135 onTextScrolledListeners = std.algorithm.remove(onTextScrolledListeners, index); 3136 break; 3137 } 3138 } 3139 } 3140 } 3141 OnTextScrolledDelegateWrapper[] onTextScrolledListeners; 3142 3143 /** 3144 * An internal signal used for communication between the terminal and 3145 * its accessibility peer. May not be emitted under certain 3146 * circumstances. 3147 * 3148 * Params: 3149 * delta = the number of lines scrolled 3150 */ 3151 gulong addOnTextScrolled(void delegate(int, Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 3152 { 3153 auto wrapper = new OnTextScrolledDelegateWrapper(dlg); 3154 wrapper.handlerId = Signals.connectData( 3155 this, 3156 "text-scrolled", 3157 cast(GCallback)&callBackTextScrolled, 3158 cast(void*)wrapper, 3159 cast(GClosureNotify)&callBackTextScrolledDestroy, 3160 connectFlags); 3161 return wrapper.handlerId; 3162 } 3163 3164 extern(C) static void callBackTextScrolled(VteTerminal* terminalStruct, int delta, OnTextScrolledDelegateWrapper wrapper) 3165 { 3166 wrapper.dlg(delta, wrapper.outer); 3167 } 3168 3169 extern(C) static void callBackTextScrolledDestroy(OnTextScrolledDelegateWrapper wrapper, GClosure* closure) 3170 { 3171 wrapper.remove(wrapper); 3172 } 3173 3174 protected class OnWindowTitleChangedDelegateWrapper 3175 { 3176 void delegate(Terminal) dlg; 3177 gulong handlerId; 3178 3179 this(void delegate(Terminal) dlg) 3180 { 3181 this.dlg = dlg; 3182 onWindowTitleChangedListeners ~= this; 3183 } 3184 3185 void remove(OnWindowTitleChangedDelegateWrapper source) 3186 { 3187 foreach(index, wrapper; onWindowTitleChangedListeners) 3188 { 3189 if (wrapper.handlerId == source.handlerId) 3190 { 3191 onWindowTitleChangedListeners[index] = null; 3192 onWindowTitleChangedListeners = std.algorithm.remove(onWindowTitleChangedListeners, index); 3193 break; 3194 } 3195 } 3196 } 3197 } 3198 OnWindowTitleChangedDelegateWrapper[] onWindowTitleChangedListeners; 3199 3200 /** 3201 * Emitted when the terminal's %window_title field is modified. 3202 */ 3203 gulong addOnWindowTitleChanged(void delegate(Terminal) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 3204 { 3205 auto wrapper = new OnWindowTitleChangedDelegateWrapper(dlg); 3206 wrapper.handlerId = Signals.connectData( 3207 this, 3208 "window-title-changed", 3209 cast(GCallback)&callBackWindowTitleChanged, 3210 cast(void*)wrapper, 3211 cast(GClosureNotify)&callBackWindowTitleChangedDestroy, 3212 connectFlags); 3213 return wrapper.handlerId; 3214 } 3215 3216 extern(C) static void callBackWindowTitleChanged(VteTerminal* terminalStruct, OnWindowTitleChangedDelegateWrapper wrapper) 3217 { 3218 wrapper.dlg(wrapper.outer); 3219 } 3220 3221 extern(C) static void callBackWindowTitleChangedDestroy(OnWindowTitleChangedDelegateWrapper wrapper, GClosure* closure) 3222 { 3223 wrapper.remove(wrapper); 3224 } 3225 3226 /** 3227 * Gets the user's shell, or %NULL. In the latter case, the 3228 * system default (usually "/bin/sh") should be used. 3229 * 3230 * Returns: a newly allocated string with the 3231 * user's shell, or %NULL 3232 */ 3233 public static string getUserShell() 3234 { 3235 auto retStr = vte_get_user_shell(); 3236 3237 scope(exit) Str.freeString(retStr); 3238 return Str.toString(retStr); 3239 } 3240 }