1
Fork 0
texttools/texttools.tcl

41 lines
745 B
Tcl
Raw Normal View History

2024-10-29 19:20:58 +00:00
#!/usr/bin/env wish
wm geometry . 750x650
wm title . "Text Tools"
text .content
text .output
2024-10-29 19:27:01 +00:00
listbox .transform
2024-10-29 19:28:25 +00:00
.transform insert end {One line}
2024-10-29 19:27:01 +00:00
.transform insert end Line/Word/Char
grid .transform -row 1 -column 1 -rowspan 2
grid .content -row 1 -column 2
grid .output -row 2 -column 2
2024-10-29 19:20:58 +00:00
focus .content
proc wordcount {} {
set text [.content get 1.0 end]
set lines [expr [llength [split $text \n]] - 1]
set words [llength [regexp -all -inline {\S+} $text]]
set len [string length $text]
lappend out $lines
lappend out $words
lappend out $len
.output replace 1.0 end $out
}
bind .content <KeyRelease> wordcount
2024-10-29 19:28:25 +00:00
proc select_transform {} {
puts {transform selected}
}
bind .transform <Button-1> select_transform
2024-10-29 19:20:58 +00:00
update