1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::TextChildAnchor;
use crate::TextIter;
use crate::TextMark;
use crate::TextTag;
use crate::TextTagTable;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib::wrapper! {
/// Stores text and attributes for display in a [`TextView`][crate::TextView].
///
/// You may wish to begin by reading the
/// [text widget conceptual overview](section-text-widget.html),
/// which gives an overview of all the objects and data types
/// related to the text widget and how they work together.
///
/// GtkTextBuffer can support undoing changes to the buffer
/// content, see [`TextBufferExt::set_enable_undo()`][crate::prelude::TextBufferExt::set_enable_undo()].
///
/// # Implements
///
/// [`TextBufferExt`][trait@crate::prelude::TextBufferExt], [`trait@glib::ObjectExt`], [`TextBufferExtManual`][trait@crate::prelude::TextBufferExtManual]
#[doc(alias = "GtkTextBuffer")]
pub struct TextBuffer(Object<ffi::GtkTextBuffer, ffi::GtkTextBufferClass>);
match fn {
type_ => || ffi::gtk_text_buffer_get_type(),
}
}
impl TextBuffer {
pub const NONE: Option<&'static TextBuffer> = None;
/// Creates a new text buffer.
/// ## `table`
/// a tag table, or [`None`] to create a new one
///
/// # Returns
///
/// a new text buffer
#[doc(alias = "gtk_text_buffer_new")]
pub fn new(table: Option<&TextTagTable>) -> TextBuffer {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gtk_text_buffer_new(table.to_glib_none().0)) }
}
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`TextBuffer`] objects.
///
/// This method returns an instance of [`TextBufferBuilder`](crate::builders::TextBufferBuilder) which can be used to create [`TextBuffer`] objects.
pub fn builder() -> TextBufferBuilder {
TextBufferBuilder::default()
}
}
impl Default for TextBuffer {
fn default() -> Self {
glib::object::Object::new::<Self>(&[])
.expect("Can't construct TextBuffer object with default parameters")
}
}
#[derive(Clone, Default)]
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`TextBuffer`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct TextBufferBuilder {
enable_undo: Option<bool>,
tag_table: Option<TextTagTable>,
text: Option<String>,
}
impl TextBufferBuilder {
// rustdoc-stripper-ignore-next
/// Create a new [`TextBufferBuilder`].
pub fn new() -> Self {
Self::default()
}
// rustdoc-stripper-ignore-next
/// Build the [`TextBuffer`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> TextBuffer {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
if let Some(ref enable_undo) = self.enable_undo {
properties.push(("enable-undo", enable_undo));
}
if let Some(ref tag_table) = self.tag_table {
properties.push(("tag-table", tag_table));
}
if let Some(ref text) = self.text {
properties.push(("text", text));
}
glib::Object::new::<TextBuffer>(&properties)
.expect("Failed to create an instance of TextBuffer")
}
/// Denotes if support for undoing and redoing changes to the buffer is allowed.
pub fn enable_undo(mut self, enable_undo: bool) -> Self {
self.enable_undo = Some(enable_undo);
self
}
/// The GtkTextTagTable for the buffer.
pub fn tag_table(mut self, tag_table: &TextTagTable) -> Self {
self.tag_table = Some(tag_table.clone());
self
}
/// The text content of the buffer.
///
/// Without child widgets and images,
/// see [`TextBufferExt::text()`][crate::prelude::TextBufferExt::text()] for more information.
pub fn text(mut self, text: &str) -> Self {
self.text = Some(text.to_string());
self
}
}
/// Trait containing all [`struct@TextBuffer`] methods.
///
/// # Implementors
///
/// [`TextBuffer`][struct@crate::TextBuffer]
pub trait TextBufferExt: 'static {
/// Adds the mark at position @where_.
///
/// The mark must not be added to another buffer, and if its name
/// is not [`None`] then there must not be another mark in the buffer
/// with the same name.
///
/// Emits the `signal::TextBuffer::mark-set` signal as notification
/// of the mark's initial placement.
/// ## `mark`
/// the mark to add
/// ## `where_`
/// location to place mark
#[doc(alias = "gtk_text_buffer_add_mark")]
fn add_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter);
/// Adds @clipboard to the list of clipboards in which the selection
/// contents of @self are available.
///
/// In most cases, @clipboard will be the [`gdk::Clipboard`][crate::gdk::Clipboard] returned by
/// [`WidgetExt::primary_clipboard()`][crate::prelude::WidgetExt::primary_clipboard()] for a view of @self.
/// ## `clipboard`
/// a [`gdk::Clipboard`][crate::gdk::Clipboard]
#[doc(alias = "gtk_text_buffer_add_selection_clipboard")]
fn add_selection_clipboard(&self, clipboard: &gdk::Clipboard);
/// Emits the “apply-tag” signal on @self.
///
/// The default handler for the signal applies
/// @tag to the given range. @start and @end do
/// not have to be in order.
/// ## `tag`
/// a [`TextTag`][crate::TextTag]
/// ## `start`
/// one bound of range to be tagged
/// ## `end`
/// other bound of range to be tagged
#[doc(alias = "gtk_text_buffer_apply_tag")]
fn apply_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter);
/// Emits the “apply-tag” signal on @self.
///
/// Calls [`TextTagTable::lookup()`][crate::TextTagTable::lookup()] on the buffer’s
/// tag table to get a [`TextTag`][crate::TextTag], then calls
/// [`apply_tag()`][Self::apply_tag()].
/// ## `name`
/// name of a named [`TextTag`][crate::TextTag]
/// ## `start`
/// one bound of range to be tagged
/// ## `end`
/// other bound of range to be tagged
#[doc(alias = "gtk_text_buffer_apply_tag_by_name")]
fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter);
/// Performs the appropriate action as if the user hit the delete
/// key with the cursor at the position specified by @iter.
///
/// In the normal case a single character will be deleted, but when
/// combining accents are involved, more than one character can
/// be deleted, and when precomposed character and accent combinations
/// are involved, less than one character will be deleted.
///
/// Because the buffer is modified, all outstanding iterators become
/// invalid after calling this function; however, the @iter will be
/// re-initialized to point to the location where text was deleted.
/// ## `iter`
/// a position in @self
/// ## `interactive`
/// whether the deletion is caused by user interaction
/// ## `default_editable`
/// whether the buffer is editable by default
///
/// # Returns
///
/// [`true`] if the buffer was modified
#[doc(alias = "gtk_text_buffer_backspace")]
fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool;
/// Denotes the beginning of an action that may not be undone.
///
/// This will cause any previous operations in the undo/redo queue
/// to be cleared.
///
/// This should be paired with a call to
/// [`end_irreversible_action()`][Self::end_irreversible_action()] after the irreversible
/// action has completed.
///
/// You may nest calls to gtk_text_buffer_begin_irreversible_action()
/// and gtk_text_buffer_end_irreversible_action() pairs.
#[doc(alias = "gtk_text_buffer_begin_irreversible_action")]
fn begin_irreversible_action(&self);
/// Called to indicate that the buffer operations between here and a
/// call to gtk_text_buffer_end_user_action() are part of a single
/// user-visible operation.
///
/// The operations between gtk_text_buffer_begin_user_action() and
/// gtk_text_buffer_end_user_action() can then be grouped when creating
/// an undo stack. [`TextBuffer`][crate::TextBuffer] maintains a count of calls to
/// gtk_text_buffer_begin_user_action() that have not been closed with
/// a call to gtk_text_buffer_end_user_action(), and emits the
/// “begin-user-action” and “end-user-action” signals only for the
/// outermost pair of calls. This allows you to build user actions
/// from other user actions.
///
/// The “interactive” buffer mutation functions, such as
/// [`insert_interactive()`][Self::insert_interactive()], automatically call
/// begin/end user action around the buffer operations they perform,
/// so there's no need to add extra calls if you user action consists
/// solely of a single call to one of those functions.
#[doc(alias = "gtk_text_buffer_begin_user_action")]
fn begin_user_action(&self);
/// Copies the currently-selected text to a clipboard.
/// ## `clipboard`
/// the [`gdk::Clipboard`][crate::gdk::Clipboard] object to copy to
#[doc(alias = "gtk_text_buffer_copy_clipboard")]
fn copy_clipboard(&self, clipboard: &gdk::Clipboard);
/// Creates and inserts a child anchor.
///
/// This is a convenience function which simply creates a child anchor
/// with [`TextChildAnchor::new()`][crate::TextChildAnchor::new()] and inserts it into the buffer
/// with [`insert_child_anchor()`][Self::insert_child_anchor()].
///
/// The new anchor is owned by the buffer; no reference count is
/// returned to the caller of this function.
/// ## `iter`
/// location in the buffer
///
/// # Returns
///
/// the created child anchor
#[doc(alias = "gtk_text_buffer_create_child_anchor")]
fn create_child_anchor(&self, iter: &mut TextIter) -> TextChildAnchor;
/// Creates a mark at position @where_.
///
/// If @mark_name is [`None`], the mark is anonymous; otherwise, the mark
/// can be retrieved by name using [`mark()`][Self::mark()].
/// If a mark has left gravity, and text is inserted at the mark’s
/// current location, the mark will be moved to the left of the
/// newly-inserted text. If the mark has right gravity
/// (@left_gravity = [`false`]), the mark will end up on the right of
/// newly-inserted text. The standard left-to-right cursor is a mark
/// with right gravity (when you type, the cursor stays on the right
/// side of the text you’re typing).
///
/// The caller of this function does not own a
/// reference to the returned [`TextMark`][crate::TextMark], so you can ignore the
/// return value if you like. Marks are owned by the buffer and go
/// away when the buffer does.
///
/// Emits the `signal::TextBuffer::mark-set` signal as notification
/// of the mark's initial placement.
/// ## `mark_name`
/// name for mark
/// ## `where_`
/// location to place mark
/// ## `left_gravity`
/// whether the mark has left gravity
///
/// # Returns
///
/// the new [`TextMark`][crate::TextMark] object
#[doc(alias = "gtk_text_buffer_create_mark")]
fn create_mark(
&self,
mark_name: Option<&str>,
where_: &TextIter,
left_gravity: bool,
) -> TextMark;
/// Copies the currently-selected text to a clipboard,
/// then deletes said text if it’s editable.
/// ## `clipboard`
/// the [`gdk::Clipboard`][crate::gdk::Clipboard] object to cut to
/// ## `default_editable`
/// default editability of the buffer
#[doc(alias = "gtk_text_buffer_cut_clipboard")]
fn cut_clipboard(&self, clipboard: &gdk::Clipboard, default_editable: bool);
/// Deletes text between @start and @end.
///
/// The order of @start and @end is not actually relevant;
/// gtk_text_buffer_delete() will reorder them.
///
/// This function actually emits the “delete-range” signal, and
/// the default handler of that signal deletes the text. Because the
/// buffer is modified, all outstanding iterators become invalid after
/// calling this function; however, the @start and @end will be
/// re-initialized to point to the location where text was deleted.
/// ## `start`
/// a position in @self
/// ## `end`
/// another position in @self
#[doc(alias = "gtk_text_buffer_delete")]
fn delete(&self, start: &mut TextIter, end: &mut TextIter);
/// Deletes all editable text in the given range.
///
/// Calls [`delete()`][Self::delete()] for each editable
/// sub-range of [@start,@end). @start and @end are revalidated
/// to point to the location of the last deleted range, or left
/// untouched if no text was deleted.
/// ## `start_iter`
/// start of range to delete
/// ## `end_iter`
/// end of range
/// ## `default_editable`
/// whether the buffer is editable by default
///
/// # Returns
///
/// whether some text was actually deleted
#[doc(alias = "gtk_text_buffer_delete_interactive")]
fn delete_interactive(
&self,
start_iter: &mut TextIter,
end_iter: &mut TextIter,
default_editable: bool,
) -> bool;
/// Deletes @mark, so that it’s no longer located anywhere in the
/// buffer.
///
/// Removes the reference the buffer holds to the mark, so if
/// you haven’t called g_object_ref() on the mark, it will be freed.
/// Even if the mark isn’t freed, most operations on @mark become
/// invalid, until it gets added to a buffer again with
/// [`add_mark()`][Self::add_mark()]. Use [`TextMarkExt::is_deleted()`][crate::prelude::TextMarkExt::is_deleted()]
/// to find out if a mark has been removed from its buffer.
///
/// The `signal::TextBuffer::mark-deleted` signal will be emitted as
/// notification after the mark is deleted.
/// ## `mark`
/// a [`TextMark`][crate::TextMark] in @self
#[doc(alias = "gtk_text_buffer_delete_mark")]
fn delete_mark(&self, mark: &impl IsA<TextMark>);
/// Deletes the mark named @name; the mark must exist.
///
/// See [`delete_mark()`][Self::delete_mark()] for details.
/// ## `name`
/// name of a mark in @self
#[doc(alias = "gtk_text_buffer_delete_mark_by_name")]
fn delete_mark_by_name(&self, name: &str);
/// Deletes the range between the “insert” and “selection_bound” marks,
/// that is, the currently-selected text.
///
/// If @interactive is [`true`], the editability of the selection will be
/// considered (users can’t delete uneditable text).
/// ## `interactive`
/// whether the deletion is caused by user interaction
/// ## `default_editable`
/// whether the buffer is editable by default
///
/// # Returns
///
/// whether there was a non-empty selection to delete
#[doc(alias = "gtk_text_buffer_delete_selection")]
fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool;
/// Denotes the end of an action that may not be undone.
///
/// This will cause any previous operations in the undo/redo
/// queue to be cleared.
///
/// This should be called after completing modifications to the
/// text buffer after [`begin_irreversible_action()`][Self::begin_irreversible_action()]
/// was called.
///
/// You may nest calls to gtk_text_buffer_begin_irreversible_action()
/// and gtk_text_buffer_end_irreversible_action() pairs.
#[doc(alias = "gtk_text_buffer_end_irreversible_action")]
fn end_irreversible_action(&self);
/// Ends a user-visible operation.
///
/// Should be paired with a call to
/// [`begin_user_action()`][Self::begin_user_action()].
/// See that function for a full explanation.
#[doc(alias = "gtk_text_buffer_end_user_action")]
fn end_user_action(&self);
/// Retrieves the first and last iterators in the buffer, i.e. the
/// entire buffer lies within the range [@start,@end).
///
/// # Returns
///
///
/// ## `start`
/// iterator to initialize with first position in the buffer
///
/// ## `end`
/// iterator to initialize with the end iterator
#[doc(alias = "gtk_text_buffer_get_bounds")]
#[doc(alias = "get_bounds")]
fn bounds(&self) -> (TextIter, TextIter);
/// Gets whether there is a redoable action in the history.
///
/// # Returns
///
/// [`true`] if there is an redoable action
#[doc(alias = "gtk_text_buffer_get_can_redo")]
#[doc(alias = "get_can_redo")]
fn can_redo(&self) -> bool;
/// Gets whether there is an undoable action in the history.
///
/// # Returns
///
/// [`true`] if there is an undoable action
#[doc(alias = "gtk_text_buffer_get_can_undo")]
#[doc(alias = "get_can_undo")]
fn can_undo(&self) -> bool;
/// Gets the number of characters in the buffer.
///
/// Note that characters and bytes are not the same, you can’t e.g.
/// expect the contents of the buffer in string form to be this
/// many bytes long.
///
/// The character count is cached, so this function is very fast.
///
/// # Returns
///
/// number of characters in the buffer
#[doc(alias = "gtk_text_buffer_get_char_count")]
#[doc(alias = "get_char_count")]
fn char_count(&self) -> i32;
/// Gets whether the buffer is saving modifications to the buffer
/// to allow for undo and redo actions.
///
/// See [`begin_irreversible_action()`][Self::begin_irreversible_action()] and
/// [`end_irreversible_action()`][Self::end_irreversible_action()] to create
/// changes to the buffer that cannot be undone.
#[doc(alias = "gtk_text_buffer_get_enable_undo")]
#[doc(alias = "get_enable_undo")]
fn enables_undo(&self) -> bool;
/// Initializes @iter with the “end iterator,” one past the last valid
/// character in the text buffer.
///
/// If dereferenced with [`TextIter::char()`][crate::TextIter::char()], the end
/// iterator has a character value of 0.
/// The entire buffer lies in the range from the first position in
/// the buffer (call [`start_iter()`][Self::start_iter()] to get
/// character position 0) to the end iterator.
///
/// # Returns
///
///
/// ## `iter`
/// iterator to initialize
#[doc(alias = "gtk_text_buffer_get_end_iter")]
#[doc(alias = "get_end_iter")]
fn end_iter(&self) -> TextIter;
/// Indicates whether the buffer has some text currently selected.
///
/// # Returns
///
/// [`true`] if the there is text selected
#[doc(alias = "gtk_text_buffer_get_has_selection")]
#[doc(alias = "get_has_selection")]
fn has_selection(&self) -> bool;
/// Returns the mark that represents the cursor (insertion point).
///
/// Equivalent to calling [`mark()`][Self::mark()]
/// to get the mark named “insert”, but very slightly more
/// efficient, and involves less typing.
///
/// # Returns
///
/// insertion point mark
#[doc(alias = "gtk_text_buffer_get_insert")]
fn get_insert(&self) -> TextMark;
/// Obtains the location of @anchor within @self.
/// ## `anchor`
/// a child anchor that appears in @self
///
/// # Returns
///
///
/// ## `iter`
/// an iterator to be initialized
#[doc(alias = "gtk_text_buffer_get_iter_at_child_anchor")]
#[doc(alias = "get_iter_at_child_anchor")]
fn iter_at_child_anchor(&self, anchor: &impl IsA<TextChildAnchor>) -> TextIter;
/// Initializes @iter to the start of the given line.
///
/// If @line_number is greater than or equal to the number of lines
/// in the @self, the end iterator is returned.
/// ## `line_number`
/// line number counting from 0
///
/// # Returns
///
/// whether the exact position has been found
///
/// ## `iter`
/// iterator to initialize
#[doc(alias = "gtk_text_buffer_get_iter_at_line")]
#[doc(alias = "get_iter_at_line")]
fn iter_at_line(&self, line_number: i32) -> Option<TextIter>;
/// Obtains an iterator pointing to @byte_index within the given line.
///
/// @byte_index must be the start of a UTF-8 character. Note bytes, not
/// characters; UTF-8 may encode one character as multiple bytes.
///
/// If @line_number is greater than or equal to the number of lines in the @self,
/// the end iterator is returned. And if @byte_index is off the
/// end of the line, the iterator at the end of the line is returned.
/// ## `line_number`
/// line number counting from 0
/// ## `byte_index`
/// byte index from start of line
///
/// # Returns
///
/// whether the exact position has been found
///
/// ## `iter`
/// iterator to initialize
#[doc(alias = "gtk_text_buffer_get_iter_at_line_index")]
#[doc(alias = "get_iter_at_line_index")]
fn iter_at_line_index(&self, line_number: i32, byte_index: i32) -> Option<TextIter>;
/// Obtains an iterator pointing to @char_offset within the given line.
///
/// Note characters, not bytes; UTF-8 may encode one character as multiple
/// bytes.
///
/// If @line_number is greater than or equal to the number of lines in the @self,
/// the end iterator is returned. And if @char_offset is off the
/// end of the line, the iterator at the end of the line is returned.
/// ## `line_number`
/// line number counting from 0
/// ## `char_offset`
/// char offset from start of line
///
/// # Returns
///
/// whether the exact position has been found
///
/// ## `iter`
/// iterator to initialize
#[doc(alias = "gtk_text_buffer_get_iter_at_line_offset")]
#[doc(alias = "get_iter_at_line_offset")]
fn iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> Option<TextIter>;
/// Initializes @iter with the current position of @mark.
/// ## `mark`
/// a [`TextMark`][crate::TextMark] in @self
///
/// # Returns
///
///
/// ## `iter`
/// iterator to initialize
#[doc(alias = "gtk_text_buffer_get_iter_at_mark")]
#[doc(alias = "get_iter_at_mark")]
fn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter;
/// Initializes @iter to a position @char_offset chars from the start
/// of the entire buffer.
///
/// If @char_offset is -1 or greater than the number
/// of characters in the buffer, @iter is initialized to the end iterator,
/// the iterator one past the last valid character in the buffer.
/// ## `char_offset`
/// char offset from start of buffer, counting from 0, or -1
///
/// # Returns
///
///
/// ## `iter`
/// iterator to initialize
#[doc(alias = "gtk_text_buffer_get_iter_at_offset")]
#[doc(alias = "get_iter_at_offset")]
fn iter_at_offset(&self, char_offset: i32) -> TextIter;
/// Obtains the number of lines in the buffer.
///
/// This value is cached, so the function is very fast.
///
/// # Returns
///
/// number of lines in the buffer
#[doc(alias = "gtk_text_buffer_get_line_count")]
#[doc(alias = "get_line_count")]
fn line_count(&self) -> i32;
/// Returns the mark named @name in buffer @self, or [`None`] if no such
/// mark exists in the buffer.
/// ## `name`
/// a mark name
///
/// # Returns
///
/// a [`TextMark`][crate::TextMark]
#[doc(alias = "gtk_text_buffer_get_mark")]
#[doc(alias = "get_mark")]
fn mark(&self, name: &str) -> Option<TextMark>;
/// Gets the maximum number of undo levels to perform.
///
/// If 0, unlimited undo actions may be performed. Note that this may
/// have a memory usage impact as it requires storing an additional
/// copy of the inserted or removed text within the text buffer.
#[doc(alias = "gtk_text_buffer_get_max_undo_levels")]
#[doc(alias = "get_max_undo_levels")]
fn max_undo_levels(&self) -> u32;
/// Indicates whether the buffer has been modified since the last call
/// to [`set_modified()`][Self::set_modified()] set the modification flag to
/// [`false`].
///
/// Used for example to enable a “save” function in a text editor.
///
/// # Returns
///
/// [`true`] if the buffer has been modified
#[doc(alias = "gtk_text_buffer_get_modified")]
#[doc(alias = "get_modified")]
fn is_modified(&self) -> bool;
/// Returns the mark that represents the selection bound.
///
/// Equivalent to calling [`mark()`][Self::mark()]
/// to get the mark named “selection_bound”, but very slightly
/// more efficient, and involves less typing.
///
/// The currently-selected text in @self is the region between the
/// “selection_bound” and “insert” marks. If “selection_bound” and
/// “insert” are in the same place, then there is no current selection.
/// [`selection_bounds()`][Self::selection_bounds()] is another convenient
/// function for handling the selection, if you just want to know whether
/// there’s a selection and what its bounds are.
///
/// # Returns
///
/// selection bound mark
#[doc(alias = "gtk_text_buffer_get_selection_bound")]
#[doc(alias = "get_selection_bound")]
fn selection_bound(&self) -> TextMark;
/// Returns [`true`] if some text is selected; places the bounds
/// of the selection in @start and @end.
///
/// If the selection has length 0, then @start and @end are filled
/// in with the same value. @start and @end will be in ascending order.
/// If @start and @end are [`None`], then they are not filled in, but the
/// return value still indicates whether text is selected.
///
/// # Returns
///
/// whether the selection has nonzero length
///
/// ## `start`
/// iterator to initialize with selection start
///
/// ## `end`
/// iterator to initialize with selection end
#[doc(alias = "gtk_text_buffer_get_selection_bounds")]
#[doc(alias = "get_selection_bounds")]
fn selection_bounds(&self) -> Option<(TextIter, TextIter)>;
/// Get a content provider for this buffer.
///
/// It can be used to make the content of @self available
/// in a [`gdk::Clipboard`][crate::gdk::Clipboard], see [`Clipboard::set_content()`][crate::gdk::Clipboard::set_content()].
///
/// # Returns
///
/// a new [`gdk::ContentProvider`][crate::gdk::ContentProvider].
#[doc(alias = "gtk_text_buffer_get_selection_content")]
#[doc(alias = "get_selection_content")]
fn selection_content(&self) -> gdk::ContentProvider;
/// Returns the text in the range [@start,@end).
///
/// Excludes undisplayed text (text marked with tags that set the
/// invisibility attribute) if @include_hidden_chars is [`false`].
/// The returned string includes a 0xFFFC character whenever the
/// buffer contains embedded images, so byte and character indexes
/// into the returned string do correspond to byte and character
/// indexes into the buffer. Contrast with [`text()`][Self::text()].
/// Note that 0xFFFC can occur in normal text as well, so it is not a
/// reliable indicator that a paintable or widget is in the buffer.
/// ## `start`
/// start of a range
/// ## `end`
/// end of a range
/// ## `include_hidden_chars`
/// whether to include invisible text
///
/// # Returns
///
/// an allocated UTF-8 string
#[doc(alias = "gtk_text_buffer_get_slice")]
#[doc(alias = "get_slice")]
fn slice(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString;
/// Initialized @iter with the first position in the text buffer.
///
/// This is the same as using [`iter_at_offset()`][Self::iter_at_offset()]
/// to get the iter at character offset 0.
///
/// # Returns
///
///
/// ## `iter`
/// iterator to initialize
#[doc(alias = "gtk_text_buffer_get_start_iter")]
#[doc(alias = "get_start_iter")]
fn start_iter(&self) -> TextIter;
/// Get the [`TextTagTable`][crate::TextTagTable] associated with this buffer.
///
/// # Returns
///
/// the buffer’s tag table
#[doc(alias = "gtk_text_buffer_get_tag_table")]
#[doc(alias = "get_tag_table")]
fn tag_table(&self) -> TextTagTable;
/// Returns the text in the range [@start,@end).
///
/// Excludes undisplayed text (text marked with tags that set the
/// invisibility attribute) if @include_hidden_chars is [`false`].
/// Does not include characters representing embedded images, so
/// byte and character indexes into the returned string do not
/// correspond to byte and character indexes into the buffer.
/// Contrast with [`slice()`][Self::slice()].
/// ## `start`
/// start of a range
/// ## `end`
/// end of a range
/// ## `include_hidden_chars`
/// whether to include invisible text
///
/// # Returns
///
/// an allocated UTF-8 string
#[doc(alias = "gtk_text_buffer_get_text")]
#[doc(alias = "get_text")]
fn text(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString;
/// Inserts @len bytes of @text at position @iter.
///
/// If @len is -1, @text must be nul-terminated and will be inserted in its
/// entirety. Emits the “insert-text” signal; insertion actually occurs
/// in the default handler for the signal. @iter is invalidated when
/// insertion occurs (because the buffer contents change), but the
/// default signal handler revalidates it to point to the end of the
/// inserted text.
/// ## `iter`
/// a position in the buffer
/// ## `text`
/// text in UTF-8 format
/// ## `len`
/// length of text in bytes, or -1
#[doc(alias = "gtk_text_buffer_insert")]
fn insert(&self, iter: &mut TextIter, text: &str);
/// Inserts @text in @self.
///
/// Simply calls [`insert()`][Self::insert()],
/// using the current cursor position as the insertion point.
/// ## `text`
/// text in UTF-8 format
/// ## `len`
/// length of text, in bytes
#[doc(alias = "gtk_text_buffer_insert_at_cursor")]
fn insert_at_cursor(&self, text: &str);
/// Inserts a child widget anchor into the text buffer at @iter.
///
/// The anchor will be counted as one character in character counts, and
/// when obtaining the buffer contents as a string, will be represented
/// by the Unicode “object replacement character” 0xFFFC. Note that the
/// “slice” variants for obtaining portions of the buffer as a string
/// include this character for child anchors, but the “text” variants do
/// not. E.g. see [`slice()`][Self::slice()] and
/// [`text()`][Self::text()].
///
/// Consider [`create_child_anchor()`][Self::create_child_anchor()] as a more
/// convenient alternative to this function. The buffer will add a
/// reference to the anchor, so you can unref it after insertion.
/// ## `iter`
/// location to insert the anchor
/// ## `anchor`
/// a [`TextChildAnchor`][crate::TextChildAnchor]
#[doc(alias = "gtk_text_buffer_insert_child_anchor")]
fn insert_child_anchor(&self, iter: &mut TextIter, anchor: &impl IsA<TextChildAnchor>);
/// Inserts @text in @self.
///
/// Like [`insert()`][Self::insert()], but the insertion will not occur
/// if @iter is at a non-editable location in the buffer. Usually you
/// want to prevent insertions at ineditable locations if the insertion
/// results from a user action (is interactive).
///
/// @default_editable indicates the editability of text that doesn't
/// have a tag affecting editability applied to it. Typically the
/// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
/// ## `iter`
/// a position in @self
/// ## `text`
/// some UTF-8 text
/// ## `len`
/// length of text in bytes, or -1
/// ## `default_editable`
/// default editability of buffer
///
/// # Returns
///
/// whether text was actually inserted
#[doc(alias = "gtk_text_buffer_insert_interactive")]
fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool;
/// Inserts @text in @self.
///
/// Calls [`insert_interactive()`][Self::insert_interactive()]
/// at the cursor position.
///
/// @default_editable indicates the editability of text that doesn't
/// have a tag affecting editability applied to it. Typically the
/// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
/// ## `text`
/// text in UTF-8 format
/// ## `len`
/// length of text in bytes, or -1
/// ## `default_editable`
/// default editability of buffer
///
/// # Returns
///
/// whether text was actually inserted
#[doc(alias = "gtk_text_buffer_insert_interactive_at_cursor")]
fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool;
/// Inserts the text in @markup at position @iter.
///
/// @markup will be inserted in its entirety and must be nul-terminated
/// and valid UTF-8. Emits the `signal::TextBuffer::insert-text` signal,
/// possibly multiple times; insertion actually occurs in the default handler
/// for the signal. @iter will point to the end of the inserted text on return.
/// ## `iter`
/// location to insert the markup
/// ## `markup`
/// a nul-terminated UTF-8 string containing Pango markup
/// ## `len`
/// length of @markup in bytes, or -1
#[doc(alias = "gtk_text_buffer_insert_markup")]
fn insert_markup(&self, iter: &mut TextIter, markup: &str);
/// Inserts an image into the text buffer at @iter.
///
/// The image will be counted as one character in character counts,
/// and when obtaining the buffer contents as a string, will be
/// represented by the Unicode “object replacement character” 0xFFFC.
/// Note that the “slice” variants for obtaining portions of the buffer
/// as a string include this character for paintable, but the “text”
/// variants do not. e.g. see [`slice()`][Self::slice()] and
/// [`text()`][Self::text()].
/// ## `iter`
/// location to insert the paintable
/// ## `paintable`
/// a [`gdk::Paintable`][crate::gdk::Paintable]
#[doc(alias = "gtk_text_buffer_insert_paintable")]
fn insert_paintable(&self, iter: &mut TextIter, paintable: &impl IsA<gdk::Paintable>);
/// Copies text, tags, and paintables between @start and @end
/// and inserts the copy at @iter.
///
/// The order of @start and @end doesn’t matter.
///
/// Used instead of simply getting/inserting text because it preserves
/// images and tags. If @start and @end are in a different buffer from
/// @self, the two buffers must share the same tag table.
///
/// Implemented via emissions of the ::insert-text and ::apply-tag signals,
/// so expect those.
/// ## `iter`
/// a position in @self
/// ## `start`
/// a position in a [`TextBuffer`][crate::TextBuffer]
/// ## `end`
/// another position in the same buffer as @start
#[doc(alias = "gtk_text_buffer_insert_range")]
fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter);
/// Copies text, tags, and paintables between @start and @end
/// and inserts the copy at @iter.
///
/// Same as [`insert_range()`][Self::insert_range()], but does nothing
/// if the insertion point isn’t editable. The @default_editable
/// parameter indicates whether the text is editable at @iter if
/// no tags enclosing @iter affect editability. Typically the result
/// of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
/// ## `iter`
/// a position in @self
/// ## `start`
/// a position in a [`TextBuffer`][crate::TextBuffer]
/// ## `end`
/// another position in the same buffer as @start
/// ## `default_editable`
/// default editability of the buffer
///
/// # Returns
///
/// whether an insertion was possible at @iter
#[doc(alias = "gtk_text_buffer_insert_range_interactive")]
fn insert_range_interactive(
&self,
iter: &mut TextIter,
start: &TextIter,
end: &TextIter,
default_editable: bool,
) -> bool;
/// Moves @mark to the new location @where_.
///
/// Emits the `signal::TextBuffer::mark-set` signal
/// as notification of the move.
/// ## `mark`
/// a [`TextMark`][crate::TextMark]
/// ## `where_`
/// new location for @mark in @self
#[doc(alias = "gtk_text_buffer_move_mark")]
fn move_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter);
/// Moves the mark named @name (which must exist) to location @where_.
///
/// See [`move_mark()`][Self::move_mark()] for details.
/// ## `name`
/// name of a mark
/// ## `where_`
/// new location for mark
#[doc(alias = "gtk_text_buffer_move_mark_by_name")]
fn move_mark_by_name(&self, name: &str, where_: &TextIter);
/// Pastes the contents of a clipboard.
///
/// If @override_location is [`None`], the pasted text will be inserted
/// at the cursor position, or the buffer selection will be replaced
/// if the selection is non-empty.
///
/// Note: pasting is asynchronous, that is, we’ll ask for the paste data
/// and return, and at some point later after the main loop runs, the paste
/// data will be inserted.
/// ## `clipboard`
/// the [`gdk::Clipboard`][crate::gdk::Clipboard] to paste from
/// ## `override_location`
/// location to insert pasted text
/// ## `default_editable`
/// whether the buffer is editable by default
#[doc(alias = "gtk_text_buffer_paste_clipboard")]
fn paste_clipboard(
&self,
clipboard: &gdk::Clipboard,
override_location: Option<&TextIter>,
default_editable: bool,
);
/// This function moves the “insert” and “selection_bound” marks
/// simultaneously.
///
/// If you move them to the same place in two steps with
/// [`move_mark()`][Self::move_mark()], you will temporarily select a
/// region in between their old and new locations, which can be pretty
/// inefficient since the temporarily-selected region will force stuff
/// to be recalculated. This function moves them as a unit, which can
/// be optimized.
/// ## `where_`
/// where to put the cursor
#[doc(alias = "gtk_text_buffer_place_cursor")]
fn place_cursor(&self, where_: &TextIter);
/// Redoes the next redoable action on the buffer, if there is one.
#[doc(alias = "gtk_text_buffer_redo")]
fn redo(&self);
/// Removes all tags in the range between @start and @end.
///
/// Be careful with this function; it could remove tags added in code
/// unrelated to the code you’re currently writing. That is, using this
/// function is probably a bad idea if you have two or more unrelated
/// code sections that add tags.
/// ## `start`
/// one bound of range to be untagged
/// ## `end`
/// other bound of range to be untagged
#[doc(alias = "gtk_text_buffer_remove_all_tags")]
fn remove_all_tags(&self, start: &TextIter, end: &TextIter);
/// Removes a [`gdk::Clipboard`][crate::gdk::Clipboard] added with
/// gtk_text_buffer_add_selection_clipboard().
/// ## `clipboard`
/// a [`gdk::Clipboard`][crate::gdk::Clipboard] added to @self by
/// [`add_selection_clipboard()`][Self::add_selection_clipboard()]
#[doc(alias = "gtk_text_buffer_remove_selection_clipboard")]
fn remove_selection_clipboard(&self, clipboard: &gdk::Clipboard);
/// Emits the “remove-tag” signal.
///
/// The default handler for the signal removes all occurrences
/// of @tag from the given range. @start and @end don’t have
/// to be in order.
/// ## `tag`
/// a [`TextTag`][crate::TextTag]
/// ## `start`
/// one bound of range to be untagged
/// ## `end`
/// other bound of range to be untagged
#[doc(alias = "gtk_text_buffer_remove_tag")]
fn remove_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter);
/// Emits the “remove-tag” signal.
///
/// Calls [`TextTagTable::lookup()`][crate::TextTagTable::lookup()] on the buffer’s
/// tag table to get a [`TextTag`][crate::TextTag], then calls
/// [`remove_tag()`][Self::remove_tag()].
/// ## `name`
/// name of a [`TextTag`][crate::TextTag]
/// ## `start`
/// one bound of range to be untagged
/// ## `end`
/// other bound of range to be untagged
#[doc(alias = "gtk_text_buffer_remove_tag_by_name")]
fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter);
/// This function moves the “insert” and “selection_bound” marks
/// simultaneously.
///
/// If you move them in two steps with
/// [`move_mark()`][Self::move_mark()], you will temporarily select a
/// region in between their old and new locations, which can be pretty
/// inefficient since the temporarily-selected region will force stuff
/// to be recalculated. This function moves them as a unit, which can
/// be optimized.
/// ## `ins`
/// where to put the “insert” mark
/// ## `bound`
/// where to put the “selection_bound” mark
#[doc(alias = "gtk_text_buffer_select_range")]
fn select_range(&self, ins: &TextIter, bound: &TextIter);
/// Sets whether or not to enable undoable actions in the text buffer.
///
/// Undoable actions in this context are changes to the text content of
/// the buffer. Changes to tags and marks are not tracked.
///
/// If enabled, the user will be able to undo the last number of actions
/// up to [`max_undo_levels()`][Self::max_undo_levels()].
///
/// See [`begin_irreversible_action()`][Self::begin_irreversible_action()] and
/// [`end_irreversible_action()`][Self::end_irreversible_action()] to create
/// changes to the buffer that cannot be undone.
/// ## `enable_undo`
/// [`true`] to enable undo
#[doc(alias = "gtk_text_buffer_set_enable_undo")]
fn set_enable_undo(&self, enable_undo: bool);
/// Sets the maximum number of undo levels to perform.
///
/// If 0, unlimited undo actions may be performed. Note that this may
/// have a memory usage impact as it requires storing an additional
/// copy of the inserted or removed text within the text buffer.
/// ## `max_undo_levels`
/// the maximum number of undo actions to perform
#[doc(alias = "gtk_text_buffer_set_max_undo_levels")]
fn set_max_undo_levels(&self, max_undo_levels: u32);
/// Used to keep track of whether the buffer has been
/// modified since the last time it was saved.
///
/// Whenever the buffer is saved to disk, call
/// `gtk_text_buffer_set_modified (@self, FALSE)`.
/// When the buffer is modified, it will automatically
/// toggled on the modified bit again. When the modified
/// bit flips, the buffer emits the
/// `signal::TextBuffer::modified-changed` signal.
/// ## `setting`
/// modification flag setting
#[doc(alias = "gtk_text_buffer_set_modified")]
fn set_modified(&self, setting: bool);
/// Deletes current contents of @self, and inserts @text instead.
///
/// If @len is -1, @text must be nul-terminated.
/// @text must be valid UTF-8.
/// ## `text`
/// UTF-8 text to insert
/// ## `len`
/// length of @text in bytes
#[doc(alias = "gtk_text_buffer_set_text")]
fn set_text(&self, text: &str);
/// Undoes the last undoable action on the buffer, if there is one.
#[doc(alias = "gtk_text_buffer_undo")]
fn undo(&self);
/// The position of the insert mark.
///
/// This is an offset from the beginning of the buffer.
/// It is useful for getting notified when the cursor moves.
#[doc(alias = "cursor-position")]
fn cursor_position(&self) -> i32;
/// Emitted to apply a tag to a range of text in a [`TextBuffer`][crate::TextBuffer].
///
/// Applying actually occurs in the default handler.
///
/// Note that if your handler runs before the default handler
/// it must not invalidate the @start and @end iters (or has to
/// revalidate them).
///
/// See also:
/// [`apply_tag()`][Self::apply_tag()],
/// [`TextBufferExtManual::insert_with_tags()`][crate::prelude::TextBufferExtManual::insert_with_tags()],
/// [`insert_range()`][Self::insert_range()].
/// ## `tag`
/// the applied tag
/// ## `start`
/// the start of the range the tag is applied to
/// ## `end`
/// the end of the range the tag is applied to
#[doc(alias = "apply-tag")]
fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
/// Emitted at the beginning of a single user-visible
/// operation on a [`TextBuffer`][crate::TextBuffer].
///
/// See also:
/// [`begin_user_action()`][Self::begin_user_action()],
/// [`insert_interactive()`][Self::insert_interactive()],
/// [`insert_range_interactive()`][Self::insert_range_interactive()],
/// [`delete_interactive()`][Self::delete_interactive()],
/// [`backspace()`][Self::backspace()],
/// [`delete_selection()`][Self::delete_selection()].
#[doc(alias = "begin-user-action")]
fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted when the content of a [`TextBuffer`][crate::TextBuffer] has changed.
#[doc(alias = "changed")]
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted to delete a range from a [`TextBuffer`][crate::TextBuffer].
///
/// Note that if your handler runs before the default handler
/// it must not invalidate the @start and @end iters (or has
/// to revalidate them). The default signal handler revalidates
/// the @start and @end iters to both point to the location
/// where text was deleted. Handlers which run after the default
/// handler (see g_signal_connect_after()) do not have access to
/// the deleted text.
///
/// See also: [`delete()`][Self::delete()].
/// ## `start`
/// the start of the range to be deleted
/// ## `end`
/// the end of the range to be deleted
#[doc(alias = "delete-range")]
fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
/// Emitted at the end of a single user-visible
/// operation on the [`TextBuffer`][crate::TextBuffer].
///
/// See also:
/// [`end_user_action()`][Self::end_user_action()],
/// [`insert_interactive()`][Self::insert_interactive()],
/// [`insert_range_interactive()`][Self::insert_range_interactive()],
/// [`delete_interactive()`][Self::delete_interactive()],
/// [`backspace()`][Self::backspace()],
/// [`delete_selection()`][Self::delete_selection()],
/// [`backspace()`][Self::backspace()].
#[doc(alias = "end-user-action")]
fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted to insert a [`TextChildAnchor`][crate::TextChildAnchor] in a [`TextBuffer`][crate::TextBuffer].
///
/// Insertion actually occurs in the default handler.
///
/// Note that if your handler runs before the default handler
/// it must not invalidate the @location iter (or has to
/// revalidate it). The default signal handler revalidates
/// it to be placed after the inserted @anchor.
///
/// See also: [`insert_child_anchor()`][Self::insert_child_anchor()].
/// ## `location`
/// position to insert @anchor in @textbuffer
/// ## `anchor`
/// the [`TextChildAnchor`][crate::TextChildAnchor] to be inserted
#[doc(alias = "insert-child-anchor")]
fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
/// Emitted to insert a [`gdk::Paintable`][crate::gdk::Paintable] in a [`TextBuffer`][crate::TextBuffer].
///
/// Insertion actually occurs in the default handler.
///
/// Note that if your handler runs before the default handler
/// it must not invalidate the @location iter (or has to
/// revalidate it). The default signal handler revalidates
/// it to be placed after the inserted @paintable.
///
/// See also: [`insert_paintable()`][Self::insert_paintable()].
/// ## `location`
/// position to insert @paintable in @textbuffer
/// ## `paintable`
/// the [`gdk::Paintable`][crate::gdk::Paintable] to be inserted
#[doc(alias = "insert-paintable")]
fn connect_insert_paintable<F: Fn(&Self, &TextIter, &gdk::Paintable) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
/// Emitted as notification after a [`TextMark`][crate::TextMark] is deleted.
///
/// See also: [`delete_mark()`][Self::delete_mark()].
/// ## `mark`
/// The mark that was deleted
#[doc(alias = "mark-deleted")]
fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted as notification after a [`TextMark`][crate::TextMark] is set.
///
/// See also:
/// [`create_mark()`][Self::create_mark()],
/// [`move_mark()`][Self::move_mark()].
/// ## `location`
/// The location of @mark in @textbuffer
/// ## `mark`
/// The mark that is set
#[doc(alias = "mark-set")]
fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
/// Emitted when the modified bit of a [`TextBuffer`][crate::TextBuffer] flips.
///
/// See also: [`set_modified()`][Self::set_modified()].
#[doc(alias = "modified-changed")]
fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted after paste operation has been completed.
///
/// This is useful to properly scroll the view to the end
/// of the pasted text. See [`paste_clipboard()`][Self::paste_clipboard()]
/// for more details.
/// ## `clipboard`
/// the [`gdk::Clipboard`][crate::gdk::Clipboard] pasted from
#[doc(alias = "paste-done")]
fn connect_paste_done<F: Fn(&Self, &gdk::Clipboard) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted when a request has been made to redo the
/// previously undone operation.
#[doc(alias = "redo")]
fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
/// Emitted to remove all occurrences of @tag from a range
/// of text in a [`TextBuffer`][crate::TextBuffer].
///
/// Removal actually occurs in the default handler.
///
/// Note that if your handler runs before the default handler
/// it must not invalidate the @start and @end iters (or has
/// to revalidate them).
///
/// See also: [`remove_tag()`][Self::remove_tag()].
/// ## `tag`
/// the tag to be removed
/// ## `start`
/// the start of the range the tag is removed from
/// ## `end`
/// the end of the range the tag is removed from
#[doc(alias = "remove-tag")]
fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId;
/// Emitted when a request has been made to undo the
/// previous operation or set of operations that have
/// been grouped together.
#[doc(alias = "undo")]
fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "can-redo")]
fn connect_can_redo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "can-undo")]
fn connect_can_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "cursor-position")]
fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "enable-undo")]
fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "has-selection")]
fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "text")]
fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<TextBuffer>> TextBufferExt for O {
fn add_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) {
unsafe {
ffi::gtk_text_buffer_add_mark(
self.as_ref().to_glib_none().0,
mark.as_ref().to_glib_none().0,
where_.to_glib_none().0,
);
}
}
fn add_selection_clipboard(&self, clipboard: &gdk::Clipboard) {
unsafe {
ffi::gtk_text_buffer_add_selection_clipboard(
self.as_ref().to_glib_none().0,
clipboard.to_glib_none().0,
);
}
}
fn apply_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter) {
unsafe {
ffi::gtk_text_buffer_apply_tag(
self.as_ref().to_glib_none().0,
tag.as_ref().to_glib_none().0,
start.to_glib_none().0,
end.to_glib_none().0,
);
}
}
fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
unsafe {
ffi::gtk_text_buffer_apply_tag_by_name(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
start.to_glib_none().0,
end.to_glib_none().0,
);
}
}
fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_backspace(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
interactive.into_glib(),
default_editable.into_glib(),
))
}
}
fn begin_irreversible_action(&self) {
unsafe {
ffi::gtk_text_buffer_begin_irreversible_action(self.as_ref().to_glib_none().0);
}
}
fn begin_user_action(&self) {
unsafe {
ffi::gtk_text_buffer_begin_user_action(self.as_ref().to_glib_none().0);
}
}
fn copy_clipboard(&self, clipboard: &gdk::Clipboard) {
unsafe {
ffi::gtk_text_buffer_copy_clipboard(
self.as_ref().to_glib_none().0,
clipboard.to_glib_none().0,
);
}
}
fn create_child_anchor(&self, iter: &mut TextIter) -> TextChildAnchor {
unsafe {
from_glib_none(ffi::gtk_text_buffer_create_child_anchor(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
))
}
}
fn create_mark(
&self,
mark_name: Option<&str>,
where_: &TextIter,
left_gravity: bool,
) -> TextMark {
unsafe {
from_glib_none(ffi::gtk_text_buffer_create_mark(
self.as_ref().to_glib_none().0,
mark_name.to_glib_none().0,
where_.to_glib_none().0,
left_gravity.into_glib(),
))
}
}
fn cut_clipboard(&self, clipboard: &gdk::Clipboard, default_editable: bool) {
unsafe {
ffi::gtk_text_buffer_cut_clipboard(
self.as_ref().to_glib_none().0,
clipboard.to_glib_none().0,
default_editable.into_glib(),
);
}
}
fn delete(&self, start: &mut TextIter, end: &mut TextIter) {
unsafe {
ffi::gtk_text_buffer_delete(
self.as_ref().to_glib_none().0,
start.to_glib_none_mut().0,
end.to_glib_none_mut().0,
);
}
}
fn delete_interactive(
&self,
start_iter: &mut TextIter,
end_iter: &mut TextIter,
default_editable: bool,
) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_delete_interactive(
self.as_ref().to_glib_none().0,
start_iter.to_glib_none_mut().0,
end_iter.to_glib_none_mut().0,
default_editable.into_glib(),
))
}
}
fn delete_mark(&self, mark: &impl IsA<TextMark>) {
unsafe {
ffi::gtk_text_buffer_delete_mark(
self.as_ref().to_glib_none().0,
mark.as_ref().to_glib_none().0,
);
}
}
fn delete_mark_by_name(&self, name: &str) {
unsafe {
ffi::gtk_text_buffer_delete_mark_by_name(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
);
}
}
fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_delete_selection(
self.as_ref().to_glib_none().0,
interactive.into_glib(),
default_editable.into_glib(),
))
}
}
fn end_irreversible_action(&self) {
unsafe {
ffi::gtk_text_buffer_end_irreversible_action(self.as_ref().to_glib_none().0);
}
}
fn end_user_action(&self) {
unsafe {
ffi::gtk_text_buffer_end_user_action(self.as_ref().to_glib_none().0);
}
}
fn bounds(&self) -> (TextIter, TextIter) {
unsafe {
let mut start = TextIter::uninitialized();
let mut end = TextIter::uninitialized();
ffi::gtk_text_buffer_get_bounds(
self.as_ref().to_glib_none().0,
start.to_glib_none_mut().0,
end.to_glib_none_mut().0,
);
(start, end)
}
}
fn can_redo(&self) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_get_can_redo(
self.as_ref().to_glib_none().0,
))
}
}
fn can_undo(&self) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_get_can_undo(
self.as_ref().to_glib_none().0,
))
}
}
fn char_count(&self) -> i32 {
unsafe { ffi::gtk_text_buffer_get_char_count(self.as_ref().to_glib_none().0) }
}
fn enables_undo(&self) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_get_enable_undo(
self.as_ref().to_glib_none().0,
))
}
}
fn end_iter(&self) -> TextIter {
unsafe {
let mut iter = TextIter::uninitialized();
ffi::gtk_text_buffer_get_end_iter(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
);
iter
}
}
fn has_selection(&self) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_get_has_selection(
self.as_ref().to_glib_none().0,
))
}
}
fn get_insert(&self) -> TextMark {
unsafe {
from_glib_none(ffi::gtk_text_buffer_get_insert(
self.as_ref().to_glib_none().0,
))
}
}
fn iter_at_child_anchor(&self, anchor: &impl IsA<TextChildAnchor>) -> TextIter {
unsafe {
let mut iter = TextIter::uninitialized();
ffi::gtk_text_buffer_get_iter_at_child_anchor(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
anchor.as_ref().to_glib_none().0,
);
iter
}
}
fn iter_at_line(&self, line_number: i32) -> Option<TextIter> {
unsafe {
let mut iter = TextIter::uninitialized();
let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
line_number,
));
if ret {
Some(iter)
} else {
None
}
}
}
fn iter_at_line_index(&self, line_number: i32, byte_index: i32) -> Option<TextIter> {
unsafe {
let mut iter = TextIter::uninitialized();
let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_index(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
line_number,
byte_index,
));
if ret {
Some(iter)
} else {
None
}
}
}
fn iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> Option<TextIter> {
unsafe {
let mut iter = TextIter::uninitialized();
let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_offset(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
line_number,
char_offset,
));
if ret {
Some(iter)
} else {
None
}
}
}
fn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter {
unsafe {
let mut iter = TextIter::uninitialized();
ffi::gtk_text_buffer_get_iter_at_mark(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
mark.as_ref().to_glib_none().0,
);
iter
}
}
fn iter_at_offset(&self, char_offset: i32) -> TextIter {
unsafe {
let mut iter = TextIter::uninitialized();
ffi::gtk_text_buffer_get_iter_at_offset(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
char_offset,
);
iter
}
}
fn line_count(&self) -> i32 {
unsafe { ffi::gtk_text_buffer_get_line_count(self.as_ref().to_glib_none().0) }
}
fn mark(&self, name: &str) -> Option<TextMark> {
unsafe {
from_glib_none(ffi::gtk_text_buffer_get_mark(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
))
}
}
fn max_undo_levels(&self) -> u32 {
unsafe { ffi::gtk_text_buffer_get_max_undo_levels(self.as_ref().to_glib_none().0) }
}
fn is_modified(&self) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_get_modified(
self.as_ref().to_glib_none().0,
))
}
}
fn selection_bound(&self) -> TextMark {
unsafe {
from_glib_none(ffi::gtk_text_buffer_get_selection_bound(
self.as_ref().to_glib_none().0,
))
}
}
fn selection_bounds(&self) -> Option<(TextIter, TextIter)> {
unsafe {
let mut start = TextIter::uninitialized();
let mut end = TextIter::uninitialized();
let ret = from_glib(ffi::gtk_text_buffer_get_selection_bounds(
self.as_ref().to_glib_none().0,
start.to_glib_none_mut().0,
end.to_glib_none_mut().0,
));
if ret {
Some((start, end))
} else {
None
}
}
}
fn selection_content(&self) -> gdk::ContentProvider {
unsafe {
from_glib_full(ffi::gtk_text_buffer_get_selection_content(
self.as_ref().to_glib_none().0,
))
}
}
fn slice(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
unsafe {
from_glib_full(ffi::gtk_text_buffer_get_slice(
self.as_ref().to_glib_none().0,
start.to_glib_none().0,
end.to_glib_none().0,
include_hidden_chars.into_glib(),
))
}
}
fn start_iter(&self) -> TextIter {
unsafe {
let mut iter = TextIter::uninitialized();
ffi::gtk_text_buffer_get_start_iter(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
);
iter
}
}
fn tag_table(&self) -> TextTagTable {
unsafe {
from_glib_none(ffi::gtk_text_buffer_get_tag_table(
self.as_ref().to_glib_none().0,
))
}
}
fn text(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
unsafe {
from_glib_full(ffi::gtk_text_buffer_get_text(
self.as_ref().to_glib_none().0,
start.to_glib_none().0,
end.to_glib_none().0,
include_hidden_chars.into_glib(),
))
}
}
fn insert(&self, iter: &mut TextIter, text: &str) {
let len = text.len() as i32;
unsafe {
ffi::gtk_text_buffer_insert(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
text.to_glib_none().0,
len,
);
}
}
fn insert_at_cursor(&self, text: &str) {
let len = text.len() as i32;
unsafe {
ffi::gtk_text_buffer_insert_at_cursor(
self.as_ref().to_glib_none().0,
text.to_glib_none().0,
len,
);
}
}
fn insert_child_anchor(&self, iter: &mut TextIter, anchor: &impl IsA<TextChildAnchor>) {
unsafe {
ffi::gtk_text_buffer_insert_child_anchor(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
anchor.as_ref().to_glib_none().0,
);
}
}
fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool {
let len = text.len() as i32;
unsafe {
from_glib(ffi::gtk_text_buffer_insert_interactive(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
text.to_glib_none().0,
len,
default_editable.into_glib(),
))
}
}
fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool {
let len = text.len() as i32;
unsafe {
from_glib(ffi::gtk_text_buffer_insert_interactive_at_cursor(
self.as_ref().to_glib_none().0,
text.to_glib_none().0,
len,
default_editable.into_glib(),
))
}
}
fn insert_markup(&self, iter: &mut TextIter, markup: &str) {
let len = markup.len() as i32;
unsafe {
ffi::gtk_text_buffer_insert_markup(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
markup.to_glib_none().0,
len,
);
}
}
fn insert_paintable(&self, iter: &mut TextIter, paintable: &impl IsA<gdk::Paintable>) {
unsafe {
ffi::gtk_text_buffer_insert_paintable(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
paintable.as_ref().to_glib_none().0,
);
}
}
fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter) {
unsafe {
ffi::gtk_text_buffer_insert_range(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
start.to_glib_none().0,
end.to_glib_none().0,
);
}
}
fn insert_range_interactive(
&self,
iter: &mut TextIter,
start: &TextIter,
end: &TextIter,
default_editable: bool,
) -> bool {
unsafe {
from_glib(ffi::gtk_text_buffer_insert_range_interactive(
self.as_ref().to_glib_none().0,
iter.to_glib_none_mut().0,
start.to_glib_none().0,
end.to_glib_none().0,
default_editable.into_glib(),
))
}
}
fn move_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) {
unsafe {
ffi::gtk_text_buffer_move_mark(
self.as_ref().to_glib_none().0,
mark.as_ref().to_glib_none().0,
where_.to_glib_none().0,
);
}
}
fn move_mark_by_name(&self, name: &str, where_: &TextIter) {
unsafe {
ffi::gtk_text_buffer_move_mark_by_name(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
where_.to_glib_none().0,
);
}
}
fn paste_clipboard(
&self,
clipboard: &gdk::Clipboard,
override_location: Option<&TextIter>,
default_editable: bool,
) {
unsafe {
ffi::gtk_text_buffer_paste_clipboard(
self.as_ref().to_glib_none().0,
clipboard.to_glib_none().0,
mut_override(override_location.to_glib_none().0),
default_editable.into_glib(),
);
}
}
fn place_cursor(&self, where_: &TextIter) {
unsafe {
ffi::gtk_text_buffer_place_cursor(
self.as_ref().to_glib_none().0,
where_.to_glib_none().0,
);
}
}
fn redo(&self) {
unsafe {
ffi::gtk_text_buffer_redo(self.as_ref().to_glib_none().0);
}
}
fn remove_all_tags(&self, start: &TextIter, end: &TextIter) {
unsafe {
ffi::gtk_text_buffer_remove_all_tags(
self.as_ref().to_glib_none().0,
start.to_glib_none().0,
end.to_glib_none().0,
);
}
}
fn remove_selection_clipboard(&self, clipboard: &gdk::Clipboard) {
unsafe {
ffi::gtk_text_buffer_remove_selection_clipboard(
self.as_ref().to_glib_none().0,
clipboard.to_glib_none().0,
);
}
}
fn remove_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter) {
unsafe {
ffi::gtk_text_buffer_remove_tag(
self.as_ref().to_glib_none().0,
tag.as_ref().to_glib_none().0,
start.to_glib_none().0,
end.to_glib_none().0,
);
}
}
fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
unsafe {
ffi::gtk_text_buffer_remove_tag_by_name(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
start.to_glib_none().0,
end.to_glib_none().0,
);
}
}
fn select_range(&self, ins: &TextIter, bound: &TextIter) {
unsafe {
ffi::gtk_text_buffer_select_range(
self.as_ref().to_glib_none().0,
ins.to_glib_none().0,
bound.to_glib_none().0,
);
}
}
fn set_enable_undo(&self, enable_undo: bool) {
unsafe {
ffi::gtk_text_buffer_set_enable_undo(
self.as_ref().to_glib_none().0,
enable_undo.into_glib(),
);
}
}
fn set_max_undo_levels(&self, max_undo_levels: u32) {
unsafe {
ffi::gtk_text_buffer_set_max_undo_levels(
self.as_ref().to_glib_none().0,
max_undo_levels,
);
}
}
fn set_modified(&self, setting: bool) {
unsafe {
ffi::gtk_text_buffer_set_modified(self.as_ref().to_glib_none().0, setting.into_glib());
}
}
fn set_text(&self, text: &str) {
let len = text.len() as i32;
unsafe {
ffi::gtk_text_buffer_set_text(
self.as_ref().to_glib_none().0,
text.to_glib_none().0,
len,
);
}
}
fn undo(&self) {
unsafe {
ffi::gtk_text_buffer_undo(self.as_ref().to_glib_none().0);
}
}
fn cursor_position(&self) -> i32 {
glib::ObjectExt::property(self.as_ref(), "cursor-position")
}
fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn apply_tag_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
tag: *mut ffi::GtkTextTag,
start: *mut ffi::GtkTextIter,
end: *mut ffi::GtkTextIter,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(tag),
&from_glib_borrow(start),
&from_glib_borrow(end),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"apply-tag\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
apply_tag_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn begin_user_action_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"begin-user-action\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
begin_user_action_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn changed_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkTextBuffer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn delete_range_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &TextIter, &TextIter) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
start: *mut ffi::GtkTextIter,
end: *mut ffi::GtkTextIter,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(start),
&from_glib_borrow(end),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"delete-range\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
delete_range_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn end_user_action_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkTextBuffer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"end-user-action\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
end_user_action_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn insert_child_anchor_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &TextIter, &TextChildAnchor) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
location: *mut ffi::GtkTextIter,
anchor: *mut ffi::GtkTextChildAnchor,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(location),
&from_glib_borrow(anchor),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"insert-child-anchor\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
insert_child_anchor_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_insert_paintable<F: Fn(&Self, &TextIter, &gdk::Paintable) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn insert_paintable_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &TextIter, &gdk::Paintable) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
location: *mut ffi::GtkTextIter,
paintable: *mut gdk::ffi::GdkPaintable,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(location),
&from_glib_borrow(paintable),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"insert-paintable\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
insert_paintable_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn mark_deleted_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &TextMark) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
mark: *mut ffi::GtkTextMark,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(mark),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"mark-deleted\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
mark_deleted_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn mark_set_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &TextIter, &TextMark) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
location: *mut ffi::GtkTextIter,
mark: *mut ffi::GtkTextMark,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(location),
&from_glib_borrow(mark),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"mark-set\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
mark_set_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn modified_changed_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"modified-changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
modified_changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_paste_done<F: Fn(&Self, &gdk::Clipboard) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn paste_done_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &gdk::Clipboard) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
clipboard: *mut gdk::ffi::GdkClipboard,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(clipboard),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"paste-done\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
paste_done_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkTextBuffer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"redo\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
redo_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn remove_tag_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
tag: *mut ffi::GtkTextTag,
start: *mut ffi::GtkTextIter,
end: *mut ffi::GtkTextIter,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(
TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(tag),
&from_glib_borrow(start),
&from_glib_borrow(end),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"remove-tag\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
remove_tag_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkTextBuffer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"undo\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
undo_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_can_redo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_can_redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkTextBuffer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::can-redo\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_can_redo_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_can_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_can_undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkTextBuffer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::can-undo\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_can_undo_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_cursor_position_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::cursor-position\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_cursor_position_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_enable_undo_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::enable-undo\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_enable_undo_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_has_selection_trampoline<
P: IsA<TextBuffer>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkTextBuffer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::has-selection\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_has_selection_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_text_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkTextBuffer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::text\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_text_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl fmt::Display for TextBuffer {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("TextBuffer")
}
}