File: note.tcl

package info (click to toggle)
tcllib 1.12-dfsg-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 25,336 kB
  • ctags: 7,235
  • sloc: tcl: 126,727; ansic: 10,090; sh: 9,855; xml: 1,766; yacc: 753; makefile: 127; perl: 84; f90: 84; pascal: 74; python: 33; ruby: 13; php: 11
file content (72 lines) | stat: -rw-r--r-- 1,292 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- tcl -*-
# (C) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>
##
# ###

namespace eval ::sak::note {}

# ###

proc ::sak::note::usage {} {
    package require sak::help
    puts stdout \n[sak::help::on note]
    exit 1
}

proc ::sak::note::run {m p tags} {
    global distribution
    variable notes
    LoadNotes

    set k [list $m $p]
    set notes($k) $tags

    set f [file join $distribution .NOTE]
    set f [open $f w]
    foreach k [array names notes] {
	puts $f [list $k $notes($k)]
    }
    close $f
    return
}

proc ::sak::note::show {} {
    variable notes
    LoadNotes

    getpackage struct::matrix   struct/matrix.tcl

    struct::matrix M ; M add columns 3
    foreach k [lsort -dict [array names notes]] {
	M add row [linsert $k end $notes($k)]
    }
    puts "    [join [split [M format 2string] \n] "\n    "]\n"
    return
}

proc ::sak::note::LoadNotes {} {
    global distribution
    variable  notes
    array set notes {}

    catch {
	set f [file join $distribution .NOTE]
	set f [open $f r]
	while {![eof $f]} {
	    if {[gets $f line] < 0} continue
	    set line [string trim $line]
	    if {$line == {}} continue
	    foreach {k t} $line break
	    set notes($k) $t
	}
	close $f
    }

    return
}


##
# ###

package provide sak::note 1.0