Repository navigation
Expand file tree
/
Copy pathwrithdeck-cli.tcl
More file actions
executable file
·7744 lines (7272 loc) · 333 KB
/
Copy pathwrithdeck-cli.tcl
File metadata and controls
executable file
·7744 lines (7272 loc) · 333 KB
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
#!/bin/sh
# sh/Tcl polyglot - backslash continues Tcl comment to next line, hiding shell bootstrap \
_w=$(stty -g 2>/dev/null); trap '[ -n "$_w" ] && stty "$_w" 2>/dev/null' EXIT INT TERM; tclsh "$0" "$@"; exit $?
# # # # # # # # # # # #
#
# writhdeck.tcl (CLI-only build)
#
# ~ Tcl/Tk 8.5+ (console/TUI) text editor for writerdecks ~
#
# Usage: tclsh writhdeck-cli.tcl [filename]
#
# https://github.com/luginf/writhdeck
# -----------------------------
# Copyright (C) 2026 by Luginfo
#
# BSD Zero Clause License
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
# FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# # # # # # # # # # # #
set ::version "v20260923"
# bail out immediately when invoked by bash tab-completion
if {[info exists ::env(COMP_LINE)] || [info exists ::env(COMP_POINT)]} { exit 0 }
if {[lsearch $::argv "--help"] >= 0 || [lsearch $::argv "-h"] >= 0} {
puts "Usage: writhdeck-cli.tcl \[FILE\]
writhdeck CLI-only (TUI) mode. No GUI/Tk support.
Keyboard shortcuts (defaults - configurable in writhdeck.ini):
^S Save ^Z Undo ^Y Redo
^Q Close / Esc ^F Find ^R Find & Replace
^H Help ^G Go to line ^O Open file
^A Select all ^K Toggle sticky selection
^C Copy ^X Cut ^V Paste
^L Line numbers ^D Dark/light toggle
^Space Next space ^Shift+Space Prev space"
exit 0
}
set ::no_gui 1
set ::force_gui 0
foreach _f {--no-gui --tui --ng --cli --gui} { set ::argv [lsearch -all -inline -not $::argv $_f] }
unset _f
set ::argc [llength $::argv]
set ::HOME_DIR [expr {[info exists ::env(HOME)] ? $::env(HOME) : \
([info exists ::env(USERPROFILE)] ? $::env(USERPROFILE) : \
[expr {![catch {file home} _h] ? $_h : [file normalize ~]}])}]
# Tcl 9 no longer expands ~ in file normalize; this proc handles it explicitly.
proc tilde-expand {path} {
if {[string index $path 0] ne "~"} { return $path }
if {$path eq "~" || [string index $path 1] eq "/"} {
return $::HOME_DIR[string range $path 1 end]
}
return $path
}
set ::DOCS_DIR_DEFAULT [file join $::HOME_DIR Documents writhdeck]
# set ::DOCS_DIR_DEFAULT "C:/Temp/writhdeck" ;# Windows custom
# set ::DOCS_DIR_DEFAULT "/tmp/writhdeck" ;# Linux custom
set ::DOCS_DIR $::DOCS_DIR_DEFAULT
set ::INI_FILE [file join $::DOCS_DIR_DEFAULT "writhdeck.ini"]
set ::FILE_EXT ".txt"
set ::filename ""
set ::dirty 0
# ===========================================================================
# state.tcl
# ===========================================================================
set ::msg ""
set ::ed_msg ""
set ::msg_after_id ""
set ::scratchpad 0
set ::file_mtime_known 0
set ::watch_after_id ""
set ::session_headings {}
set ::gui_cmd_mode 0
set ::tui_cmd_mode 0
set ::tui_cmd_idx 0
file mkdir $::DOCS_DIR_DEFAULT
set ::STATE_FILE [file join $::DOCS_DIR_DEFAULT ".writhdeck.json"]
# Portable override, same logic as ini-load (src/config.tcl): if the
# LAUNCH directory ([pwd], not where the script lives) already has a
# state file of that name, it entirely replaces the default one
# (cursors, favorites, recent, daily stats) - full substitution, not a
# merge. Reuses [file tail $::STATE_FILE] so it also matches WDECK.JSN
# on DOS without a separate candidate list.
set _local_state [file join [pwd] [file tail $::STATE_FILE]]
if {[file exists $_local_state]} { set ::STATE_FILE $_local_state }
unset _local_state
set ::cursor_cache {}
set ::favorites_list {}
set ::recent_list {}
set ::daily_data {}
set ::session_file ""
set ::session_baseline -1
set ::session_max_today 0
set ::state_cache_valid 0
# --- state persistence (.writhdeck.json) --------------------------------------
# Format: {"cursors":{"path":[cy,cx],...},"favorites":[...],"recent":[...],"daily":["path\tdate\tN",...]}
proc state-parse-array {raw key} {
set ri [string first "\"$key\"" $raw]
if {$ri < 0} { return {} }
set ai [string first "\[" $raw $ri]
set ae [string first "\]" $raw [expr {$ai + 1}]]
if {$ai < 0 || $ae < 0} { return {} }
set sub [string range $raw [expr {$ai + 1}] [expr {$ae - 1}]]
set result {}
set re {"((?:[^"\\]|\\.)*)"}
set start 0
while {[regexp -start $start -indices $re $sub match item]} {
set item_text [string range $sub {*}$item]
lappend result $item_text
set end [lindex $match 1]
set start [expr {$end + 1}]
}
return $result
}
# state-file-parse / state-file-write operate on an arbitrary path and return/take
# a plain dict {cursors {...} favorites {...} recent {...} daily {...}} - no global
# state touched. state-load/state-save (below) are thin wrappers around ::STATE_FILE;
# the reconciliation tool (src/gui-reconcile.tcl) calls these directly to load/merge
# two state files side by side without disturbing the live app's caches.
proc state-file-parse {path} {
set cursors {}
set favorites {}
set recent {}
set daily {}
if {[file exists $path]} {
set fh [open $path r]; chan configure $fh -encoding utf-8
set raw [read $fh]; close $fh
set ci [string first "\"cursors\"" $raw]
if {$ci >= 0} {
set ob [string first "\{" $raw $ci]
set cb [string first "\}" $raw [expr {$ob + 1}]]
if {$ob >= 0 && $cb >= 0} {
set sub [string range $raw [expr {$ob + 1}] [expr {$cb - 1}]]
set re {"((?:[^"\\]|\\.)*)"\s*:\s*\[(\d+)\s*,\s*(\d+)\]}
set start 0
while {[regexp -start $start $re $sub -> key cy cx]} {
set idx [string first "\"$key\"" $sub $start]
set start [expr {$idx + [string length $key] + 2}]
set key [string map [list {\\} "\\" {\"} "\""] $key]
dict set cursors $key [list [expr {int($cy)}] [expr {int($cx)}]]
}
}
}
foreach p [state-parse-array $raw "favorites"] {
lappend favorites [file normalize [string map [list {\\} "\\" {\"} "\""] $p]]
}
foreach p [state-parse-array $raw "recent"] {
lappend recent [file normalize [string map [list {\\} "\\" {\"} "\""] $p]]
}
# cursors/daily keys are re-canonicalized here for legacy/hand-edited data - but
# ONLY as a full path (file normalize): in "name" key mode (see state-key below)
# a stored key is already a bare filename, and running it through
# [file normalize] would wrongly resolve it against the current working
# directory instead of leaving it alone.
set new_cursors {}
dict for {k v} $cursors {
set nk [expr {$::cfg_cursor_key_mode eq "name" ? $k : [file normalize $k]}]
dict set new_cursors $nk $v
}
set cursors $new_cursors
foreach item [state-parse-array $raw "daily"] {
set item [string map [list {\\} "\\" {\"} "\"" {\t} "\t"] $item]
set parts [split $item "\t"]
if {[llength $parts] >= 3} {
set fp0 [lindex $parts 0]
set fp [expr {$::cfg_cursor_key_mode eq "name" ? $fp0 : [file normalize $fp0]}]
if {![dict exists $daily $fp]} { dict set daily $fp {} }
for {set i 1} {$i + 1 < [llength $parts]} {incr i 2} {
set date [lindex $parts $i]
set cnt [lindex $parts [expr {$i + 1}]]
dict set daily $fp $date [expr {int($cnt)}]
}
}
}
}
return [dict create cursors $cursors favorites $favorites recent $recent daily $daily]
}
proc state-file-write {path data} {
set cp {}
dict for {k v} [dict get $data cursors] {
set ke [string map {\\ \\\\ \" \\\"} $k]
lappend cp "\"$ke\":\[[lindex $v 0],[lindex $v 1]\]"
}
set fp {}
foreach p [dict get $data favorites] { lappend fp "\"[string map {\\ \\\\ \" \\\"} $p]\"" }
set rp {}
foreach p [dict get $data recent] { lappend rp "\"[string map {\\ \\\\ \" \\\"} $p]\"" }
set dp {}
dict for {fpath fdata} [dict get $data daily] {
set entry [string map {\\ \\\\ \" \\\"} $fpath]
dict for {date cnt} $fdata {
append entry "\\t${date}\\t${cnt}"
}
lappend dp "\"${entry}\""
}
set fh [open $path w]; chan configure $fh -encoding utf-8
puts $fh "\{"
if {[llength $cp]} {
puts $fh "\"cursors\":\{\n[join $cp ",\n"]\n\},"
} else {
puts $fh "\"cursors\":\{\},"
}
if {[llength $fp]} {
puts $fh "\"favorites\":\[\n[join $fp ",\n"]\n\],"
} else {
puts $fh "\"favorites\":\[\],"
}
if {[llength $rp]} {
puts $fh "\"recent\":\[\n[join $rp ",\n"]\n\],"
} else {
puts $fh "\"recent\":\[\],"
}
if {[llength $dp]} {
puts $fh "\"daily\":\[\n[join $dp ",\n"]\n\]"
} else {
puts $fh "\"daily\":\[\]"
}
puts $fh "\}"
close $fh
}
proc state-load {} {
set data [state-file-parse $::STATE_FILE]
set ::cursor_cache [dict get $data cursors]
set ::favorites_list [dict get $data favorites]
set ::recent_list [dict get $data recent]
set ::daily_data [dict get $data daily]
set ::state_cache_valid 1
daily-cleanup
}
proc state-save {} {
state-file-write $::STATE_FILE [dict create \
cursors $::cursor_cache \
favorites $::favorites_list \
recent $::recent_list \
daily $::daily_data]
}
# cfg_cursor_key_mode ("path", default, or "name"): the key used to persist a cursor
# position or daily word-count entry for a file. "path" is the note's normalized
# absolute path, unchanged historical behaviour - a moved/renamed note loses its saved
# position/stats. "name" is the bare filename only (file tail), ignoring its folder -
# survives a move/rename into another folder, at the cost of two different notes
# sharing a filename in different folders then sharing one saved position/history.
proc state-key {filepath} {
set filepath [file normalize $filepath]
if {$::cfg_cursor_key_mode eq "name"} { return [file tail $filepath] }
return $filepath
}
proc cursor-get {filepath} {
if {!$::cfg_cursor_restore} { return {1 0} }
set key [state-key $filepath]
if {!$::state_cache_valid} { state-load }
if {[dict exists $::cursor_cache $key]} {
lassign [dict get $::cursor_cache $key] cy cx
return [list [expr {$cy + 1}] $cx]
}
return {1 0}
}
proc cursor-put {filepath cy cx} {
if {!$::cfg_cursor_restore} return
set key [state-key $filepath]
if {!$::state_cache_valid} { state-load }
dict set ::cursor_cache $key [list [expr {$cy - 1}] $cx]
state-save
}
# ===========================================================================
# config.tcl
# ===========================================================================
proc recent-push {path} {
set path [file normalize $path]
if {!$::state_cache_valid} { state-load }
set ::recent_list [lsearch -all -inline -not -exact $::recent_list $path]
set ::recent_list [linsert $::recent_list 0 $path]
if {[llength $::recent_list] > 5} { set ::recent_list [lrange $::recent_list 0 4] }
state-save
}
proc recent-remove {path} {
set path [file normalize $path]
if {!$::state_cache_valid} { state-load }
set ::recent_list [lsearch -all -inline -not -exact $::recent_list $path]
state-save
}
proc recent-rename {old new} {
set old [file normalize $old]
set new [file normalize $new]
if {!$::state_cache_valid} { state-load }
set changed 0
set idx [lsearch -exact $::recent_list $old]
if {$idx >= 0} { set ::recent_list [lreplace $::recent_list $idx $idx $new]; set changed 1 }
set idx [lsearch -exact $::favorites_list $old]
if {$idx >= 0} { set ::favorites_list [lreplace $::favorites_list $idx $idx $new]; set changed 1 }
if {$changed} { state-save }
}
# --- daily writing stats ------------------------------------------------------
# Keyed the same way as cursor positions (see state-key in state.tcl / cfg_cursor_key_mode)
# - "path" (default): the note's normalized absolute path. "name": bare filename only.
proc daily-open {filepath wc} {
set filepath [file normalize $filepath]
set ::session_file $filepath
set key [state-key $filepath]
set today [clock format [clock seconds] -format "%Y-%m-%d"]
if {!$::state_cache_valid} { state-load }
set prior 0
if {[dict exists $::daily_data $key] &&
[dict exists [dict get $::daily_data $key] $today]} {
set prior [dict get [dict get $::daily_data $key] $today]
}
set ::session_baseline [expr {$wc - $prior}]
set ::session_max_today $prior
}
proc daily-today {wc} {
if {$::session_baseline < 0} { return 0 }
set current [expr {max(0, $wc - $::session_baseline)}]
if {$current > $::session_max_today} { set ::session_max_today $current }
return $::session_max_today
}
proc daily-update {wc} {
if {$::session_file eq "" || $::session_baseline < 0} return
set key [state-key $::session_file]
set today [clock format [clock seconds] -format "%Y-%m-%d"]
set added [daily-today $wc]
if {![dict exists $::daily_data $key]} { dict set ::daily_data $key {} }
dict set ::daily_data $key $today $added
state-save
}
proc daily-cleanup {} {
set today [clock format [clock seconds] -format "%Y-%m-%d"]
# Compared via state-key (not the raw path) so a favorite is still recognized under
# "name" key mode, where $::daily_data is keyed by filename, not by $::favorites_list's
# full paths.
set fav_keys {}
foreach p $::favorites_list { lappend fav_keys [state-key $p] }
set new_data {}
dict for {fp fdata} $::daily_data {
if {$fp in $fav_keys} {
dict set new_data $fp $fdata
} else {
if {[dict exists $fdata $today]} {
dict set new_data $fp [dict create $today [dict get $fdata $today]]
}
}
}
set ::daily_data $new_data
}
proc daily-clear {filepath} {
set key [state-key $filepath]
if {[dict exists $::daily_data $key]} {
dict unset ::daily_data $key
}
state-save
}
# --- schemes (loaded from src/schemes/*.tcl) --------------------------------
set ::scheme_defs {}
# --- ini ----------------------------------------------------------------------
set ::cfg_scheme "default"
set ::cfg_schemes {}
set ::cfg_profile "default"
set ::cfg_profiles {}
set ::cfg_margin_width 60
set ::cfg_margin_height 40
set ::cfg_limit_width_enabled 0
set ::cfg_limit_width 82
set ::cfg_split_shrink_margin 1
set ::cfg_watch_file 1
set ::cfg_hemingway_mode 0
set ::cfg_font_size 13
set ::cfg_font_family "Mono"
set ::cfg_bar_font_family "Mono"
set ::cfg_bg "#1a1a1a"
set ::cfg_fg "#e8e8e8"
set ::cfg_bg_bar "#2a2a2a"
set ::cfg_fg_bar "#aaaaaa"
set ::cfg_bg_sel "#3a5a8a"
set ::cfg_docs_dir ""
set ::cfg_browser_filter "*.txt *.t2t *.md *.ini"
set ::cfg_browser_show_all 0
set ::cfg_browser_subdirs 1
set ::cfg_repetition_scope 100
set ::cfg_repetition_min_len 4
set ::cfg_repetition_hidden 0
set ::cfg_sentence_short_max 7
set ::cfg_sentence_long_min 16
set ::cfg_spell_lang ""
set ::cfg_spell_highlight 0
set ::cfg_analysis_ignore_comments 0
set ::cfg_console_margin_cols 6
set ::cfg_console_margin_rows 4
set ::cfg_heading_marker "="
set ::cfg_markdown_support 1
set ::cfg_color_heading "#c8a060"
set ::cfg_comment_marker "%"
set ::cfg_color_comment "#606060"
set ::cfg_bold_marker "**"
set ::cfg_italic_marker "//"
set ::cfg_underline_marker "__"
set ::cfg_strikethrough_marker "--"
set ::cfg_color_markup "#6aa9d4"
# alternate (light) theme - used when dark_mode = 0
set ::cfg_bg_alt "#fdf6e3"
set ::cfg_fg_alt "#657b83"
set ::cfg_bg_bar_alt "#eee8d5"
set ::cfg_fg_bar_alt "#93a1a1"
set ::cfg_bg_sel_alt "#e6ddb9"
set ::cfg_color_heading_alt "#b58900"
set ::cfg_color_comment_alt "#aaaaaa"
set ::cfg_color_markup_alt "#2a7090"
set ::cfg_bg2 "#1a1a1a"
set ::cfg_bg2_alt "#fdf6e3"
# dark_mode: 0 = light (alt colors), 1 = dark (primary colors)
set ::cfg_dark_mode 1
set ::cfg_key_dark_toggle "Control-d"
set ::cfg_browser 1
set ::cfg_console_center_alert 1
# tui_mouse: off by default - claims the terminal's own mouse reporting,
# which usually disables its native click-drag text selection/copy (most
# terminals let Shift+drag bypass this and select natively regardless)
set ::cfg_tui_mouse 0
set ::cfg_line_numbers 0
set ::cfg_cursor_restore 1
set ::cfg_cursor_key_mode "path"
set ::cfg_toc_pinned 0
set ::cfg_block_cursor_gui 1
set ::cfg_block_cursor_console 1
set ::cfg_blink_cursor 0
set ::cfg_line_spacing 100
set ::cfg_bar_height 18
set ::cfg_bar_show 1
set ::cfg_lang "en"
set ::cfg_help_bar "^S save ^Q close F10 workspace ^H help"
set ::cfg_word_goal 500
# status bar zones - tokens: filename dirty sel ln col words chars goal clock help_bar space
set ::cfg_status_left "workspace filename dirty sel ln col words chars"
set ::cfg_status_center ""
set ::cfg_status_right "help_bar clock"
# shortcuts (Tk key names)
set ::cfg_key_save "Control-s"
set ::cfg_key_save_as "Control-S"
set ::cfg_key_close "Control-q"
set ::cfg_key_find "Control-f"
set ::cfg_key_replace "Control-r"
set ::cfg_key_help "Control-h"
set ::cfg_key_goto "Control-g"
set ::cfg_key_open "Control-o"
set ::cfg_key_undo "Control-z"
set ::cfg_key_copy "Control-c"
set ::cfg_key_cut "Control-x"
set ::cfg_key_paste "Control-v"
set ::cfg_key_select_all "Control-a"
set ::cfg_key_sticky_sel "Control-k"
set ::cfg_key_toc "F11"
set ::cfg_key_toc_pinned "Control-Shift-F11"
set ::cfg_key_toc_focus "Control-F11"
set ::cfg_key_line_numbers "Control-l"
set ::cfg_key_redo "Control-y"
set ::cfg_key_typewriter "Control-t"
set ::cfg_key_fullscreen "Alt-Return"
set ::cfg_key_split "F3"
set ::cfg_key_split_focus "F4"
set ::cfg_key_workspace "F10"
set ::cfg_key_timer "Alt-t"
set ::cfg_key_cmd_mode "Escape"
set ::cfg_key_error ""
set ::cfg_timer_duration 25
set ::cfg_timer_sound 1
set ::cfg_timer_alert 1
set ::cfg_chrono_show 1
set ::cfg_timer_type "countdown"
# TUI colors - enabled = 1 by default. tui_col_* is a deprecated alias for
# tui_color_* still accepted on load (renamed 2026-09-09), see ini-load switch.
# Defaults below are the ANSI-16 equivalents of the truecolor palette
# documented in ini-save (#FF0000/#7F7F7F/... - see the tui_colors section).
set ::cfg_tui_colors 1
set ::cfg_tui_256colors 0
set ::cfg_tui_truecolor 0
set ::cfg_tui_color_heading "bright_red"
set ::cfg_tui_color_comment "bright_black"
set ::cfg_tui_color_markup "bright_yellow"
set ::cfg_tui_color_bar_fg "black"
set ::cfg_tui_color_bar_bg "yellow"
set ::cfg_tui_color_sel_bg "bright_black"
set ::cfg_tui_color_fg "bright_white"
set ::cfg_tui_color_bg "black"
# Light-mode (dark_mode = no) variants
set ::cfg_tui_color_heading_alt "red"
set ::cfg_tui_color_comment_alt "bright_black"
set ::cfg_tui_color_markup_alt "green"
set ::cfg_tui_color_fg_alt "black"
set ::cfg_tui_color_bg_alt "bright_white"
set ::timer_active 0
set ::timer_remaining 0
set ::timer_last_tick 0
set ::timer_schedule_id ""
set ::timer_alert_shown 0
set ::cfg_autosave_enabled 1
set ::cfg_autosave_interval 1
# Minimum seconds between two recomputations of the cursor_percent/cursor_chars/
# cursor_words status tokens (0 = on every refresh). See cstat-due in common.tcl.
set ::cfg_cursor_stats_interval 2
set ::autosave_last_time 0
set ::autosave_schedule_id ""
set ::fullscreen 0
set ::split_mode 0
# workspace state (WS1 = primary, WS2 = secondary toggled via cfg_key_workspace)
set ::ws_n 1
set ::ws_dual_mode 0
set ::ws1_filename ""
set ::ws1_scratchpad 0
set ::ws1_dirty 0
set ::ws1_content ""
set ::ws1_cursor "1.0"
set ::ws1_file_mtime 0
set ::ws2_filename ""
set ::ws2_scratchpad 1
set ::ws2_dirty 0
set ::ws2_content ""
set ::ws2_cursor "1.0"
set ::ws2_file_mtime 0
set ::split_ws2_mode 0
proc marker-val {v} { expr {$v eq "0" ? "" : $v} }
proc timer-alert {} {
if {$::timer_alert_shown} return
set ::timer_alert_shown 1
if {!$::no_gui} {
if {$::cfg_timer_sound} { catch { timer-alert-gui } }
} else {
if {$::cfg_timer_sound} { do-beep }
if {$::cfg_timer_alert} { catch { tui-timer-alert } }
}
}
proc timer-tick {} {
if {!$::timer_active} return
if {$::cfg_timer_type eq "countdown" && $::timer_remaining <= 0} return
set now [clock seconds]
if {$::timer_last_tick == 0} {
set ::timer_last_tick $now
return
}
if {$now > $::timer_last_tick} {
if {$::cfg_timer_type eq "countdown"} {
incr ::timer_remaining -[expr {$now - $::timer_last_tick}]
if {$::timer_remaining < 0} { set ::timer_remaining 0 }
if {$::timer_remaining == 0 && $::cfg_timer_alert} {
timer-alert
}
} else {
incr ::timer_remaining [expr {$now - $::timer_last_tick}]
}
set ::timer_last_tick $now
if {!$::no_gui} { catch {ed-status} }
}
}
proc timer-schedule {} {
if {$::timer_active && $::cfg_chrono_show} {
set ::timer_schedule_id [after 1000 timer-schedule-tick]
} else {
if {$::timer_schedule_id ne ""} {
catch {after cancel $::timer_schedule_id}
set ::timer_schedule_id ""
}
}
}
proc timer-schedule-tick {} {
timer-tick
timer-schedule
}
proc timer-start {} {
if {$::cfg_timer_type eq "countdown"} {
set ::timer_remaining [expr {$::cfg_timer_duration * 60}]
} else {
set ::timer_remaining 0
}
set ::timer_active 1
set ::timer_alert_shown 0
set ::timer_last_tick [clock seconds]
timer-schedule
}
proc timer-pause {} {
set ::timer_active 0
if {$::timer_schedule_id ne ""} {
catch {after cancel $::timer_schedule_id}
set ::timer_schedule_id ""
}
}
proc timer-resume {} {
set ::timer_active 1
set ::timer_alert_shown 0
set ::timer_last_tick [clock seconds]
timer-schedule
}
proc timer-reset {} {
set ::timer_active 0
if {$::cfg_timer_type eq "countdown"} {
set ::timer_remaining [expr {$::cfg_timer_duration * 60}]
} else {
set ::timer_remaining 0
}
set ::timer_last_tick 0
if {$::timer_schedule_id ne ""} {
catch {after cancel $::timer_schedule_id}
set ::timer_schedule_id ""
}
if {!$::no_gui} { catch {ed-status} }
}
proc profile-apply {name} {
if {![dict exists $::cfg_profiles $name]} return
set d [dict get $::cfg_profiles $name]
foreach {key var} {
margin_width ::cfg_margin_width
margin_height ::cfg_margin_height
limit_width ::cfg_limit_width
font_size ::cfg_font_size
font_family ::cfg_font_family
bar_font_family ::cfg_bar_font_family
line_spacing ::cfg_line_spacing
bar_height ::cfg_bar_height
word_goal ::cfg_word_goal
lang ::cfg_lang
line_numbers ::cfg_line_numbers
status_left ::cfg_status_left
status_center ::cfg_status_center
status_right ::cfg_status_right
help_bar ::cfg_help_bar
} {
if {[dict exists $d $key]} { set $var [dict get $d $key] }
}
foreach {key var} {
dark_mode ::cfg_dark_mode
block_cursor_gui ::cfg_block_cursor_gui
blink_cursor ::cfg_blink_cursor
limit_width_enabled ::cfg_limit_width_enabled
} {
if {[dict exists $d $key]} { set $var [string is true [dict get $d $key]] }
}
set ::cfg_profile $name
}
proc scheme-apply {name} {
if {![dict exists $::cfg_schemes $name]} return
set d [dict get $::cfg_schemes $name]
foreach {key var} {
color_bg ::cfg_bg
color_fg ::cfg_fg
color_bg_bar ::cfg_bg_bar
color_fg_bar ::cfg_fg_bar
color_bg_sel ::cfg_bg_sel
color_heading ::cfg_color_heading
color_comment ::cfg_color_comment
color_markup ::cfg_color_markup
color_bg_alt ::cfg_bg_alt
color_fg_alt ::cfg_fg_alt
color_bg_bar_alt ::cfg_bg_bar_alt
color_fg_bar_alt ::cfg_fg_bar_alt
color_bg_sel_alt ::cfg_bg_sel_alt
color_heading_alt ::cfg_color_heading_alt
color_comment_alt ::cfg_color_comment_alt
color_markup_alt ::cfg_color_markup_alt
color_bg2 ::cfg_bg2
color_bg2_alt ::cfg_bg2_alt
} {
if {[dict exists $d $key]} { set $var [dict get $d $key] }
}
if {![dict exists $d color_bg2]} { set ::cfg_bg2 $::cfg_bg }
if {![dict exists $d color_bg2_alt]} { set ::cfg_bg2_alt $::cfg_bg_alt }
}
proc ini-load {} {
# Repertoire de LANCEMENT (celui d'ou la commande est executee, [pwd] --
# PAS celui ou reside writhdeck.tcl, [file dirname [info script]]) :
# si l'un de ces noms courts y existe, il prend le pas sur
# l'emplacement fixe habituel ($::INI_FILE, deja possiblement
# redirige par compat-dos.tcl vers WRITHDEC.INI a cote du script).
# Utile sur un support a noms de fichiers limites (FAT 8.3) ou quand
# DOCS_DIR_DEFAULT n'est pas accessible/pertinent (ex. disquette de
# boot). Premier trouve gagne, dans cet ordre.
foreach _cand {writhdec.ini writhd.ini wrid.ini writhdeck.ini} {
set _p [file join [pwd] $_cand]
if {[file exists $_p]} { set ::INI_FILE $_p; break }
}
unset _cand _p
if {![file exists $::INI_FILE]} { ini-save; return }
set fh [open $::INI_FILE r]
chan configure $fh -encoding utf-8
set section ""
set cur_scheme ""
set cur_profile ""
set toplevel {editor behaviour keys}
while {[gets $fh line] >= 0} {
set line [string trim $line]
if {$line eq "" || [string match "#*" $line] || [string match "%*" $line]} continue
# section header
if {[regexp {^\[(\w+)\]$} $line -> hdr]} {
if {$hdr eq "schemes"} {
set section "schemes"
set cur_scheme ""
set cur_profile ""
} elseif {$hdr eq "profiles"} {
set section "profiles"
set cur_profile ""
set cur_scheme ""
} elseif {$section eq "schemes" && $hdr ni $toplevel} {
set cur_scheme $hdr
} elseif {$section eq "profiles" && $hdr ni $toplevel} {
set cur_profile $hdr
} else {
set section $hdr
set cur_scheme ""
set cur_profile ""
}
continue
}
if {[regexp {^(\w+)\s*=(.*)$} $line -> key val]} {
set v [regsub {\s+[#%].*$} [string trim $val] {}]
# inside a named scheme block - store in dict
if {$cur_scheme ne ""} {
dict set ::cfg_schemes $cur_scheme $key $v
continue
}
# inside a named profile block - store in dict
if {$cur_profile ne ""} {
dict set ::cfg_profiles $cur_profile $key $v
continue
}
switch [string trim $key] {
scheme { set ::cfg_scheme $v }
profile { set ::cfg_profile $v }
margin_width { set ::cfg_margin_width $v }
margin_height { set ::cfg_margin_height $v }
limit_width_enabled { set ::cfg_limit_width_enabled [string is true $v] }
limit_width { set ::cfg_limit_width $v }
split_shrink_margin { set ::cfg_split_shrink_margin [string is true $v] }
watch_file { set ::cfg_watch_file [string is true $v] }
hemingway_mode { set ::cfg_hemingway_mode [string is true $v] }
font_size { set ::cfg_font_size $v }
font_family { set ::cfg_font_family $v }
bar_font_family { set ::cfg_bar_font_family $v }
color_bg { set ::cfg_bg $v }
color_fg { set ::cfg_fg $v }
color_bg_bar { set ::cfg_bg_bar $v }
color_fg_bar { set ::cfg_fg_bar $v }
docs_dir { set ::cfg_docs_dir $v }
console_margin_cols { set ::cfg_console_margin_cols $v }
console_margin_rows { set ::cfg_console_margin_rows $v }
margin_cols { set ::cfg_console_margin_cols $v }
margin_rows { set ::cfg_console_margin_rows $v }
color_bg_sel { set ::cfg_bg_sel $v }
heading_marker { set ::cfg_heading_marker $v }
markdown_support { set ::cfg_markdown_support [string is true $v] }
markdown_headings { set ::cfg_markdown_support [string is true $v] }
color_heading { set ::cfg_color_heading $v }
dim_marker { set ::cfg_comment_marker [marker-val $v] }
comment_marker { set ::cfg_comment_marker [marker-val $v] }
bold_marker { set ::cfg_bold_marker [marker-val $v] }
italic_marker { set ::cfg_italic_marker [marker-val $v] }
underline_marker { set ::cfg_underline_marker [marker-val $v] }
strikethrough_marker { set ::cfg_strikethrough_marker [marker-val $v] }
color_dim { set ::cfg_color_comment $v }
color_comment { set ::cfg_color_comment $v }
color_markup { set ::cfg_color_markup $v }
color_bg_alt { set ::cfg_bg_alt $v }
color_fg_alt { set ::cfg_fg_alt $v }
color_bg_bar_alt { set ::cfg_bg_bar_alt $v }
color_fg_bar_alt { set ::cfg_fg_bar_alt $v }
color_bg_sel_alt { set ::cfg_bg_sel_alt $v }
color_heading_alt { set ::cfg_color_heading_alt $v }
color_dim_alt { set ::cfg_color_comment_alt $v }
color_comment_alt { set ::cfg_color_comment_alt $v }
color_markup_alt { set ::cfg_color_markup_alt $v }
color_bg2 { set ::cfg_bg2 $v }
color_bg2_alt { set ::cfg_bg2_alt $v }
word_goal { set ::cfg_word_goal $v }
dark_mode { set ::cfg_dark_mode [string is true $v] }
key_dark_toggle { set ::cfg_key_dark_toggle $v }
browser { set ::cfg_browser [string is true $v] }
browser_filter { set ::cfg_browser_filter $v }
browser_show_all { set ::cfg_browser_show_all [string is true $v] }
browser_subdirs { set ::cfg_browser_subdirs [string is true $v] }
repetition_scope { set ::cfg_repetition_scope $v }
repetition_min_len { set ::cfg_repetition_min_len $v }
repetition_hidden { set ::cfg_repetition_hidden [string is true $v] }
sentence_short_max { if {[string is integer -strict $v] && $v >= 1} { set ::cfg_sentence_short_max $v } }
sentence_long_min { if {[string is integer -strict $v] && $v >= 2} { set ::cfg_sentence_long_min $v } }
spell_lang { set ::cfg_spell_lang $v }
spell_highlight { set ::cfg_spell_highlight [string is true $v] }
analysis_ignore_comments { set ::cfg_analysis_ignore_comments [string is true $v] }
console_center_alert { set ::cfg_console_center_alert [string is true $v] }
tui_mouse { set ::cfg_tui_mouse [string is true $v] }
line_numbers { set ::cfg_line_numbers [string is true $v] }
cursor_restore { set ::cfg_cursor_restore [string is true $v] }
cursor_key_mode { set ::cfg_cursor_key_mode [expr {$v eq "name" ? "name" : "path"}] }
toc_pinned { set ::cfg_toc_pinned [string is true $v] }
block_cursor { set ::cfg_block_cursor_gui [string is true $v]
set ::cfg_block_cursor_console [string is true $v] }
block_cursor_gui { set ::cfg_block_cursor_gui [string is true $v] }
block_cursor_console { set ::cfg_block_cursor_console [string is true $v] }
blink_cursor { set ::cfg_blink_cursor [string is true $v] }
line_spacing { set ::cfg_line_spacing $v }
bar_height { set ::cfg_bar_height $v }
bar { set ::cfg_bar_show [string is true $v] }
lang { set ::cfg_lang $v }
help_bar { set ::cfg_help_bar $v }
status_left { set ::cfg_status_left $v }
status_center { set ::cfg_status_center $v }
status_right { set ::cfg_status_right $v }
key_save { set ::cfg_key_save $v }
key_save_as { set ::cfg_key_save_as $v }
key_close { set ::cfg_key_close $v }
key_find { set ::cfg_key_find $v }
key_replace { set ::cfg_key_replace $v }
key_help { set ::cfg_key_help $v }
key_goto { set ::cfg_key_goto $v }
key_open { set ::cfg_key_open $v }
key_undo { set ::cfg_key_undo $v }
key_copy { set ::cfg_key_copy $v }
key_cut { set ::cfg_key_cut $v }
key_paste { set ::cfg_key_paste $v }
key_select_all { set ::cfg_key_select_all $v }
key_sticky_sel { set ::cfg_key_sticky_sel $v }
key_toc { set ::cfg_key_toc $v }
key_toc_pinned { set ::cfg_key_toc_pinned $v }
key_toc_focus { set ::cfg_key_toc_focus $v }
key_line_numbers { set ::cfg_key_line_numbers $v }
key_redo { set ::cfg_key_redo $v }
key_typewriter { set ::cfg_key_typewriter $v }
key_fullscreen { set ::cfg_key_fullscreen $v }
key_split { set ::cfg_key_split $v }
key_split_focus { set ::cfg_key_split_focus $v }
key_workspace { set ::cfg_key_workspace $v }
key_timer { set ::cfg_key_timer $v }
key_cmd_mode { set ::cfg_key_cmd_mode $v }
toc_key { set ::cfg_key_toc $v }
ln_key { set ::cfg_key_line_numbers $v }
fullscreen_key { set ::cfg_key_fullscreen $v }
timer_duration { set ::cfg_timer_duration $v }
timer_sound { set ::cfg_timer_sound [string is true $v] }
timer_alert { set ::cfg_timer_alert [string is true $v] }
timer_type { set ::cfg_timer_type $v }
chrono_show { set ::cfg_chrono_show [string is true $v] }
tui_colors { set ::cfg_tui_colors [string is true $v] }
tui_256colors { set ::cfg_tui_256colors [string is true $v] }
tui_truecolor { set ::cfg_tui_truecolor [string is true $v] }
tui_color_heading { set ::cfg_tui_color_heading $v }
tui_color_comment { set ::cfg_tui_color_comment $v }
tui_color_markup { set ::cfg_tui_color_markup $v }
tui_color_bar_fg { set ::cfg_tui_color_bar_fg $v }
tui_color_bar_bg { set ::cfg_tui_color_bar_bg $v }
tui_color_sel_bg { set ::cfg_tui_color_sel_bg $v }
tui_color_heading_alt { set ::cfg_tui_color_heading_alt $v }
tui_color_comment_alt { set ::cfg_tui_color_comment_alt $v }
tui_color_markup_alt { set ::cfg_tui_color_markup_alt $v }
tui_color_fg { set ::cfg_tui_color_fg $v }
tui_color_bg { set ::cfg_tui_color_bg $v }
tui_color_fg_alt { set ::cfg_tui_color_fg_alt $v }
tui_color_bg_alt { set ::cfg_tui_color_bg_alt $v }
tui_col_heading { set ::cfg_tui_color_heading $v }
tui_col_comment { set ::cfg_tui_color_comment $v }
tui_col_markup { set ::cfg_tui_color_markup $v }
tui_col_bar_fg { set ::cfg_tui_color_bar_fg $v }
tui_col_bar_bg { set ::cfg_tui_color_bar_bg $v }
tui_col_sel_bg { set ::cfg_tui_color_sel_bg $v }
autosave_enabled { set ::cfg_autosave_enabled [string is true $v] }
autosave_interval { set ::cfg_autosave_interval $v }
cursor_stats_interval {
if {[string is integer -strict $v] && $v >= 0} { set ::cfg_cursor_stats_interval $v }
}
}
}
}
close $fh
profile-apply $::cfg_profile
scheme-apply $::cfg_scheme
}
proc ini-save {} {
set fh [open $::INI_FILE w]
chan configure $fh -encoding utf-8
puts $fh "= WrithDeck configuration ="
puts $fh "% https://github.com/luginf/writhdeck"
puts $fh ""
puts $fh "= editor ="
puts $fh "\[editor\]"
puts $fh "profile = $::cfg_profile"
puts $fh "scheme = $::cfg_scheme"
if {$::cfg_docs_dir ne ""} {
puts $fh "docs_dir = $::cfg_docs_dir"
} else {
puts $fh "% docs_dir = ~/Documents/writerdeck"
}
puts $fh "% (main default document and conf folder: ~/Documents/writhdeck)"
puts $fh "console_margin_cols = $::cfg_console_margin_cols"
puts $fh "console_margin_rows = $::cfg_console_margin_rows"
puts $fh ""
puts $fh "heading_marker = $::cfg_heading_marker"
puts $fh "comment_marker = $::cfg_comment_marker"
puts $fh "bold_marker = $::cfg_bold_marker"
puts $fh "italic_marker = $::cfg_italic_marker"
puts $fh "underline_marker = $::cfg_underline_marker"
puts $fh "strikethrough_marker = $::cfg_strikethrough_marker"
puts $fh ""
puts $fh "= behaviour ="
puts $fh "\[behaviour\]"
puts $fh "browser = [expr {$::cfg_browser ? "yes" : "no"}]"
puts $fh "% browser_filter: space-separated glob patterns for files shown in the browser"
puts $fh "% (empty = show all files)"
puts $fh "browser_filter = $::cfg_browser_filter"
puts $fh "% browser_show_all: bypass browser_filter and show all files"
puts $fh "browser_show_all = [expr {$::cfg_browser_show_all ? "yes" : "no"}]"
puts $fh "% browser_subdirs: scan and browse subfolders inside document folders"
puts $fh "browser_subdirs = [expr {$::cfg_browser_subdirs ? "yes" : "no"}]"
puts $fh "% repetition_scope: word distance (each direction) checked by the repetition tool"
puts $fh "repetition_scope = $::cfg_repetition_scope"
puts $fh "% repetition_min_len: minimum word length for hidden-substring repetition checks"
puts $fh "repetition_min_len = $::cfg_repetition_min_len"
puts $fh "% repetition_hidden: also flag hidden-substring repetitions (e.g. 'tour' in 'alentours')"
puts $fh "repetition_hidden = [expr {$::cfg_repetition_hidden ? "yes" : "no"}]"
puts $fh "% sentence_short_max / sentence_long_min: word thresholds of the sentence-length tool"
puts $fh "% (short = up to short_max words, long = long_min words or more, medium = in between)"
puts $fh "sentence_short_max = $::cfg_sentence_short_max"
puts $fh "sentence_long_min = $::cfg_sentence_long_min"
puts $fh "% spell_lang: hunspell dictionary name (e.g. fr_FR); empty = derive from 'lang'"
puts $fh "spell_lang = $::cfg_spell_lang"
puts $fh "% spell_highlight: underline misspelled words (visible lines only) in the editor"
puts $fh "spell_highlight = [expr {$::cfg_spell_highlight ? "yes" : "no"}]"
puts $fh "% analysis_ignore_comments: skip commented lines (cfg_comment_marker) in spellcheck, repetitions, word occurrences"
puts $fh "analysis_ignore_comments = [expr {$::cfg_analysis_ignore_comments ? "yes" : "no"}]"
puts $fh "watch_file = [expr {$::cfg_watch_file ? "yes" : "no"}]"
puts $fh "hemingway_mode = [expr {$::cfg_hemingway_mode ? "yes" : "no"}]"
puts $fh "% markdown_headings is a deprecated alias for markdown_support (kept for now)"
puts $fh "markdown_headings = [expr {$::cfg_markdown_support ? "yes" : "no"}]"
puts $fh "markdown_support = [expr {$::cfg_markdown_support ? "yes" : "no"}]"
puts $fh "split_shrink_margin = [expr {$::cfg_split_shrink_margin ? "yes" : "no"}]"
puts $fh "console_center_alert = [expr {$::cfg_console_center_alert ? "yes" : "no"}]"
puts $fh "% tui_mouse: click to place the cursor, click-drag to select, wheel to scroll"
puts $fh "% (TUI only; usually disables the terminal's own click-drag selection - most"
puts $fh "% terminals let Shift+drag bypass this and select natively regardless)"
puts $fh "tui_mouse = [expr {$::cfg_tui_mouse ? "yes" : "no"}]"
puts $fh "% bar: show the editor status bar (no = hide it; the browser bar is unaffected; search field and ESC menu still appear, sized by bar_height)"
puts $fh "bar = [expr {$::cfg_bar_show ? "yes" : "no"}]"
puts $fh "line_numbers = [expr {$::cfg_line_numbers ? "yes" : "no"}]"
puts $fh "% limit_width_enabled/limit_width: fixed character column instead of margins - GUI and TUI"
puts $fh "limit_width_enabled = [expr {$::cfg_limit_width_enabled ? "yes" : "no"}]"
puts $fh "limit_width = $::cfg_limit_width"
puts $fh "cursor_restore = [expr {$::cfg_cursor_restore ? "yes" : "no"}]"
puts $fh "% cursor_key_mode: \"path\" (per exact file location, default) or \"name\" (by filename only, ignoring its folder)"
puts $fh "cursor_key_mode = $::cfg_cursor_key_mode"
puts $fh "toc_pinned = [expr {$::cfg_toc_pinned ? "yes" : "no"}]"
puts $fh "block_cursor_gui = [expr {$::cfg_block_cursor_gui ? "yes" : "no"}]"
puts $fh "block_cursor_console = [expr {$::cfg_block_cursor_console ? "yes" : "no"}]"
puts $fh "blink_cursor = [expr {$::cfg_blink_cursor ? "yes" : "no"}]"
puts $fh "% lang: interface language - en fr de es ko no"
puts $fh "lang = $::cfg_lang"
puts $fh "% help_bar: text shown in the shortcuts bar, empty to hide"