This file is indexed.

/usr/share/tcltk/tklib0.6/diagrams/navigation.tcl is in tklib 0.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
## -*- tcl -*-
## (C) 2010 Andreas Kupries <andreas_kupries@users.sourceforge.net>
## BSD Licensed
# # ## ### ##### ######## ############# ######################

#
# Auto-layout management
#

##
# # ## ### ##### ######## ############# ######################
## Requisites

package require Tcl 8.5              ; # Want the nice things it
				       # brings (dicts, {*}, etc.)
package require snit                 ; # Object framework.
package require struct::stack
package require diagram::point

# # ## ### ##### ######## ############# ######################
## Implementation

snit::type ::diagram::navigation {

    # # ## ### ##### ######## ############# ######################
    ## Public API :: Modify the state

    method reset {} {
	set mylocation {0 0}
	set mydirection east
	set mycorner    west
	set mycorners   {}
	$mystack clear
	return
    }

    method turn {direction {commit 0}} {
	#puts T|$direction|$commit
	set mydirection [$mydirections validate $direction]
	set mycorner    [$mydirections get $mydirection opposite]
	#puts O|$mycorner

	if {$commit && [dict exists $mycorners $mydirection]} {
	    set mylocation \
		[diagram::point unbox \
		     [diagram::point absolute \
			  [dict get $mycorners $mydirection]]]
	}
	return
    }

    method move {newcorners} {
	#puts M|$newcorners
	if {[dict exists $newcorners end]} {
	    set mycorners {}
	    set at [dict get $newcorners end]
	} else {
	    # Note: We map mydirection to the corners to handle the
	    # possibility of directions which are not on the compass
	    # rose. Such are mapped to the nearest compass or other
	    # direction which is supported by the element we have
	    # moved to.
	    set mycorners $newcorners
	    set at [dict get $newcorners \
			[$mydirections map $newcorners $mydirection]]
	}

	set mylocation \
	    [diagram::point unbox [diagram::point absolute $at]]
	return
    }

    # # ## ### ##### ######## ############# ######################
    ## Public API :: State nesting

    method save {} {
	$mystack push [list \
			   $mylocation \
			   $mydirection \
			   $mycorner \
			   $mycorners]
	return
    }

    method restore {} {
	lassign [$mystack pop] \
	    mylocation \
	    mydirection \
	    mycorner \
	    mycorners
	return
    }

    # # ## ### ##### ######## ############# ######################
    ## Public API :: Querying

    method at {} {
	# TODO :: gap processing goes here -- maybe not required, given 'chop'.
	return $mylocation
    }

    method corner {} {
	return $mycorner
    }

    method direction {} {
	return $mydirection
    }

    # # ## ### ##### ######## ############# ######################
    ## Public API ::

    constructor {directions} {
	install mystack using struct::stack ${selfns}::STACK
	set mydirections $directions
	return
    }

    # # ## ### ##### ######## ############# ######################
    ## Instance data,

    component mystack
    component mydirections

    variable mylocation     {0 0} ; # attribute 'at' default
    variable mydirection    east  ; # current layout direction.
    variable mycorner       west  ; # attribute 'with' default
				    # (opposite of direction').
    variable mycorners      {}    ; # The corners we can turn to.

    ##
    # # ## ### ##### ######## ############# ######################
}

# # ## ### ##### ######## ############# ######################
## Ready

package provide diagram::navigation 1