forked from tridactyl/tridactyl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ts
1652 lines (1500 loc) · 58.3 KB
/
config.ts
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
// Sketch
//
// Need an easy way of getting and setting settings
// If a setting is not set, the default should probably be returned.
// That probably means that binds etc. should be per-key?
//
// We should probably store all settings in memory, and only load from storage on startup and when we set it
//
// Really, we'd like a way of just letting things use the variables
//
/** # Tridactyl Configuration
*
* We very strongly recommend that you pretty much ignore this page and instead follow the link below DEFAULTS that will take you to our own source code which is formatted in a marginally more sane fashion.
*
*/
/** @hidden */
const CONFIGNAME = "userconfig"
/** @hidden */
const WAITERS = []
/** @hidden */
let INITIALISED = false
/** @hidden */
// make a naked object
export function o(object) {
return Object.assign(Object.create(null), object)
}
/** @hidden */
// "Import" is a reserved word so this will have to do
function schlepp(settings) {
Object.assign(USERCONFIG, settings)
}
/** @hidden */
export let USERCONFIG = o({})
/** @hidden
* Ideally, LoggingLevel should be in logging.ts and imported from there. However this would cause a circular dependency, which webpack can't deal with
*/
export type LoggingLevel = "never" | "error" | "warning" | "info" | "debug"
/**
* This is the default configuration that Tridactyl comes with.
*
* You can change anything here using `set key1.key2.key3 value` or specific things any of the various helper commands such as `bind` or `command`. You can also jump to the help section of a setting using `:help $settingname`. Some of the settings have an input field containing their current value. You can modify these values and save them by pressing `<Enter>` but using `:set $setting $value` is a good habit to take as it doesn't force you to leave the page you're visiting to change your settings.
*/
export class default_config {
/**
* Internal version number Tridactyl uses to know whether it needs to update from old versions of the configuration.
*
* Changing this might do weird stuff.
*/
configversion = "0.0"
/**
* Internal field to handle site-specific configs. Use :seturl/:unseturl to change these values.
*/
subconfigs: { [key: string]: default_config } = {
"www.google.com": {
followpagepatterns: {
next: "Next",
prev: "Previous",
},
} as default_config,
}
/**
* Internal field to handle site-specific config priorities. Use :seturl/:unseturl to change this value.
*/
priority = 0
// Note to developers: When creating new <modifier-letter> maps, make sure to make the modifier uppercase (e.g. <C-a> instead of <c-a>) otherwise some commands might not be able to find them (e.g. `bind <c-a>`)
/**
* exmaps contains all of the bindings for the command line.
* You can of course bind regular ex commands but also [editor functions](/static/docs/modules/_src_lib_editor_.html) and [commandline-specific functions](/static/docs/modules/_src_commandline_frame_.html).
*/
exmaps = {
"<Enter>": "ex.accept_line",
"<C-j>": "ex.accept_line",
"<C-m>": "ex.accept_line",
"<Escape>": "ex.hide_and_clear",
"<ArrowUp>": "ex.prev_history",
"<ArrowDown>": "ex.next_history",
"<C-a>": "text.beginning_of_line",
"<C-e>": "text.end_of_line",
"<C-u>": "text.backward_kill_line",
"<C-k>": "text.kill_line",
"<C-c>": "text.kill_whole_line",
"<C-f>": "ex.complete",
"<Tab>": "ex.next_completion",
"<S-Tab>": "ex.prev_completion",
"<Space>": "ex.insert_space_or_completion",
}
/**
* ignoremaps contain all of the bindings for "ignore mode".
*
* They consist of key sequences mapped to ex commands.
*/
ignoremaps = {
"<S-Insert>": "mode normal",
"AC-Escape>": "mode normal",
"<AC-`>": "mode normal",
"<S-Escape>": "mode normal",
"<C-^>": "tab #",
"<C-6>": "tab #",
}
/**
* imaps contain all of the bindings for "insert mode".
*
* On top of regular ex commands, you can also bind [editor functions](/static/docs/modules/_src_lib_editor_.html) in insert mode.
*
* They consist of key sequences mapped to ex commands.
*/
imaps = {
"<Escape>": "composite unfocus | mode normal",
"<C-[>": "composite unfocus | mode normal",
"<C-i>": "editor",
"<AC-Escape>": "mode normal",
"<AC-`>": "mode normal",
"<C-6>": "tab #",
"<C-^>": "tab #",
"<S-Escape>": "mode ignore",
}
/**
* inputmaps contain all of the bindings for "input mode".
*
* On top of regular ex commands, you can also bind [editor functions](/static/docs/modules/_src_lib_editor_.html) in input mode.
*
* They consist of key sequences mapped to ex commands.
*/
inputmaps = mergeDeep(this.imaps, {
"<Tab>": "focusinput -n",
"<S-Tab>": "focusinput -N",
})
/**
* nmaps contain all of the bindings for "normal mode".
*
* They consist of key sequences mapped to ex commands.
*/
nmaps = {
"<A-p>": "pin",
"<A-m>": "mute toggle",
"<F1>": "help",
o: "fillcmdline open",
O: "current_url open",
w: "fillcmdline winopen",
W: "current_url winopen",
t: "fillcmdline tabopen",
"]]": "followpage next",
"[[": "followpage prev",
"[c": "urlincrement -1",
"]c": "urlincrement 1",
"<C-x>": "urlincrement -1",
"<C-a>": "urlincrement 1",
T: "current_url tabopen",
yy: "clipboard yank",
ys: "clipboard yankshort",
yc: "clipboard yankcanon",
ym: "clipboard yankmd",
yt: "clipboard yanktitle",
gh: "home",
gH: "home true",
p: "clipboard open",
P: "clipboard tabopen",
j: "scrollline 10",
"<C-e>": "scrollline 10",
k: "scrollline -10",
"<C-y>": "scrollline -10",
h: "scrollpx -50",
l: "scrollpx 50",
G: "scrollto 100",
gg: "scrollto 0",
"<C-u>": "scrollpage -0.5",
"<C-d>": "scrollpage 0.5",
"<C-f>": "scrollpage 1",
"<C-b>": "scrollpage -1",
$: "scrollto 100 x",
// "0": "scrollto 0 x", // will get interpreted as a count
"^": "scrollto 0 x",
"<C-6>": "tab #",
"<C-^>": "tab #",
H: "back",
L: "forward",
"<C-o>": "jumpprev",
"<C-i>": "jumpnext",
d: "tabclose",
D: "composite tabprev; tabclose #",
gx0: "tabclosealltoleft",
gx$: "tabclosealltoright",
"<<": "tabmove -1",
">>": "tabmove +1",
u: "undo",
U: "undo window",
r: "reload",
R: "reloadhard",
x: "stop",
gi: "focusinput -l",
"g?": "rot13",
"g;": "changelistjump -1",
J: "tabprev",
K: "tabnext",
gt: "tabnext_gt",
gT: "tabprev",
// "<c-n>": "tabnext_gt", // c-n is reserved for new window
// "<c-p>": "tabprev",
"g^": "tabfirst",
g0: "tabfirst",
g$: "tablast",
gr: "reader",
gu: "urlparent",
gU: "urlroot",
gf: "viewsource",
":": "fillcmdline_notrail",
s: "fillcmdline open search",
S: "fillcmdline tabopen search",
// find mode not suitable for general consumption yet.
// "/": "fillcmdline find",
// "?": "fillcmdline find -?",
// n: "findnext 1",
// N: "findnext -1",
// ",<Space>": "nohlsearch",
M: "gobble 1 quickmark",
B: "fillcmdline taball",
b: "fillcmdline tab",
ZZ: "qall",
f: "hint",
F: "hint -b",
gF: "hint -qb",
";i": "hint -i",
";b": "hint -b",
";o": "hint",
";I": "hint -I",
";k": "hint -k",
";y": "hint -y",
";p": "hint -p",
";P": "hint -P",
";r": "hint -r",
";s": "hint -s",
";S": "hint -S",
";a": "hint -a",
";A": "hint -A",
";;": "hint -;",
";#": "hint -#",
";v": "hint -W mpvsafe",
";w": "hint -w",
";t": "hint -W tabopen",
";O": "hint -W fillcmdline_notrail open ",
";W": "hint -W fillcmdline_notrail winopen ",
";T": "hint -W fillcmdline_notrail tabopen ",
";z": "hint -z",
";m":
"composite hint -pipe img src | js -p tri.excmds.open('images.google.com/searchbyimage?image_url=' + JS_ARG)",
";M":
"composite hint -pipe img src | jsb -p tri.excmds.tabopen('images.google.com/searchbyimage?image_url=' + JS_ARG)",
";gi": "hint -qi",
";gI": "hint -qI",
";gk": "hint -qk",
";gy": "hint -qy",
";gp": "hint -qp",
";gP": "hint -qP",
";gr": "hint -qr",
";gs": "hint -qs",
";gS": "hint -qS",
";ga": "hint -qa",
";gA": "hint -qA",
";g;": "hint -q;",
";g#": "hint -q#",
";gv": "hint -qW mpvsafe",
";gw": "hint -qw",
";gb": "hint -qb",
// These two don't strictly follow the "bind is ;g[flag]" rule but they make sense
";gF": "hint -qb",
";gf": "hint -q",
"<S-Insert>": "mode ignore",
"<AC-Escape>": "mode ignore",
"<AC-`>": "mode ignore",
"<S-Escape>": "mode ignore",
"<Escape>": "composite mode normal ; hidecmdline",
"<C-[>": "composite mode normal ; hidecmdline",
a: "current_url bmark",
A: "bmark",
zi: "zoom 0.1 true",
zo: "zoom -0.1 true",
zm: "zoom 0.5 true",
zr: "zoom -0.5 true",
zM: "zoom 0.5 true",
zR: "zoom -0.5 true",
zz: "zoom 1",
zI: "zoom 3",
zO: "zoom 0.3",
".": "repeat",
"<AS-ArrowUp><AS-ArrowUp><AS-ArrowDown><AS-ArrowDown><AS-ArrowLeft><AS-ArrowRight><AS-ArrowLeft><AS-ArrowRight>ba":
"open https://www.youtube.com/watch?v=M3iOROuTuMA",
}
hintmaps = {
"<Backspace>": "hint.popKey",
"<Escape>": "hint.reset",
"<Tab>": "hint.focusPreviousHint",
"<S-Tab>": "hint.focusNextHint",
"<ArrowUp>": "hint.focusTopHint",
"<ArrowDown>": "hint.focusBottomHint",
"<ArrowLeft>": "hint.focusLeftHint",
"<ArrowRight>": "hint.focusRightHint",
"<Enter>": "hint.selectFocusedHint",
"<Space>": "hint.selectFocusedHint",
}
/**
* Whether to allow pages (not necessarily github) to override `/`, which is a default Firefox binding.
*/
leavegithubalone: "true" | "false" = "false"
/**
* Which keys to protect from pages that try to override them. Requires [[leavegithubalone]] to be set to false.
*/
blacklistkeys: string[] = ["/"]
/**
* Autocommands that run when certain events happen, and other conditions are met.
*
* Related ex command: `autocmd`.
*/
autocmds = {
/**
* Commands that will be run as soon as Tridactyl loads into a page.
*
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
*/
DocStart: {
// "addons.mozilla.org": "mode ignore",
},
/**
* Commands that will be run when pages are loaded.
*
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
*/
DocLoad: {
"^https://github.com/tridactyl/tridactyl/issues/new$": "issue",
},
/**
* Commands that will be run when pages are unloaded.
*
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
*/
DocEnd: {
// "emacs.org": "sanitise history",
},
/**
* Commands that will be run when Tridactyl first runs each time you start your browser.
*
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
*/
TriStart: {
".*": "source_quiet",
},
/**
* Commands that will be run when you enter a tab.
*
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
*/
TabEnter: {
// "gmail.com": "mode ignore",
},
/**
* Commands that will be run when you leave a tab.
*
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
*/
TabLeft: {
// Actually, this doesn't work because tabclose closes the current tab
// Too bad :/
// "emacs.org": "tabclose",
},
/**
* Commands that will be run when fullscreen state changes.
*/
FullscreenChange: {},
/**
* Commands that will be run when fullscreen state is entered.
*/
FullscreenEnter: {},
/**
* Commands that will be run when fullscreen state is left.
*/
FullscreenLeft: {},
}
/**
* Map for translating keys directly into other keys in normal-ish modes. For example, if you have an entry in this config option mapping `п` to `g`, then you could type `пп` instead of `gg` or `пi` instead of `gi` or `;п` instead of `;g`. This is primarily useful for international users who don't want to deal with rebuilding their bindings every time tridactyl ships a new default keybind. It's not as good as shipping properly internationalized sets of default bindings, but it's probably as close as we're going to get on a small open-source project like this.
*
* Note that the current implementation does not allow you to "chain" keys, for example, "a"=>"b" and "b"=>"c" for "a"=>"c". You can, however, swap or rotate keys, so "a"=>"b" and "b"=>"a" will work the way you'd expect, as will "a"=>"b" and "b"=>"c" and "c"=>"a".
*/
keytranslatemap = {
// Examples (I think >_>):
// "д": "l", // Russian language
// "é" : "w", // BÉPO
// "h": "j", // Dvorak
// "n": "j", // Colemak
// etc
}
/**
* Whether to use the keytranslatemap in various maps.
*/
keytranslatemodes: { [key: string]: "true" | "false" } = {
nmaps: "true",
imaps: "false",
inputmaps: "false",
ignoremaps: "false",
exmaps: "false",
hintmaps: "false",
}
/**
* Automatically place these sites in the named container.
*
* Each key corresponds to a URL fragment which, if contained within the page URL, the site will be opened in a container tab instead.
*/
autocontain = o({
// "github.com": "microsoft",
// "youtube.com": "google",
})
/**
* Strict mode will always ensure a domain is open in the correct container, replacing the current tab if necessary.
*
* Relaxed mode is less aggressive and instead treats container domains as a default when opening a new tab.
*/
autocontainmode: "strict" | "relaxed" = "strict"
/**
* Aliases for the commandline.
*
* You can make a new one with `command alias ex-command`.
*/
exaliases = {
alias: "command",
au: "autocmd",
aucon: "autocontain",
audel: "autocmddelete",
audelete: "autocmddelete",
b: "tab",
clsh: "clearsearchhighlight",
nohlsearch: "clearsearchhighlight",
noh: "clearsearchhighlight",
o: "open",
w: "winopen",
t: "tabopen",
tabnew: "tabopen",
tabm: "tabmove",
tabo: "tabonly",
tn: "tabnext_gt",
bn: "tabnext_gt",
tnext: "tabnext_gt",
bnext: "tabnext_gt",
tp: "tabprev",
tN: "tabprev",
bp: "tabprev",
bN: "tabprev",
tprev: "tabprev",
bprev: "tabprev",
tabfirst: "tab 1",
tablast: "tab 0",
bfirst: "tabfirst",
blast: "tablast",
tfirst: "tabfirst",
tlast: "tablast",
buffer: "tab",
bufferall: "taball",
bd: "tabclose",
bdelete: "tabclose",
quit: "tabclose",
q: "tabclose",
qa: "qall",
sanitize: "sanitise",
tutorial: "tutor",
h: "help",
unmute: "mute unmute",
authors: "credits",
openwith: "hint -W",
"!": "exclaim",
"!s": "exclaim_quiet",
containerremove: "containerdelete",
colours: "colourscheme",
colorscheme: "colourscheme",
colors: "colourscheme",
man: "help",
"!js": "fillcmdline_tmp 3000 !js is deprecated. Please use js instead",
"!jsb":
"fillcmdline_tmp 3000 !jsb is deprecated. Please use jsb instead",
get_current_url: "js document.location.href",
current_url: "composite get_current_url | fillcmdline_notrail ",
stop: "js window.stop()",
zo: "zoom",
installnative: "nativeinstall",
nativeupdate: "updatenative",
mkt: "mktridactylrc",
"mkt!": "mktridactylrc -f",
"mktridactylrc!": "mktridactylrc -f",
mpvsafe: "js -p tri.excmds.shellescape(JS_ARG).then(url => tri.excmds.exclaim_quiet('mpv ' + url))",
exto: "extoptions",
extpreferences: "extoptions",
extp: "extpreferences",
}
/**
* Used by `]]` and `[[` to look for links containing these words.
*
* Edit these if you want to add, e.g. other language support.
*/
followpagepatterns = {
next: "^(next|newer)\\b|»|>>|more",
prev: "^(prev(ious)?|older)\\b|«|<<",
}
/**
* The default search engine used by `open search`. If empty string, your browser's default search engine will be used. If set to something, Tridactyl will first look at your [[searchurls]] and then at the search engines for which you have defined a keyword on `about:preferences#search`.
*/
searchengine = ""
/**
* Definitions of search engines for use via `open [keyword]`.
*
* `%s` will be replaced with your whole query and `%s1`, `%s2`, ..., `%sn` will be replaced with the first, second and nth word of your query. If there are none of these patterns in your search urls, your query will simply be appended to the searchurl.
*
* Examples:
* - When running `open gi cute puppies`, with a `gi` searchurl defined with `set searchurls.gi https://www.google.com/search?q=%s&tbm=isch`, tridactyl will navigate to `https://www.google.com/search?q=cute puppies&tbm=isch`.
* - When running `tabopen translate en ja Tridactyl`, with a `translate` searchurl defined with `set searchurls.translate https://translate.google.com/#view=home&op=translate&sl=%s1&tl=%s2&text=%s3`, tridactyl will navigate to `https://translate.google.com/#view=home&op=translate&sl=en&tl=ja&text=Tridactyl`.
*/
searchurls = {
google: "https://www.google.com/search?q=",
googlelucky: "https://www.google.com/search?btnI=I'm+Feeling+Lucky&q=",
scholar: "https://scholar.google.com/scholar?q=",
googleuk: "https://www.google.co.uk/search?q=",
bing: "https://www.bing.com/search?q=",
duckduckgo: "https://duckduckgo.com/?q=",
yahoo: "https://search.yahoo.com/search?p=",
twitter: "https://twitter.com/search?q=",
wikipedia: "https://en.wikipedia.org/wiki/Special:Search/",
youtube: "https://www.youtube.com/results?search_query=",
amazon:
"https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=",
amazonuk:
"https://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=",
startpage:
"https://startpage.com/do/search?language=english&cat=web&query=",
github: "https://github.com/search?utf8=✓&q=",
searx: "https://searx.me/?category_general=on&q=",
cnrtl: "http://www.cnrtl.fr/lexicographie/",
osm: "https://www.openstreetmap.org/search?query=",
mdn: "https://developer.mozilla.org/en-US/search?q=",
gentoo_wiki:
"https://wiki.gentoo.org/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search=",
qwant: "https://www.qwant.com/?q=",
}
/**
* URL the newtab will redirect to.
*
* All usual rules about things you can open with `open` apply, with the caveat that you'll get interesting results if you try to use something that needs `nativeopen`: so don't try `about:newtab`.
*/
newtab = ""
/**
* Whether `:viewsource` will use our own page that you can use Tridactyl binds on, or Firefox's default viewer, which you cannot use Tridactyl on.
*/
viewsource: "tridactyl" | "default" = "tridactyl"
/**
* Which storage to use. Sync storage will synchronise your settings via your Firefox Account.
*/
storageloc: "sync" | "local" = "sync"
/**
* Pages opened with `gH`. In order to set this value, use `:set homepages ["example.org", "example.net", "example.com"]` and so on.
*/
homepages: string[] = []
/**
* Characters to use in hint mode.
*
* They are used preferentially from left to right.
*/
hintchars = "hjklasdfgyuiopqwertnmzxcvb"
/**
* The type of hinting to use. `vimperator` will allow you to filter links based on their names by typing non-hint chars. It is recommended that you use this in conjuction with the [[hintchars]] setting, which you should probably set to e.g, `5432167890`. ´vimperator-reflow´ additionally updates the hint labels after filtering.
*/
hintfiltermode: "simple" | "vimperator" | "vimperator-reflow" = "simple"
/**
* Whether to optimise for the shortest possible names for each hint, or to use a simple numerical ordering. If set to `numeric`, overrides `hintchars` setting.
*/
hintnames: "short" | "numeric" | "uniform" = "short"
/**
* Whether to display the names for hints in uppercase.
*/
hintuppercase: "true" | "false" = "true"
/**
* The delay in milliseconds in `vimperator` style hint modes after selecting a hint before you are returned to normal mode.
*
* The point of this is to prevent accidental execution of normal mode binds due to people typing more than is necessary to choose a hint.
*/
hintdelay = 300
/**
* Controls whether the page can focus elements for you via js
*
* NB: will break fancy editors such as CodeMirror on Jupyter. Simply use `seturl` to whitelist pages you need it on.
*
* Best used in conjunction with browser.autofocus in `about:config`
*/
allowautofocus: "true" | "false" = "true"
/**
* Uses a loop to prevent focus until you interact with a page. Only recommended for use via `seturl` for problematic sites as it can be a little heavy on CPU if running on all tabs. Should be used in conjuction with [[allowautofocus]]
*/
preventautofocusjackhammer: "true" | "false" = "false"
/**
* Controls whether the newtab focuses on tridactyl's newtab page or the firefox urlbar.
*
* To get FF default behaviour, use "urlbar".
*/
newtabfocus: "page" | "urlbar" = "page"
/**
* Whether to use Tridactyl's (bad) smooth scrolling.
*/
smoothscroll: "true" | "false" = "false"
/**
* How viscous you want smooth scrolling to feel.
*/
scrollduration = 100
/**
* Where to open tabs opened with `tabopen` - to the right of the current tab, or at the end of the tabs.
*/
tabopenpos: "next" | "last" = "next"
/**
* Where to open tabs opened with hinting - as if it had been middle clicked, to the right of the current tab, or at the end of the tabs.
*/
relatedopenpos: "related" | "next" | "last" = "related"
/**
* The name of the voice to use for text-to-speech. You can get the list of installed voices by running the following snippet: `js alert(window.speechSynthesis.getVoices().reduce((a, b) => a + " " + b.name))`
*/
ttsvoice = "default" // chosen from the listvoices list or "default"
/**
* Controls text-to-speech volume. Has to be a number between 0 and 1.
*/
ttsvolume = 1
/**
* Controls text-to-speech speed. Has to be a number between 0.1 and 10.
*/
ttsrate = 1
/**
* Controls text-to-speech pitch. Has to be between 0 and 2.
*/
ttspitch = 1
/**
* If nextinput, <Tab> after gi brings selects the next input
*
* If firefox, <Tab> selects the next selectable element, e.g. a link
*/
gimode: "nextinput" | "firefox" = "nextinput"
/**
* Decides where to place the cursor when selecting non-empty input fields
*/
cursorpos: "beginning" | "end" = "end"
/**
* The theme to use.
*
* Permitted values: run `:composite js tri.styling.THEMES | fillcmdline` to find out.
*/
theme = "default"
/**
* Storage for custom themes
*
* Maps theme names to CSS. Predominantly used automatically by [[colourscheme]] to store themes read from disk, as documented by [[colourscheme]]. Setting this manually is untested but might work provided that [[colourscheme]] is then used to change the theme to the right theme name.
*/
customthemes = {}
/**
* Whether to display the mode indicator or not.
*/
modeindicator: "true" | "false" = "true"
/**
* Milliseconds before registering a scroll in the jumplist
*/
jumpdelay = 3000
/**
* Logging levels. Unless you're debugging Tridactyl, it's unlikely you'll ever need to change these.
*/
logging: { [key: string]: LoggingLevel } = {
cmdline: "warning",
containers: "warning",
controller: "warning",
excmd: "error",
hinting: "warning",
messaging: "warning",
native: "warning",
performance: "warning",
state: "warning",
styling: "warning",
}
/**
* Disables the commandline iframe. Dangerous setting, use [[seturl]] to set it. If you ever set this setting to "true" globally and then want to set it to false again, you can do this by opening Tridactyl's preferences page from about:addons.
*/
noiframe: "true" | "false" = "false"
/**
* @deprecated A list of URLs on which to not load the iframe. Use `seturl [URL] noiframe true` instead, as shown in [[noiframe]].
*/
noiframeon: string[] = []
/**
* Insert / input mode edit-in-$EDITOR command to run
* This has to be a command that stays in the foreground for the whole editing session
* "auto" will attempt to find a sane editor in your path.
* Please send your requests to have your favourite terminal moved further up the list to /dev/null.
* (but we are probably happy to add your terminal to the list if it isn't already there.)
*
* Example values:
* - linux: `xterm -e vim`
* - windows: `start cmd.exe /c \"vim\"`.
*
* Also see [:editor](/static/docs/modules/_src_excmds_.html#editor).
*/
editorcmd = "auto"
/**
* Command that should be run by the [[rssexec]] ex command. Has the
* following format:
* - %u: url
* - %t: title
* - %y: type (rss, atom, xml...)
* Warning: This is a very large footgun. %u will be inserted without any
* kind of escaping, hence you must obey the following rules if you care
* about security:
* - Do not use a composite command. If you need a composite command,
* create an alias.
* - Do not use `js` or `jsb`. If you need to use them, create an alias.
* - Do not insert any %u, %t or %y in shell commands run by the native
* messenger. Use pipes instead.
*
* Here's an example of how to save an rss url in a file on your disk
* safely:
* `alias save_rss jsb -p tri.native.run("cat >> ~/.config.newsboat/urls", JS_ARG)`
* `set rsscmd save_rss %u`
* This is safe because the url is passed to jsb as an argument rather than
* being expanded inside of the string it will execute and because it is
* piped to the shell command rather than being expanded inside of it.
*/
rsscmd = "yank %u"
/**
* The browser executable to look for in commands such as `restart`. Not as mad as it seems if you have multiple versions of Firefox...
*/
browser = "firefox"
/**
* Which clipboard to store items in. Requires the native messenger to be installed.
*/
yankto: "clipboard" | "selection" | "both" = "clipboard"
/**
* Which clipboard to retrieve items from. Requires the native messenger to be installed.
*
* Permitted values: `clipboard`, or `selection`.
*/
putfrom: "clipboard" | "selection" = "clipboard"
/**
* Clipboard command to try to get the selection from (e.g. `xsel` or `xclip`)
*/
externalclipboardcmd = "auto"
/**
* Set this to something weird if you want to have fun every time Tridactyl tries to update its native messenger.
*
* %TAG will be replaced with your version of Tridactyl for stable builds, or "master" for beta builds
*/
nativeinstallcmd =
"curl -fsSl https://raw.githubusercontent.com/tridactyl/tridactyl/master/native/install.sh -o /tmp/trinativeinstall.sh && bash /tmp/trinativeinstall.sh %TAG"
/**
* Set this to something weird if you want to have fun every time Tridactyl tries to update its native messenger.
*
* Replaces %WINTAG with "-Tag $TRI_VERSION", similarly to [[nativeinstallcmd]].
*/
win_nativeinstallcmd = `powershell -NoProfile -InputFormat None -Command "Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/cmcaine/tridactyl/master/native/win_install.ps1'))"`
/**
* Used by :updatecheck and related built-in functionality to automatically check for updates and prompt users to upgrade.
*/
update = {
/**
* Whether Tridactyl should check for available updates at startup.
*/
nag: true,
/**
* How many days to wait after an update is first available until telling people.
*/
nagwait: 7,
/**
* The version we last nagged you about. We only nag you once per version.
*/
lastnaggedversion: "1.14.0",
/**
* Time we last checked for an update, milliseconds since unix epoch.
*/
lastchecktime: 0,
/**
* Minimum interval between automatic update checks, in seconds.
*/
checkintervalsecs: 60 * 60 * 24,
}
/**
* Profile directory to use with native messenger with e.g, `guiset`.
*/
profiledir = "auto"
// Container settings
/**
* If enabled, tabopen opens a new tab in the currently active tab's container.
*/
tabopencontaineraware: "true" | "false" = "false"
/**
* If moodeindicator is enabled, containerindicator will color the border of the mode indicator with the container color.
*/
containerindicator: "true" | "false" = "true"
/**
* Autocontain directives create a container if it doesn't exist already.
*/
auconcreatecontainer: "true" | "false" = "true"
/**
* Number of most recent results to ask Firefox for. We display the top 20 or so most frequently visited ones.
*/
historyresults = 50
/**
* When displaying bookmarks in history completions, how many page views to pretend they have.
*/
bmarkweight = 100
/**
* Number of results that should be shown in completions. -1 for unlimited
*/
findresults = -1
/**
* Number of characters to use as context for the matches shown in completions
*/
findcontextlen = 100
/**
* Whether find should be case-sensitive
*/
findcase: "smart" | "sensitive" | "insensitive" = "smart"
/**
* Whether Tridactyl should jump to the first match when using `:find`
*/
incsearch: "true" | "false" = "false"
/**
* How many characters should be typed before triggering incsearch/completions
*/
minincsearchlen = 3
/**
* Deprecated.
* Change this to "clobber" to ruin the "Content Security Policy" of all sites a bit and make Tridactyl run a bit better on some of them, e.g. raw.github*
*/
csp: "untouched" | "clobber" = "untouched"
/**
* JavaScript RegExp used to recognize words in text.* functions (e.g. text.transpose_words). Should match any character belonging to a word.
*/
wordpattern = "[^\\s]+"
/**
* Activate tridactyl's performance counters. These have a
* measurable performance impact, since every sample is a few
* hundred bytes and we sample tridactyl densely, but they're good
* when you're trying to optimize things.
*/
perfcounters: "true" | "false" = "false"
/**
* How many samples to store from the perf counters.
*
* Each performance entry is two numbers (16 bytes), an entryType
* of either "mark" or "measure" (js strings are utf-16 ad we have
* two marks for each measure, so amortize to about 10 bytes per
* entry), and a string name that for Tridactyl object will be
* about 40 (utf-16) characters (80 bytes), plus object overhead
* roughly proportional to the string-length of the name of the
* constructor (in this case something like 30 bytes), for a total
* of what we'll call 128 bytes for ease of math.
*
* We want to store, by default, about 1MB of performance
* statistics, so somewhere around 10k samples.
*
*/
perfsamples: string = "10000"
/**
* Show (partial) command in the mode indicator.
* Corresponds to 'showcmd' option of vi.
*/
modeindicatorshowkeys: "true" | "false" = "false"
/**
* Whether a trailing slash is appended when we get the parent of a url with
* gu (or other means).
*/
urlparenttrailingslash: "true" | "false" = "true"
}
/** @hidden */
const DEFAULTS = o(new default_config())
/** Given an object and a target, extract the target if it exists, else return undefined
@param target path of properties as an array
@hidden
*/
function getDeepProperty(obj, target: string[]) {
if (obj !== undefined && target.length) {
return getDeepProperty(obj[target[0]], target.slice(1))
} else {
return obj
}
}
/** Create the key path target if it doesn't exist and set the final property to value.
If the path is an empty array, replace the obj.
@param target path of properties as an array
@hidden
*/
function setDeepProperty(obj, value, target) {
if (target.length > 1) {
// If necessary antecedent objects don't exist, create them.
if (obj[target[0]] === undefined) {
obj[target[0]] = o({})
}
return setDeepProperty(obj[target[0]], value, target.slice(1))
} else {
obj[target[0]] = value
}
}
/** @hidden
* Merges two objects and any child objects they may have
*/
export function mergeDeep(o1, o2) {
const r = Array.isArray(o1) ? o1.slice() : Object.create(o1)
Object.assign(r, o1, o2)
if (o2 === undefined) return r