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
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
|
/*
* Copyright (C) 2001-2004,2009,2010 Red Hat, Inc.
* Copyright © 2008, 2009, 2010, 2015 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* SECTION: vte-terminal
* @short_description: A terminal widget implementation
*
* A VteTerminal is a terminal emulator implemented as a GTK3 widget.
*
* Note that altough #VteTerminal implements the #GtkScrollable interface,
* you should not place a #VteTerminal inside a #GtkScrolledWindow
* container, since they are incompatible. Instead, pack the terminal in
* a horizontal #GtkBox together with a #GtkScrollbar which uses the
* #GtkAdjustment returned from gtk_scrollable_get_vadjustment().
*/
#include "config.h"
#include <new> /* placement new */
#include <pwd.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "vte/vteenums.h"
#include "vte/vtepty.h"
#include "vte/vteterminal.h"
#include "vte/vtetypebuiltins.h"
#include "debug.h"
#include "marshal.h"
#include "reaper.hh"
#include "vtedefines.hh"
#include "vteinternal.hh"
#include "vteaccess.h"
#include "widget.hh"
#include "vtegtk.hh"
#include "vteregexinternal.hh"
#if !GLIB_CHECK_VERSION(2, 42, 0)
#define G_PARAM_EXPLICIT_NOTIFY 0
#endif
#define I_(string) (g_intern_static_string(string))
#define VTE_TERMINAL_CSS_NAME "vte-terminal"
struct _VteTerminalClassPrivate {
GtkStyleProvider *style_provider;
};
#ifdef VTE_DEBUG
G_DEFINE_TYPE_WITH_CODE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET,
{
VteTerminal_private_offset =
g_type_add_instance_private(g_define_type_id, sizeof(vte::platform::Widget));
}
g_type_add_class_private (g_define_type_id, sizeof (VteTerminalClassPrivate));
G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, NULL)
if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
g_printerr("vte_terminal_get_type()\n");
})
#else
G_DEFINE_TYPE_WITH_CODE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET,
{
VteTerminal_private_offset =
g_type_add_instance_private(g_define_type_id, sizeof(vte::platform::Widget));
}
g_type_add_class_private (g_define_type_id, sizeof (VteTerminalClassPrivate));
G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, NULL))
#endif
static inline
vte::platform::Widget* get_widget(VteTerminal* terminal)
{
return reinterpret_cast<vte::platform::Widget*>(vte_terminal_get_instance_private(terminal));
}
#define WIDGET(t) (get_widget(t))
vte::terminal::Terminal*
_vte_terminal_get_impl(VteTerminal *terminal)
{
return WIDGET(terminal)->terminal();
}
#define IMPL(t) (_vte_terminal_get_impl(t))
guint signals[LAST_SIGNAL];
GParamSpec *pspecs[LAST_PROP];
GTimer *process_timer;
uint64_t g_test_flags = 0;
static bool
valid_color(GdkRGBA const* color)
{
return color->red >= 0. && color->red <= 1. &&
color->green >= 0. && color->green <= 1. &&
color->blue >= 0. && color->blue <= 1. &&
color->alpha >= 0. && color->alpha <= 1.;
}
static void
vte_terminal_set_hadjustment(VteTerminal *terminal,
GtkAdjustment *adjustment)
{
g_return_if_fail(adjustment == nullptr || GTK_IS_ADJUSTMENT(adjustment));
WIDGET(terminal)->set_hadjustment(adjustment);
}
static void
vte_terminal_set_vadjustment(VteTerminal *terminal,
GtkAdjustment *adjustment)
{
g_return_if_fail(adjustment == nullptr || GTK_IS_ADJUSTMENT(adjustment));
WIDGET(terminal)->set_vadjustment(adjustment);
}
static void
vte_terminal_set_hscroll_policy(VteTerminal *terminal,
GtkScrollablePolicy policy)
{
IMPL(terminal)->m_hscroll_policy = policy;
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (terminal));
}
static void
vte_terminal_set_vscroll_policy(VteTerminal *terminal,
GtkScrollablePolicy policy)
{
IMPL(terminal)->m_vscroll_policy = policy;
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (terminal));
}
static void
vte_terminal_real_copy_clipboard(VteTerminal *terminal)
{
WIDGET(terminal)->copy(VTE_SELECTION_CLIPBOARD, VTE_FORMAT_TEXT);
}
static void
vte_terminal_real_paste_clipboard(VteTerminal *terminal)
{
WIDGET(terminal)->paste(GDK_SELECTION_CLIPBOARD);
}
static void
vte_terminal_style_updated (GtkWidget *widget)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
GTK_WIDGET_CLASS (vte_terminal_parent_class)->style_updated (widget);
WIDGET(terminal)->style_updated();
}
static gboolean
vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
/* We do NOT want chain up to GtkWidget::key-press-event, since that would
* cause GtkWidget's keybindings to be handled and consumed. However we'll
* have to handle the one sane binding (Shift-F10 or MenuKey, to pop up the
* context menu) ourself, so for now we simply skip the offending keybinding
* in class_init.
*/
/* First, check if GtkWidget's behavior already does something with
* this key. */
if (GTK_WIDGET_CLASS(vte_terminal_parent_class)->key_press_event) {
if ((GTK_WIDGET_CLASS(vte_terminal_parent_class))->key_press_event(widget,
event)) {
return TRUE;
}
}
return WIDGET(terminal)->key_press(event);
}
static gboolean
vte_terminal_key_release(GtkWidget *widget, GdkEventKey *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
return WIDGET(terminal)->key_release(event);
}
static gboolean
vte_terminal_motion_notify(GtkWidget *widget, GdkEventMotion *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
return WIDGET(terminal)->motion_notify(event);
}
static gboolean
vte_terminal_button_press(GtkWidget *widget, GdkEventButton *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
return WIDGET(terminal)->button_press(event);
}
static gboolean
vte_terminal_button_release(GtkWidget *widget, GdkEventButton *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
return WIDGET(terminal)->button_release(event);
}
static gboolean
vte_terminal_scroll(GtkWidget *widget, GdkEventScroll *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
WIDGET(terminal)->scroll(event);
return TRUE;
}
static gboolean
vte_terminal_focus_in(GtkWidget *widget, GdkEventFocus *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
WIDGET(terminal)->focus_in(event);
return FALSE;
}
static gboolean
vte_terminal_focus_out(GtkWidget *widget, GdkEventFocus *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
WIDGET(terminal)->focus_out(event);
return FALSE;
}
static gboolean
vte_terminal_enter(GtkWidget *widget, GdkEventCrossing *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
gboolean ret = FALSE;
if (GTK_WIDGET_CLASS (vte_terminal_parent_class)->enter_notify_event) {
ret = GTK_WIDGET_CLASS (vte_terminal_parent_class)->enter_notify_event (widget, event);
}
WIDGET(terminal)->enter(event);
return ret;
}
static gboolean
vte_terminal_leave(GtkWidget *widget, GdkEventCrossing *event)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
gboolean ret = FALSE;
if (GTK_WIDGET_CLASS (vte_terminal_parent_class)->leave_notify_event) {
ret = GTK_WIDGET_CLASS (vte_terminal_parent_class)->leave_notify_event (widget, event);
}
WIDGET(terminal)->leave(event);
return ret;
}
static void
vte_terminal_get_preferred_width(GtkWidget *widget,
int *minimum_width,
int *natural_width)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
WIDGET(terminal)->get_preferred_width(minimum_width, natural_width);
}
static void
vte_terminal_get_preferred_height(GtkWidget *widget,
int *minimum_height,
int *natural_height)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
WIDGET(terminal)->get_preferred_height(minimum_height, natural_height);
}
static void
vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
VteTerminal *terminal = VTE_TERMINAL(widget);
WIDGET(terminal)->size_allocate(allocation);
}
static gboolean
vte_terminal_draw(GtkWidget *widget,
cairo_t *cr)
{
VteTerminal *terminal = VTE_TERMINAL (widget);
WIDGET(terminal)->draw(cr);
return FALSE;
}
static void
vte_terminal_realize(GtkWidget *widget)
{
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_realize()\n");
GTK_WIDGET_CLASS(vte_terminal_parent_class)->realize(widget);
VteTerminal *terminal= VTE_TERMINAL(widget);
WIDGET(terminal)->realize();
}
static void
vte_terminal_unrealize(GtkWidget *widget)
{
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_unrealize()\n");
VteTerminal *terminal = VTE_TERMINAL (widget);
WIDGET(terminal)->unrealize();
GTK_WIDGET_CLASS(vte_terminal_parent_class)->unrealize(widget);
}
static void
vte_terminal_map(GtkWidget *widget)
{
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_map()\n");
VteTerminal *terminal = VTE_TERMINAL(widget);
GTK_WIDGET_CLASS(vte_terminal_parent_class)->map(widget);
WIDGET(terminal)->map();
}
static void
vte_terminal_unmap(GtkWidget *widget)
{
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_unmap()\n");
VteTerminal *terminal = VTE_TERMINAL(widget);
WIDGET(terminal)->unmap();
GTK_WIDGET_CLASS(vte_terminal_parent_class)->unmap(widget);
}
static void
vte_terminal_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen)
{
VteTerminal *terminal = VTE_TERMINAL (widget);
if (GTK_WIDGET_CLASS (vte_terminal_parent_class)->screen_changed) {
GTK_WIDGET_CLASS (vte_terminal_parent_class)->screen_changed (widget, previous_screen);
}
WIDGET(terminal)->screen_changed(previous_screen);
}
static void
vte_terminal_constructed (GObject *object)
{
VteTerminal *terminal = VTE_TERMINAL (object);
G_OBJECT_CLASS (vte_terminal_parent_class)->constructed (object);
WIDGET(terminal)->constructed();
}
static void
vte_terminal_init(VteTerminal *terminal)
{
void *place;
GtkStyleContext *context;
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_init()\n");
context = gtk_widget_get_style_context(&terminal->widget);
gtk_style_context_add_provider (context,
VTE_TERMINAL_GET_CLASS (terminal)->priv->style_provider,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
/* Initialize private data. NOTE: place is zeroed */
place = vte_terminal_get_instance_private(terminal);
new (place) vte::platform::Widget(terminal);
gtk_widget_set_has_window(&terminal->widget, FALSE);
}
static void
vte_terminal_dispose(GObject *object)
{
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_dispose()\n");
VteTerminal *terminal = VTE_TERMINAL (object);
WIDGET(terminal)->dispose();
/* Call the inherited dispose() method. */
G_OBJECT_CLASS(vte_terminal_parent_class)->dispose(object);
}
static void
vte_terminal_finalize(GObject *object)
{
_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_finalize()\n");
VteTerminal *terminal = VTE_TERMINAL (object);
WIDGET(terminal)->~Widget();
/* Call the inherited finalize() method. */
G_OBJECT_CLASS(vte_terminal_parent_class)->finalize(object);
}
static void
vte_terminal_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
VteTerminal *terminal = VTE_TERMINAL (object);
auto widget = WIDGET(terminal);
auto impl = IMPL(terminal);
switch (prop_id)
{
case PROP_HADJUSTMENT:
g_value_set_object (value, widget->get_hadjustment());
break;
case PROP_VADJUSTMENT:
g_value_set_object (value, widget->get_vadjustment());
break;
case PROP_HSCROLL_POLICY:
g_value_set_enum (value, widget->hscroll_policy());
break;
case PROP_VSCROLL_POLICY:
g_value_set_enum (value, widget->vscroll_policy());
break;
case PROP_ALLOW_BOLD:
g_value_set_boolean (value, vte_terminal_get_allow_bold (terminal));
break;
case PROP_ALLOW_HYPERLINK:
g_value_set_boolean (value, vte_terminal_get_allow_hyperlink (terminal));
break;
case PROP_AUDIBLE_BELL:
g_value_set_boolean (value, vte_terminal_get_audible_bell (terminal));
break;
case PROP_BACKSPACE_BINDING:
g_value_set_enum (value, impl->m_backspace_binding);
break;
case PROP_BOLD_IS_BRIGHT:
g_value_set_boolean (value, vte_terminal_get_bold_is_bright (terminal));
break;
case PROP_CELL_HEIGHT_SCALE:
g_value_set_double (value, vte_terminal_get_cell_height_scale (terminal));
break;
case PROP_CELL_WIDTH_SCALE:
g_value_set_double (value, vte_terminal_get_cell_width_scale (terminal));
break;
case PROP_CJK_AMBIGUOUS_WIDTH:
g_value_set_int (value, vte_terminal_get_cjk_ambiguous_width (terminal));
break;
case PROP_CURSOR_BLINK_MODE:
g_value_set_enum (value, vte_terminal_get_cursor_blink_mode (terminal));
break;
case PROP_CURRENT_DIRECTORY_URI:
g_value_set_string (value, vte_terminal_get_current_directory_uri (terminal));
break;
case PROP_CURRENT_FILE_URI:
g_value_set_string (value, vte_terminal_get_current_file_uri (terminal));
break;
case PROP_CURSOR_SHAPE:
g_value_set_enum (value, vte_terminal_get_cursor_shape (terminal));
break;
case PROP_DELETE_BINDING:
g_value_set_enum (value, impl->m_delete_binding);
break;
case PROP_ENABLE_BIDI:
g_value_set_boolean (value, vte_terminal_get_enable_bidi (terminal));
break;
case PROP_ENABLE_SHAPING:
g_value_set_boolean (value, vte_terminal_get_enable_shaping (terminal));
break;
case PROP_ENCODING:
g_value_set_string (value, vte_terminal_get_encoding (terminal));
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, vte_terminal_get_font (terminal));
break;
case PROP_FONT_SCALE:
g_value_set_double (value, vte_terminal_get_font_scale (terminal));
break;
case PROP_HYPERLINK_HOVER_URI:
g_value_set_string (value, impl->m_hyperlink_hover_uri);
break;
case PROP_ICON_TITLE:
g_value_set_string (value, vte_terminal_get_icon_title (terminal));
break;
case PROP_INPUT_ENABLED:
g_value_set_boolean (value, vte_terminal_get_input_enabled (terminal));
break;
case PROP_MOUSE_POINTER_AUTOHIDE:
g_value_set_boolean (value, vte_terminal_get_mouse_autohide (terminal));
break;
case PROP_PTY:
g_value_set_object (value, vte_terminal_get_pty(terminal));
break;
case PROP_REWRAP_ON_RESIZE:
g_value_set_boolean (value, vte_terminal_get_rewrap_on_resize (terminal));
break;
case PROP_SCROLLBACK_LINES:
g_value_set_uint (value, vte_terminal_get_scrollback_lines(terminal));
break;
case PROP_SCROLL_ON_KEYSTROKE:
g_value_set_boolean (value, vte_terminal_get_scroll_on_keystroke(terminal));
break;
case PROP_SCROLL_ON_OUTPUT:
g_value_set_boolean (value, vte_terminal_get_scroll_on_output(terminal));
break;
case PROP_TEXT_BLINK_MODE:
g_value_set_enum (value, vte_terminal_get_text_blink_mode (terminal));
break;
case PROP_WINDOW_TITLE:
g_value_set_string (value, vte_terminal_get_window_title (terminal));
break;
case PROP_WORD_CHAR_EXCEPTIONS:
g_value_set_string (value, vte_terminal_get_word_char_exceptions (terminal));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
return;
}
}
static void
vte_terminal_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
VteTerminal *terminal = VTE_TERMINAL (object);
switch (prop_id)
{
case PROP_HADJUSTMENT:
vte_terminal_set_hadjustment (terminal, (GtkAdjustment *)g_value_get_object (value));
break;
case PROP_VADJUSTMENT:
vte_terminal_set_vadjustment (terminal, (GtkAdjustment *)g_value_get_object (value));
break;
case PROP_HSCROLL_POLICY:
vte_terminal_set_hscroll_policy(terminal, (GtkScrollablePolicy)g_value_get_enum(value));
break;
case PROP_VSCROLL_POLICY:
vte_terminal_set_vscroll_policy(terminal, (GtkScrollablePolicy)g_value_get_enum(value));
break;
case PROP_ALLOW_BOLD:
vte_terminal_set_allow_bold (terminal, g_value_get_boolean (value));
break;
case PROP_ALLOW_HYPERLINK:
vte_terminal_set_allow_hyperlink (terminal, g_value_get_boolean (value));
break;
case PROP_AUDIBLE_BELL:
vte_terminal_set_audible_bell (terminal, g_value_get_boolean (value));
break;
case PROP_BACKSPACE_BINDING:
vte_terminal_set_backspace_binding (terminal, (VteEraseBinding)g_value_get_enum (value));
break;
case PROP_BOLD_IS_BRIGHT:
vte_terminal_set_bold_is_bright (terminal, g_value_get_boolean (value));
break;
case PROP_CELL_HEIGHT_SCALE:
vte_terminal_set_cell_height_scale (terminal, g_value_get_double (value));
break;
case PROP_CELL_WIDTH_SCALE:
vte_terminal_set_cell_width_scale (terminal, g_value_get_double (value));
break;
case PROP_CJK_AMBIGUOUS_WIDTH:
vte_terminal_set_cjk_ambiguous_width (terminal, g_value_get_int (value));
break;
case PROP_CURSOR_BLINK_MODE:
vte_terminal_set_cursor_blink_mode (terminal, (VteCursorBlinkMode)g_value_get_enum (value));
break;
case PROP_CURSOR_SHAPE:
vte_terminal_set_cursor_shape (terminal, (VteCursorShape)g_value_get_enum (value));
break;
case PROP_DELETE_BINDING:
vte_terminal_set_delete_binding (terminal, (VteEraseBinding)g_value_get_enum (value));
break;
case PROP_ENABLE_BIDI:
vte_terminal_set_enable_bidi (terminal, g_value_get_boolean (value));
break;
case PROP_ENABLE_SHAPING:
vte_terminal_set_enable_shaping (terminal, g_value_get_boolean (value));
break;
case PROP_ENCODING:
vte_terminal_set_encoding (terminal, g_value_get_string (value), NULL);
break;
case PROP_FONT_DESC:
vte_terminal_set_font (terminal, (PangoFontDescription *)g_value_get_boxed (value));
break;
case PROP_FONT_SCALE:
vte_terminal_set_font_scale (terminal, g_value_get_double (value));
break;
case PROP_INPUT_ENABLED:
vte_terminal_set_input_enabled (terminal, g_value_get_boolean (value));
break;
case PROP_MOUSE_POINTER_AUTOHIDE:
vte_terminal_set_mouse_autohide (terminal, g_value_get_boolean (value));
break;
case PROP_PTY:
vte_terminal_set_pty (terminal, (VtePty *)g_value_get_object (value));
break;
case PROP_REWRAP_ON_RESIZE:
vte_terminal_set_rewrap_on_resize (terminal, g_value_get_boolean (value));
break;
case PROP_SCROLLBACK_LINES:
vte_terminal_set_scrollback_lines (terminal, g_value_get_uint (value));
break;
case PROP_SCROLL_ON_KEYSTROKE:
vte_terminal_set_scroll_on_keystroke(terminal, g_value_get_boolean (value));
break;
case PROP_SCROLL_ON_OUTPUT:
vte_terminal_set_scroll_on_output (terminal, g_value_get_boolean (value));
break;
case PROP_TEXT_BLINK_MODE:
vte_terminal_set_text_blink_mode (terminal, (VteTextBlinkMode)g_value_get_enum (value));
break;
case PROP_WORD_CHAR_EXCEPTIONS:
vte_terminal_set_word_char_exceptions (terminal, g_value_get_string (value));
break;
/* Not writable */
case PROP_CURRENT_DIRECTORY_URI:
case PROP_CURRENT_FILE_URI:
case PROP_HYPERLINK_HOVER_URI:
case PROP_ICON_TITLE:
case PROP_WINDOW_TITLE:
g_assert_not_reached ();
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
return;
}
}
static void
vte_terminal_class_init(VteTerminalClass *klass)
{
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
GtkBindingSet *binding_set;
#ifdef VTE_DEBUG
{
_vte_debug_init();
_vte_debug_print(VTE_DEBUG_LIFECYCLE,
"vte_terminal_class_init()\n");
/* print out the legend */
_vte_debug_print(VTE_DEBUG_WORK,
"Debugging work flow (top input to bottom output):\n"
" . _vte_terminal_process_incoming\n"
" < start process_timeout\n"
" {[ start update_timeout [ => rate limited\n"
" T start of terminal in update_timeout\n"
" ( start _vte_terminal_process_incoming\n"
" ? _vte_invalidate_cells (call)\n"
" ! _vte_invalidate_cells (dirty)\n"
" * _vte_invalidate_all\n"
" ) end _vte_terminal_process_incoming\n"
" = vte_terminal_paint\n"
" ]} end update_timeout\n"
" > end process_timeout\n");
}
#endif
_VTE_DEBUG_IF (VTE_DEBUG_UPDATES) gdk_window_set_debug_updates(TRUE);
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
gobject_class = G_OBJECT_CLASS(klass);
widget_class = GTK_WIDGET_CLASS(klass);
/* Override some of the default handlers. */
gobject_class->constructed = vte_terminal_constructed;
gobject_class->dispose = vte_terminal_dispose;
gobject_class->finalize = vte_terminal_finalize;
gobject_class->get_property = vte_terminal_get_property;
gobject_class->set_property = vte_terminal_set_property;
widget_class->realize = vte_terminal_realize;
widget_class->unrealize = vte_terminal_unrealize;
widget_class->map = vte_terminal_map;
widget_class->unmap = vte_terminal_unmap;
widget_class->scroll_event = vte_terminal_scroll;
widget_class->draw = vte_terminal_draw;
widget_class->key_press_event = vte_terminal_key_press;
widget_class->key_release_event = vte_terminal_key_release;
widget_class->button_press_event = vte_terminal_button_press;
widget_class->button_release_event = vte_terminal_button_release;
widget_class->motion_notify_event = vte_terminal_motion_notify;
widget_class->enter_notify_event = vte_terminal_enter;
widget_class->leave_notify_event = vte_terminal_leave;
widget_class->focus_in_event = vte_terminal_focus_in;
widget_class->focus_out_event = vte_terminal_focus_out;
widget_class->style_updated = vte_terminal_style_updated;
widget_class->get_preferred_width = vte_terminal_get_preferred_width;
widget_class->get_preferred_height = vte_terminal_get_preferred_height;
widget_class->size_allocate = vte_terminal_size_allocate;
widget_class->screen_changed = vte_terminal_screen_changed;
#if GTK_CHECK_VERSION(3, 19, 5)
gtk_widget_class_set_css_name(widget_class, VTE_TERMINAL_CSS_NAME);
#else
/* Bug #763538 */
if (gtk_check_version(3, 19, 5) == nullptr)
g_printerr("VTE needs to be recompiled against a newer gtk+ version.\n");
#endif
/* Initialize default handlers. */
klass->eof = NULL;
klass->child_exited = NULL;
klass->encoding_changed = NULL;
klass->char_size_changed = NULL;
klass->window_title_changed = NULL;
klass->icon_title_changed = NULL;
klass->selection_changed = NULL;
klass->contents_changed = NULL;
klass->cursor_moved = NULL;
klass->commit = NULL;
klass->deiconify_window = NULL;
klass->iconify_window = NULL;
klass->raise_window = NULL;
klass->lower_window = NULL;
klass->refresh_window = NULL;
klass->restore_window = NULL;
klass->maximize_window = NULL;
klass->resize_window = NULL;
klass->move_window = NULL;
klass->increase_font_size = NULL;
klass->decrease_font_size = NULL;
klass->text_modified = NULL;
klass->text_inserted = NULL;
klass->text_deleted = NULL;
klass->text_scrolled = NULL;
klass->copy_clipboard = vte_terminal_real_copy_clipboard;
klass->paste_clipboard = vte_terminal_real_paste_clipboard;
klass->bell = NULL;
/* GtkScrollable interface properties */
g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
g_object_class_override_property (gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy");
g_object_class_override_property (gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy");
/* Register some signals of our own. */
/**
* VteTerminal::eof:
* @vteterminal: the object which received the signal
*
* Emitted when the terminal receives an end-of-file from a child which
* is running in the terminal. This signal is frequently (but not
* always) emitted with a #VteTerminal::child-exited signal.
*/
signals[SIGNAL_EOF] =
g_signal_new(I_("eof"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, eof),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_EOF],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::child-exited:
* @vteterminal: the object which received the signal
* @status: the child's exit status
*
* This signal is emitted when the terminal detects that a child
* watched using vte_terminal_watch_child() has exited.
*/
signals[SIGNAL_CHILD_EXITED] =
g_signal_new(I_("child-exited"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, child_exited),
NULL,
NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE,
1, G_TYPE_INT);
g_signal_set_va_marshaller(signals[SIGNAL_CHILD_EXITED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__INTv);
/**
* VteTerminal::window-title-changed:
* @vteterminal: the object which received the signal
*
* Emitted when the terminal's %window_title field is modified.
*/
signals[SIGNAL_WINDOW_TITLE_CHANGED] =
g_signal_new(I_("window-title-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, window_title_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_WINDOW_TITLE_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::icon-title-changed:
* @vteterminal: the object which received the signal
*
* Deprecated: 0.54: This signal is never emitted.
*/
signals[SIGNAL_ICON_TITLE_CHANGED] =
g_signal_new(I_("icon-title-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, icon_title_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_ICON_TITLE_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::current-directory-uri-changed:
* @vteterminal: the object which received the signal
*
* Emitted when the current directory URI is modified.
*/
signals[SIGNAL_CURRENT_DIRECTORY_URI_CHANGED] =
g_signal_new(I_("current-directory-uri-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_CURRENT_DIRECTORY_URI_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::current-file-uri-changed:
* @vteterminal: the object which received the signal
*
* Emitted when the current file URI is modified.
*/
signals[SIGNAL_CURRENT_FILE_URI_CHANGED] =
g_signal_new(I_("current-file-uri-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_CURRENT_FILE_URI_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::hyperlink-hover-uri-changed:
* @vteterminal: the object which received the signal
* @uri: the nonempty target URI under the mouse, or NULL
* @bbox: the bounding box of the hyperlink anchor text, or NULL
*
* Emitted when the hovered hyperlink changes.
*
* @uri and @bbox are owned by VTE, must not be modified, and might
* change after the signal handlers returns.
*
* The signal is not re-emitted when the bounding box changes for the
* same hyperlink. This might change in a future VTE version without notice.
*
* Since: 0.50
*/
signals[SIGNAL_HYPERLINK_HOVER_URI_CHANGED] =
g_signal_new(I_("hyperlink-hover-uri-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
_vte_marshal_VOID__STRING_BOXED,
G_TYPE_NONE,
2, G_TYPE_STRING, GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
g_signal_set_va_marshaller(signals[SIGNAL_HYPERLINK_HOVER_URI_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
_vte_marshal_VOID__STRING_BOXEDv);
/**
* VteTerminal::encoding-changed:
* @vteterminal: the object which received the signal
*
* Emitted whenever the terminal's current encoding has changed.
*
* Note: support for non-UTF-8 is deprecated.
*/
signals[SIGNAL_ENCODING_CHANGED] =
g_signal_new(I_("encoding-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, encoding_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_ENCODING_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::commit:
* @vteterminal: the object which received the signal
* @text: a string of text
* @size: the length of that string of text
*
* Emitted whenever the terminal receives input from the user and
* prepares to send it to the child process. The signal is emitted even
* when there is no child process.
*/
signals[SIGNAL_COMMIT] =
g_signal_new(I_("commit"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, commit),
NULL,
NULL,
_vte_marshal_VOID__STRING_UINT,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
g_signal_set_va_marshaller(signals[SIGNAL_COMMIT],
G_OBJECT_CLASS_TYPE(klass),
_vte_marshal_VOID__STRING_UINTv);
/**
* VteTerminal::char-size-changed:
* @vteterminal: the object which received the signal
* @width: the new character cell width
* @height: the new character cell height
*
* Emitted whenever the cell size changes, e.g. due to a change in
* font, font-scale or cell-width/height-scale.
*
* Note that this signal should rather be called "cell-size-changed".
*/
signals[SIGNAL_CHAR_SIZE_CHANGED] =
g_signal_new(I_("char-size-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, char_size_changed),
NULL,
NULL,
_vte_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
g_signal_set_va_marshaller(signals[SIGNAL_CHAR_SIZE_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
_vte_marshal_VOID__UINT_UINTv);
/**
* VteTerminal::selection-changed:
* @vteterminal: the object which received the signal
*
* Emitted whenever the contents of terminal's selection changes.
*/
signals[SIGNAL_SELECTION_CHANGED] =
g_signal_new (I_("selection-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, selection_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_SELECTION_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::contents-changed:
* @vteterminal: the object which received the signal
*
* Emitted whenever the visible appearance of the terminal has changed.
* Used primarily by #VteTerminalAccessible.
*/
signals[SIGNAL_CONTENTS_CHANGED] =
g_signal_new(I_("contents-changed"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, contents_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_CONTENTS_CHANGED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::cursor-moved:
* @vteterminal: the object which received the signal
*
* Emitted whenever the cursor moves to a new character cell. Used
* primarily by #VteTerminalAccessible.
*/
signals[SIGNAL_CURSOR_MOVED] =
g_signal_new(I_("cursor-moved"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, cursor_moved),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_CURSOR_MOVED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::deiconify-window:
* @vteterminal: the object which received the signal
*
* Emitted at the child application's request.
*/
signals[SIGNAL_DEICONIFY_WINDOW] =
g_signal_new(I_("deiconify-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, deiconify_window),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_DEICONIFY_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::iconify-window:
* @vteterminal: the object which received the signal
*
* Emitted at the child application's request.
*/
signals[SIGNAL_ICONIFY_WINDOW] =
g_signal_new(I_("iconify-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, iconify_window),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_ICONIFY_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::raise-window:
* @vteterminal: the object which received the signal
*
* Emitted at the child application's request.
*/
signals[SIGNAL_RAISE_WINDOW] =
g_signal_new(I_("raise-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, raise_window),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_RAISE_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::lower-window:
* @vteterminal: the object which received the signal
*
* Emitted at the child application's request.
*/
signals[SIGNAL_LOWER_WINDOW] =
g_signal_new(I_("lower-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, lower_window),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_LOWER_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::refresh-window:
* @vteterminal: the object which received the signal
*
* Emitted at the child application's request.
*/
signals[SIGNAL_REFRESH_WINDOW] =
g_signal_new(I_("refresh-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, refresh_window),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_REFRESH_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::restore-window:
* @vteterminal: the object which received the signal
*
* Emitted at the child application's request.
*/
signals[SIGNAL_RESTORE_WINDOW] =
g_signal_new(I_("restore-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, restore_window),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_RESTORE_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::maximize-window:
* @vteterminal: the object which received the signal
*
* Emitted at the child application's request.
*/
signals[SIGNAL_MAXIMIZE_WINDOW] =
g_signal_new(I_("maximize-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, maximize_window),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_MAXIMIZE_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::resize-window:
* @vteterminal: the object which received the signal
* @width: the desired number of columns
* @height: the desired number of rows
*
* Emitted at the child application's request.
*/
signals[SIGNAL_RESIZE_WINDOW] =
g_signal_new(I_("resize-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, resize_window),
NULL,
NULL,
_vte_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
g_signal_set_va_marshaller(signals[SIGNAL_RESIZE_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
_vte_marshal_VOID__UINT_UINTv);
/**
* VteTerminal::move-window:
* @vteterminal: the object which received the signal
* @x: the terminal's desired location, X coordinate
* @y: the terminal's desired location, Y coordinate
*
* Emitted at the child application's request.
*/
signals[SIGNAL_MOVE_WINDOW] =
g_signal_new(I_("move-window"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, move_window),
NULL,
NULL,
_vte_marshal_VOID__UINT_UINT,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
g_signal_set_va_marshaller(signals[SIGNAL_MOVE_WINDOW],
G_OBJECT_CLASS_TYPE(klass),
_vte_marshal_VOID__UINT_UINTv);
/**
* VteTerminal::increase-font-size:
* @vteterminal: the object which received the signal
*
* Emitted when the user hits the '+' key while holding the Control key.
*/
signals[SIGNAL_INCREASE_FONT_SIZE] =
g_signal_new(I_("increase-font-size"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, increase_font_size),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_INCREASE_FONT_SIZE],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::decrease-font-size:
* @vteterminal: the object which received the signal
*
* Emitted when the user hits the '-' key while holding the Control key.
*/
signals[SIGNAL_DECREASE_FONT_SIZE] =
g_signal_new(I_("decrease-font-size"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, decrease_font_size),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_DECREASE_FONT_SIZE],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::text-modified:
* @vteterminal: the object which received the signal
*
* An internal signal used for communication between the terminal and
* its accessibility peer. May not be emitted under certain
* circumstances.
*/
signals[SIGNAL_TEXT_MODIFIED] =
g_signal_new(I_("text-modified"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, text_modified),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_TEXT_MODIFIED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::text-inserted:
* @vteterminal: the object which received the signal
*
* An internal signal used for communication between the terminal and
* its accessibility peer. May not be emitted under certain
* circumstances.
*/
signals[SIGNAL_TEXT_INSERTED] =
g_signal_new(I_("text-inserted"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, text_inserted),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_TEXT_INSERTED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::text-deleted:
* @vteterminal: the object which received the signal
*
* An internal signal used for communication between the terminal and
* its accessibility peer. May not be emitted under certain
* circumstances.
*/
signals[SIGNAL_TEXT_DELETED] =
g_signal_new(I_("text-deleted"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, text_deleted),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_TEXT_DELETED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::text-scrolled:
* @vteterminal: the object which received the signal
* @delta: the number of lines scrolled
*
* An internal signal used for communication between the terminal and
* its accessibility peer. May not be emitted under certain
* circumstances.
*/
signals[SIGNAL_TEXT_SCROLLED] =
g_signal_new(I_("text-scrolled"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, text_scrolled),
NULL,
NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
g_signal_set_va_marshaller(signals[SIGNAL_TEXT_SCROLLED],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__INTv);
/**
* VteTerminal::copy-clipboard:
* @vteterminal: the object which received the signal
*
* Emitted whenever vte_terminal_copy_clipboard() is called.
*/
signals[SIGNAL_COPY_CLIPBOARD] =
g_signal_new(I_("copy-clipboard"),
G_OBJECT_CLASS_TYPE(klass),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
G_STRUCT_OFFSET(VteTerminalClass, copy_clipboard),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_COPY_CLIPBOARD],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::paste-clipboard:
* @vteterminal: the object which received the signal
*
* Emitted whenever vte_terminal_paste_clipboard() is called.
*/
signals[SIGNAL_PASTE_CLIPBOARD] =
g_signal_new(I_("paste-clipboard"),
G_OBJECT_CLASS_TYPE(klass),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
G_STRUCT_OFFSET(VteTerminalClass, paste_clipboard),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_PASTE_CLIPBOARD],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal::bell:
* @vteterminal: the object which received the signal
*
* This signal is emitted when the a child sends a bell request to the
* terminal.
*/
signals[SIGNAL_BELL] =
g_signal_new(I_("bell"),
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(VteTerminalClass, bell),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_set_va_marshaller(signals[SIGNAL_BELL],
G_OBJECT_CLASS_TYPE(klass),
g_cclosure_marshal_VOID__VOIDv);
/**
* VteTerminal:allow-bold:
*
* Controls whether or not the terminal will attempt to draw bold text.
* This may happen either by using a bold font variant, or by
* repainting text with a different offset.
*/
pspecs[PROP_ALLOW_BOLD] =
g_param_spec_boolean ("allow-bold", NULL, NULL,
TRUE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:allow-hyperlink:
*
* Controls whether or not hyperlinks (OSC 8 escape sequence) are recognized and displayed.
*
* Since: 0.50
*/
pspecs[PROP_ALLOW_HYPERLINK] =
g_param_spec_boolean ("allow-hyperlink", NULL, NULL,
FALSE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:audible-bell:
*
* Controls whether or not the terminal will beep when the child outputs the
* "bl" sequence.
*/
pspecs[PROP_AUDIBLE_BELL] =
g_param_spec_boolean ("audible-bell", NULL, NULL,
TRUE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:backspace-binding:
*
* Controls what string or control sequence the terminal sends to its child
* when the user presses the backspace key.
*/
pspecs[PROP_BACKSPACE_BINDING] =
g_param_spec_enum ("backspace-binding", NULL, NULL,
VTE_TYPE_ERASE_BINDING,
VTE_ERASE_AUTO,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:bold-is-bright:
*
* Whether the SGR 1 attribute also switches to the bright counterpart
* of the first 8 palette colors, in addition to making them bold (legacy behavior)
* or if SGR 1 only enables bold and leaves the color intact.
*
* Since: 0.52
*/
pspecs[PROP_BOLD_IS_BRIGHT] =
g_param_spec_boolean ("bold-is-bright", NULL, NULL,
FALSE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:cell-height-scale:
*
* Scale factor for the cell height, to increase line spacing. (The font's height is not affected.)
*
* Since: 0.52
*/
pspecs[PROP_CELL_HEIGHT_SCALE] =
g_param_spec_double ("cell-height-scale", NULL, NULL,
VTE_CELL_SCALE_MIN,
VTE_CELL_SCALE_MAX,
1.,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:cell-width-scale:
*
* Scale factor for the cell width, to increase letter spacing. (The font's width is not affected.)
*
* Since: 0.52
*/
pspecs[PROP_CELL_WIDTH_SCALE] =
g_param_spec_double ("cell-width-scale", NULL, NULL,
VTE_CELL_SCALE_MIN,
VTE_CELL_SCALE_MAX,
1.,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:cjk-ambiguous-width:
*
* This setting controls whether ambiguous-width characters are narrow or wide.
* (Note that when using a non-UTF-8 encoding set via vte_terminal_set_encoding(),
* the width of ambiguous-width characters is fixed and determined by the encoding
* itself.)
*
* This setting only takes effect the next time the terminal is reset, either
* via escape sequence or with vte_terminal_reset().
*/
pspecs[PROP_CJK_AMBIGUOUS_WIDTH] =
g_param_spec_int ("cjk-ambiguous-width", NULL, NULL,
1, 2, VTE_DEFAULT_UTF8_AMBIGUOUS_WIDTH,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:cursor-blink-mode:
*
* Sets whether or not the cursor will blink. Using %VTE_CURSOR_BLINK_SYSTEM
* will use the #GtkSettings::gtk-cursor-blink setting.
*/
pspecs[PROP_CURSOR_BLINK_MODE] =
g_param_spec_enum ("cursor-blink-mode", NULL, NULL,
VTE_TYPE_CURSOR_BLINK_MODE,
VTE_CURSOR_BLINK_SYSTEM,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:cursor-shape:
*
* Controls the shape of the cursor.
*/
pspecs[PROP_CURSOR_SHAPE] =
g_param_spec_enum ("cursor-shape", NULL, NULL,
VTE_TYPE_CURSOR_SHAPE,
VTE_CURSOR_SHAPE_BLOCK,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:delete-binding:
*
* Controls what string or control sequence the terminal sends to its child
* when the user presses the delete key.
*/
pspecs[PROP_DELETE_BINDING] =
g_param_spec_enum ("delete-binding", NULL, NULL,
VTE_TYPE_ERASE_BINDING,
VTE_ERASE_AUTO,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:enable-bidi:
*
* Controls whether or not the terminal will perform bidirectional text rendering.
*
* Since: 0.58
*/
pspecs[PROP_ENABLE_BIDI] =
g_param_spec_boolean ("enable-bidi", NULL, NULL,
TRUE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:enable-shaping:
*
* Controls whether or not the terminal will shape Arabic text.
*
* Since: 0.58
*/
pspecs[PROP_ENABLE_SHAPING] =
g_param_spec_boolean ("enable-shaping", NULL, NULL,
TRUE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:font-scale:
*
* The terminal's font scale.
*/
pspecs[PROP_FONT_SCALE] =
g_param_spec_double ("font-scale", NULL, NULL,
VTE_FONT_SCALE_MIN,
VTE_FONT_SCALE_MAX,
1.,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:encoding:
*
* Controls the encoding the terminal will expect data from the child to
* be encoded with. For certain terminal types, applications executing in the
* terminal can change the encoding. The default is defined by the
* application's locale settings.
*
* Deprecated: 0.54: Instead of using this, you should use a tool like
* luit(1) when support for non-UTF-8 is required
*/
pspecs[PROP_ENCODING] =
g_param_spec_string ("encoding", NULL, NULL,
NULL,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:font-desc:
*
* Specifies the font used for rendering all text displayed by the terminal,
* overriding any fonts set using gtk_widget_modify_font(). The terminal
* will immediately attempt to load the desired font, retrieve its
* metrics, and attempt to resize itself to keep the same number of rows
* and columns.
*/
pspecs[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", NULL, NULL,
PANGO_TYPE_FONT_DESCRIPTION,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:icon-title:
*
* Deprecated: 0.54: This property is always %NULL.
*/
pspecs[PROP_ICON_TITLE] =
g_param_spec_string ("icon-title", NULL, NULL,
NULL,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:input-enabled:
*
* Controls whether the terminal allows user input. When user input is disabled,
* key press and mouse button press and motion events are not sent to the
* terminal's child.
*/
pspecs[PROP_INPUT_ENABLED] =
g_param_spec_boolean ("input-enabled", NULL, NULL,
TRUE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:pointer-autohide:
*
* Controls the value of the terminal's mouse autohide setting. When autohiding
* is enabled, the mouse cursor will be hidden when the user presses a key and
* shown when the user moves the mouse.
*/
pspecs[PROP_MOUSE_POINTER_AUTOHIDE] =
g_param_spec_boolean ("pointer-autohide", NULL, NULL,
FALSE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:pty:
*
* The PTY object for the terminal.
*/
pspecs[PROP_PTY] =
g_param_spec_object ("pty", NULL, NULL,
VTE_TYPE_PTY,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:rewrap-on-resize:
*
* Controls whether or not the terminal will rewrap its contents, including
* the scrollback buffer, whenever the terminal's width changes.
*
* Deprecated: 0.58
*/
pspecs[PROP_REWRAP_ON_RESIZE] =
g_param_spec_boolean ("rewrap-on-resize", NULL, NULL,
TRUE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:scrollback-lines:
*
* The length of the scrollback buffer used by the terminal. The size of
* the scrollback buffer will be set to the larger of this value and the number
* of visible rows the widget can display, so 0 can safely be used to disable
* scrollback. Note that this setting only affects the normal screen buffer.
* For terminal types which have an alternate screen buffer, no scrollback is
* allowed on the alternate screen buffer.
*/
pspecs[PROP_SCROLLBACK_LINES] =
g_param_spec_uint ("scrollback-lines", NULL, NULL,
0, G_MAXUINT,
VTE_SCROLLBACK_INIT,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:scroll-on-keystroke:
*
* Controls whether or not the terminal will forcibly scroll to the bottom of
* the viewable history when the user presses a key. Modifier keys do not
* trigger this behavior.
*/
pspecs[PROP_SCROLL_ON_KEYSTROKE] =
g_param_spec_boolean ("scroll-on-keystroke", NULL, NULL,
FALSE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:scroll-on-output:
*
* Controls whether or not the terminal will forcibly scroll to the bottom of
* the viewable history when the new data is received from the child.
*/
pspecs[PROP_SCROLL_ON_OUTPUT] =
g_param_spec_boolean ("scroll-on-output", NULL, NULL,
TRUE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:text-blink-mode:
*
* Controls whether or not the terminal will allow blinking text.
*
* Since: 0.52
*/
pspecs[PROP_TEXT_BLINK_MODE] =
g_param_spec_enum ("text-blink-mode", NULL, NULL,
VTE_TYPE_TEXT_BLINK_MODE,
VTE_TEXT_BLINK_ALWAYS,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:window-title:
*
* The terminal's title.
*/
pspecs[PROP_WINDOW_TITLE] =
g_param_spec_string ("window-title", NULL, NULL,
NULL,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:current-directory-uri:
*
* The current directory URI, or %NULL if unset.
*/
pspecs[PROP_CURRENT_DIRECTORY_URI] =
g_param_spec_string ("current-directory-uri", NULL, NULL,
NULL,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:current-file-uri:
*
* The current file URI, or %NULL if unset.
*/
pspecs[PROP_CURRENT_FILE_URI] =
g_param_spec_string ("current-file-uri", NULL, NULL,
NULL,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:hyperlink-hover-uri:
*
* The currently hovered hyperlink URI, or %NULL if unset.
*
* Since: 0.50
*/
pspecs[PROP_HYPERLINK_HOVER_URI] =
g_param_spec_string ("hyperlink-hover-uri", NULL, NULL,
NULL,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
/**
* VteTerminal:word-char-exceptions:
*
* The set of characters which will be considered parts of a word
* when doing word-wise selection, in addition to the default which only
* considers alphanumeric characters part of a word.
*
* If %NULL, a built-in set is used.
*
* Since: 0.40
*/
pspecs[PROP_WORD_CHAR_EXCEPTIONS] =
g_param_spec_string ("word-char-exceptions", NULL, NULL,
NULL,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
g_object_class_install_properties(gobject_class, LAST_PROP, pspecs);
/* Disable GtkWidget's keybindings except for Shift-F10 and MenuKey
* which pop up the context menu.
*/
binding_set = gtk_binding_set_by_class(vte_terminal_parent_class);
gtk_binding_entry_skip(binding_set, GDK_KEY_F1, GDK_CONTROL_MASK);
gtk_binding_entry_skip(binding_set, GDK_KEY_F1, GDK_SHIFT_MASK);
gtk_binding_entry_skip(binding_set, GDK_KEY_KP_F1, GDK_CONTROL_MASK);
gtk_binding_entry_skip(binding_set, GDK_KEY_KP_F1, GDK_SHIFT_MASK);
process_timer = g_timer_new();
klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, VTE_TYPE_TERMINAL, VteTerminalClassPrivate);
klass->priv->style_provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (klass->priv->style_provider),
"VteTerminal, " VTE_TERMINAL_CSS_NAME " {\n"
"padding: 1px 1px 1px 1px;\n"
"background-color: @theme_base_color;\n"
"color: @theme_fg_color;\n"
"}\n",
-1, NULL);
/* a11y */
gtk_widget_class_set_accessible_type(widget_class, VTE_TYPE_TERMINAL_ACCESSIBLE);
}
/* public API */
/**
* vte_get_features:
*
* Gets a list of features vte was compiled with.
*
* Returns: (transfer none): a string with features
*
* Since: 0.40
*/
const char *
vte_get_features (void)
{
return
#ifdef WITH_FRIBIDI
"+BIDI"
#else
"-BIDI"
#endif
" "
#ifdef WITH_GNUTLS
"+GNUTLS"
#else
"-GNUTLS"
#endif
;
}
/**
* vte_get_major_version:
*
* Returns the major version of the VTE library at runtime.
* Contrast this with %VTE_MAJOR_VERSION which represents
* the version of the VTE library that the code was compiled
* with.
*
* Returns: the major version
*
* Since: 0.40
*/
guint
vte_get_major_version (void)
{
return VTE_MAJOR_VERSION;
}
/**
* vte_get_minor_version:
*
* Returns the minor version of the VTE library at runtime.
* Contrast this with %VTE_MINOR_VERSION which represents
* the version of the VTE library that the code was compiled
* with.
*
* Returns: the minor version
*
* Since: 0.40
*/
guint
vte_get_minor_version (void)
{
return VTE_MINOR_VERSION;
}
/**
* vte_get_micro_version:
*
* Returns the micro version of the VTE library at runtime.
* Contrast this with %VTE_MICRO_VERSION which represents
* the version of the VTE library that the code was compiled
* with.
*
* Returns: the micro version
*
* Since: 0.40
*/
guint
vte_get_micro_version (void)
{
return VTE_MICRO_VERSION;
}
/**
* vte_get_user_shell:
*
* Gets the user's shell, or %NULL. In the latter case, the
* system default (usually "/bin/sh") should be used.
*
* Returns: (transfer full) (type filename): a newly allocated string with the
* user's shell, or %NULL
*/
char *
vte_get_user_shell (void)
{
struct passwd *pwd;
pwd = getpwuid(getuid());
if (pwd && pwd->pw_shell)
return g_strdup (pwd->pw_shell);
return NULL;
}
/**
* vte_set_test_flags: (skip):
* @flags: flags
*
* Sets test flags. This function is only useful for implementing
* unit tests for vte itself; it is a no-op in non-debug builds.
*
* Since: 0.54
*/
void
vte_set_test_flags(guint64 flags)
{
#ifdef VTE_DEBUG
g_test_flags = flags;
#endif
}
/* VteTerminal public API */
/**
* vte_terminal_new:
*
* Creates a new terminal widget.
*
* Returns: (transfer none) (type Vte.Terminal): a new #VteTerminal object
*/
GtkWidget *
vte_terminal_new(void)
{
return (GtkWidget *)g_object_new(VTE_TYPE_TERMINAL, nullptr);
}
/**
* vte_terminal_copy_clipboard:
* @terminal: a #VteTerminal
*
* Places the selected text in the terminal in the #GDK_SELECTION_CLIPBOARD
* selection.
*
* Deprecated: 0.50: Use vte_terminal_copy_clipboard_format() with %VTE_FORMAT_TEXT
* instead.
*/
void
vte_terminal_copy_clipboard(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->emit_copy_clipboard();
}
/**
* vte_terminal_copy_clipboard_format:
* @terminal: a #VteTerminal
* @format: a #VteFormat
*
* Places the selected text in the terminal in the #GDK_SELECTION_CLIPBOARD
* selection in the form specified by @format.
*
* For all formats, the selection data (see #GtkSelectionData) will include the
* text targets (see gtk_target_list_add_text_targets() and
* gtk_selection_data_targets_includes_text()). For %VTE_FORMAT_HTML,
* the selection will also include the "text/html" target, which when requested,
* returns the HTML data in UTF-16 with a U+FEFF BYTE ORDER MARK character at
* the start.
*
* Since: 0.50
*/
void
vte_terminal_copy_clipboard_format(VteTerminal *terminal,
VteFormat format)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(format == VTE_FORMAT_TEXT || format == VTE_FORMAT_HTML);
WIDGET(terminal)->copy(VTE_SELECTION_CLIPBOARD, format);
}
/**
* vte_terminal_copy_primary:
* @terminal: a #VteTerminal
*
* Places the selected text in the terminal in the #GDK_SELECTION_PRIMARY
* selection.
*/
void
vte_terminal_copy_primary(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
_vte_debug_print(VTE_DEBUG_SELECTION, "Copying to PRIMARY.\n");
WIDGET(terminal)->copy(VTE_SELECTION_PRIMARY, VTE_FORMAT_TEXT);
}
/**
* vte_terminal_paste_clipboard:
* @terminal: a #VteTerminal
*
* Sends the contents of the #GDK_SELECTION_CLIPBOARD selection to the
* terminal's child. It's called on paste menu item, or when
* user presses Shift+Insert.
*/
void
vte_terminal_paste_clipboard(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->emit_paste_clipboard();
}
/**
* vte_terminal_paste_primary:
* @terminal: a #VteTerminal
*
* Sends the contents of the #GDK_SELECTION_PRIMARY selection to the terminal's
* child. The terminal will call also paste the
* #GDK_SELECTION_PRIMARY selection when the user clicks with the the second
* mouse button.
*/
void
vte_terminal_paste_primary(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
_vte_debug_print(VTE_DEBUG_SELECTION, "Pasting PRIMARY.\n");
WIDGET(terminal)->paste(GDK_SELECTION_PRIMARY);
}
/**
* vte_terminal_match_add_gregex:
* @terminal: a #VteTerminal
* @gregex: a #GRegex
* @gflags: the #GRegexMatchFlags to use when matching the regex
*
* Adds the regular expression @regex to the list of matching expressions. When the
* user moves the mouse cursor over a section of displayed text which matches
* this expression, the text will be highlighted.
*
* Returns: an integer associated with this expression, or -1 if @gregex could not be
* transformed into a #VteRegex or @gflags were incompatible
*
* Deprecated: 0.46: Use vte_terminal_match_add_regex() or vte_terminal_match_add_regex_full() instead.
*/
int
vte_terminal_match_add_gregex(VteTerminal *terminal,
GRegex *gregex,
GRegexMatchFlags gflags)
{
g_return_val_if_fail(gregex != NULL, -1);
auto regex = _vte_regex_new_gregex(VteRegexPurpose::match, gregex);
if (regex == NULL)
return -1;
auto rv = vte_terminal_match_add_regex(terminal, regex,
_vte_regex_translate_gregex_match_flags(gflags));
vte_regex_unref(regex);
return rv;
}
/**
* vte_terminal_match_add_regex:
* @terminal: a #VteTerminal
* @regex: (transfer none): a #VteRegex
* @flags: PCRE2 match flags, or 0
*
* Adds the regular expression @regex to the list of matching expressions. When the
* user moves the mouse cursor over a section of displayed text which matches
* this expression, the text will be highlighted.
*
* Returns: an integer associated with this expression
*
* Since: 0.46
*/
int
vte_terminal_match_add_regex(VteTerminal *terminal,
VteRegex *regex,
guint32 flags)
{
struct vte_match_regex new_regex_match;
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
g_return_val_if_fail(regex != NULL, -1);
g_return_val_if_fail(_vte_regex_has_purpose(regex, VteRegexPurpose::match), -1);
g_warn_if_fail(_vte_regex_get_compile_flags(regex) & PCRE2_MULTILINE);
auto impl = IMPL(terminal);
new_regex_match.regex.regex = vte_regex_ref(regex);
new_regex_match.regex.match_flags = flags;
new_regex_match.cursor_mode = VTE_REGEX_CURSOR_GDKCURSORTYPE;
new_regex_match.cursor.cursor_type = VTE_DEFAULT_CURSOR;
return impl->regex_match_add(&new_regex_match);
}
/**
* vte_terminal_match_check:
* @terminal: a #VteTerminal
* @column: the text column
* @row: the text row
* @tag: (out) (allow-none): a location to store the tag, or %NULL
*
* Checks if the text in and around the specified position matches any of the
* regular expressions previously set using vte_terminal_match_add(). If a
* match exists, the text string is returned and if @tag is not %NULL, the number
* associated with the matched regular expression will be stored in @tag.
*
* If more than one regular expression has been set with
* vte_terminal_match_add(), then expressions are checked in the order in
* which they were added.
*
* Returns: (transfer full): a newly allocated string which matches one of the previously
* set regular expressions
*
* Deprecated: 0.46: Use vte_terminal_match_check_event() instead.
*/
char *
vte_terminal_match_check(VteTerminal *terminal,
long column,
long row,
int *tag)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
return IMPL(terminal)->regex_match_check(column, row, tag);
}
/**
* vte_terminal_match_check_event:
* @terminal: a #VteTerminal
* @event: a #GdkEvent
* @tag: (out) (allow-none): a location to store the tag, or %NULL
*
* Checks if the text in and around the position of the event matches any of the
* regular expressions previously set using vte_terminal_match_add(). If a
* match exists, the text string is returned and if @tag is not %NULL, the number
* associated with the matched regular expression will be stored in @tag.
*
* If more than one regular expression has been set with
* vte_terminal_match_add(), then expressions are checked in the order in
* which they were added.
*
* Returns: (transfer full): a newly allocated string which matches one of the previously
* set regular expressions
*/
char *
vte_terminal_match_check_event(VteTerminal *terminal,
GdkEvent *event,
int *tag)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->regex_match_check(event, tag);
}
/**
* vte_terminal_hyperlink_check_event:
* @terminal: a #VteTerminal
* @event: a #GdkEvent
*
* Returns a nonempty string: the target of the explicit hyperlink (printed using the OSC 8
* escape sequence) at the position of the event, or %NULL.
*
* Proper use of the escape sequence should result in URI-encoded URIs with a proper scheme
* like "http://", "https://", "file://", "mailto:" etc. This is, however, not enforced by VTE.
* The caller must tolerate the returned string potentially not being a valid URI.
*
* Returns: (transfer full): a newly allocated string containing the target of the hyperlink
*
* Since: 0.50
*/
char *
vte_terminal_hyperlink_check_event(VteTerminal *terminal,
GdkEvent *event)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->hyperlink_check(event);
}
/**
* vte_terminal_event_check_regex_simple:
* @terminal: a #VteTerminal
* @event: a #GdkEvent
* @regexes: (array length=n_regexes): an array of #VteRegex
* @n_regexes: number of items in @regexes
* @match_flags: PCRE2 match flags, or 0
* @matches: (out caller-allocates) (array length=n_regexes): a location to store the matches
*
* Checks each regex in @regexes if the text in and around the position of
* the event matches the regular expressions. If a match exists, the matched
* text is stored in @matches at the position of the regex in @regexes; otherwise
* %NULL is stored there.
*
* Returns: %TRUE iff any of the regexes produced a match
*
* Since: 0.46
*/
gboolean
vte_terminal_event_check_regex_simple(VteTerminal *terminal,
GdkEvent *event,
VteRegex **regexes,
gsize n_regexes,
guint32 match_flags,
char **matches)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
g_return_val_if_fail(regexes != NULL || n_regexes == 0, FALSE);
for (gsize i = 0; i < n_regexes; i++) {
g_return_val_if_fail(_vte_regex_has_purpose(regexes[i], VteRegexPurpose::match), -1);
g_warn_if_fail(_vte_regex_get_compile_flags(regexes[i]) & PCRE2_MULTILINE);
}
g_return_val_if_fail(matches != NULL, FALSE);
return IMPL(terminal)->regex_match_check_extra(event, regexes, n_regexes, match_flags, matches);
}
/**
* vte_terminal_event_check_gregex_simple:
* @terminal: a #VteTerminal
* @event: a #GdkEvent
* @regexes: (array length=n_regexes): an array of #GRegex
* @n_regexes: number of items in @regexes
* @match_flags: the #GRegexMatchFlags to use when matching the regexes
* @matches: (out caller-allocates) (array length=n_regexes): a location to store the matches
*
* This function does nothing.
*
* Returns: %FALSE
*
* Since: 0.44
* Deprecated: 0.46: Use vte_terminal_event_check_regex_simple() instead.
*/
gboolean
vte_terminal_event_check_gregex_simple(VteTerminal *terminal,
GdkEvent *event,
GRegex **regexes,
gsize n_regexes,
GRegexMatchFlags match_flags,
char **matches)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
g_return_val_if_fail(regexes != NULL || n_regexes == 0, FALSE);
g_return_val_if_fail(matches != NULL, FALSE);
return FALSE;
}
/**
* vte_terminal_match_set_cursor:
* @terminal: a #VteTerminal
* @tag: the tag of the regex which should use the specified cursor
* @cursor: (allow-none): the #GdkCursor which the terminal should use when the pattern is
* highlighted, or %NULL to use the standard cursor
*
* Sets which cursor the terminal will use if the pointer is over the pattern
* specified by @tag. The terminal keeps a reference to @cursor.
*
* Deprecated: 0.40: Use vte_terminal_match_set_cursor_name() instead.
*/
void
vte_terminal_match_set_cursor(VteTerminal *terminal,
int tag,
GdkCursor *cursor)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->regex_match_set_cursor(tag, cursor);
}
/**
* vte_terminal_match_set_cursor_type:
* @terminal: a #VteTerminal
* @tag: the tag of the regex which should use the specified cursor
* @cursor_type: a #GdkCursorType
*
* Sets which cursor the terminal will use if the pointer is over the pattern
* specified by @tag.
*
* Deprecated: 0.54: Use vte_terminal_match_set_cursor_name() instead.
*/
void
vte_terminal_match_set_cursor_type(VteTerminal *terminal,
int tag,
GdkCursorType cursor_type)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->regex_match_set_cursor(tag, cursor_type);
}
/**
* vte_terminal_match_set_cursor_name:
* @terminal: a #VteTerminal
* @tag: the tag of the regex which should use the specified cursor
* @cursor_name: the name of the cursor
*
* Sets which cursor the terminal will use if the pointer is over the pattern
* specified by @tag.
*/
void
vte_terminal_match_set_cursor_name(VteTerminal *terminal,
int tag,
const char *cursor_name)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->regex_match_set_cursor(tag, cursor_name);
}
/**
* vte_terminal_match_remove:
* @terminal: a #VteTerminal
* @tag: the tag of the regex to remove
*
* Removes the regular expression which is associated with the given @tag from
* the list of expressions which the terminal will highlight when the user
* moves the mouse cursor over matching text.
*/
void
vte_terminal_match_remove(VteTerminal *terminal, int tag)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(tag != -1);
IMPL(terminal)->regex_match_remove(tag);
}
/**
* vte_terminal_match_remove_all:
* @terminal: a #VteTerminal
*
* Clears the list of regular expressions the terminal uses to highlight text
* when the user moves the mouse cursor.
*/
void
vte_terminal_match_remove_all(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->regex_match_remove_all();
}
/**
* vte_terminal_search_find_previous:
* @terminal: a #VteTerminal
*
* Searches the previous string matching the search regex set with
* vte_terminal_search_set_regex().
*
* Returns: %TRUE if a match was found
*/
gboolean
vte_terminal_search_find_previous (VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->search_find(true);
}
/**
* vte_terminal_search_find_next:
* @terminal: a #VteTerminal
*
* Searches the next string matching the search regex set with
* vte_terminal_search_set_regex().
*
* Returns: %TRUE if a match was found
*/
gboolean
vte_terminal_search_find_next (VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->search_find(false);
}
/**
* vte_terminal_search_set_regex:
* @terminal: a #VteTerminal
* @regex: (allow-none): a #VteRegex, or %NULL
* @flags: PCRE2 match flags, or 0
*
* Sets the regex to search for. Unsets the search regex when passed %NULL.
*
* Since: 0.46
*/
void
vte_terminal_search_set_regex (VteTerminal *terminal,
VteRegex *regex,
guint32 flags)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(regex == nullptr || _vte_regex_has_purpose(regex, VteRegexPurpose::search));
g_warn_if_fail(regex == nullptr || _vte_regex_get_compile_flags(regex) & PCRE2_MULTILINE);
IMPL(terminal)->search_set_regex(regex, flags);
}
/**
* vte_terminal_search_get_regex:
* @terminal: a #VteTerminal
*
* Returns: (transfer none): the search #VteRegex regex set in @terminal, or %NULL
*
* Since: 0.46
*/
VteRegex *
vte_terminal_search_get_regex(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
auto impl = IMPL(terminal);
return impl->m_search_regex.regex;
}
/**
* vte_terminal_search_set_gregex:
* @terminal: a #VteTerminal
* @gregex: (allow-none): a #GRegex, or %NULL
* @gflags: flags from #GRegexMatchFlags
*
* Sets the #GRegex regex to search for. Unsets the search regex when passed %NULL.
*
* Deprecated: 0.46: use vte_terminal_search_set_regex() instead.
*/
void
vte_terminal_search_set_gregex (VteTerminal *terminal,
GRegex *gregex,
GRegexMatchFlags gflags)
{
VteRegex *regex = nullptr;
if (gregex)
regex = _vte_regex_new_gregex(VteRegexPurpose::search, gregex);
vte_terminal_search_set_regex(terminal, regex,
_vte_regex_translate_gregex_match_flags(gflags));
if (regex)
vte_regex_unref(regex);
}
/**
* vte_terminal_search_get_gregex:
* @terminal: a #VteTerminal
*
* Returns: (transfer none): %NULL
*
* Deprecated: 0.46: use vte_terminal_search_get_regex() instead.
*/
GRegex *
vte_terminal_search_get_gregex (VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
return NULL;
}
/**
* vte_terminal_search_set_wrap_around:
* @terminal: a #VteTerminal
* @wrap_around: whether search should wrap
*
* Sets whether search should wrap around to the beginning of the
* terminal content when reaching its end.
*/
void
vte_terminal_search_set_wrap_around (VteTerminal *terminal,
gboolean wrap_around)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->search_set_wrap_around(wrap_around != FALSE);
}
/**
* vte_terminal_search_get_wrap_around:
* @terminal: a #VteTerminal
*
* Returns: whether searching will wrap around
*/
gboolean
vte_terminal_search_get_wrap_around (VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_search_wrap_around;
}
/**
* vte_terminal_select_all:
* @terminal: a #VteTerminal
*
* Selects all text within the terminal (including the scrollback buffer).
*/
void
vte_terminal_select_all (VteTerminal *terminal)
{
g_return_if_fail (VTE_IS_TERMINAL (terminal));
IMPL(terminal)->select_all();
}
/**
* vte_terminal_unselect_all:
* @terminal: a #VteTerminal
*
* Clears the current selection.
*/
void
vte_terminal_unselect_all(VteTerminal *terminal)
{
g_return_if_fail (VTE_IS_TERMINAL (terminal));
IMPL(terminal)->deselect_all();
}
/**
* vte_terminal_get_cursor_position:
* @terminal: a #VteTerminal
* @column: (out) (allow-none): a location to store the column, or %NULL
* @row: (out) (allow-none): a location to store the row, or %NULL
*
* Reads the location of the insertion cursor and returns it. The row
* coordinate is absolute.
*/
void
vte_terminal_get_cursor_position(VteTerminal *terminal,
long *column,
long *row)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
auto impl = IMPL(terminal);
if (column) {
*column = impl->m_screen->cursor.col;
}
if (row) {
*row = impl->m_screen->cursor.row;
}
}
/**
* vte_terminal_pty_new_sync:
* @terminal: a #VteTerminal
* @flags: flags from #VtePtyFlags
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Creates a new #VtePty, and sets the emulation property
* from #VteTerminal:emulation.
*
* See vte_pty_new() for more information.
*
* Returns: (transfer full): a new #VtePty
*/
VtePty *
vte_terminal_pty_new_sync(VteTerminal *terminal,
VtePtyFlags flags,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
VtePty *pty = vte_pty_new_sync(flags, cancellable, error);
if (pty == NULL)
return NULL;
return pty;
}
/**
* vte_terminal_watch_child:
* @terminal: a #VteTerminal
* @child_pid: a #GPid
*
* Watches @child_pid. When the process exists, the #VteTerminal::child-exited
* signal will be called with the child's exit status.
*
* Prior to calling this function, a #VtePty must have been set in @terminal
* using vte_terminal_set_pty().
* When the child exits, the terminal's #VtePty will be set to %NULL.
*
* Note: g_child_watch_add() or g_child_watch_add_full() must not have
* been called for @child_pid, nor a #GSource for it been created with
* g_child_watch_source_new().
*
* Note: when using the g_spawn_async() family of functions,
* the %G_SPAWN_DO_NOT_REAP_CHILD flag MUST have been passed.
*/
void
vte_terminal_watch_child (VteTerminal *terminal,
GPid child_pid)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(child_pid != -1);
auto impl = IMPL(terminal);
g_return_if_fail(impl->m_pty != NULL);
impl->watch_child(child_pid);
}
/**
* vte_terminal_spawn_sync:
* @terminal: a #VteTerminal
* @pty_flags: flags from #VtePtyFlags
* @working_directory: (allow-none): the name of a directory the command should start
* in, or %NULL to use the current working directory
* @argv: (array zero-terminated=1) (element-type filename): child's argument vector
* @envv: (allow-none) (array zero-terminated=1) (element-type filename): a list of environment
* variables to be added to the environment before starting the process, or %NULL
* @spawn_flags: flags from #GSpawnFlags
* @child_setup: (allow-none) (scope call): an extra child setup function to run in the child just before exec(), or %NULL
* @child_setup_data: user data for @child_setup
* @child_pid: (out) (allow-none) (transfer full): a location to store the child PID, or %NULL
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Starts the specified command under a newly-allocated controlling
* pseudo-terminal. The @argv and @envv lists should be %NULL-terminated.
* The "TERM" environment variable is automatically set to a default value,
* but can be overridden from @envv.
* @pty_flags controls logging the session to the specified system log files.
*
* Note that %G_SPAWN_DO_NOT_REAP_CHILD will always be added to @spawn_flags.
*
* Note that all open file descriptors will be closed in the child. If you want
* to keep some file descriptor open for use in the child process, you need to
* use a child setup function that unsets the FD_CLOEXEC flag on that file
* descriptor.
*
* See vte_pty_new(), g_spawn_async() and vte_terminal_watch_child() for more information.
*
* Beginning with 0.52, sets PWD to @working_directory in order to preserve symlink components.
* The caller should also make sure that symlinks were preserved while constructing the value of @working_directory,
* e.g. by using vte_terminal_get_current_directory_uri(), g_get_current_dir() or get_current_dir_name().
*
* Returns: %TRUE on success, or %FALSE on error with @error filled in
*
* Deprecated: 0.48: Use vte_terminal_spawn_async() instead.
*/
gboolean
vte_terminal_spawn_sync(VteTerminal *terminal,
VtePtyFlags pty_flags,
const char *working_directory,
char **argv,
char **envv,
GSpawnFlags spawn_flags_,
GSpawnChildSetupFunc child_setup,
gpointer child_setup_data,
GPid *child_pid /* out */,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
g_return_val_if_fail(argv != NULL, FALSE);
g_return_val_if_fail(child_setup_data == NULL || child_setup, FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
return IMPL(terminal)->spawn_sync(pty_flags,
working_directory,
argv,
envv,
spawn_flags_,
child_setup,
child_setup_data,
child_pid,
cancellable,
error);
}
typedef struct {
GWeakRef wref;
VteTerminalSpawnAsyncCallback callback;
gpointer user_data;
} SpawnAsyncCallbackData;
static gpointer
spawn_async_callback_data_new(VteTerminal *terminal,
VteTerminalSpawnAsyncCallback callback,
gpointer user_data)
{
SpawnAsyncCallbackData *data = g_new0 (SpawnAsyncCallbackData, 1);
g_weak_ref_init(&data->wref, terminal);
data->callback = callback;
data->user_data = user_data;
return data;
}
static void
spawn_async_callback_data_free (SpawnAsyncCallbackData *data)
{
g_weak_ref_clear(&data->wref);
g_free(data);
}
static void
spawn_async_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
SpawnAsyncCallbackData *data = reinterpret_cast<SpawnAsyncCallbackData*>(user_data);
VtePty *pty = VTE_PTY(source);
GPid pid = -1;
GError *error = nullptr;
vte_pty_spawn_finish(pty, result, &pid, &error);
/* Now get a ref to the terminal */
VteTerminal* terminal = (VteTerminal*)g_weak_ref_get(&data->wref);
/* Automatically watch the child */
if (terminal != nullptr) {
if (pid != -1) {
vte_terminal_set_pty(terminal, pty);
vte_terminal_watch_child(terminal, pid);
} else {
vte_terminal_set_pty(terminal, nullptr);
}
} else {
if (pid != -1) {
vte_reaper_add_child(pid);
}
}
if (data->callback)
data->callback(terminal, pid, error, data->user_data);
if (terminal == nullptr) {
/* If the terminal was destroyed, we need to abort the child process, if any */
if (pid != -1) {
#ifdef HAVE_GETPGID
pid_t pgrp;
pgrp = getpgid(pid);
if (pgrp != -1) {
kill(-pgrp, SIGHUP);
}
#endif
kill(pid, SIGHUP);
}
}
if (error)
g_error_free(error);
spawn_async_callback_data_free(data);
if (terminal != nullptr)
g_object_unref(terminal);
}
/**
* VteTerminalSpawnAsyncCallback:
* @terminal: the #VteTerminal
* @pid: a #GPid
* @error: a #GError, or %NULL
* @user_data: user data that was passed to vte_terminal_spawn_async
*
* Callback for vte_terminal_spawn_async().
*
* On success, @pid contains the PID of the spawned process, and @error
* is %NULL.
* On failure, @pid is -1 and @error contains the error information.
*
* Since: 0.48
*/
/**
* vte_terminal_spawn_async:
* @terminal: a #VteTerminal
* @pty_flags: flags from #VtePtyFlags
* @working_directory: (allow-none): the name of a directory the command should start
* in, or %NULL to use the current working directory
* @argv: (array zero-terminated=1) (element-type filename): child's argument vector
* @envv: (allow-none) (array zero-terminated=1) (element-type filename): a list of environment
* variables to be added to the environment before starting the process, or %NULL
* @spawn_flags_: flags from #GSpawnFlags
* @child_setup: (allow-none) (scope async): an extra child setup function to run in the child just before exec(), or %NULL
* @child_setup_data: (closure child_setup): user data for @child_setup, or %NULL
* @child_setup_data_destroy: (destroy child_setup_data): a #GDestroyNotify for @child_setup_data, or %NULL
* @timeout: a timeout value in ms, or -1 to wait indefinitely
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @callback: (scope async): a #VteTerminalSpawnAsyncCallback, or %NULL
* @user_data: (closure callback): user data for @callback, or %NULL
*
* A convenience function that wraps creating the #VtePty and spawning
* the child process on it. See vte_pty_new_sync(), vte_pty_spawn_async(),
* and vte_pty_spawn_finish() for more information.
*
* When the operation is finished successfully, @callback will be called
* with the child #GPid, and a %NULL #GError. The child PID will already be
* watched via vte_terminal_watch_child().
*
* When the operation fails, @callback will be called with a -1 #GPid,
* and a non-%NULL #GError containing the error information.
*
* Note that if @terminal has been destroyed before the operation is called,
* @callback will be called with a %NULL @terminal; you must not do anything
* in the callback besides freeing any resources associated with @user_data,
* but taking care not to access the now-destroyed #VteTerminal. Note that
* in this case, if spawning was successful, the child process will be aborted
* automatically.
*
* Beginning with 0.52, sets PWD to @working_directory in order to preserve symlink components.
* The caller should also make sure that symlinks were preserved while constructing the value of @working_directory,
* e.g. by using vte_terminal_get_current_directory_uri(), g_get_current_dir() or get_current_dir_name().
*
* Since: 0.48
*/
void
vte_terminal_spawn_async(VteTerminal *terminal,
VtePtyFlags pty_flags,
const char *working_directory,
char **argv,
char **envv,
GSpawnFlags spawn_flags_,
GSpawnChildSetupFunc child_setup,
gpointer child_setup_data,
GDestroyNotify child_setup_data_destroy,
int timeout,
GCancellable *cancellable,
VteTerminalSpawnAsyncCallback callback,
gpointer user_data)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(argv != nullptr);
g_return_if_fail(!child_setup_data || child_setup);
g_return_if_fail(!child_setup_data_destroy || child_setup_data);
g_return_if_fail(cancellable == nullptr || G_IS_CANCELLABLE (cancellable));
GError *error = NULL;
VtePty* pty = vte_terminal_pty_new_sync(terminal, pty_flags, cancellable, &error);
if (pty == nullptr) {
if (child_setup_data_destroy)
child_setup_data_destroy(child_setup_data);
callback(terminal, -1, error, user_data);
g_error_free(error);
return;
}
guint spawn_flags = (guint)spawn_flags_;
/* We do NOT support this flag. If you want to have some FD open in the child
* process, simply use a child setup function that unsets the CLOEXEC flag
* on that FD.
*/
spawn_flags &= ~G_SPAWN_LEAVE_DESCRIPTORS_OPEN;
vte_pty_spawn_async(pty,
working_directory,
argv,
envv,
GSpawnFlags(spawn_flags),
child_setup, child_setup_data, child_setup_data_destroy,
timeout, cancellable,
spawn_async_cb,
spawn_async_callback_data_new(terminal, callback, user_data));
g_object_unref(pty);
}
/**
* vte_terminal_feed:
* @terminal: a #VteTerminal
* @data: (array length=length) (element-type guint8) (allow-none): a string in the terminal's current encoding
* @length: the length of the string, or -1 to use the full length or a nul-terminated string
*
* Interprets @data as if it were data received from a child process. This
* can either be used to drive the terminal without a child process, or just
* to mess with your users.
*/
void
vte_terminal_feed(VteTerminal *terminal,
const char *data,
gssize length)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(length == 0 || data != NULL);
IMPL(terminal)->feed(data, length);
}
/**
* vte_terminal_feed_child:
* @terminal: a #VteTerminal
* @text: (array length=length) (element-type gchar) (allow-none): data to send to the child
* @length: length of @text in bytes, or -1 if @text is NUL-terminated
*
* Sends a block of UTF-8 text to the child as if it were entered by the user
* at the keyboard.
*/
void
vte_terminal_feed_child(VteTerminal *terminal,
const char *text,
gssize length)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(length == 0 || text != NULL);
IMPL(terminal)->feed_child(text, length);
}
/**
* vte_terminal_feed_child_binary:
* @terminal: a #VteTerminal
* @data: (array length=length) (element-type guint8) (allow-none): data to send to the child
* @length: length of @data
*
* Sends a block of binary data to the child.
*/
void
vte_terminal_feed_child_binary(VteTerminal *terminal,
const guint8 *data,
gsize length)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(length == 0 || data != NULL);
IMPL(terminal)->feed_child_binary(data, length);
}
/**
* VteSelectionFunc:
* @terminal: terminal in which the cell is.
* @column: column in which the cell is.
* @row: row in which the cell is.
* @data: (closure): user data.
*
* Specifies the type of a selection function used to check whether
* a cell has to be selected or not.
*
* Returns: %TRUE if cell has to be selected; %FALSE if otherwise.
*/
static void
warn_if_callback(VteSelectionFunc func)
{
if (!func)
return;
#ifndef VTE_DEBUG
static gboolean warned = FALSE;
if (warned)
return;
warned = TRUE;
#endif
g_warning ("VteSelectionFunc callback ignored.\n");
}
/**
* vte_terminal_get_text:
* @terminal: a #VteTerminal
* @is_selected: (scope call) (allow-none): a #VteSelectionFunc callback
* @user_data: (closure): user data to be passed to the callback
* @attributes: (out caller-allocates) (transfer full) (array) (element-type Vte.CharAttributes): location for storing text attributes
*
* Extracts a view of the visible part of the terminal. If @is_selected is not
* %NULL, characters will only be read if @is_selected returns %TRUE after being
* passed the column and row, respectively. A #VteCharAttributes structure
* is added to @attributes for each byte added to the returned string detailing
* the character's position, colors, and other characteristics.
*
* Returns: (transfer full): a newly allocated text string, or %NULL.
*/
char *
vte_terminal_get_text(VteTerminal *terminal,
VteSelectionFunc is_selected,
gpointer user_data,
GArray *attributes)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
warn_if_callback(is_selected);
auto text = IMPL(terminal)->get_text_displayed(true /* wrap */,
attributes);
if (text == nullptr)
return nullptr;
return (char*)g_string_free(text, FALSE);
}
/**
* vte_terminal_get_text_include_trailing_spaces:
* @terminal: a #VteTerminal
* @is_selected: (scope call) (allow-none): a #VteSelectionFunc callback
* @user_data: (closure): user data to be passed to the callback
* @attributes: (out caller-allocates) (transfer full) (array) (element-type Vte.CharAttributes): location for storing text attributes
*
* Extracts a view of the visible part of the terminal. If @is_selected is not
* %NULL, characters will only be read if @is_selected returns %TRUE after being
* passed the column and row, respectively. A #VteCharAttributes structure
* is added to @attributes for each byte added to the returned string detailing
* the character's position, colors, and other characteristics.
*
* Returns: (transfer full): a newly allocated text string, or %NULL.
*
* Deprecated: 0.56: Use vte_terminal_get_text() instead.
*/
char *
vte_terminal_get_text_include_trailing_spaces(VteTerminal *terminal,
VteSelectionFunc is_selected,
gpointer user_data,
GArray *attributes)
{
return vte_terminal_get_text(terminal, is_selected, user_data, attributes);
}
/**
* vte_terminal_get_text_range:
* @terminal: a #VteTerminal
* @start_row: first row to search for data
* @start_col: first column to search for data
* @end_row: last row to search for data
* @end_col: last column to search for data
* @is_selected: (scope call) (allow-none): a #VteSelectionFunc callback
* @user_data: (closure): user data to be passed to the callback
* @attributes: (out caller-allocates) (transfer full) (array) (element-type Vte.CharAttributes): location for storing text attributes
*
* Extracts a view of the visible part of the terminal. If @is_selected is not
* %NULL, characters will only be read if @is_selected returns %TRUE after being
* passed the column and row, respectively. A #VteCharAttributes structure
* is added to @attributes for each byte added to the returned string detailing
* the character's position, colors, and other characteristics. The
* entire scrollback buffer is scanned, so it is possible to read the entire
* contents of the buffer using this function.
*
* Returns: (transfer full): a newly allocated text string, or %NULL.
*/
char *
vte_terminal_get_text_range(VteTerminal *terminal,
long start_row,
long start_col,
long end_row,
long end_col,
VteSelectionFunc is_selected,
gpointer user_data,
GArray *attributes)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
warn_if_callback(is_selected);
auto text = IMPL(terminal)->get_text(start_row, start_col,
end_row, end_col,
false /* block */,
true /* wrap */,
attributes);
if (text == nullptr)
return nullptr;
return (char*)g_string_free(text, FALSE);
}
/**
* vte_terminal_reset:
* @terminal: a #VteTerminal
* @clear_tabstops: whether to reset tabstops
* @clear_history: whether to empty the terminal's scrollback buffer
*
* Resets as much of the terminal's internal state as possible, discarding any
* unprocessed input data, resetting character attributes, cursor state,
* national character set state, status line, terminal modes (insert/delete),
* selection state, and encoding.
*
*/
void
vte_terminal_reset(VteTerminal *terminal,
gboolean clear_tabstops,
gboolean clear_history)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->reset(clear_tabstops, clear_history, true);
}
/**
* vte_terminal_set_size:
* @terminal: a #VteTerminal
* @columns: the desired number of columns
* @rows: the desired number of rows
*
* Attempts to change the terminal's size in terms of rows and columns. If
* the attempt succeeds, the widget will resize itself to the proper size.
*/
void
vte_terminal_set_size(VteTerminal *terminal,
long columns,
long rows)
{
g_return_if_fail(columns >= 1);
g_return_if_fail(rows >= 1);
IMPL(terminal)->set_size(columns, rows);
}
/**
* vte_terminal_get_text_blink_mode:
* @terminal: a #VteTerminal
*
* Checks whether or not the terminal will allow blinking text.
*
* Returns: the blinking setting
*
* Since: 0.52
*/
VteTextBlinkMode
vte_terminal_get_text_blink_mode(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), VTE_TEXT_BLINK_ALWAYS);
return IMPL(terminal)->m_text_blink_mode;
}
/**
* vte_terminal_set_text_blink_mode:
* @terminal: a #VteTerminal
* @text_blink_mode: the #VteTextBlinkMode to use
*
* Controls whether or not the terminal will allow blinking text.
*
* Since: 0.52
*/
void
vte_terminal_set_text_blink_mode(VteTerminal *terminal,
VteTextBlinkMode text_blink_mode)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_text_blink_mode(text_blink_mode))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_TEXT_BLINK_MODE]);
}
/**
* vte_terminal_get_allow_bold:
* @terminal: a #VteTerminal
*
* Checks whether or not the terminal will attempt to draw bold text,
* either by using a bold font variant or by repainting text with a different
* offset.
*
* Returns: %TRUE if bolding is enabled, %FALSE if not
*/
gboolean
vte_terminal_get_allow_bold(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_allow_bold;
}
/**
* vte_terminal_set_allow_bold:
* @terminal: a #VteTerminal
* @allow_bold: %TRUE if the terminal should attempt to draw bold text
*
* Controls whether or not the terminal will attempt to draw bold text,
* either by using a bold font variant or by repainting text with a different
* offset.
*/
void
vte_terminal_set_allow_bold(VteTerminal *terminal,
gboolean allow_bold)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_allow_bold(allow_bold != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_ALLOW_BOLD]);
}
/**
* vte_terminal_get_allow_hyperlink:
* @terminal: a #VteTerminal
*
* Checks whether or not hyperlinks (OSC 8 escape sequence) are allowed.
*
* Returns: %TRUE if hyperlinks are enabled, %FALSE if not
*
* Since: 0.50
*/
gboolean
vte_terminal_get_allow_hyperlink(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_allow_hyperlink;
}
/**
* vte_terminal_set_allow_hyperlink:
* @terminal: a #VteTerminal
* @allow_hyperlink: %TRUE if the terminal should allow hyperlinks
*
* Controls whether or not hyperlinks (OSC 8 escape sequence) are allowed.
*
* Since: 0.50
*/
void
vte_terminal_set_allow_hyperlink(VteTerminal *terminal,
gboolean allow_hyperlink)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_allow_hyperlink(allow_hyperlink != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_ALLOW_HYPERLINK]);
}
/**
* vte_terminal_get_audible_bell:
* @terminal: a #VteTerminal
*
* Checks whether or not the terminal will beep when the child outputs the
* "bl" sequence.
*
* Returns: %TRUE if audible bell is enabled, %FALSE if not
*/
gboolean
vte_terminal_get_audible_bell(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_audible_bell;
}
/**
* vte_terminal_set_audible_bell:
* @terminal: a #VteTerminal
* @is_audible: %TRUE if the terminal should beep
*
* Controls whether or not the terminal will beep when the child outputs the
* "bl" sequence.
*/
void
vte_terminal_set_audible_bell(VteTerminal *terminal,
gboolean is_audible)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_audible_bell(is_audible != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_AUDIBLE_BELL]);
}
/**
* vte_terminal_set_backspace_binding:
* @terminal: a #VteTerminal
* @binding: a #VteEraseBinding for the backspace key
*
* Modifies the terminal's backspace key binding, which controls what
* string or control sequence the terminal sends to its child when the user
* presses the backspace key.
*/
void
vte_terminal_set_backspace_binding(VteTerminal *terminal,
VteEraseBinding binding)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(binding >= VTE_ERASE_AUTO && binding <= VTE_ERASE_TTY);
if (IMPL(terminal)->set_backspace_binding(binding))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_BACKSPACE_BINDING]);
}
/**
* vte_terminal_get_bold_is_bright:
* @terminal: a #VteTerminal
*
* Checks whether the SGR 1 attribute also switches to the bright counterpart
* of the first 8 palette colors, in addition to making them bold (legacy behavior)
* or if SGR 1 only enables bold and leaves the color intact.
*
* Returns: %TRUE if bold also enables bright, %FALSE if not
*
* Since: 0.52
*/
gboolean
vte_terminal_get_bold_is_bright(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_bold_is_bright;
}
/**
* vte_terminal_set_bold_is_bright:
* @terminal: a #VteTerminal
* @bold_is_bright: %TRUE if bold should also enable bright
*
* Sets whether the SGR 1 attribute also switches to the bright counterpart
* of the first 8 palette colors, in addition to making them bold (legacy behavior)
* or if SGR 1 only enables bold and leaves the color intact.
*
* Since: 0.52
*/
void
vte_terminal_set_bold_is_bright(VteTerminal *terminal,
gboolean bold_is_bright)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_bold_is_bright(bold_is_bright != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_BOLD_IS_BRIGHT]);
}
/**
* vte_terminal_get_char_height:
* @terminal: a #VteTerminal
*
* Returns: the height of a character cell
*
* Note that this method should rather be called vte_terminal_get_cell_height,
* because the return value takes cell-height-scale into account.
*/
glong
vte_terminal_get_char_height(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
return IMPL(terminal)->get_cell_height();
}
/**
* vte_terminal_get_char_width:
* @terminal: a #VteTerminal
*
* Returns: the width of a character cell
*
* Note that this method should rather be called vte_terminal_get_cell_width,
* because the return value takes cell-width-scale into account.
*/
glong
vte_terminal_get_char_width(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
return IMPL(terminal)->get_cell_width();
}
/**
* vte_terminal_get_cjk_ambiguous_width:
* @terminal: a #VteTerminal
*
* Returns whether ambiguous-width characters are narrow or wide.
* (Note that when using a non-UTF-8 encoding set via vte_terminal_set_encoding(),
* the width of ambiguous-width characters is fixed and determined by the encoding
* itself.)
*
* Returns: 1 if ambiguous-width characters are narrow, or 2 if they are wide
*/
int
vte_terminal_get_cjk_ambiguous_width(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), 1);
return IMPL(terminal)->m_utf8_ambiguous_width;
}
/**
* vte_terminal_set_cjk_ambiguous_width:
* @terminal: a #VteTerminal
* @width: either 1 (narrow) or 2 (wide)
*
* This setting controls whether ambiguous-width characters are narrow or wide.
* (Note that when using a non-UTF-8 encoding set via vte_terminal_set_encoding(),
* the width of ambiguous-width characters is fixed and determined by the encoding
* itself.)
*/
void
vte_terminal_set_cjk_ambiguous_width(VteTerminal *terminal, int width)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(width == 1 || width == 2);
if (IMPL(terminal)->set_cjk_ambiguous_width(width))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_CJK_AMBIGUOUS_WIDTH]);
}
/**
* vte_terminal_set_color_background:
* @terminal: a #VteTerminal
* @background: the new background color
*
* Sets the background color for text which does not have a specific background
* color assigned. Only has effect when no background image is set and when
* the terminal is not transparent.
*/
void
vte_terminal_set_color_background(VteTerminal *terminal,
const GdkRGBA *background)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(background != NULL);
g_return_if_fail(valid_color(background));
auto impl = IMPL(terminal);
impl->set_color_background(vte::color::rgb(background));
impl->set_background_alpha(background->alpha);
}
/**
* vte_terminal_set_color_bold:
* @terminal: a #VteTerminal
* @bold: (allow-none): the new bold color or %NULL
*
* Sets the color used to draw bold text in the default foreground color.
* If @bold is %NULL then the default color is used.
*/
void
vte_terminal_set_color_bold(VteTerminal *terminal,
const GdkRGBA *bold)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(bold == nullptr || valid_color(bold));
auto impl = IMPL(terminal);
if (bold)
impl->set_color_bold(vte::color::rgb(bold));
else
impl->reset_color_bold();
}
/**
* vte_terminal_set_color_cursor:
* @terminal: a #VteTerminal
* @cursor_background: (allow-none): the new color to use for the text cursor, or %NULL
*
* Sets the background color for text which is under the cursor. If %NULL, text
* under the cursor will be drawn with foreground and background colors
* reversed.
*/
void
vte_terminal_set_color_cursor(VteTerminal *terminal,
const GdkRGBA *cursor_background)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(cursor_background == nullptr || valid_color(cursor_background));
auto impl = IMPL(terminal);
if (cursor_background)
impl->set_color_cursor_background(vte::color::rgb(cursor_background));
else
impl->reset_color_cursor_background();
}
/**
* vte_terminal_set_color_cursor_foreground:
* @terminal: a #VteTerminal
* @cursor_foreground: (allow-none): the new color to use for the text cursor, or %NULL
*
* Sets the foreground color for text which is under the cursor. If %NULL, text
* under the cursor will be drawn with foreground and background colors
* reversed.
*
* Since: 0.44
*/
void
vte_terminal_set_color_cursor_foreground(VteTerminal *terminal,
const GdkRGBA *cursor_foreground)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(cursor_foreground == nullptr || valid_color(cursor_foreground));
auto impl = IMPL(terminal);
if (cursor_foreground)
impl->set_color_cursor_foreground(vte::color::rgb(cursor_foreground));
else
impl->reset_color_cursor_foreground();
}
/**
* vte_terminal_set_color_foreground:
* @terminal: a #VteTerminal
* @foreground: the new foreground color
*
* Sets the foreground color used to draw normal text.
*/
void
vte_terminal_set_color_foreground(VteTerminal *terminal,
const GdkRGBA *foreground)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(foreground != nullptr);
g_return_if_fail(valid_color(foreground));
IMPL(terminal)->set_color_foreground(vte::color::rgb(foreground));
}
/**
* vte_terminal_set_color_highlight:
* @terminal: a #VteTerminal
* @highlight_background: (allow-none): the new color to use for highlighted text, or %NULL
*
* Sets the background color for text which is highlighted. If %NULL,
* it is unset. If neither highlight background nor highlight foreground are set,
* highlighted text (which is usually highlighted because it is selected) will
* be drawn with foreground and background colors reversed.
*/
void
vte_terminal_set_color_highlight(VteTerminal *terminal,
const GdkRGBA *highlight_background)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(highlight_background == nullptr || valid_color(highlight_background));
auto impl = IMPL(terminal);
if (highlight_background)
impl->set_color_highlight_background(vte::color::rgb(highlight_background));
else
impl->reset_color_highlight_background();
}
/**
* vte_terminal_set_color_highlight_foreground:
* @terminal: a #VteTerminal
* @highlight_foreground: (allow-none): the new color to use for highlighted text, or %NULL
*
* Sets the foreground color for text which is highlighted. If %NULL,
* it is unset. If neither highlight background nor highlight foreground are set,
* highlighted text (which is usually highlighted because it is selected) will
* be drawn with foreground and background colors reversed.
*/
void
vte_terminal_set_color_highlight_foreground(VteTerminal *terminal,
const GdkRGBA *highlight_foreground)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(highlight_foreground == nullptr || valid_color(highlight_foreground));
auto impl = IMPL(terminal);
if (highlight_foreground)
impl->set_color_highlight_foreground(vte::color::rgb(highlight_foreground));
else
impl->reset_color_highlight_foreground();
}
/**
* vte_terminal_set_colors:
* @terminal: a #VteTerminal
* @foreground: (allow-none): the new foreground color, or %NULL
* @background: (allow-none): the new background color, or %NULL
* @palette: (array length=palette_size zero-terminated=0) (element-type Gdk.RGBA) (allow-none): the color palette
* @palette_size: the number of entries in @palette
*
* @palette specifies the new values for the 256 palette colors: 8 standard colors,
* their 8 bright counterparts, 6x6x6 color cube, and 24 grayscale colors.
* Omitted entries will default to a hardcoded value.
*
* @palette_size must be 0, 8, 16, 232 or 256.
*
* If @foreground is %NULL and @palette_size is greater than 0, the new foreground
* color is taken from @palette[7]. If @background is %NULL and @palette_size is
* greater than 0, the new background color is taken from @palette[0].
*/
void
vte_terminal_set_colors(VteTerminal *terminal,
const GdkRGBA *foreground,
const GdkRGBA *background,
const GdkRGBA *palette,
gsize palette_size)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail((palette_size == 0) ||
(palette_size == 8) ||
(palette_size == 16) ||
(palette_size == 232) ||
(palette_size == 256));
g_return_if_fail(foreground == nullptr || valid_color(foreground));
g_return_if_fail(background == nullptr || valid_color(background));
for (gsize i = 0; i < palette_size; ++i)
g_return_if_fail(valid_color(&palette[i]));
vte::color::rgb fg;
if (foreground)
fg = vte::color::rgb(foreground);
vte::color::rgb bg;
if (background)
bg = vte::color::rgb(background);
vte::color::rgb* pal = nullptr;
if (palette_size) {
pal = g_new0(vte::color::rgb, palette_size);
for (gsize i = 0; i < palette_size; ++i)
pal[i] = vte::color::rgb(palette[i]);
}
auto impl = IMPL(terminal);
impl->set_colors(foreground ? &fg : nullptr,
background ? &bg : nullptr,
pal, palette_size);
impl->set_background_alpha(background ? background->alpha : 1.0);
g_free(pal);
}
/**
* vte_terminal_set_default_colors:
* @terminal: a #VteTerminal
*
* Reset the terminal palette to reasonable compiled-in default color.
*/
void
vte_terminal_set_default_colors(VteTerminal *terminal)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->set_colors_default();
}
/**
* vte_terminal_get_column_count:
* @terminal: a #VteTerminal
*
* Returns: the number of columns
*/
glong
vte_terminal_get_column_count(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
return IMPL(terminal)->m_column_count;
}
/**
* vte_terminal_get_current_directory_uri:
* @terminal: a #VteTerminal
*
* Returns: (nullable) (transfer none): the URI of the current directory of the
* process running in the terminal, or %NULL
*/
const char *
vte_terminal_get_current_directory_uri(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
auto impl = IMPL(terminal);
return impl->m_current_directory_uri.size() ? impl->m_current_directory_uri.data() : nullptr;
}
/**
* vte_terminal_get_current_file_uri:
* @terminal: a #VteTerminal
*
* Returns: (nullable) (transfer none): the URI of the current file the
* process running in the terminal is operating on, or %NULL if
* not set
*/
const char *
vte_terminal_get_current_file_uri(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
auto impl = IMPL(terminal);
return impl->m_current_file_uri.size() ? impl->m_current_file_uri.data() : nullptr;
}
/**
* vte_terminal_get_cursor_blink_mode:
* @terminal: a #VteTerminal
*
* Returns the currently set cursor blink mode.
*
* Return value: cursor blink mode.
*/
VteCursorBlinkMode
vte_terminal_get_cursor_blink_mode(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), VTE_CURSOR_BLINK_SYSTEM);
return IMPL(terminal)->m_cursor_blink_mode;
}
/**
* vte_terminal_set_cursor_blink_mode:
* @terminal: a #VteTerminal
* @mode: the #VteCursorBlinkMode to use
*
* Sets whether or not the cursor will blink. Using %VTE_CURSOR_BLINK_SYSTEM
* will use the #GtkSettings::gtk-cursor-blink setting.
*/
void
vte_terminal_set_cursor_blink_mode(VteTerminal *terminal,
VteCursorBlinkMode mode)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(mode >= VTE_CURSOR_BLINK_SYSTEM && mode <= VTE_CURSOR_BLINK_OFF);
if (IMPL(terminal)->set_cursor_blink_mode(mode))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_CURSOR_BLINK_MODE]);
}
/**
* vte_terminal_get_cursor_shape:
* @terminal: a #VteTerminal
*
* Returns the currently set cursor shape.
*
* Return value: cursor shape.
*/
VteCursorShape
vte_terminal_get_cursor_shape(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), VTE_CURSOR_SHAPE_BLOCK);
return IMPL(terminal)->m_cursor_shape;
}
/**
* vte_terminal_set_cursor_shape:
* @terminal: a #VteTerminal
* @shape: the #VteCursorShape to use
*
* Sets the shape of the cursor drawn.
*/
void
vte_terminal_set_cursor_shape(VteTerminal *terminal, VteCursorShape shape)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(shape >= VTE_CURSOR_SHAPE_BLOCK && shape <= VTE_CURSOR_SHAPE_UNDERLINE);
if (IMPL(terminal)->set_cursor_shape(shape))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_CURSOR_SHAPE]);
}
/**
* vte_terminal_set_delete_binding:
* @terminal: a #VteTerminal
* @binding: a #VteEraseBinding for the delete key
*
* Modifies the terminal's delete key binding, which controls what
* string or control sequence the terminal sends to its child when the user
* presses the delete key.
*/
void
vte_terminal_set_delete_binding(VteTerminal *terminal,
VteEraseBinding binding)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(binding >= VTE_ERASE_AUTO && binding <= VTE_ERASE_TTY);
if (IMPL(terminal)->set_delete_binding(binding))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_DELETE_BINDING]);
}
/**
* vte_terminal_get_enable_bidi:
* @terminal: a #VteTerminal
*
* Checks whether the terminal performs bidirectional text rendering.
*
* Returns: %TRUE if BiDi is enabled, %FALSE if not
*
* Since: 0.58
*/
gboolean
vte_terminal_get_enable_bidi(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_enable_bidi;
}
/**
* vte_terminal_set_enable_bidi:
* @terminal: a #VteTerminal
* @enable_bidi: %TRUE to enable BiDi support
*
* Controls whether or not the terminal will perform bidirectional text rendering.
*
* Since: 0.58
*/
void
vte_terminal_set_enable_bidi(VteTerminal *terminal,
gboolean enable_bidi)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_enable_bidi(enable_bidi != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_ENABLE_BIDI]);
}
/**
* vte_terminal_get_enable_shaping:
* @terminal: a #VteTerminal
*
* Checks whether the terminal shapes Arabic text.
*
* Returns: %TRUE if Arabic shaping is enabled, %FALSE if not
*
* Since: 0.58
*/
gboolean
vte_terminal_get_enable_shaping(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_enable_shaping;
}
/**
* vte_terminal_set_enable_shaping:
* @terminal: a #VteTerminal
* @enable_shaping: %TRUE to enable Arabic shaping
*
* Controls whether or not the terminal will shape Arabic text.
*
* Since: 0.58
*/
void
vte_terminal_set_enable_shaping(VteTerminal *terminal,
gboolean enable_shaping)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_enable_shaping(enable_shaping != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_ENABLE_SHAPING]);
}
/**
* vte_terminal_get_encoding:
* @terminal: a #VteTerminal
*
* Determines the name of the encoding in which the terminal expects data to be
* encoded, or %NULL if UTF-8 is in use.
*
* Returns: (nullable) (transfer none): the current encoding for the terminal
*
* Deprecated: 0.54: Support for non-UTF-8 is deprecated.
*/
const char *
vte_terminal_get_encoding(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
return WIDGET(terminal)->encoding();
}
/**
* vte_terminal_set_encoding:
* @terminal: a #VteTerminal
* @codeset: (allow-none): a valid #GIConv target, or %NULL to use UTF-8
* @error: (allow-none): return location for a #GError, or %NULL
*
* Changes the encoding the terminal will expect data from the child to
* be encoded with. For certain terminal types, applications executing in the
* terminal can change the encoding. If @codeset is %NULL, it uses "UTF-8".
*
* Note: Support for non-UTF-8 is deprecated and may get removed altogether.
* Instead of this function, you should use a wrapper like luit(1) when
* spawning the child process.
*
* Returns: %TRUE if the encoding could be changed to the specified one,
* or %FALSE with @error set to %G_CONVERT_ERROR_NO_CONVERSION.
*
* Deprecated: 0.54: Support for non-UTF-8 is deprecated.
*/
gboolean
vte_terminal_set_encoding(VteTerminal *terminal,
const char *codeset,
GError **error)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
GObject *object = G_OBJECT(terminal);
g_object_freeze_notify(object);
bool rv = IMPL(terminal)->set_encoding(codeset);
if (rv)
g_object_notify_by_pspec(object, pspecs[PROP_ENCODING]);
else
g_set_error(error, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION,
_("Unable to convert characters from %s to %s."),
"UTF-8", codeset);
g_object_thaw_notify(object);
return rv;
}
/**
* vte_terminal_get_font:
* @terminal: a #VteTerminal
*
* Queries the terminal for information about the fonts which will be
* used to draw text in the terminal. The actual font takes the font scale
* into account, this is not reflected in the return value, the unscaled
* font is returned.
*
* Returns: (transfer none): a #PangoFontDescription describing the font the
* terminal uses to render text at the default font scale of 1.0.
*/
const PangoFontDescription *
vte_terminal_get_font(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
return IMPL(terminal)->m_unscaled_font_desc;
}
/**
* vte_terminal_set_font:
* @terminal: a #VteTerminal
* @font_desc: (allow-none): a #PangoFontDescription for the desired font, or %NULL
*
* Sets the font used for rendering all text displayed by the terminal,
* overriding any fonts set using gtk_widget_modify_font(). The terminal
* will immediately attempt to load the desired font, retrieve its
* metrics, and attempt to resize itself to keep the same number of rows
* and columns. The font scale is applied to the specified font.
*/
void
vte_terminal_set_font(VteTerminal *terminal,
const PangoFontDescription *font_desc)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_font_desc(font_desc))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_FONT_DESC]);
}
/**
* vte_terminal_get_font_scale:
* @terminal: a #VteTerminal
*
* Returns: the terminal's font scale
*/
gdouble
vte_terminal_get_font_scale(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), 1.);
return IMPL(terminal)->m_font_scale;
}
/**
* vte_terminal_set_font_scale:
* @terminal: a #VteTerminal
* @scale: the font scale
*
* Sets the terminal's font scale to @scale.
*/
void
vte_terminal_set_font_scale(VteTerminal *terminal,
double scale)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
scale = CLAMP(scale, VTE_FONT_SCALE_MIN, VTE_FONT_SCALE_MAX);
if (IMPL(terminal)->set_font_scale(scale))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_FONT_SCALE]);
}
/**
* vte_terminal_get_cell_height_scale:
* @terminal: a #VteTerminal
*
* Returns: the terminal's cell height scale
*
* Since: 0.52
*/
double
vte_terminal_get_cell_height_scale(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), 1.);
return IMPL(terminal)->m_cell_height_scale;
}
/**
* vte_terminal_set_cell_height_scale:
* @terminal: a #VteTerminal
* @scale: the cell height scale
*
* Sets the terminal's cell height scale to @scale.
*
* This can be used to increase the line spacing. (The font's height is not affected.)
* Valid values go from 1.0 (default) to 2.0 ("double spacing").
*
* Since: 0.52
*/
void
vte_terminal_set_cell_height_scale(VteTerminal *terminal,
double scale)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
scale = CLAMP(scale, VTE_CELL_SCALE_MIN, VTE_CELL_SCALE_MAX);
if (IMPL(terminal)->set_cell_height_scale(scale))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_CELL_HEIGHT_SCALE]);
}
/**
* vte_terminal_get_cell_width_scale:
* @terminal: a #VteTerminal
*
* Returns: the terminal's cell width scale
*
* Since: 0.52
*/
double
vte_terminal_get_cell_width_scale(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), 1.);
return IMPL(terminal)->m_cell_width_scale;
}
/**
* vte_terminal_set_cell_width_scale:
* @terminal: a #VteTerminal
* @scale: the cell width scale
*
* Sets the terminal's cell width scale to @scale.
*
* This can be used to increase the letter spacing. (The font's width is not affected.)
* Valid values go from 1.0 (default) to 2.0.
*
* Since: 0.52
*/
void
vte_terminal_set_cell_width_scale(VteTerminal *terminal,
double scale)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
scale = CLAMP(scale, VTE_CELL_SCALE_MIN, VTE_CELL_SCALE_MAX);
if (IMPL(terminal)->set_cell_width_scale(scale))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_CELL_WIDTH_SCALE]);
}
/* Just some arbitrary minimum values */
#define MIN_COLUMNS (16)
#define MIN_ROWS (2)
/**
* vte_terminal_get_geometry_hints:
* @terminal: a #VteTerminal
* @hints: (out caller-allocates): a #GdkGeometry to fill in
* @min_rows: the minimum number of rows to request
* @min_columns: the minimum number of columns to request
*
* Fills in some @hints from @terminal's geometry. The hints
* filled are those covered by the %GDK_HINT_RESIZE_INC,
* %GDK_HINT_MIN_SIZE and %GDK_HINT_BASE_SIZE flags.
*
* See gtk_window_set_geometry_hints() for more information.
*
* @terminal must be realized (see gtk_widget_get_realized()).
*
* Deprecated: 0.52
*/
void
vte_terminal_get_geometry_hints(VteTerminal *terminal,
GdkGeometry *hints,
int min_rows,
int min_columns)
{
GtkWidget *widget;
GtkBorder padding;
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(hints != NULL);
widget = &terminal->widget;
g_return_if_fail(gtk_widget_get_realized(widget));
auto impl = IMPL(terminal);
auto context = gtk_widget_get_style_context(widget);
gtk_style_context_get_padding(context, gtk_style_context_get_state(context),
&padding);
hints->base_width = padding.left + padding.right;
hints->base_height = padding.top + padding.bottom;
hints->width_inc = impl->m_cell_width;
hints->height_inc = impl->m_cell_height;
hints->min_width = hints->base_width + hints->width_inc * min_columns;
hints->min_height = hints->base_height + hints->height_inc * min_rows;
_vte_debug_print(VTE_DEBUG_WIDGET_SIZE,
"[Terminal %p] Geometry cell width %ld height %ld\n"
" base width %d height %d\n"
" increments width %d height %d\n"
" minimum width %d height %d\n",
terminal,
impl->m_cell_width, impl->m_cell_height,
hints->base_width, hints->base_height,
hints->width_inc, hints->height_inc,
hints->min_width, hints->min_height);
}
/**
* vte_terminal_set_geometry_hints_for_window:
* @terminal: a #VteTerminal
* @window: a #GtkWindow
*
* Sets @terminal as @window's geometry widget. See
* gtk_window_set_geometry_hints() for more information.
*
* @terminal must be realized (see gtk_widget_get_realized()).
*
* Deprecated: 0.52
*/
void
vte_terminal_set_geometry_hints_for_window(VteTerminal *terminal,
GtkWindow *window)
{
GdkGeometry hints;
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(gtk_widget_get_realized(&terminal->widget));
vte_terminal_get_geometry_hints(terminal, &hints, MIN_ROWS, MIN_COLUMNS);
gtk_window_set_geometry_hints(window,
#if GTK_CHECK_VERSION (3, 19, 5)
NULL,
#else
&terminal->widget,
#endif
&hints,
(GdkWindowHints)(GDK_HINT_RESIZE_INC |
GDK_HINT_MIN_SIZE |
GDK_HINT_BASE_SIZE));
}
/**
* vte_terminal_get_has_selection:
* @terminal: a #VteTerminal
*
* Checks if the terminal currently contains selected text. Note that this
* is different from determining if the terminal is the owner of any
* #GtkClipboard items.
*
* Returns: %TRUE if part of the text in the terminal is selected.
*/
gboolean
vte_terminal_get_has_selection(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return !IMPL(terminal)->m_selection_resolved.empty();
}
/**
* vte_terminal_get_icon_title:
* @terminal: a #VteTerminal
*
* Returns: (nullable) (transfer none): %NULL
*
* Deprecated: 0.54:
*/
const char *
vte_terminal_get_icon_title(VteTerminal *terminal)
{
return nullptr;
}
/**
* vte_terminal_get_input_enabled:
* @terminal: a #VteTerminal
*
* Returns whether the terminal allow user input.
*/
gboolean
vte_terminal_get_input_enabled (VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_input_enabled;
}
/**
* vte_terminal_set_input_enabled:
* @terminal: a #VteTerminal
* @enabled: whether to enable user input
*
* Enables or disables user input. When user input is disabled,
* the terminal's child will not receive any key press, or mouse button
* press or motion events sent to it.
*/
void
vte_terminal_set_input_enabled (VteTerminal *terminal,
gboolean enabled)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_input_enabled(enabled != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_INPUT_ENABLED]);
}
/**
* vte_terminal_get_mouse_autohide:
* @terminal: a #VteTerminal
*
* Determines the value of the terminal's mouse autohide setting. When
* autohiding is enabled, the mouse cursor will be hidden when the user presses
* a key and shown when the user moves the mouse. This setting can be changed
* using vte_terminal_set_mouse_autohide().
*
* Returns: %TRUE if autohiding is enabled, %FALSE if not
*/
gboolean
vte_terminal_get_mouse_autohide(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_mouse_autohide;
}
/**
* vte_terminal_set_mouse_autohide:
* @terminal: a #VteTerminal
* @setting: whether the mouse pointer should autohide
*
* Changes the value of the terminal's mouse autohide setting. When autohiding
* is enabled, the mouse cursor will be hidden when the user presses a key and
* shown when the user moves the mouse. This setting can be read using
* vte_terminal_get_mouse_autohide().
*/
void
vte_terminal_set_mouse_autohide(VteTerminal *terminal, gboolean setting)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_mouse_autohide(setting != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_MOUSE_POINTER_AUTOHIDE]);
}
/**
* vte_terminal_set_pty:
* @terminal: a #VteTerminal
* @pty: (allow-none): a #VtePty, or %NULL
*
* Sets @pty as the PTY to use in @terminal.
* Use %NULL to unset the PTY.
*/
void
vte_terminal_set_pty(VteTerminal *terminal,
VtePty *pty)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(pty == NULL || VTE_IS_PTY(pty));
GObject *object = G_OBJECT(terminal);
g_object_freeze_notify(object);
if (IMPL(terminal)->set_pty(pty))
g_object_notify_by_pspec(object, pspecs[PROP_PTY]);
g_object_thaw_notify(object);
}
/**
* vte_terminal_get_pty:
* @terminal: a #VteTerminal
*
* Returns the #VtePty of @terminal.
*
* Returns: (transfer none): a #VtePty, or %NULL
*/
VtePty *
vte_terminal_get_pty(VteTerminal *terminal)
{
g_return_val_if_fail (VTE_IS_TERMINAL (terminal), NULL);
return IMPL(terminal)->m_pty;
}
/**
* vte_terminal_get_rewrap_on_resize:
* @terminal: a #VteTerminal
*
* Checks whether or not the terminal will rewrap its contents upon resize.
*
* Returns: %TRUE if rewrapping is enabled, %FALSE if not
*
* Deprecated: 0.58
*/
gboolean
vte_terminal_get_rewrap_on_resize(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_rewrap_on_resize;
}
/**
* vte_terminal_set_rewrap_on_resize:
* @terminal: a #VteTerminal
* @rewrap: %TRUE if the terminal should rewrap on resize
*
* Controls whether or not the terminal will rewrap its contents, including
* the scrollback history, whenever the terminal's width changes.
*
* Deprecated: 0.58
*/
void
vte_terminal_set_rewrap_on_resize(VteTerminal *terminal,
gboolean rewrap)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_rewrap_on_resize(rewrap != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_REWRAP_ON_RESIZE]);
}
/**
* vte_terminal_get_row_count:
* @terminal: a #VteTerminal
*
*
* Returns: the number of rows
*/
glong
vte_terminal_get_row_count(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), -1);
return IMPL(terminal)->m_row_count;
}
/**
* vte_terminal_set_scrollback_lines:
* @terminal: a #VteTerminal
* @lines: the length of the history buffer
*
* Sets the length of the scrollback buffer used by the terminal. The size of
* the scrollback buffer will be set to the larger of this value and the number
* of visible rows the widget can display, so 0 can safely be used to disable
* scrollback.
*
* A negative value means "infinite scrollback".
*
* Note that this setting only affects the normal screen buffer.
* No scrollback is allowed on the alternate screen buffer.
*/
void
vte_terminal_set_scrollback_lines(VteTerminal *terminal, glong lines)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(lines >= -1);
GObject *object = G_OBJECT(terminal);
g_object_freeze_notify(object);
if (IMPL(terminal)->set_scrollback_lines(lines))
g_object_notify_by_pspec(object, pspecs[PROP_SCROLLBACK_LINES]);
g_object_thaw_notify(object);
}
/**
* vte_terminal_get_scrollback_lines:
* @terminal: a #VteTerminal
*
* Returns: length of the scrollback buffer used by the terminal.
* A negative value means "infinite scrollback".
*
* Since: 0.52
*/
glong
vte_terminal_get_scrollback_lines(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), 0);
return IMPL(terminal)->m_scrollback_lines;
}
/**
* vte_terminal_set_scroll_on_keystroke:
* @terminal: a #VteTerminal
* @scroll: whether the terminal should scroll on keystrokes
*
* Controls whether or not the terminal will forcibly scroll to the bottom of
* the viewable history when the user presses a key. Modifier keys do not
* trigger this behavior.
*/
void
vte_terminal_set_scroll_on_keystroke(VteTerminal *terminal,
gboolean scroll)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_scroll_on_keystroke(scroll != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_SCROLL_ON_OUTPUT]);
}
/**
* vte_terminal_get_scroll_on_keystroke:
* @terminal: a #VteTerminal
*
* Returns: whether or not the terminal will forcibly scroll to the bottom of
* the viewable history when the user presses a key. Modifier keys do not
* trigger this behavior.
*
* Since: 0.52
*/
gboolean
vte_terminal_get_scroll_on_keystroke(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_scroll_on_keystroke;
}
/**
* vte_terminal_set_scroll_on_output:
* @terminal: a #VteTerminal
* @scroll: whether the terminal should scroll on output
*
* Controls whether or not the terminal will forcibly scroll to the bottom of
* the viewable history when the new data is received from the child.
*/
void
vte_terminal_set_scroll_on_output(VteTerminal *terminal,
gboolean scroll)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_scroll_on_output(scroll != FALSE))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_SCROLL_ON_OUTPUT]);
}
/**
* vte_terminal_get_scroll_on_output:
* @terminal: a #VteTerminal
*
* Returns: whether or not the terminal will forcibly scroll to the bottom of
* the viewable history when the new data is received from the child.
*
* Since: 0.52
*/
gboolean
vte_terminal_get_scroll_on_output(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
return IMPL(terminal)->m_scroll_on_output;
}
/**
* vte_terminal_get_window_title:
* @terminal: a #VteTerminal
*
* Returns: (nullable) (transfer none): the window title, or %NULL
*/
const char *
vte_terminal_get_window_title(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), nullptr);
return IMPL(terminal)->m_window_title.data();
}
/**
* vte_terminal_get_word_char_exceptions:
* @terminal: a #VteTerminal
*
* Returns the set of characters which will be considered parts of a word
* when doing word-wise selection, in addition to the default which only
* considers alphanumeric characters part of a word.
*
* If %NULL, a built-in set is used.
*
* Returns: (nullable) (transfer none): a string, or %NULL
*
* Since: 0.40
*/
const char *
vte_terminal_get_word_char_exceptions(VteTerminal *terminal)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
auto impl = IMPL(terminal);
return impl->m_word_char_exceptions_string.empty() ? nullptr : impl->m_word_char_exceptions_string.data();
}
/**
* vte_terminal_set_word_char_exceptions:
* @terminal: a #VteTerminal
* @exceptions: a string of ASCII punctuation characters, or %NULL
*
* With this function you can provide a set of characters which will
* be considered parts of a word when doing word-wise selection, in
* addition to the default which only considers alphanumeric characters
* part of a word.
*
* The characters in @exceptions must be non-alphanumeric, each character
* must occur only once, and if @exceptions contains the character
* U+002D HYPHEN-MINUS, it must be at the start of the string.
*
* Use %NULL to reset the set of exception characters to the default.
*
* Since: 0.40
*/
void
vte_terminal_set_word_char_exceptions(VteTerminal *terminal,
const char *exceptions)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
if (IMPL(terminal)->set_word_char_exceptions(exceptions))
g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_WORD_CHAR_EXCEPTIONS]);
}
/**
* vte_terminal_write_contents_sync:
* @terminal: a #VteTerminal
* @stream: a #GOutputStream to write to
* @flags: a set of #VteWriteFlags
* @cancellable: (allow-none): a #GCancellable object, or %NULL
* @error: (allow-none): a #GError location to store the error occuring, or %NULL
*
* Write contents of the current contents of @terminal (including any
* scrollback history) to @stream according to @flags.
*
* If @cancellable is not %NULL, then the operation can be cancelled by triggering
* the cancellable object from another thread. If the operation was cancelled,
* the error %G_IO_ERROR_CANCELLED will be returned in @error.
*
* This is a synchronous operation and will make the widget (and input
* processing) during the write operation, which may take a long time
* depending on scrollback history and @stream availability for writing.
*
* Returns: %TRUE on success, %FALSE if there was an error
*/
gboolean
vte_terminal_write_contents_sync (VteTerminal *terminal,
GOutputStream *stream,
VteWriteFlags flags,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
g_return_val_if_fail(G_IS_OUTPUT_STREAM(stream), FALSE);
return IMPL(terminal)->write_contents_sync(stream, flags, cancellable, error);
}
/**
* vte_terminal_set_clear_background:
* @terminal: a #VteTerminal
* @setting:
*
* Sets whether to paint the background with the background colour.
* The default is %TRUE.
*
* This function is rarely useful. One use for it is to add a background
* image to the terminal.
*
* Since: 0.52
*/
void
vte_terminal_set_clear_background(VteTerminal* terminal,
gboolean setting)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
IMPL(terminal)->set_clear_background(setting != FALSE);
}
/**
* vte_terminal_get_color_background_for_draw:
* @terminal: a #VteTerminal
* @color: (out): a location to store a #GdbRGBA color
*
* Returns the background colour, as used by @terminal when
* drawing the background, which may be different from
* the color set by vte_terminal_set_color_background().
*
* Note: you must only call this function while handling the
* GtkWidget::draw signal.
*
* This function is rarely useful. One use for it is if you disable
* drawing the background (see vte_terminal_set_clear_background())
* and then need to draw the background yourself.
*
* Since: 0.54
*/
void
vte_terminal_get_color_background_for_draw(VteTerminal* terminal,
GdkRGBA* color)
{
g_return_if_fail(VTE_IS_TERMINAL(terminal));
g_return_if_fail(color != nullptr);
auto impl = IMPL(terminal);
auto const c = impl->get_color(VTE_DEFAULT_BG);
color->red = c->red / 65535.;
color->green = c->green / 65535.;
color->blue = c->blue / 65535.;
color->alpha = impl->m_background_alpha;
}
|