/usr/lib/exmh/seditSel.tcl is in exmh 1:2.8.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | proc SeditCiteSelectionPar { draft t } {
global sedit address
if [catch {selection get} txt] {
SeditMsg $t "No selection"
return
}
$t insert insert "\n$address wrote:\n"
regsub -all "(\n|^)" $txt "\\1$sedit(pref,replPrefix)" txt
set res [exec par -rTbgqR -B=.\?_A_a -Q=_s\>\| $sedit(lineLength) << $txt]
$t insert insert "$res\n"
}
proc SeditCiteSelectionNoFmt { draft t } {
global sedit address
if [catch {selection get} txt] {
SeditMsg $t "No selection"
return
}
$t insert insert "\n$address wrote:\n"
regsub -all "(\n|^)" $txt "\\1$sedit(pref,replPrefix)" txt
$t insert insert "$txt\n"
}
proc Sedit_FormatParagraphPar { t } {
global sedit address
if [catch {$t index "sel.first linestart"} first] {
set first [$t index "insert linestart"]
set last [$t index "insert lineend"]
while 1 {
set line [$t get $first "$first lineend"]
set len [string length $line]
if {$len == 0} {
break
}
set first [$t index "$first - 1line"]
if {[regexp ^-- $line] || [$t compare $first <= hlimit]} {
break
}
}
set first [$t index "$first + 1line"]
while 1 {
set line [$t get "$last linestart" $last]
set len [string length $line]
if {($len == 0) || [regexp ^-- $line]} {
set last [$t index "$last - 1line lineend +1char"]
break
}
set nlast [$t index "$last + 1line lineend"]
if {[$t compare $nlast == $last]} {
break
}
set last $nlast
}
} else {
set last [$t index "sel.last lineend"]
}
set line [$t get $first "$last -1char"]
set tags [$t tag names $first]
SeditMsg $t "Reformatting paragraph..."
if [catch {set fmtline [exec par -rTbgqR -B=.\?_A_a -Q=_s\>\| $sedit(lineLength) << [set line]]}] {
SeditMsg $t "par error"
} else {
$t delete $first $last
$t mark set insert $first
if {[string compare "" $fmtline] != 0} {
$t insert insert "$fmtline\n"
}
SeditMsg $t ""
}
$t mark set insert "insert -1char"
}
proc SeditSelFmt {t} {
global sedit
if [catch {selection get} txt] {
SeditMsg $t "No selection"
return
}
set res [exec par -rTbgqR -B=.\?_A_a -Q=_s\>\| $sedit(lineLength) << $txt]
if ![catch {$t index sel.first} tndx] {
$t delete sel.first sel.last
} else {
set tndx [$t index insert]
}
$t mark set insert $tndx
$t insert insert "$res\n"
}
proc SeditSelFmtArg {t} {
global par sedit
set par(t) $t
if [catch {selection get} par(txt)] {
SeditMsg $t "No selection"
return
}
if [Exwin_Toplevel .par "Format" Format] {
set par(options) "rTbgqR"
set par(body) ".?_A_a"
set par(quote) "_s>|"
set par(protect) ""
set par(width) $sedit(lineLength)
.par.but.quit configure -command {Exwin_Dismiss .par nosize}
Widget_BeginEntries 7 17
Widget_LabeledEntry .par.options "Options:" par(options)
Widget_LabeledEntry .par.body "Body:" par(body)
Widget_LabeledEntry .par.quote "Quote:" par(quote)
Widget_LabeledEntry .par.protect "Protect:" par(protect)
Widget_LabeledEntry .par.width "Width:" par(width)
Widget_AddBut .par.but format "Format" {
Exmh_Status "Formatting Selection"
if [catch {exec par -$par(options) -B=$par(body) -Q=$par(quote) -P=$par(protect) $par(width) << $par(txt)} res] {
Exmh_Status "Error: Invalid options for Par" warning
} else {
if ![catch {$par(t) index sel.first} tndx] {
$par(t) delete sel.first sel.last
} else {
set tndx [$par(t) index insert]
}
$par(t) mark set insert $tndx
$par(t) insert insert "$res\n"
Exmh_Status ""
Exwin_Dismiss .par nosize
}
}
}
}
proc SeditSelSpell { f t } {
global sedit editor wish argv0 install
set parent [file root $f]
catch {[destroy $parent.spell]}
if [catch {selection get} txt] {
SeditMsg $t "No selection"
return
}
set path [Env_Tmp]/exmh.s[pid].[file tail $t]
set out [open $path w 0600]
puts $out $txt
close $out
set async_hack 0
switch -- $sedit(spell) {
ispell {set prog "exmh-async xterm -e ispell" ; set async_hack 1}
custom {set prog $editor(spell)}
default {set prog spell}
}
if {[regexp ^exmh-async $prog]} {
set async_hack 1
}
if {$async_hack} {
# exmh-async isn't really right
# craft a wish script instead
set script [Env_Tmp]/exmh.w[pid].[file tail $t]
if [catch {open $script w 0600} out] {
Exmh_Status $out
return 0
}
puts $out "wm withdraw ."
puts $out "catch \{"
puts $out "exec [lrange $prog 1 end] $path"
puts $out "\}"
puts $out [list send [winfo name .] [list SeditReplaceSel $t $path]]
puts $out "file delete -force $path"
puts $out "file delete -force $script"
puts $out exit
close $out
exec $wish -f $script &
return
}
# Display the results of the spell program
catch {eval exec $prog {$path}} result
catch {file delete -force $path}
set f2 [Widget_Frame $parent spell {top fill}]
set lines [llength [split $result \n]]
set height [expr {$lines > 8 ? 8 : $lines}]
set t2 [Widget_Text $f2 $height]
$t2 configure -height $height ;# Widget_Text broken
$t2 insert 1.0 $result
$t2 config -state disabled
pack $f2 -before $f -side top
}
proc SeditReplaceSel { t infile } {
set in [open $infile]
if ![catch {$t index sel.first} tndx] {
$t delete sel.first sel.last
} else {
set tndx [$t index insert]
}
$t mark set insert $tndx
$t insert insert [read -nonewline $in]
close $in
}
|