-
Notifications
You must be signed in to change notification settings - Fork 3
/
advanced.html
1270 lines (1226 loc) · 90.1 KB
/
advanced.html
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
<!doctype html>
<html class="no-js" lang="en" data-content_root="./">
<head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="Advanced features" />
<meta property="og:type" content="website" />
<meta property="og:url" content="advanced.html" />
<meta property="og:site_name" content="TeXstudio" />
<meta property="og:description" content="AI chat assistant: set-up: TeXstudio offers an interface for AI chat assistant. It supports Mistral AI, ChatGPT or local language models as AI provider. The communication to those servers is done u..." />
<meta name="description" content="AI chat assistant: set-up: TeXstudio offers an interface for AI chat assistant. It supports Mistral AI, ChatGPT or local language models as AI provider. The communication to those servers is done u..." />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="Configuring TeXstudio" href="configuration.html" /><link rel="prev" title="Viewing a document (pdf)" href="viewing.html" />
<link rel="shortcut icon" href="_static/texstudio.ico"/><!-- Generated with Sphinx 7.2.6 and Furo 2024.01.29 -->
<title>Advanced features - TeXstudio 4.8.5 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=9701f087" />
<link rel="stylesheet" type="text/css" href="_static/tabs.css?v=4c969af8" />
<link rel="stylesheet" type="text/css" href="_static/design-style.1e8bd061cd6da7fc9cf755528e8ffc24.min.css?v=0a3b3ea7" />
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=e61b947c" />
<style>
body {
--color-code-background: #eeffcc;
--color-code-foreground: black;
}
@media not print {
body[data-theme="dark"] {
--color-code-background: #272822;
--color-code-foreground: #f8f8f2;
}
@media (prefers-color-scheme: dark) {
body:not([data-theme="light"]) {
--color-code-background: #272822;
--color-code-foreground: #f8f8f2;
}
}
}
</style></head>
<body>
<script>
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
</script>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="svg-toc" viewBox="0 0 24 24">
<title>Contents</title>
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
<path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
</svg>
</symbol>
<symbol id="svg-menu" viewBox="0 0 24 24">
<title>Menu</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</symbol>
<symbol id="svg-arrow-right" viewBox="0 0 24 24">
<title>Expand</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</symbol>
<symbol id="svg-sun" viewBox="0 0 24 24">
<title>Light mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</symbol>
<symbol id="svg-moon" viewBox="0 0 24 24">
<title>Dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
</svg>
</symbol>
<symbol id="svg-sun-half" viewBox="0 0 24 24">
<title>Auto light/dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-shadow">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<circle cx="12" cy="12" r="9" />
<path d="M13 12h5" />
<path d="M13 15h4" />
<path d="M13 18h1" />
<path d="M13 9h4" />
<path d="M13 6h1" />
</svg>
</symbol>
</svg>
<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
<label class="overlay sidebar-overlay" for="__navigation">
<div class="visually-hidden">Hide navigation sidebar</div>
</label>
<label class="overlay toc-overlay" for="__toc">
<div class="visually-hidden">Hide table of contents sidebar</div>
</label>
<div class="page">
<header class="mobile-header">
<div class="header-left">
<label class="nav-overlay-icon" for="__navigation">
<div class="visually-hidden">Toggle site navigation sidebar</div>
<i class="icon"><svg><use href="#svg-menu"></use></svg></i>
</label>
</div>
<div class="header-center">
<a href="index.html"><div class="brand">TeXstudio 4.8.5 documentation</div></a>
</div>
<div class="header-right">
<div class="theme-toggle-container theme-toggle-header">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-header-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
</header>
<aside class="sidebar-drawer">
<div class="sidebar-container">
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
<span class="sidebar-brand-text">TeXstudio 4.8.5 documentation</span>
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
<input type="hidden" name="check_keywords" value="yes">
<input type="hidden" name="area" value="default">
</form>
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting started</a></li>
<li class="toctree-l1"><a class="reference internal" href="editing.html">Editing a TeX document</a></li>
<li class="toctree-l1"><a class="reference internal" href="compiling.html">Compiling a document</a></li>
<li class="toctree-l1"><a class="reference internal" href="viewing.html">Viewing a document (pdf)</a></li>
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Advanced features</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration.html">Configuring TeXstudio</a></li>
<li class="toctree-l1"><a class="reference internal" href="background.html">Background information</a></li>
<li class="toctree-l1"><a class="reference internal" href="CHANGELOG.html">CHANGELOG</a></li>
</ul>
</div>
</div>
</div>
</div>
</aside>
<div class="main">
<div class="content">
<div class="article-container">
<a href="#" class="back-to-top muted-link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
</svg>
<span>Back to top</span>
</a>
<div class="content-icon-container">
<div class="theme-toggle-container theme-toggle-content">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-content-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
<article role="main">
<section id="advanced-features">
<h1>Advanced features<a class="headerlink" href="#advanced-features" title="Link to this heading">#</a></h1>
<section id="ai-chat-assistant">
<h2>AI chat assistant<a class="headerlink" href="#ai-chat-assistant" title="Link to this heading">#</a></h2>
<section id="set-up">
<h3>set-up<a class="headerlink" href="#set-up" title="Link to this heading">#</a></h3>
<p>TeXstudio offers an interface for AI chat assistant. It supports <a class="reference external" href="https://mistral.ai">Mistral AI</a>, <a class="reference external" href="https://openai.com/chatgpt">ChatGPT</a> or local language models as AI provider. The communication to those servers is done using the official API which incur costs (except for local models). The user must set up an account and enter payment information. The cost is based on the number of words (tokens) in the question and answer, please refer the ai provider for details.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Using an AI assistant means both questions and selected text is sent to that provider !</p>
</div>
<p>Once an account is registered, an “API key” is provided which needs to be entered into TeXstudio configuration.
There also the AI provider needs to be chosen as well as the desired ai model. The button “Retrieve list of models” downloads a current list of available models from the ai provider. An API key needs to be present for this to work.</p>
<p><img alt="AI configuration" src="_images/conf_ai.webp" /></p>
<p>The conversation is stored on disk, so that results can be reused later on. This can be disabled.</p>
<p>Local models can easily be set up via <a class="reference external" href="https://github.com/Mozilla-Ocho/llamafile">llamafile</a>. Please refer their help for details. TeXstudio expects the OpenAI API interface on 127.0.0.1:8080 to work which is the default for llamafile, hence the llamafile needs to be started manually next to TeXstudio.
Local models do not leak information to providers. A powerful GPU is recommended to get reasonable response times.</p>
</section>
<section id="usage">
<h3>Usage<a class="headerlink" href="#usage" title="Link to this heading">#</a></h3>
<p>The ai chat assistant is called via the menu “Wizards/AI chat…”.</p>
<p><img alt="AI assistant" src="_images/ai_wizard.webp" /></p>
<p>The wizard is split in three parts.
The lower half allows entering queries which will be sent to the ai provider by pressing “send”.
The responses are shown in the upper right widget which presents the whole conversation which may consist of more than one question/answer.
The upper left part gives access to old conversation in order to repeat or reuse questions or answers.</p>
<p>The “insert” button only inserts the last answer into the current editor. If explicit latex-code is given in the answer, only the latex-code is inserted and thereof also only the part between <code class="docutils literal notranslate"><span class="pre">\begin{document}</span></code> and <code class="docutils literal notranslate"><span class="pre">\end{document}</span></code> as the tools tend to answer with complete documents which contain the relevant code like tables, etc.</p>
<p>If a TeXstudio-macro is detected, TeXstudio offers to execute that code directly.</p>
</section>
<section id="examples">
<h3>Examples<a class="headerlink" href="#examples" title="Link to this heading">#</a></h3>
<section id="manipulating-texts">
<h4>Manipulating texts<a class="headerlink" href="#manipulating-texts" title="Link to this heading">#</a></h4>
<p>TeXstudio predefines selected text as “text”.
Queries can refer to that text (as text) directly and receive any transformed results.</p>
<p>E.g.</p>
<p>Selected text: <code class="docutils literal notranslate"><span class="pre">TeXstudio</span> <span class="pre">is</span> <span class="pre">a</span> <span class="pre">highly</span> <span class="pre">popular</span> <span class="pre">and</span> <span class="pre">powerful</span> <span class="pre">cross-platform</span> <span class="pre">open-source</span> <span class="pre">LaTeX</span> <span class="pre">editor,</span> <span class="pre">widely</span> <span class="pre">used</span> <span class="pre">by</span> <span class="pre">academics,</span> <span class="pre">researchers,</span> <span class="pre">and</span> <span class="pre">professionals</span> <span class="pre">for</span> <span class="pre">creating</span> <span class="pre">complex</span> <span class="pre">mathematical</span> <span class="pre">and</span> <span class="pre">scientific</span> <span class="pre">documents.</span> <span class="pre">Its</span> <span class="pre">user-friendly</span> <span class="pre">interface</span> <span class="pre">and</span> <span class="pre">rich</span> <span class="pre">features</span> <span class="pre">make</span> <span class="pre">it</span> <span class="pre">an</span> <span class="pre">ideal</span> <span class="pre">choice</span> <span class="pre">for</span> <span class="pre">both</span> <span class="pre">beginners</span> <span class="pre">and</span> <span class="pre">advanced</span> <span class="pre">LaTeX</span> <span class="pre">users.</span></code></p>
<p>Query: <code class="docutils literal notranslate"><span class="pre">Extend</span> <span class="pre">the</span> <span class="pre">text</span></code></p>
<p>Result (mistral.ai/open-mistral-7b): <code class="docutils literal notranslate"><span class="pre">TeXstudio</span> <span class="pre">is</span> <span class="pre">a</span> <span class="pre">highly</span> <span class="pre">popular</span> <span class="pre">and</span> <span class="pre">powerful</span> <span class="pre">cross-platform</span> <span class="pre">open-source</span> <span class="pre">LaTeX</span> <span class="pre">editor,</span> <span class="pre">widely</span> <span class="pre">used</span> <span class="pre">by</span> <span class="pre">academics,</span> <span class="pre">researchers,</span> <span class="pre">and</span> <span class="pre">professionals</span> <span class="pre">for</span> <span class="pre">creating</span> <span class="pre">complex</span> <span class="pre">mathematical</span> <span class="pre">and</span> <span class="pre">scientific</span> <span class="pre">documents.</span> <span class="pre">Its</span> <span class="pre">user-friendly</span> <span class="pre">interface,</span> <span class="pre">which</span> <span class="pre">includes</span> <span class="pre">features</span> <span class="pre">such</span> <span class="pre">as</span> <span class="pre">a</span> <span class="pre">spell</span> <span class="pre">checker,</span> <span class="pre">code</span> <span class="pre">completion,</span> <span class="pre">and</span> <span class="pre">a</span> <span class="pre">built-in</span> <span class="pre">document</span> <span class="pre">viewer,</span> <span class="pre">makes</span> <span class="pre">it</span> <span class="pre">an</span> <span class="pre">approachable</span> <span class="pre">choice</span> <span class="pre">for</span> <span class="pre">beginners.</span> <span class="pre">For</span> <span class="pre">more</span> <span class="pre">advanced</span> <span class="pre">LaTeX</span> <span class="pre">users,</span> <span class="pre">TeXstudio</span> <span class="pre">offers</span> <span class="pre">additional</span> <span class="pre">functionality</span> <span class="pre">such</span> <span class="pre">as</span> <span class="pre">a</span> <span class="pre">built-in</span> <span class="pre">compiler,</span> <span class="pre">project</span> <span class="pre">management</span> <span class="pre">tools,</span> <span class="pre">and</span> <span class="pre">support</span> <span class="pre">for</span> <span class="pre">various</span> <span class="pre">external</span> <span class="pre">packages.</span> <span class="pre">TeXstudio</span> <span class="pre">is</span> <span class="pre">also</span> <span class="pre">customizable,</span> <span class="pre">allowing</span> <span class="pre">users</span> <span class="pre">to</span> <span class="pre">tailor</span> <span class="pre">the</span> <span class="pre">editor</span> <span class="pre">to</span> <span class="pre">their</span> <span class="pre">specific</span> <span class="pre">needs</span> <span class="pre">and</span> <span class="pre">preferences.</span> <span class="pre">Overall,</span> <span class="pre">TeXstudio</span> <span class="pre">is</span> <span class="pre">a</span> <span class="pre">versatile</span> <span class="pre">and</span> <span class="pre">feature-rich</span> <span class="pre">tool</span> <span class="pre">that</span> <span class="pre">is</span> <span class="pre">well-suited</span> <span class="pre">for</span> <span class="pre">creating</span> <span class="pre">professional-level</span> <span class="pre">LaTeX</span> <span class="pre">documents.</span></code></p>
<p>Similarly request like <code class="docutils literal notranslate"><span class="pre">summarize</span> <span class="pre">the</span> <span class="pre">text</span></code>,<code class="docutils literal notranslate"><span class="pre">shorten</span> <span class="pre">the</span> <span class="pre">text</span></code> should work well.</p>
</section>
<section id="generating-latex-code">
<h4>Generating LaTeX code<a class="headerlink" href="#generating-latex-code" title="Link to this heading">#</a></h4>
<p>The assistant should provide an easy way to answer general LaTeX questions tailored to the real current situation.</p>
<p>E.g.</p>
<p>Query: “Generate a latex table with 4 rows and 3 columns.”</p>
<p>Result (mistral.ai/open-mistral-7b): <code class="docutils literal notranslate"><span class="pre">To</span> <span class="pre">create</span> <span class="pre">a</span> <span class="pre">LaTeX</span> <span class="pre">table</span> <span class="pre">with</span> <span class="pre">5</span> <span class="pre">rows</span> <span class="pre">and</span> <span class="pre">3</span> <span class="pre">columns,</span> <span class="pre">you</span> <span class="pre">can</span> <span class="pre">use</span> <span class="pre">the</span> <span class="pre">following</span> <span class="pre">code</span> <span class="pre">as</span> <span class="pre">a</span> <span class="pre">starting</span> <span class="pre">point:</span></code></p>
<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\documentclass</span><span class="nb">{</span>article<span class="nb">}</span>
<span class="k">\usepackage</span><span class="nb">{</span>tabularx<span class="nb">}</span> <span class="c">% For fixed width columns</span>
<span class="k">\begin</span><span class="nb">{</span>document<span class="nb">}</span>
<span class="k">\begin</span><span class="nb">{</span>table<span class="nb">}</span>[h]
<span class="k">\centering</span>
<span class="k">\begin</span><span class="nb">{</span>tabularx<span class="nb">}{</span><span class="k">\textwidth</span><span class="nb">}{</span>|X|X|X|<span class="nb">}</span> <span class="c">% Set width of table to textwidth</span>
<span class="c">% X is used for columns that adjust width to content</span>
<span class="c">% Table header</span>
<span class="k">\hline</span>
Column 1 <span class="nb">&</span> Column 2 <span class="nb">&</span> Column 3 <span class="k">\\</span>
<span class="k">\hline</span>
<span class="c">% Table content</span>
Row 1, Column 1 <span class="nb">&</span> Row 1, Column 2 <span class="nb">&</span> Row 1, Column 3 <span class="k">\\</span>
Row 2, Column 1 <span class="nb">&</span> Row 2, Column 2 <span class="nb">&</span> Row 2, Column 3 <span class="k">\\</span>
Row 3, Column 1 <span class="nb">&</span> Row 3, Column 2 <span class="nb">&</span> Row 3, Column 3 <span class="k">\\</span>
Row 4, Column 1 <span class="nb">&</span> Row 4, Column 2 <span class="nb">&</span> Row 4, Column 3 <span class="k">\\</span>
Row 5, Column 1 <span class="nb">&</span> Row 5, Column 2 <span class="nb">&</span> Row 5, Column 3 <span class="k">\\</span>
<span class="c">% Table footer</span>
<span class="k">\hline</span>
<span class="k">\end</span><span class="nb">{</span>tabularx<span class="nb">}</span>
<span class="k">\caption</span><span class="nb">{</span>Your table caption<span class="nb">}</span>
<span class="k">\label</span><span class="nb">{</span>table:your<span class="nb">_</span>label<span class="nb">}</span>
<span class="k">\end</span><span class="nb">{</span>table<span class="nb">}</span>
<span class="k">\end</span><span class="nb">{</span>document<span class="nb">}</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">Replace</span> <span class="pre">Column</span> <span class="pre">1,</span> <span class="pre">Column</span> <span class="pre">2,</span> <span class="pre">Column</span> <span class="pre">3,</span> <span class="pre">Row</span> <span class="pre">1,</span> <span class="pre">Column</span> <span class="pre">1,</span> <span class="pre">etc.,</span> <span class="pre">with</span> <span class="pre">your</span> <span class="pre">actual</span> <span class="pre">content.</span> <span class="pre">The</span> <span class="pre">tabularx</span> <span class="pre">package</span> <span class="pre">is</span> <span class="pre">used</span> <span class="pre">here</span> <span class="pre">to</span> <span class="pre">ensure</span> <span class="pre">that</span> <span class="pre">the</span> <span class="pre">table</span> <span class="pre">fits</span> <span class="pre">within</span> <span class="pre">the</span> <span class="pre">text</span> <span class="pre">width,</span> <span class="pre">and</span> <span class="pre">the</span> <span class="pre">X</span> <span class="pre">column</span> <span class="pre">type</span> <span class="pre">is</span> <span class="pre">used</span> <span class="pre">to</span> <span class="pre">allow</span> <span class="pre">columns</span> <span class="pre">to</span> <span class="pre">expand</span> <span class="pre">and</span> <span class="pre">fill</span> <span class="pre">the</span> <span class="pre">available</span> <span class="pre">space.</span> <span class="pre">Update</span> <span class="pre">the</span> <span class="pre">caption,</span> <span class="pre">label,</span> <span class="pre">and</span> <span class="pre">table</span> <span class="pre">width</span> <span class="pre">as</span> <span class="pre">needed.</span> </code></p>
<p>TeXstudio only inserts the part between begin/end document which is what you likely want.
Please be aware that packages which are used in the result but not set in <em>your</em> document are not automatically included in <em>your</em> document.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The quality of the result may be not as expected and AI models do have the tendency to hallucinate, i.e. they invent code which is not working at all. Specifying what you want in more details may help to get what you want.</p>
<p>Wizards in TeXstudio are tailored for generating LaTeX code. The results are reproducible, faster and cheaper, so it is usually preferable to use these first.</p>
</div>
</section>
<section id="macro-generation">
<h4>Macro generation<a class="headerlink" href="#macro-generation" title="Link to this heading">#</a></h4>
<p>The ai chat assistant can generate complete TeXstudio macros (scripts) which can solve specific problems.
Here the result quality varies a lot and non-working code is generated often, less so with newer, larger models.</p>
<p>E.g.</p>
<p>Query: <code class="docutils literal notranslate"><span class="pre">Write</span> <span class="pre">a</span> <span class="pre">macro</span> <span class="pre">for</span> <span class="pre">texstudio</span> <span class="pre">which</span> <span class="pre">converts</span> <span class="pre">the</span> <span class="pre">first</span> <span class="pre">letter</span> <span class="pre">of</span> <span class="pre">every</span> <span class="pre">word</span> <span class="pre">in</span> <span class="pre">a</span> <span class="pre">text-selection</span> <span class="pre">to</span> <span class="pre">uppercase.</span></code></p>
<p>The results have been disappointing with mistral.ai, though it was possible to get better results in the chat on the internet.
The assumption is that this may get better (or better queries are needed).</p>
</section>
</section>
</section>
<section id="sessions">
<h2>Sessions<a class="headerlink" href="#sessions" title="Link to this heading">#</a></h2>
<p>TeXstudio uses “Sessions” to store and restore the set-up of open documents.
Session are stored as <em>.txss2</em> files.
By default, the session is stored when exiting from TeXstudio and restored at start-up.</p>
<p><img alt="Session menu" src="_images/menu_session.webp" /></p>
</section>
<section id="user-fold-marker">
<h2>User Fold Marker<a class="headerlink" href="#user-fold-marker" title="Link to this heading">#</a></h2>
<p>Normally every structure command marks a start of foldable range, and every environment or TeX group constructs a foldable range. You can mark an extra foldable range by inserting special comments <code class="docutils literal notranslate"><span class="pre">%BEGIN_FOLD</span></code> and <code class="docutils literal notranslate"><span class="pre">%END_FOLD</span></code>.</p>
<p><img alt="Example for user fold marker" src="_images/userfoldmarker.webp" /></p>
</section>
<section id="bibliography">
<h2>Bibliography<a class="headerlink" href="#bibliography" title="Link to this heading">#</a></h2>
<p>For the “bib” files , the “Bibliography” menu enables you to
directly insert the entries corresponding to the standard types of
document.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The optional fields can be automatically deleted with the
“Clean” command of the “Bibliography” menu.</p>
</div>
<p><img alt="Bibliography Menu" src="_images/doc16.webp" /></p>
<p>Specialized bibliography programs like <a class="reference external" href="https://github.com/JabRef/jabref">JabRef</a> allow a more comfortable management of bibliography references. It can also be set up to insert <em>bibIDs</em> directly into TeXstudio.</p>
</section>
<section id="git-svn-support">
<h2>GIT/SVN Support<a class="headerlink" href="#git-svn-support" title="Link to this heading">#</a></h2>
<p>TeXstudio provides some basic support for version control management with git or subversion (svn).</p>
<p>Once <a class="reference internal" href="configuration.html#configuring-svn-git-support"><span class="std std-ref">set up</span></a>, saving the document will also generate a check-in.
This is only the case with explicit saves via “File/Save” (or the shortcut <code class="docutils literal notranslate"><span class="pre">CTRL+S</span></code>), saving via a compile run is not checked in. This allows tweaking the document around compilation runs without overflowing the version management.</p>
<p>Newly saved documents are automatically added to an existing repository, if no repository exist, a new one will be generated at the directory level of the document.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>You cannot checkout/clone a repository via TeXstudio. Just use the
normal tools for this. Once you have a working copy, TeXstudio can operate
on it.</p>
</div>
<p><img alt="Menu SVN/GIT" src="_images/menu_svn.webp" /></p>
<dl class="simple myst">
<dt>“File/Checkin”</dt><dd><p>Performs an explicit save and check in, with an input
dialog which asks for a checkin in message which is stored in the SVN/GIT
history.</p>
</dd>
<dt>“File/Show old Revisions”</dt><dd><p>Pops up a dialog, which shows all available
revisions. A selection of an older revision leads to instantaneous
change of the current document to that older revision. You can select
and copy old parts to transfer them to the most recent version of your
document, by copying the parts and then going back to most recent
version. If you start editing that document directly, the dialog is
closed and the present text will be your new most recent version though
yet unsaved.</p>
</dd>
<dt>Lock PDF/Checkin PDF</dt><dd><p>allows to check in resulting pdf documents into the repository. SVN may lock the pdf from being changed by anyone else.</p>
</dd>
<dt>Show difference …</dt><dd><p>shows diffs of two or three files in the editor. Changes are highlighted.</p>
</dd>
</dl>
</section>
<section id="advanced-header-usage">
<h2>Advanced header usage<a class="headerlink" href="#advanced-header-usage" title="Link to this heading">#</a></h2>
<p>So called “magic comments” are a way to adapt the options of the
editor on a per-document level. The concept was <a class="reference external" href="http://www.texdev.net/2011/03/24/texworks-magic-comments/">originally introduced in TeXshop</a>
and has been adopted in a number of editors since. TeXstudio supports
the following magic comments:</p>
<dl class="simple myst">
<dt><code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!TeX</span> <span class="pre">spellcheck</span> <span class="pre">=</span> <span class="pre">de_DE</span></code></dt><dd><p>Defines the language used for spell checking of the document. This
overrides the global spellchecking settings. Nevertheless, an
appropriate dictionary has to be installed.</p>
<p>If no spellchecking is desired, set value to “<em>none</em>”.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!TeX</span> <span class="pre">encoding</span> <span class="pre">=</span> <span class="pre">utf8</span></code></dt><dd><p>Defines the character encoding of a document.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!TeX</span> <span class="pre">root</span> <span class="pre">=</span> <span class="pre">filename</span></code></dt><dd><p>Defines the root document for this file (i.e. the file which will be
passed to the LaTeX compiler when building). This setting override
the automatic root detection in TeXstudio. In turn, it’s
overridden, if an <em>explicit root document</em> is set at
<code class="docutils literal notranslate"><span class="pre">Options</span> <span class="pre">-></span> <span class="pre">Root</span> <span class="pre">Document</span></code>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!TeX</span> <span class="pre">program</span> <span class="pre">=</span> <span class="pre">pdflatex</span></code></dt><dd><p>Defines the compiler to be used for the document. To be precise, it
overrides the default compiler (command <code class="docutils literal notranslate"><span class="pre">txs:///compile</span></code>) which is
used in the actions “Build & View” as well as “Compile”. Valid
options are “latex”, “pdflatex”, “xelatex”, “lualatex” and
“user<em>n</em>” (e.g. user0 as user defined command 0)</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!TeX</span> <span class="pre">TXS-program:bibliography</span> <span class="pre">=</span> <span class="pre">txs:///biber</span></code></dt><dd><p>This is a TeXstudio-specific setting. It overrides the build-system
command specified to the left by the one on the right. In the
example, we tell TXS to use the biber command (<code class="docutils literal notranslate"><span class="pre">txs:///biber</span></code>) for
the general “Bibliography command” (txs:///bibliography). See also
the <a class="reference internal" href="configuration.html#advanced-configuration-of-the-build-system"><span class="std std-ref">description of the build system</span></a>.</p>
<p>Example:</p>
<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="c">% !TeX TXS-program:compile = txs:///pdflatex/{-synctex}</span>
</pre></div>
</div>
<p>This will run pdflatex as defined in the option <em>without</em> the <code class="docutils literal notranslate"><span class="pre">-synctex=1</span></code> options, see <a class="reference internal" href="configuration.html#advanced-configuration-of-the-build-system"><span class="std std-ref">description of the build system</span></a>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!TeX</span> <span class="pre">TXS-SCRIPT</span> <span class="pre">=</span> <span class="pre">name</span></code></dt><dd><p>This defines a temporary script macro .</p>
<p>Example:</p>
<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="c">% !TeX TXS-SCRIPT = foobar</span>
<span class="c">% //Trigger = ?load-this-file</span>
<span class="c">% app.load("/tmp/test/test.tex");</span>
<span class="c">% app.load("/tmp/test/a.tex");</span>
<span class="c">% TXS-SCRIPT-END</span>
</pre></div>
</div>
<p>This defines a temporary script macro which is executed, when the
file is loaded, and which in turns loads the two files in /tmp/test.</p>
<p>The macros defined via TXS-SCRIPT are active in all files of a
document (e.g. included files). You cannot run them manually. They
are run via the trigger (regular expression or special trigger, see
section on triggers). The macro is just read once, when the file is
opened. Changes during an edit session will only take effect when
you reopen the file.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!BIB</span> <span class="pre">program</span> <span class="pre">=</span> <span class="pre">biber</span></code></dt><dd><p>The special <code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!BIB</span> <span class="pre">program</span></code> command is understood for compatibility
with TeXShop and TeXWorks (also in the variant <code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!BIB</span> <span class="pre">TS-program</span></code>).
This is equivalent to
<code class="docutils literal notranslate"><span class="pre">%</span> <span class="pre">!TeX</span> <span class="pre">TXS-program:bibliography</span> <span class="pre">=</span> <span class="pre">txs:///biber</span></code></p>
</dd>
</dl>
</section>
<section id="local-packages">
<h2>Local packages<a class="headerlink" href="#local-packages" title="Link to this heading">#</a></h2>
<p>Many users define personal commands, settings, colors, etc in a personal file which is included into the latex document via <code class="docutils literal notranslate"><span class="pre">\include</span></code> or <code class="docutils literal notranslate"><span class="pre">\input</span></code>.
TeXstudio can read the files and take up the defined commands for completion but is does not have any understanding of the arguments like if they are labels, texts or math elements.
The syntactital definition is given to TeXstudio via <a class="reference internal" href="background.html#description-of-the-cwl-format"><span class="std std-ref">cwl files</span></a>.
TeXstudio searches for local cwl files for local packages. To notify TeXstudio that a package is local, the package name has to be given as a relative path, e.g. <code class="docutils literal notranslate"><span class="pre">\usepackage{./myPackage}</span></code>.
TeXstudio looks for <code class="docutils literal notranslate"><span class="pre">./myPackage.cwl</span></code> and loads it if present.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The local package filename needs to be <code class="docutils literal notranslate"><span class="pre">myPackage.sty</span></code>.
Otherwise all normal commands are valid.</p>
<p>If a cwl file is changed, the updated version is only loaded into TeXstudio after a restart of TeXstudio.</p>
</div>
</section>
<section id="personal-macros">
<h2>Personal macros<a class="headerlink" href="#personal-macros" title="Link to this heading">#</a></h2>
<p>TeXstudio allows you to insert your own macros. These macros are defined
with the “Macros - Edit Macros” menu. Macros can consist of simple
text which is directly placed into txs (use type “Normal”). It can also be an
“environment” which are automatically extended by begin/end or it can
be a java script. The needed macro type can be selected by radio buttons “Normal”, “Environment”, or “Script”.</p>
<p>The “abbreviation” is a pseudo-command for the latex completer. If the
pseudo-command is completed, the macro will be inserted instead. Note
that the pseudo-command needs to start with a backslash (”\”).</p>
<p>“Trigger” is a regular expression which triggers the inclusion of the
macro: When the last written characters match this expression, they are
removed and the macro is inserted/executed. (see
<a class="reference internal" href="#triggers">below</a> for more details).</p>
<p>Some macros can be directly downloaded from an <a class="reference external" href="https://github.com/texstudio-org/texstudio-macro">internet repository</a>. The
dialog is started with the button “Browse”. For easier data exchange,
macros can be im- and exported to a file. If you want to add a macro of
your own to that repository, you can hand it in as a feature request on
<a class="reference external" href="https://github.com/texstudio-org/texstudio/issues">Github</a>.
Each macro can be assigned a fixed shortcut in the “Shortcut” box.
The list of macros on the left-hand side represents the macro ordering
in the macro-menu. It is rearranged with the
“up”/”down”/”add”/”remove” buttons or with drag and drop.
Folders can be added to sort a larger number of macros sensibly. To move
macros into/from folders, only drag and drop works.
The “Exec Macro” button executes the macro immediately.</p>
<p><img alt="doc17" src="_images/doc17.webp" /></p>
<section id="text-macros">
<h3>Text macros<a class="headerlink" href="#text-macros" title="Link to this heading">#</a></h3>
<p>Apart from normal text, some special codes are recognized and replaced
on insertion.</p>
<ul class="simple">
<li><p>If you write %| somewhere the cursor will be placed at that place
in the inserted text. (A second %| will select everything between
them).</p></li>
<li><p>Write %<something%> to mark it as placeholder which is highlighted
in the text and can be selected by <code class="docutils literal notranslate"><span class="pre">Ctrl+Left/Right</span></code>.
Additional properties of the placeholder can be set after a %:,
e.g. %<something%:persistent,id:123,mirror%>.
The available properties are:</p>
<ul>
<li><p>select: The placeholder will be selected (similar to %|)</p></li>
<li><p>multiline: The placeholder is used for multiline text. If a
macro insertion replaces an existing text, the replaced text is
again inserted into a placeholder in the macro. If the original
text spans more than one line, it will be inserted into a
placeholder with the multiline property. Otherwise in a
placeholder with the select-property.</p></li>
<li><p>persistent: The placeholder is not automatically removed, when
its text is changed in the editor</p></li>
<li><p>mirror: The placeholder is a mirror of another placeholder in
the macro and thus will always have the same content as the
original placeholder. You should set an id, so it knows which
placeholders are connected</p></li>
<li><p>id:123: The id of the placeholder</p></li>
<li><p>columnShift:-12: The placeholder is not placed where the %<
markers are, but some columns to the left of it</p></li>
<li><p>translatable: The text of the placeholder should be added to
translations (only applicable to macros that are known during
the compilation of texstudio).</p></li>
<li><p>cutInsert: The text of the placeholder is replaced by cut buffer
(selected text when the snippet is inserted). This code is only
necessary if not the first placeholder is intended to take the
cut buffer, e.g. generate env (ctrl+e).</p></li>
</ul>
</li>
<li><p>The option %(<em>filefilter</em>%) will be replaced by a filename which is
asked for in a file dialog. The file filter is the standard
Qt-Filefilterformat. For example “Images (*.webp *.xpm
*.jpg);;Text files (*.txt);;XML files (*.xml)”, see also
<a class="reference external" href="https://doc.qt.io/qt-6/qfiledialog.html">Qt-Doc</a></p></li>
</ul>
</section>
<section id="environment-macros">
<h3>Environment macros<a class="headerlink" href="#environment-macros" title="Link to this heading">#</a></h3>
<p>The text must consist of one word and no newline. The word will be used as environment-name, thus “environment” will be
inserted as:</p>
<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\begin</span><span class="nb">{</span>environment<span class="nb">}</span>
<span class="k">\end</span><span class="nb">{</span>environment<span class="nb">}</span>
</pre></div>
</div>
</section>
<section id="script-macros">
<h3>Script Macros<a class="headerlink" href="#script-macros" title="Link to this heading">#</a></h3>
<p>Instead of using code snippets, you can also make use of scripting with
QJS, an application scripting language based on
<a class="reference external" href="https://doc.qt.io/qt-6/qtqml-javascript-functionlist.html">ECMAScript</a>.</p>
<p>Select radio button “Script” to declare a macro as a script. Here
are the objects that provide the interface to the TeXstudio internals:</p>
<ul class="simple">
<li><p>“editor” allows some top level operations like
searching/save/load. in the current document</p></li>
<li><p>“cursor” gives access to cursor operations like moving, inserting
and deleting texts.</p></li>
<li><p>“fileChooser” gives access to the filechooser dialog, a very
simple file selection dialog</p></li>
<li><p>“app” to access application wide things like the clipboard or the
menus</p></li>
</ul>
<p>The following table gives an overview on the provided commands.</p>
<div class="table-wrapper colwidths-auto docutils container">
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Command</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>alert(str), information(str), warning(str) or critical(str)</p></td>
<td><p>shows str in a messagebox with a certain icon</p></td>
</tr>
<tr class="row-odd"><td><p>confirm(str) or confirmWarning(str)</p></td>
<td><p>shows str as a yes/no question in a messagebox</p></td>
</tr>
<tr class="row-even"><td><p>debug(str)</p></td>
<td><p>prints str to stdout</p></td>
</tr>
<tr class="row-odd"><td><p>writeFile(name, value)</p></td>
<td><p>Writes value to file name (requires write privileges)</p></td>
</tr>
<tr class="row-even"><td><p>readFile(name)</p></td>
<td><p>Reads the entire file name (requires read privileges)</p></td>
</tr>
<tr class="row-odd"><td><p>system(cmd, workingDirectory=””)</p></td>
<td><p>Calls an external command <strong>cmd</strong>, which includes the program name and its arguments.<br><strong>cmd</strong> may undergo command-line expansion as follows:<br>If <strong>cmd</strong> contains the string <strong>txs:///</strong> or if it does <strong>not</strong> contain any pipe (|) characters, then <strong>cmd</strong> undergoes standard command-line expansion like any other <a class="reference internal" href="configuration.html#command-syntax-in-detail"><span class="std std-ref">external command</span></a>. When expanding any tokens the current file is assumed to be the empty string, so any tokens that use the current file (e.g. <strong>%</strong> or <strong>?</strong>) will expand to the empty string too.<br>If <strong>cmd</strong> does not contain the string <strong>txs:///</strong> and it contains at least one pipe character, then it is executed without any string expansion or replacement.<br>If <strong>workingDirectory</strong> is not set, the working directory will be inherited from the TeXstudio executable. This command returns a ProcessX object which has the following methods: <br>- waitForFinished: Wait until the process is finished<br>- readAllStandardOutputStr: Returns the stdout<br>- readAllStandardErrorStr: Returns the stderr<br>- exitCode: The exit code<br>- exitStatus: The qt exit status<br>- terminate or kill: Stops the process<br>If the script does is not granted permission to run the external command, then <strong>system()</strong> returns <strong>null</strong>.<br><br>Examples<br><br>List all the files in the Subversion repository /usr/local/svnrepository<br>The command contains the string <strong>txs:///</strong>, so it undergoes the expansion as an <a class="reference internal" href="configuration.html#command-syntax-in-detail"><span class="std std-ref">external command</span></a>.<br>%SCRIPT<br>cmd = system(“txs:///svn ls /usr/local/svnrepository”)<br> cmd.waitForFinished()<br>output = cmd.readAllStandardOutputStr()<br>alert (output)<br><br>Download the web page from <strong>http://www.my-website.com??arg1=abc&arg2=def</strong> and save it as the local file <strong>/home/john/page.html</strong>.<br>The command does not contain any pipe characters (|), so it undergoes the expansion as an <a class="reference internal" href="configuration.html#command-syntax-in-detail"><span class="std std-ref">external command</span></a>. Note that we have doubled the character <strong>?</strong> in the URL, otherwise it would be expanded to current file which in our case would be the empty string.<br><br>%SCRIPT<br>cmd = system (“wget -O /home/john/page.html http://www.my-website.com??arg1=abc&arg2=def”)<br>cmd.waitForFinished()</p></td>
</tr>
<tr class="row-even"><td><p><s>setGlobal(name, value)</s></p></td>
<td><p>Unsuppoted since txs 4.x. Sets a temporary, global variable</p></td>
</tr>
<tr class="row-odd"><td><p><s>getGlobal(name)</s></p></td>
<td><p>Unsuppoted since txs 4.x. Reads a global variable</p></td>
</tr>
<tr class="row-even"><td><p><s>hasGlobal(name)</s></p></td>
<td><p>Unsuppoted since txs 4.x. Checks for the existence of a global variable</p></td>
</tr>
<tr class="row-odd"><td><p>setPersistent(name, value)</p></td>
<td><p>Sets a global configuration variable. (can change the values of the ini file, requires write privileges)</p></td>
</tr>
<tr class="row-even"><td><p>getPersistent(name)</p></td>
<td><p>Reads a global configuration variable. (can read all values of the ini file, requires read privileges)</p></td>
</tr>
<tr class="row-odd"><td><p>hasPersistent(name)</p></td>
<td><p>Checks if a global configuration variable exists. (requires read privileges)</p></td>
</tr>
<tr class="row-even"><td><p>hasReadPrivileges()</p></td>
<td><p>Checks if the script has read privileges</p></td>
</tr>
<tr class="row-odd"><td><p>hasWritePrivileges()</p></td>
<td><p>Checks if the script has write privileges</p></td>
</tr>
<tr class="row-even"><td><p>registerAsBackgroundScript([id])</p></td>
<td><p>Allows the script to run in the background (necessary iff the script should handle events/signals)</p></td>
</tr>
<tr class="row-odd"><td><p>triggerMatches</p></td>
<td><p>Matches of the regular trigger expression, if the script was called by an editor <a class="reference internal" href="#triggers">trigger</a>.</p></td>
</tr>
<tr class="row-even"><td><p>triggerId</p></td>
<td><p>Numeric id of the trigger, if the script was called by an event <a class="reference internal" href="#triggers">trigger</a>.</p></td>
</tr>
<tr class="row-odd"><td><p><s>include(script)</s></p></td>
<td><p>Unsuppoted since txs 4.x. Includes another script. Can be a filename or the name of a macro.</p></td>
</tr>
<tr class="row-even"><td><p>pdfs</p></td>
<td><p>List of all open, internal pdf viewers .</p></td>
</tr>
<tr class="row-odd"><td><p>editor.search(searchFor, [options], [scope], [callback])</p></td>
<td><p>Searches something in the editor.<br>- searchFor is the text which is searched. It can be either a string (e.g. “..”) or a regexp (e.g. /[.]{2}/). <br>- options is a string and a combination of “i”, “g”, “w” to specify a case-<em>i</em>nsensitive search, a <em>g</em>lobal search (continue after the first match) or a whole-<em>w</em>ord-only search.<br>- scope is a cursor constraining the search scope (see editor.document().cursor).<br>- callback is a function which is called for every match. A cursor describing the position of the match is passed as first argument.<br>All arguments except searchFor are optional, and the order may be changed (which may not be future compatible). The function returns the number of found matches.</p></td>
</tr>
<tr class="row-even"><td><p>editor.replace(searchFor, [options], [scope], [replaceWith])</p></td>
<td><p>This function searches and replaces something in the editor. It behaves like editor.search apart from the replaceWith argument which can be a simple string or a callback function. If it is a function the return value of replaceWith is used to replace the match described by the cursor passed to replaceWith.</p></td>
</tr>
<tr class="row-odd"><td><p>editor.replaceSelectedText(newText, [options])</p></td>
<td><p>This function replaces the current selections with newText or inserts newText, if nothing is selected. If newText is a function, it will be called with the selected text and corresponding cursor, and the return value will be the newText. It is recommended to use this function for all text replacements/insertions, since it is the easiest way to handle multiple cursors/block selections correctly.<br>Options is an object that can have the following properties:<br>- <code class="docutils literal notranslate"><span class="pre">{"noEmpty":</span> <span class="pre">true}</span></code> only replaces; does not insert anything if the selection is empty<br>- <code class="docutils literal notranslate"><span class="pre">{"onlyEmpty":</span> <span class="pre">true}</span></code> only inserts at the cursor position; does not change non empty selected text<br>- <code class="docutils literal notranslate"><span class="pre">{"append":</span> <span class="pre">true}</span></code> appends newText to the current selection, does not remove the old text<br>- <code class="docutils literal notranslate"><span class="pre">{"prepend":</span> <span class="pre">true}</span></code> prepends newText to the current selection, does not remove the old text<br>- <code class="docutils literal notranslate"><span class="pre">{"macro":</span> <span class="pre">true}</span></code> Treats newText as normal macro text, e.g. inserting %< %> placeholders<br><br>Examples:<br><code class="docutils literal notranslate"><span class="pre">editor.replaceSelectedText("world",</span> <span class="pre">{"append":</span> <span class="pre">true}</span> <span class="pre">)</span></code> Appends “world” to the current selections.<br><code class="docutils literal notranslate"><span class="pre">editor.replaceSelectedText(function(s){return</span> <span class="pre">s.toUpperCase();})</span></code> Converts the current selection to uppercase.</p></td>
</tr>
<tr class="row-even"><td><p>editor.insertSnippet(text);</p></td>
<td><p>Inserts a text snippet into the editor. For a list of extended features and syntax see <a class="reference internal" href="#text-macros">Text Macros</a>.</p></td>
</tr>
<tr class="row-odd"><td><p>editor.undo();</p></td>
<td><p>undo last command in editor</p></td>
</tr>
<tr class="row-even"><td><p>editor.redo();</p></td>
<td><p>redo last command in editor</p></td>
</tr>
<tr class="row-odd"><td><p>editor.cut();</p></td>
<td><p>cut selection to clipboard</p></td>
</tr>
<tr class="row-even"><td><p>editor.copy();</p></td>
<td><p>copy selection to clipboard</p></td>
</tr>
<tr class="row-odd"><td><p>editor.paste();</p></td>
<td><p>paste clipboard contents</p></td>
</tr>
<tr class="row-even"><td><p>editor.selectAll();</p></td>
<td><p>select all</p></td>
</tr>
<tr class="row-odd"><td><p>editor.selectNothing();</p></td>
<td><p>select nothing (clear selections)</p></td>
</tr>
<tr class="row-even"><td><p>editor.cutBuffer</p></td>
<td><p>If a macro was triggered by a key press and there was a selection previous to the key press, the content of the selection is stored in the cutBuffer. The selection and its content is removed before the macro is entered.</p></td>
</tr>
<tr class="row-odd"><td><p>editor.find();</p></td>
<td><p>activate “find panel”</p></td>
</tr>
<tr class="row-even"><td><p>editor.find(QString text, bool highlight, bool regex, bool word=false,bool caseSensitive=false);</p></td>
<td><p>activate “find panel” with predefined values</p></td>
</tr>
<tr class="row-odd"><td><p>editor.find(QString text, bool highlight, bool regex, bool word, bool caseSensitive, bool fromCursor, bool selection);</p></td>
<td><p>activate “find panel” with predefined values</p></td>
</tr>
<tr class="row-even"><td><p>editor.findNext();</p></td>
<td><p>find next</p></td>
</tr>
<tr class="row-odd"><td><p>editor.replacePanel();</p></td>
<td><p>replace (if find panel open and something is selected)</p></td>
</tr>
<tr class="row-even"><td><p>editor.gotoLine();</p></td>
<td><p>activate “goto line panel”</p></td>
</tr>
<tr class="row-odd"><td><p>editor.indentSelection();</p></td>
<td><p>indent selection</p></td>
</tr>
<tr class="row-even"><td><p>editor.unindentSelection();</p></td>
<td><p>unindent selection</p></td>
</tr>
<tr class="row-odd"><td><p>editor.commentSelection();</p></td>
<td><p>comment selection</p></td>
</tr>
<tr class="row-even"><td><p>editor.uncommentSelection();</p></td>
<td><p>uncomment selection</p></td>
</tr>
<tr class="row-odd"><td><p>editor.clearPlaceHolders();</p></td>
<td><p>clear place holders</p></td>
</tr>
<tr class="row-even"><td><p>editor.nextPlaceHolder();</p></td>
<td><p>jump to next place holder</p></td>
</tr>
<tr class="row-odd"><td><p>editor.previousPlaceHolder()</p></td>
<td><p>jump to previous place holder</p></td>
</tr>
<tr class="row-even"><td><p>editor.setPlaceHolder(int i, bool selectCursors=true);</p></td>
<td><p>set Placeholder</p></td>
</tr>
<tr class="row-odd"><td><p>editor.setFileName(f);</p></td>
<td><p>set filename to <em>f</em></p></td>
</tr>
<tr class="row-even"><td><p>editor.write(str)</p></td>
<td><p>inserts str at the current cursors position (if there are cursor mirrors, str will be inserted by all of them)</p></td>
</tr>
<tr class="row-odd"><td><p>editor.insertText(str)</p></td>
<td><p>inserts str at the current cursor position (cursor mirrors are ignored,so it is preferable to use replaceSelectedText or write instead)</p></td>
</tr>
<tr class="row-even"><td><p>editor.setText(<em>text</em>)</p></td>
<td><p>replace the whole text of the current document by <em>text</em></p></td>
</tr>
<tr class="row-odd"><td><p>editor.text()</p></td>
<td><p>return the text of the complete document</p></td>
</tr>
<tr class="row-even"><td><p>editor.text(int line)</p></td>
<td><p>return text of <em>line</em></p></td>
</tr>
<tr class="row-odd"><td><p>editor.document().lineCount()</p></td>
<td><p>Returns the number of lines</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().visualLineCount()</p></td>
<td><p>Returns the number of visual lines (counting wrapped lines)</p></td>
</tr>
<tr class="row-odd"><td><p><s>editor.document().cursor(line, [column = 0], [lineTo = -1],[columnTo = length of lineTo])</s></p></td>
<td><p>Unsupported in txs 4.x. Use new QDocumentCursor(…) instead, see section cursor.</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().text([removeTrailing = false], [preserveIndent = true])</p></td>
<td><p>Returns the complete text of the document</p></td>
</tr>
<tr class="row-odd"><td><p>editor.document().textLines()</p></td>
<td><p>Returns an array of all text lines</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().lineEndingString()</p></td>
<td><p>Returns a string containing the ending of a line (\n or \n\r)</p></td>
</tr>
<tr class="row-odd"><td><p><s>editor.document().getLineTokens(lineNr)</s></p></td>
<td><p>Unsupported in txs 4.x.</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().canUndo()</p></td>
<td><p>Returns true if undo is possible</p></td>
</tr>
<tr class="row-odd"><td><p>editor.document().canRedo()</p></td>
<td><p>Returns true if redo is possible</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().expand(lineNr)</p></td>
<td><p>Unfold the line in editor</p></td>
</tr>
<tr class="row-odd"><td><p>editor.document().collapse(lineNr)</p></td>
<td><p>Fold the line in editor</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().expandParents(lineNr)</p></td>
<td><p>Expand all parents of the line until it is visible</p></td>
</tr>
<tr class="row-odd"><td><p>editor.document().foldBlockAt(bool unFold, lineNr);</p></td>
<td><p>Collapses or expands the first block before lineNr</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().getMasterDocument();</p></td>
<td><p>Returns the open document which directly includes this document</p></td>
</tr>
<tr class="row-odd"><td><p><s>editor.document().getTopMasterDocument();</s></p></td>
<td><p><em>Deprecated:</em> Use getRootDocument() instead</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().getRootDocument();</p></td>
<td><p>Returns the open document which indireclty includes this document and is not itself included by any other document</p></td>
</tr>
<tr class="row-odd"><td><p>editor.document().getMagicComment(name);</p></td>
<td><p>Returns the content of a magic comment, if it exists</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().updateMagicComment(name, value, [create = false]);</p></td>
<td><p>Changes a magic comment</p></td>
</tr>
<tr class="row-odd"><td><p>editor.document().labelItems/refItems/bibItems</p></td>
<td><p>Returns the ids of all labels/references or included bibliography files.</p></td>
</tr>
<tr class="row-even"><td><p>editor.document().getLastEnvName(lineNr)</p></td>
<td><p>Returns the name of the current environment (at the end of the line).</p></td>
</tr>
<tr class="row-odd"><td><p>documentManager.currentDocument</p></td>
<td><p>Current document (usually the same as editor.document(), unless the script is running in background mode)</p></td>
</tr>
<tr class="row-even"><td><p>documents.masterDocument</p></td>
<td><p>Master document if defined</p></td>
</tr>
<tr class="row-odd"><td><p>[documentManager.]documents</p></td>
<td><p>Array of all open documents</p></td>
</tr>
<tr class="row-even"><td><p>documentManager.findDocument(fileName)</p></td>
<td><p>Returns the open document with a certain file name</p></td>
</tr>
<tr class="row-odd"><td><p>documentManager.singleMode()</p></td>
<td><p>Returns true if there is no explicit master document</p></td>
</tr>
<tr class="row-even"><td><p><s>documentManager.</s> <s>getMasterDocumentForDoc(document)</s></p></td>
<td><p><em>Deprecated:</em> Use getRootDocumentForDoc(document) instead</p></td>
</tr>
<tr class="row-odd"><td><p>documentManager. getRootDocumentForDoc(document)</p></td>
<td><p>Returns the open document (possibly indirectly) including the given document</p></td>
</tr>
<tr class="row-even"><td><p>documentManager.findFileFromBibId(id)</p></td>
<td><p>Returns the file name of the bib file containing an entry with the given id</p></td>
</tr>
<tr class="row-odd"><td><p>new QDocumentCursor(editor.document(),line, [column = 0], [lineTo = -1], [columnTo = length of lineTo])</p></td>
<td><p>Returns a cursor object. If lineTo is given the cursor has a selection from line:column to lineTo:columnTo, otherwise not.</p></td>
</tr>
<tr class="row-even"><td><p>cursor.atEnd()</p></td>
<td><p>returns whether the cursor is at the end of the document</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.atStart()</p></td>
<td><p>returns whether the cursor is at the start of the document</p></td>
</tr>
<tr class="row-even"><td><p>cursor.atBlockEnd()</p></td>
<td><p>returns whether the cursor is at the end of a block</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.atBlockStart()</p></td>
<td><p>returns whether the cursor is at the start of a block</p></td>
</tr>
<tr class="row-even"><td><p>cursor.atLineEnd()</p></td>
<td><p>returns whether the cursor is at the end of a line</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.atLineStart()</p></td>
<td><p>returns whether the cursor is at the start of a line</p></td>
</tr>
<tr class="row-even"><td><p>cursor.hasSelection()</p></td>
<td><p>return whether the cursor has a selection</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.lineNumber()</p></td>
<td><p>returns the line number of the cursor</p></td>
</tr>
<tr class="row-even"><td><p>cursor.columnNumber()</p></td>
<td><p>returns the column of the cursor</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.anchorLineNumber()</p></td>
<td><p>returns the line number of the anchor.</p></td>
</tr>
<tr class="row-even"><td><p>cursor.anchorColumnNumber()</p></td>
<td><p>returns the column of the anchor.</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.shift(int offset)</p></td>
<td><p>Shift cursor position (text column) by a number of columns (characters)</p></td>
</tr>
<tr class="row-even"><td><p>cursor.setPosition(int pos, MoveMode m = MoveAnchor)</p></td>
<td><p>set the cursor position after pos-characters counted from document start (very slow)</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.movePosition(int offset, MoveOperation op = NextCharacter, MoveMode m = MoveAnchor);</p></td>
<td><p>move cursor <em>offset</em> times. MoveOperations may be: <br>- cursorEnums.NoMove<br>- cursorEnums.Up<br>- cursorEnums.Down<br>- cursorEnums.Left<br>- cursorEnums.PreviousCharacter = Left<br>- cursorEnums.Right<br>- cursorEnums.NextCharacter = Right<br>- cursorEnums.Start<br>- cursorEnums.StartOfLine<br>- cursorEnums.StartOfBlock = StartOfLine<br>- cursorEnums.StartOfWord<br>- cursorEnums.StartOfWordOrCommand<br>- cursorEnums.PreviousBlock<br>- cursorEnums.PreviousLine = PreviousBlock<br>- cursorEnums.PreviousWord<br>- cursorEnums.WordLeft<br>- cursorEnums.WordRight<br>- cursorEnums.End<br>- cursorEnums.EndOfLine<br>- cursorEnums.EndOfBlock = EndOfLine<br>- cursorEnums.EndOfWord<br>- cursorEnums.EndOfWordOrCommand<br>- cursorEnums.NextWord<br>- cursorEnums.NextBlock<br>- cursorEnums.NextLine = NextBlock<br><br>Options for MoveMode are:<br><br>- cursorEnums.MoveAnchor<br>- cursorEnums.KeepAnchor<br>- cursorEnums.ThroughWrap</p></td>
</tr>
<tr class="row-even"><td><p>cursor.moveTo(int line, int column);</p></td>
<td><p>move cursor to <em>line</em> and <em>column</em></p></td>
</tr>
<tr class="row-odd"><td><p>cursor.eraseLine();</p></td>
<td><p>remove current line</p></td>
</tr>
<tr class="row-even"><td><p>cursor.insertLine(bool keepAnchor = false);</p></td>
<td><p>insert empty line</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.insertText(text, bool keepAnchor = false)</p></td>
<td><p>insert <em>text</em> text at cursor (this function will ignore indentations and mirrors, see editor.write and editor.insertText)</p></td>
</tr>
<tr class="row-even"><td><p>cursor.selectedText()</p></td>
<td><p>return the selected text</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.clearSelection();</p></td>
<td><p>clears selection</p></td>
</tr>
<tr class="row-even"><td><p>cursor.removeSelectedText();</p></td>
<td><p>removes selected text</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.replaceSelectedText(text);</p></td>
<td><p>replace selected text with <em>text</em></p></td>
</tr>
<tr class="row-even"><td><p>cursor.deleteChar();</p></td>
<td><p>removes char right to the cursor</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.deletePreviousChar();</p></td>
<td><p>removes char left to the cursor</p></td>
</tr>
<tr class="row-even"><td><p>cursor.beginEditBlock();</p></td>
<td><p>begins a new edit block. All cursor operations encapsulated in an edit block are undone/redone at once.</p></td>
</tr>
<tr class="row-odd"><td><p>cursor.endEditBlock();</p></td>
<td><p>ends an edit block</p></td>
</tr>
<tr class="row-even"><td><p>app.getVersion()</p></td>
<td><p>Current version (0xMMmm00)</p></td>
</tr>
<tr class="row-odd"><td><p>app.clipboard</p></td>
<td><p>Property to read/write to the clipboard</p></td>
</tr>
<tr class="row-even"><td><p>app.getCurrentFileName()</p></td>
<td><p>File name of currently edited file</p></td>
</tr>
<tr class="row-odd"><td><p>app.getAbsoluteFilePath(rel, ext = “”)</p></td>
<td><p>Converts a relative filename to an absolute one</p></td>
</tr>
<tr class="row-even"><td><p>app.load(file)</p></td>
<td><p>Loads a file</p></td>
</tr>
<tr class="row-odd"><td><p>app.fileOpen/Save/Close/…/editUndo/…/QuickBuild/…</p></td>
<td><p>All menu commands (i.e. all slots in the texstudio.h file). You can view a list of all currently existing slots on the “menu” page of the config dialog.</p></td>
</tr>
<tr class="row-even"><td><p>app.completerIsVisible()</p></td>
<td><p>check if completer is visible.</p></td>
</tr>
<tr class="row-odd"><td><p>app.newManagedMenu([parent menu,] id, caption)</p></td>
<td><p>Creates a new menu and returns it</p></td>
</tr>
<tr class="row-even"><td><p>app.getManagedMenu(id)</p></td>
<td><p>Returns a <a class="reference external" href="https://doc.qt.io/qt-6/qmenu.html">QMenu</a> with a certain id</p></td>
</tr>
<tr class="row-odd"><td><p>app.newManagedAction(menu, id, caption)</p></td>
<td><p>Creates a new action and returns it<br><br>- menu: Parent menu<br>- id: Id of the new action (the final, unique id will be <em>menu id/action id</em>)<br>- caption: Visible text<br><br>You can use action.triggered.connect(function(){ … }); to link a function to the returned action (for details see the <a class="reference external" href="https://doc.qt.io/qt-6/signalsandslots.html">qt signal/slot</a> documentation).</p></td>
</tr>
<tr class="row-even"><td><p>app.getManagedAction([id])</p></td>
<td><p>Returns a <a class="reference external" href="https://doc.qt.io/qt-6/qaction.html">QAction</a> with a certain id (all ids have the form main/menu1/menu2/…/menuN/action, with usually one menu, e.g. “main/edit/undo”, see texstudio.cpp)</p></td>
</tr>
<tr class="row-odd"><td><p>app.loadManagedMenu(filename)</p></td>
<td><p>load menu structure from an xml-file, same format as uiconfig.xml</p></td>
</tr>
<tr class="row-even"><td><p>app.setupToolBars()</p></td>
<td><p>recreate toolbars. Call this if a newly created menu is used in the toolbar.</p></td>
</tr>
<tr class="row-odd"><td><p>app.createUI(file, [parent])</p></td>
<td><p>Loads a certain ui file and creates a QWidget* from it</p></td>
</tr>
<tr class="row-even"><td><p>app.createUIFromString(string, [parent])</p></td>
<td><p>Creates a QWidget* described in the string</p></td>
</tr>
<tr class="row-odd"><td><p>app.slowOperationStarted()/slowOperationEnded()</p></td>
<td><p>Notify txs about the start/end of a slow operation to temporary disable the endless loop detection.</p></td>
</tr>
<tr class="row-even"><td><p>app.simulateKeyPress(shortcut)</p></td>
<td><p>Trigger a KeyPress event for the given shortcut, e.g. <code class="docutils literal notranslate"><span class="pre">app.simulateKeyPress("Shift+Up")</span></code>. <em>Note</em>: this is mainly intended for shortcuts and navigation. Currently, it does not support all functions of a KeyPress event. In particular, you cannot type any text.</p></td>
</tr>
<tr class="row-odd"><td><p>new UniversalInputDialog()</p></td>
<td><p>Creates a new dialog</p></td>
</tr>
<tr class="row-even"><td><p>dialog.add(defaultValue, [description, [id]])</p></td>
<td><p>Adds a new variable with the given default value, optional description and id to the dialog; and returns the corresponding qt component. A string default value becomes a QLineEdit, a number a QSpinBox and an array a QComboBox.</p></td>
</tr>
<tr class="row-odd"><td><p>dialog.get(nr/id)</p></td>
<td><p>Returns the current value of the nr-th added variable or the variable with a certain id.</p></td>
</tr>
<tr class="row-even"><td><p>dialog.getAll()</p></td>
<td><p>Returns the value of all variables as combined numerical/associative array. You can use returnvalue[i] to get the i-th variable, and returnvalue.id to get the variable with a certain id.</p></td>
</tr>
<tr class="row-odd"><td><p>dialog.exec()</p></td>
<td><p>Displays the dialog. Returns 1 if the user accepted the dialog, 0 if it was canceled.</p></td>
</tr>
<tr class="row-even"><td><p>dialog.show()</p></td>
<td><p>Displays the dialog asynchronously.</p></td>
</tr>
<tr class="row-odd"><td><p><s>UniversalInputDialog([[defaultValue_0, description_0, id_0],[defaultValue_1, description_1, id_1], …])</s></p></td>
<td><p>Not working in txs 4.0.0. <s>Short form: Creates a new dialog, adds all variables of the array and call exec on it.</s></p></td>
</tr>
<tr class="row-even"><td><p>fileChooser.exec()</p></td>
<td><p>show dialog and wait until it is closed again</p></td>
</tr>
<tr class="row-odd"><td><p>fileChooser.setDir(dir)</p></td>
<td><p>set directory in the dialog to <em>dir</em></p></td>
</tr>
<tr class="row-even"><td><p>fileChooser.setFilter(filter)</p></td>
<td><p>set file filter to <em>filter</em>, using the QT-format, see above</p></td>
</tr>
<tr class="row-odd"><td><p>fileChooser.fileName()</p></td>
<td><p>return selected filename (after exec)</p></td>
</tr>
</tbody>
</table>
</div>
<p>Some examples:</p>
<ul>
<li><p>Copy current file name to clipboard:</p>
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="nx">SCRIPT</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">clipboard</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">editor</span><span class="p">.</span><span class="nx">fileName</span><span class="p">();</span>
</pre></div>
</div>
</li>
<li><p>Execution of editor text:</p>
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="nx">SCRIPT</span>
<span class="nb">eval</span><span class="p">(</span><span class="nx">editor</span><span class="p">.</span><span class="nx">text</span><span class="p">());</span>
</pre></div>
</div>
</li>
<li><p>Show all properties of an object:</p>
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="nx">SCRIPT</span>
<span class="kd">function</span><span class="w"> </span><span class="nx">write_properties</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="nx">app</span><span class="p">.</span><span class="nx">fileNew</span><span class="p">();</span>
<span class="w"> </span><span class="nx">newEditor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">documentManager</span><span class="p">.</span><span class="nx">currentDocument</span><span class="p">.</span><span class="nx">editorView</span><span class="p">.</span><span class="nx">editor</span><span class="p">;</span><span class="w"> </span><span class="c1">//access the newly created document</span>
<span class="w"> </span><span class="nx">newEditor</span><span class="p">.</span><span class="nx">setText</span><span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">getOwnPropertyNames</span><span class="p">(</span><span class="nx">obj</span><span class="p">).</span><span class="nx">join</span><span class="p">(</span><span class="s2">"\n"</span><span class="p">));</span><span class="w"> </span><span class="c1">//print the properties</span>
<span class="p">}</span>
<span class="nx">obj</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">editor</span><span class="p">;</span><span class="w"> </span><span class="c1">//object to show (e.g. the current editor)</span>
<span class="nx">write_properties</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>Additional action in the edit menu</p>
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="nx">SCRIPT</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">menu</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">app</span><span class="p">.</span><span class="nx">getManagedMenu</span><span class="p">(</span><span class="s2">"main/edit"</span><span class="p">);</span><span class="w"> </span><span class="c1">//get edit menu</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">act</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">app</span><span class="p">.</span><span class="nx">newManagedAction</span><span class="p">(</span><span class="nx">menu</span><span class="p">,</span><span class="w"> </span><span class="s2">"script"</span><span class="p">,</span><span class="w"> </span><span class="s2">"scripttest"</span><span class="p">);</span><span class="w"> </span><span class="c1">//add action</span>
<span class="nx">act</span><span class="p">.</span><span class="nx">triggered</span><span class="p">.</span><span class="nx">connect</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="nx">alert</span><span class="p">(</span><span class="s2">"called"</span><span class="p">);});</span><span class="w"> </span><span class="c1">//register simple handler</span>
<span class="nx">registerAsBackgroundScript</span><span class="p">(</span><span class="s2">"test"</span><span class="p">);</span><span class="w"> </span><span class="c1">//keep handler valid</span>
</pre></div>
</div>
</li>
<li><p>Asynchronous dialog:</p>
<div class="highlight-javascript notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="nx">SCRIPT</span>
<span class="kd">var</span><span class="w"> </span><span class="nx">ui</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">createUI</span><span class="p">(</span><span class="s2">" ... path to your ui file ..."</span><span class="p">);</span><span class="w"> </span><span class="c1">//load dialog</span>
<span class="nx">ui</span><span class="p">.</span><span class="nx">accepted</span><span class="p">.</span><span class="nx">connect</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="nx">alert</span><span class="p">(</span><span class="s2">"x"</span><span class="p">);})</span><span class="w"> </span><span class="c1">//react to dialog closing</span>
<span class="nx">registerAsBackgroundScript</span><span class="p">(</span><span class="s2">"abc"</span><span class="p">);</span><span class="w"> </span><span class="c1">//keep function valid</span>
<span class="nx">ui</span><span class="p">.</span><span class="nx">show</span><span class="p">();</span><span class="w"> </span><span class="c1">//show dialog</span>
</pre></div>
</div>
<p>The dialog is described in an ui file which can be created with the
Qt Designer.</p>