summaryrefslogtreecommitdiffstats
path: root/contrib/nvi/tcl_scripts
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-11-01 06:45:43 +0000
committerpeter <peter@FreeBSD.org>1996-11-01 06:45:43 +0000
commit59cc89c2c2e686da3bdab2d5cfac4f33462d29fe (patch)
tree88f923c9c0be2e2a225a9b21716fd582de668b42 /contrib/nvi/tcl_scripts
downloadFreeBSD-src-59cc89c2c2e686da3bdab2d5cfac4f33462d29fe.zip
FreeBSD-src-59cc89c2c2e686da3bdab2d5cfac4f33462d29fe.tar.gz
Import of nvi-1.79, minus a few bits that we dont need (eg: postscript
files, curses, db, regex etc that we already have). The other glue will follow shortly. Obtained from: Keith Bostic <bostic@bostic.com>
Diffstat (limited to 'contrib/nvi/tcl_scripts')
-rw-r--r--contrib/nvi/tcl_scripts/errors.tcl44
-rw-r--r--contrib/nvi/tcl_scripts/gnats.tcl95
-rw-r--r--contrib/nvi/tcl_scripts/mailprocs.tcl115
-rw-r--r--contrib/nvi/tcl_scripts/wc.tcl16
4 files changed, 270 insertions, 0 deletions
diff --git a/contrib/nvi/tcl_scripts/errors.tcl b/contrib/nvi/tcl_scripts/errors.tcl
new file mode 100644
index 0000000..94a1e6a
--- /dev/null
+++ b/contrib/nvi/tcl_scripts/errors.tcl
@@ -0,0 +1,44 @@
+# @(#)errors.tcl 8.2 (Berkeley) 11/18/95
+#
+# File: errors.tcl
+#
+# Author: George V. Neville-Neil
+#
+# Purpose: This file contains vi/tcl code that allows a vi user to parse
+# compiler errors and warnings from a make.out file.
+
+proc findErr {} {
+ global errScreen
+ global currFile
+ global fileScreen
+ set errLine [lindex [viGetCursor $errScreen] 0]
+ set currLine [split [viGetLine $errScreen $errLine] :]
+ set currFile [lindex $currLine 0]
+ set fileScreen [viNewScreen $errScreen $currFile]
+ viSetCursor $fileScreen [lindex $currLine 1] 1
+ viMapKey $viScreenId  nextErr
+}
+
+proc nextErr {} {
+ global errScreen
+ global fileScreen
+ global currFile
+ set errLine [lindex [viGetCursor $errScreen] 0]
+ set currLine [split [viGetLine $errScreen $errLine] :]
+ if {[string match $currFile [lindex $currLine 0]]} {
+ viSetCursor $fileScreen [lindex $currLine 1] 0
+ viSwitchScreen $fileScreen
+ } else {
+ viEndScreen $fileScreen
+ set currFile [lindex $currLine 0]
+ set fileScreen[viNewScreen $errScreen $currFile]
+ viSetCursor $fileScreen [lindex $currLine 1] 0
+ }
+}
+
+proc initErr {} {
+ global viScreenId
+ global errScreen
+ set errScreen [viNewScreen $viScreenId make.out]
+ viMapKey $viScreenId  findErr
+}
diff --git a/contrib/nvi/tcl_scripts/gnats.tcl b/contrib/nvi/tcl_scripts/gnats.tcl
new file mode 100644
index 0000000..61ecb6e
--- /dev/null
+++ b/contrib/nvi/tcl_scripts/gnats.tcl
@@ -0,0 +1,95 @@
+# @(#)gnats.tcl 8.2 (Berkeley) 11/18/95
+#
+proc init {catFile} {
+ global viScreenId
+ global categories
+ set categories {}
+ set categoriesFile [open $catFile r]
+ while {[gets $categoriesFile line] >= 0} {
+ lappend categories $line
+ }
+ close $categoriesFile
+ viMsg $viScreenId $categories
+ viMapKey $viScreenId  next
+}
+
+proc next {} {
+ global viScreenId
+ set cursor [viGetCursor $viScreenId]
+ set lineNum [lindex $cursor 0]
+ set line [viGetLine $viScreenId $lineNum]
+ viMsg $viScreenId [lindex $line 0]
+ if {[lindex $line 0] == ">Confidential:"} {
+ confNext $lineNum $line
+ } elseif {[lindex $line 0] == ">Severity:"} {
+ sevNext $lineNum $line
+ } elseif {[lindex $line 0] == ">Priority:"} {
+ priNext $lineNum $line
+ } elseif {[lindex $line 0] == ">Class:"} {
+ classNext $lineNum $line
+ } elseif {[lindex $line 0] == ">Category:"} {
+ catNext $lineNum $line
+ }
+}
+
+proc confNext {lineNum line} {
+ global viScreenId
+ viMsg $viScreenId [lindex $line 1]
+ if {[lindex $line 1] == "yes"} {
+ viSetLine $viScreenId $lineNum ">Confidential: no"
+ } else {
+ viSetLine $viScreenId $lineNum ">Confidential: yes"
+ }
+}
+
+proc sevNext {lineNum line} {
+ global viScreenId
+ viMsg $viScreenId [lindex $line 1]
+ if {[lindex $line 1] == "non-critical"} {
+ viSetLine $viScreenId $lineNum ">Severity: serious"
+ } elseif {[lindex $line 1] == "serious"} {
+ viSetLine $viScreenId $lineNum ">Severity: critical"
+ } elseif {[lindex $line 1] == "critical"} {
+ viSetLine $viScreenId $lineNum ">Severity: non-critical"
+ }
+}
+
+proc priNext {lineNum line} {
+ global viScreenId
+ viMsg $viScreenId [lindex $line 1]
+ if {[lindex $line 1] == "low"} {
+ viSetLine $viScreenId $lineNum ">Priority: medium"
+ } elseif {[lindex $line 1] == "medium"} {
+ viSetLine $viScreenId $lineNum ">Priority: high"
+ } elseif {[lindex $line 1] == "high"} {
+ viSetLine $viScreenId $lineNum ">Priority: low"
+ }
+}
+
+proc classNext {lineNum line} {
+ global viScreenId
+ viMsg $viScreenId [lindex $line 1]
+ if {[lindex $line 1] == "sw-bug"} {
+ viSetLine $viScreenId $lineNum ">Class: doc-bug"
+ } elseif {[lindex $line 1] == "doc-bug"} {
+ viSetLine $viScreenId $lineNum ">Class: change-request"
+ } elseif {[lindex $line 1] == "change-request"} {
+ viSetLine $viScreenId $lineNum ">Class: support"
+ } elseif {[lindex $line 1] == "support"} {
+ viSetLine $viScreenId $lineNum ">Class: sw-bug"
+ }
+}
+
+proc catNext {lineNum line} {
+ global viScreenId
+ global categories
+ viMsg $viScreenId [lindex $line 1]
+ set curr [lsearch -exact $categories [lindex $line 1]]
+ if {$curr == -1} {
+ set curr 0
+ }
+ viMsg $viScreenId $curr
+ viSetLine $viScreenId $lineNum ">Class: [lindex $categories $curr]"
+}
+
+init abekas
diff --git a/contrib/nvi/tcl_scripts/mailprocs.tcl b/contrib/nvi/tcl_scripts/mailprocs.tcl
new file mode 100644
index 0000000..eccb9cd
--- /dev/null
+++ b/contrib/nvi/tcl_scripts/mailprocs.tcl
@@ -0,0 +1,115 @@
+# @(#)mailprocs.tcl 8.3 (Berkeley) 4/29/96
+#
+proc validLine {} {
+ global viScreenId
+ set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
+ if {[string compare [lindex [split $line :] 0] "To"] == 0} {
+ set addrs [lindex [split $line :] 1]
+ foreach name [split $addrs ,] {
+ isValid [string trim $name]
+ }
+ }
+}
+
+proc valid {target} {
+ set found 0
+ set aliasFile [open "~/Mail/aliases" r]
+ while {[gets $aliasFile line] >= 0} {
+ set name [lindex [split $line :] 0]
+ set address [lindex [split $line :] 1]
+ if {[string compare $target $name] == 0} {
+ set found 1
+ break
+ }
+ }
+ close $aliasFile
+ if {$found == 1} {
+ return $address
+ } else {
+ return $found
+ }
+}
+
+proc isValid {target} {
+ global viScreenId
+ set address [valid $target]
+ if {$address != 0} {
+ viMsg $viScreenId "$target is [string trim $address]"
+ } else {
+ viMsg $viScreenId "$target not found"
+ }
+}
+
+proc isAliasedLine {} {
+ global viScreenId
+ set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
+ if {[string match [lindex [split $line :] 0] "*To"] == 0} {
+ set addrs [lindex [split $line :] 1]
+ foreach name [split $addrs ,] {
+ isAliased [string trim $name]
+ }
+ }
+}
+
+proc aliased {target} {
+ set found 0
+ set aliasFile [open "~/Mail/aliases" r]
+ while {[gets $aliasFile line] >= 0} {
+ set name [lindex [split $line :] 0]
+ set address [lindex [split $line :] 1]
+ if {[string compare $target [string trim $address]] == 0} {
+ set found 1
+ break
+ }
+ }
+ close $aliasFile
+
+ return $found
+}
+
+proc isAliased {target} {
+ global viScreenId
+ set found [aliased $target]
+
+ if {$found} {
+ viMsg $viScreenId "$target is aliased to [string trim $name]"
+ } else {
+ viMsg $viScreenId "$target not aliased"
+ }
+}
+
+proc appendAlias {target address} {
+ if {![aliased $target]} {
+ set aliasFile [open "~/Mail/aliases" a]
+ puts $aliasFile "$target: $address"
+ }
+ close $aliasFile
+}
+
+proc expand {} {
+ global viScreenId
+ set row [lindex [viGetCursor $viScreenId] 0]]
+ set column [lindex [viGetCursor $viScreenId] 1]]
+ set line [viGetLine $viScreenId $row]
+ while {$column < [string length $line] && \
+ [string index $line $column] != ' '} {
+ append $target [string index $line $column]
+ incr $column
+ }
+ set found [isValid $target]
+}
+
+proc cite {} {
+ global viScreenId
+ global viStartLine
+ global viStopLine
+ for {set i $viStartLine} {$i <= $viStopLine} {incr i} {
+ set newLine "> "
+ append newLine [viGetLine $viScreenId $i]
+ viSetLine $viScreenId $i $newLine
+ }
+}
+
+global viScreenId
+viMapKey $viScreenId  isAliasedLine
+viMapKey $viScreenId  validLine
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