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