This file is indexed.

/usr/share/tcltk/iwidgets4.0.1/scripts/entryfield.itk is in iwidgets4 4.0.1-6.

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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
#
# Entryfield
# ----------------------------------------------------------------------
# Implements an enhanced text entry widget.
#
# ----------------------------------------------------------------------
#   AUTHOR:  Sue Yockey               E-mail: yockey@acm.org
#            Mark L. Ulferts          E-mail: mulferts@austin.dsccc.com
#
#   @(#) $Id: entryfield.itk,v 1.6 2001/09/17 19:24:46 smithc Exp $
# ----------------------------------------------------------------------
#            Copyright (c) 1995 DSC Technologies Corporation
# ======================================================================
# Permission to use, copy, modify, distribute and license this software 
# and its documentation for any purpose, and without fee or written 
# agreement with DSC, is hereby granted, provided that the above copyright 
# notice appears in all copies and that both the copyright notice and 
# warranty disclaimer below appear in supporting documentation, and that 
# the names of DSC Technologies Corporation or DSC Communications 
# Corporation not be used in advertising or publicity pertaining to the 
# software without specific, written prior permission.
# 
# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-
# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE
# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, 
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL 
# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 
# SOFTWARE.
# ======================================================================

#
# Usual options.
#
itk::usual Entryfield {
    keep -background -borderwidth -cursor -foreground -highlightcolor \
	 -highlightthickness -insertbackground -insertborderwidth \
	 -insertofftime -insertontime -insertwidth -labelfont \
	 -selectbackground -selectborderwidth -selectforeground \
	 -textbackground -textfont
}

# ------------------------------------------------------------------
#                            ENTRYFIELD
# ------------------------------------------------------------------
itcl::class iwidgets::Entryfield {
    inherit iwidgets::Labeledwidget 
    
    constructor {args} {}

    itk_option define -childsitepos childSitePos Position e
    itk_option define -command command Command {}
    itk_option define -fixed fixed Fixed 0
    itk_option define -focuscommand focusCommand Command {}
    itk_option define -invalid invalid Command {bell}
    itk_option define -pasting pasting Behavior 1
    itk_option define -validate validate Command {}
    
    public {
	method childsite {}
	method get {}
	method delete {args}
	method icursor {args}
	method index {args}
	method insert {args}
	method scan {args}
	method selection {args}
	method xview {args}
	method clear {}
    }

    proc numeric {char} {}
    proc integer {string} {}
    proc alphabetic {char} {}
    proc alphanumeric {char} {}
    proc hexidecimal {string} {}
    proc real {string} {}

    protected {
	method _focusCommand {}
	method _keyPress {char sym state}
    }

    private method _peek {char}
    private method _checkLength {}
}

#
# Provide a lowercased access method for the Entryfield class.
# 
proc ::iwidgets::entryfield {pathName args} {
    uplevel ::iwidgets::Entryfield $pathName $args
}

# ------------------------------------------------------------------
#                        CONSTRUCTOR
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::constructor {args} {
    component hull configure -borderwidth 0
    
    itk_component add entry {
	entry $itk_interior.entry
    } {
	keep -borderwidth -cursor -exportselection \
		-foreground -highlightcolor \
		-highlightthickness -insertbackground -insertborderwidth \
		-insertofftime -insertontime -insertwidth -justify \
		-relief -selectbackground -selectborderwidth \
		-selectforeground -show -state -textvariable -width
	
	rename -font -textfont textFont Font
	rename -highlightbackground -background background Background
	rename -background -textbackground textBackground Background
    }
    
    #
    # Create the child site widget.
    #
    itk_component add -protected efchildsite {
	frame $itk_interior.efchildsite
    } 
    set itk_interior $itk_component(efchildsite)
    
    #
    # Entryfield instance bindings.
    #
    bind $itk_component(entry) <KeyPress> [itcl::code $this _keyPress %A %K %s]
    bind $itk_component(entry) <FocusIn> [itcl::code $this _focusCommand]

    #
    # Initialize the widget based on the command line options.
    #
    eval itk_initialize $args
}

# ------------------------------------------------------------------
#                             OPTIONS
# ------------------------------------------------------------------

# ------------------------------------------------------------------
# OPTION: -command
#
# Command associated upon detection of Return key press event
# ------------------------------------------------------------------
itcl::configbody iwidgets::Entryfield::command {}

# ------------------------------------------------------------------
# OPTION: -focuscommand
#
# Command associated upon detection of focus.
# ------------------------------------------------------------------
itcl::configbody iwidgets::Entryfield::focuscommand {}

# ------------------------------------------------------------------
# OPTION: -validate
#
# Specify a command to executed for the validation of Entryfields.
# ------------------------------------------------------------------
itcl::configbody iwidgets::Entryfield::validate {
    switch $itk_option(-validate) {
	{} {
	    set itk_option(-validate) {}
	}
	numeric {
	    set itk_option(-validate) "::iwidgets::Entryfield::numeric %c"
	}
	integer {
	    set itk_option(-validate) "::iwidgets::Entryfield::integer %P"
	}
	hexidecimal {
	    set itk_option(-validate) "::iwidgets::Entryfield::hexidecimal %P"
	}
	real {
	    set itk_option(-validate) "::iwidgets::Entryfield::real %P"
	}
	alphabetic {
	    set itk_option(-validate) "::iwidgets::Entryfield::alphabetic %c"
	}
	alphanumeric {
	    set itk_option(-validate) "::iwidgets::Entryfield::alphanumeric %c"
	}
    }
}

# ------------------------------------------------------------------
# OPTION: -invalid
#
# Specify a command to executed should the current Entryfield contents
# be proven invalid.
# ------------------------------------------------------------------
itcl::configbody iwidgets::Entryfield::invalid {}

# ------------------------------------------------------------------
# OPTION: -pasting
#
# Allows the developer to enable and disable pasting into the entry
# component of the entryfield.  This is done to avoid potential stack
# dumps when using the -validate configuration option.  Plus, it's just
# a good idea to have complete control over what you allow the user
# to enter into the entryfield.
# ------------------------------------------------------------------
itcl::configbody iwidgets::Entryfield::pasting {
  set oldtags [bindtags $itk_component(entry)]
  if {[lindex $oldtags 0] != "pastetag"} {
    bindtags $itk_component(entry) [linsert $oldtags 0 pastetag] 
  }

  if ($itk_option(-pasting)) {
    bind pastetag <ButtonRelease-2> [itcl::code $this _checkLength]
    bind pastetag <Control-v> [itcl::code $this _checkLength]
    bind pastetag <Insert> [itcl::code $this _checkLength]
    bind pastetag <KeyPress> {}
  } else {
    bind pastetag <ButtonRelease-2> {break}
    bind pastetag <Control-v> {break}
    bind pastetag <Insert> {break}
    bind pastetag <KeyPress> {
      # Disable function keys > F9.
      if {[regexp {^F[1,2][0-9]+$} "%K"]} {
	break
      }
    }
  }
}

# ------------------------------------------------------------------
# OPTION: -fixed
#
# Restrict entry to 0 (unlimited) chars.  The value is the maximum 
# number of chars the user may type into the field, regardles of 
# field width, i.e. the field width may be 20, but the user will 
# only be able to type -fixed number of characters into it (or 
# unlimited if -fixed = 0).
# ------------------------------------------------------------------
itcl::configbody iwidgets::Entryfield::fixed {
    if {[regexp {[^0-9]} $itk_option(-fixed)] || \
	    ($itk_option(-fixed) < 0)} {
	error "bad fixed option \"$itk_option(-fixed)\",\
		should be positive integer"
    }
}

# ------------------------------------------------------------------
# OPTION: -childsitepos
#
# Specifies the position of the child site in the widget.
# ------------------------------------------------------------------
itcl::configbody iwidgets::Entryfield::childsitepos {
    set parent [winfo parent $itk_component(entry)]

    switch $itk_option(-childsitepos) {
	n {
	    grid $itk_component(efchildsite) -row 0 -column 0 -sticky ew
	    grid $itk_component(entry) -row 1 -column 0 -sticky nsew

	    grid rowconfigure $parent 0 -weight 0
	    grid rowconfigure $parent 1 -weight 1
	    grid columnconfigure $parent 0 -weight 1
	    grid columnconfigure $parent 1 -weight 0
	}
	
	e {
	    grid $itk_component(efchildsite) -row 0 -column 1 -sticky ns
	    grid $itk_component(entry) -row 0 -column 0 -sticky nsew

	    grid rowconfigure $parent 0 -weight 1
	    grid rowconfigure $parent 1 -weight 0
	    grid columnconfigure $parent 0 -weight 1
	    grid columnconfigure $parent 1 -weight 0
	}
	
	s {
	    grid $itk_component(efchildsite) -row 1 -column 0 -sticky ew
	    grid $itk_component(entry) -row 0 -column 0 -sticky nsew

	    grid rowconfigure $parent 0 -weight 1
	    grid rowconfigure $parent 1 -weight 0
	    grid columnconfigure $parent 0 -weight 1
	    grid columnconfigure $parent 1 -weight 0
	}
	
	w {
	    grid $itk_component(efchildsite) -row 0 -column 0 -sticky ns
	    grid $itk_component(entry) -row 0 -column 1 -sticky nsew

	    grid rowconfigure $parent 0 -weight 1
	    grid rowconfigure $parent 1 -weight 0
	    grid columnconfigure $parent 0 -weight 0
	    grid columnconfigure $parent 1 -weight 1
	}
	
	default {
	    error "bad childsite option\
		    \"$itk_option(-childsitepos)\":\
		    should be n, e, s, or w"
	}
    }
}

# ------------------------------------------------------------------
#                            METHODS
# ------------------------------------------------------------------

# ------------------------------------------------------------------
# METHOD: childsite
#
# Returns the path name of the child site widget.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::childsite {} {
    return $itk_component(efchildsite)
}

# ------------------------------------------------------------------
# METHOD: get 
#
# Thin wrap of the standard entry widget get method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::get {} {
    return [$itk_component(entry) get]
}

# ------------------------------------------------------------------
# METHOD: delete
#
# Thin wrap of the standard entry widget delete method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::delete {args} {
    return [eval $itk_component(entry) delete $args]
}

# ------------------------------------------------------------------
# METHOD: icursor 
#
# Thin wrap of the standard entry widget icursor method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::icursor {args} {
    return [eval $itk_component(entry) icursor $args]
}

# ------------------------------------------------------------------
# METHOD: index 
#
# Thin wrap of the standard entry widget index method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::index {args} {
    return [eval $itk_component(entry) index $args]
}

# ------------------------------------------------------------------
# METHOD: insert 
#
# Thin wrap of the standard entry widget index method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::insert {args} {
    return [eval $itk_component(entry) insert $args]
}

# ------------------------------------------------------------------
# METHOD: scan 
#
# Thin wrap of the standard entry widget scan method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::scan {args} {
    return [eval $itk_component(entry) scan $args]
}

# ------------------------------------------------------------------
# METHOD: selection
#
# Thin wrap of the standard entry widget selection method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::selection {args} {
    return [eval $itk_component(entry) selection $args]
}

# ------------------------------------------------------------------
# METHOD: xview 
#
# Thin wrap of the standard entry widget xview method.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::xview {args} {
    return [eval $itk_component(entry) xview $args]
}

# ------------------------------------------------------------------
# METHOD: clear 
#
# Delete the current entry contents.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::clear {} {
    $itk_component(entry) delete 0 end
    icursor 0
}

# ------------------------------------------------------------------
# PROCEDURE: numeric char
#
# The numeric procedure validates character input for a given 
# Entryfield to be numeric and returns the result.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::numeric {char} {
    return [regexp {[0-9]} $char]
}

# ------------------------------------------------------------------
# PROCEDURE: integer string
#
# The integer procedure validates character input for a given 
# Entryfield to be integer and returns the result.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::integer {string} {
    return [regexp {^[-+]?[0-9]*$} $string]
}

# ------------------------------------------------------------------
# PROCEDURE: alphabetic char
#
# The alphabetic procedure validates character input for a given 
# Entryfield to be alphabetic and returns the result.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::alphabetic {char} {
    return [regexp -nocase {[a-z]} $char]
}

# ------------------------------------------------------------------
# PROCEDURE: alphanumeric char
#
# The alphanumeric procedure validates character input for a given 
# Entryfield to be alphanumeric and returns the result.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::alphanumeric {char} {
    return [regexp -nocase {[0-9a-z]} $char]
}

# ------------------------------------------------------------------
# PROCEDURE: hexadecimal string
#
# The hexidecimal procedure validates character input for a given 
# Entryfield to be hexidecimal and returns the result.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::hexidecimal {string} {
    return [regexp {^(0x)?[0-9a-fA-F]*$} $string]
}

# ------------------------------------------------------------------
# PROCEDURE: real string
#
# The real procedure validates character input for a given Entryfield
# to be real and returns the result.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::real {string} {
    return [regexp {^[-+]?[0-9]*\.?[0-9]*([0-9]\.?[eE][-+]?[0-9]*)?$} $string]
}

# ------------------------------------------------------------------
# PRIVATE METHOD: _peek char
#
# The peek procedure returns the value of the Entryfield with the
# char inserted at the insert position.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::_peek {char} {
    set str [get]

    set insertPos [index insert] 
    set firstPart [string range $str 0 [expr {$insertPos - 1}]]
    set lastPart [string range $str $insertPos end]

    regsub -all {\\} "$char" {\\\\} char
    append rtnVal $firstPart $char $lastPart
    return $rtnVal
}

# ------------------------------------------------------------------
# PROTECTED METHOD: _focusCommand
#
# Method bound to focus event which evaluates the current command
# specified in the focuscommand option
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::_focusCommand {} {
    uplevel #0 $itk_option(-focuscommand)
}

# ------------------------------------------------------------------
# PROTECTED METHOD: _keyPress 
#
# Monitor the key press event checking for return keys, fixed width
# specification, and optional validation procedures.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::_keyPress {char sym state} {
    #
    # A Return key invokes the optionally specified command option.
    #
    if {$sym == "Return"} {
	uplevel #0 $itk_option(-command)
	return -code break 1
    } 
    
    #
    # Tabs, BackSpace, and Delete are passed on for other bindings.
    #
    if {($sym == "Tab") || ($sym == "BackSpace") || ($sym == "Delete")} {
	return -code continue 1
    }

    # 
    # Character is not printable or the state is greater than one which
    # means a modifier was used such as a control, meta key, or control
    # or meta key with numlock down.
    #
    #-----------------------------------------------------------
    # BUG FIX: csmith (Chad Smith: csmith@adc.com), 3/15/99
    #-----------------------------------------------------------
    # The following conditional used to hardcode specific state values, such
    # as "4" and "8".  These values are used to detect <Ctrl>, <Shift>, etc.
    # key combinations.  On the windows platform, the <Alt> key is state
    # 16, and on the unix platform, the <Alt> key is state 8.  All <Ctrl>
    # and <Alt> combinations should be masked out, regardless of the
    # <NumLock> or <CapsLock> status, and regardless of platform.
    #-----------------------------------------------------------
    set CTRL 4
    global tcl_platform
    if {$tcl_platform(platform) == "unix"} {
      set ALT 8
    } elseif {$tcl_platform(platform) == "windows"} {
      set ALT 16
    } else {
      # This is something other than UNIX or WINDOWS.  Default to the
      # old behavior (UNIX).
      set ALT 8
    }
    # Thanks to Rolf Schroedter for the following elegant conditional.  This
    # masks out all <Ctrl> and <Alt> key combinations.
    if {($char == "") || ($state & ($CTRL | $ALT))} {
      return -code continue 1
    }

    #
    # If the fixed length option is not zero, then verify that the
    # current length plus one will not exceed the limit.  If so then
    # invoke the invalid command procedure.
    #
    if {$itk_option(-fixed) != 0} {
	if {[string length [get]] >= $itk_option(-fixed)} {
	    uplevel #0 $itk_option(-invalid)
	    return -code break 0
	}
    } 
    
    #
    # The validate option may contain a keyword (numeric, alphabetic),
    # the name of a procedure, or nothing.  The numeric and alphabetic
    # keywords engage typical base level checks.  If a command procedure
    # is specified, then invoke it with the object and character passed
    # as arguments.  If the validate procedure returns false, then the 
    # invalid procedure is called.
    #
    if {$itk_option(-validate) != {}} {
	set cmd $itk_option(-validate)

	regsub -all "%W" "$cmd" $itk_component(hull) cmd
	regsub -all "%P" "$cmd" [list [_peek $char]] cmd
	regsub -all "%S" "$cmd" [list [get]] cmd
	regsub -all "%c" "$cmd" [list $char] cmd
        regsub -all {\\} "$cmd" {\\\\} cmd

	set valid [uplevel #0 $cmd]
	
	if {($valid == "") || ([regexp 0|false|off|no $valid])} {
	    uplevel #0 $itk_option(-invalid)
	    return -code break 0
	}
    }
    
    return -code continue 1
}

# ------------------------------------------------------------------
# PRIVATE METHOD: _checkLength
#
# This method was added by csmith for SF ticket 227912. We need to
# to check the clipboard content before allowing any pasting into
# the entryfield to disallow text that is longer than the value
# specified by the -fixed option.
# ------------------------------------------------------------------
itcl::body iwidgets::Entryfield::_checkLength {} {
  if {$itk_option(-fixed) != 0} {
    if [catch {::selection get -selection CLIPBOARD} pending] {
      # Nothing in the clipboard.  Check the primary selection.
      if [catch {::selection get -selection PRIMARY} pending] {
        # Nothing here either.  Goodbye.
        return
      }
    }
    set len [expr {[string length $pending] + [string length [get]]}]
    if {$len > $itk_option(-fixed)} {
      uplevel #0 $itk_option(-invalid)
      return -code break 0
    }
  }
}