summaryrefslogtreecommitdiffstats
path: root/contrib/nvi/tcl_scripts/wc.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/nvi/tcl_scripts/wc.tcl')
-rw-r--r--contrib/nvi/tcl_scripts/wc.tcl16
1 files changed, 16 insertions, 0 deletions
diff --git a/contrib/nvi/tcl_scripts/wc.tcl b/contrib/nvi/tcl_scripts/wc.tcl
new file mode 100644
index 0000000..25d0f62
--- /dev/null
+++ b/contrib/nvi/tcl_scripts/wc.tcl
@@ -0,0 +1,16 @@
+# @(#)wc.tcl 8.2 (Berkeley) 11/18/95
+#
+proc wc {} {
+ global viScreenId
+ global viStartLine
+ global viStopLine
+
+ set lines [viLastLine $viScreenId]
+ set output ""
+ set words 0
+ for {set i $viStartLine} {$i <= $viStopLine} {incr i} {
+ set outLine [split [string trim [viGetLine $viScreenId $i]]]
+ set words [expr $words + [llength $outLine]]
+ }
+ viMsg $viScreenId "$words words"
+}
OpenPOWER on IntegriCloud