From d7fc0dd64af6d119b2119cc3eb16ecb17315169d Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 29 Oct 2024 20:20:58 +0100 Subject: [PATCH] word count works! --- texttools.tcl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 texttools.tcl diff --git a/texttools.tcl b/texttools.tcl new file mode 100755 index 0000000..a2cd89f --- /dev/null +++ b/texttools.tcl @@ -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 wordcount + +grid .content -row 1 +grid .output -row 2 + +update