lib / line.tclon commit git-gui: deal with unknown files when pressing the "Stage Changed" button (856c2d7)
   1# goto line number
   2# based on code from gitk, Copyright (C) Paul Mackerras
   3
   4class linebar {
   5
   6field w
   7field ctext
   8
   9field linenum   {}
  10
  11constructor new {i_w i_text args} {
  12        global use_ttk NS
  13        set w      $i_w
  14        set ctext  $i_text
  15
  16        ${NS}::frame  $w
  17        ${NS}::label  $w.l       -text [mc "Goto Line:"]
  18        entry  $w.ent -textvariable ${__this}::linenum -background lightgreen
  19        ${NS}::button $w.bn      -text [mc Go] -command [cb _incrgoto]
  20
  21        pack   $w.l   -side left
  22        pack   $w.bn  -side right
  23        pack   $w.ent -side left -expand 1 -fill x
  24
  25        eval grid conf $w -sticky we $args
  26        grid remove $w
  27
  28        bind $w.ent <Return> [cb _incrgoto]
  29        bind $w.ent <Escape> [list linebar::hide $this]
  30
  31        bind $w <Destroy> [list delete_this $this]
  32        return $this
  33}
  34
  35method show {} {
  36        if {![visible $this]} {
  37                grid $w
  38        }
  39        focus -force $w.ent
  40}
  41
  42method hide {} {
  43        if {[visible $this]} {
  44                focus $ctext
  45                grid remove $w
  46        }
  47}
  48
  49method visible {} {
  50        return [winfo ismapped $w]
  51}
  52
  53method editor {} {
  54        return $w.ent
  55}
  56
  57method _incrgoto {} {
  58        if {$linenum ne {}} {
  59                $ctext see $linenum.0
  60                hide $this
  61        }
  62}
  63
  64}