word count works!
This commit is contained in:
parent
ede3d39dd5
commit
d7fc0dd64a
28
texttools.tcl
Executable file
28
texttools.tcl
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env wish
|
||||||
|
|
||||||
|
wm geometry . 750x650
|
||||||
|
wm title . "Text Tools"
|
||||||
|
|
||||||
|
text .content
|
||||||
|
text .output
|
||||||
|
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
|
||||||
|
|
||||||
|
grid .content -row 1
|
||||||
|
grid .output -row 2
|
||||||
|
|
||||||
|
update
|
Loading…
Reference in a new issue