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