codekingpro/portable-devtools
114k
1#!/bin/sh2# Tcl ignores the next line -*- tcl -*- \3exec 'wish' "$0" -- "$@"4 5# This is an implementation of a simple yes no dialog6# which is injected into the git commandline by git gui7# in case a yesno question needs to be answered.8#9# The window title, which defaults to "Question?", can be10# overridden via the optional `--title` command-line11# option.12 13set NS {}14set use_ttk [package vsatisfies [package provide Tk] 8.5]15if {$use_ttk} {16 set NS ttk17}18 19set title "Question?"20if {$argc < 1} {21 puts stderr "Usage: $argv0 <question>"22 exit 123} else {24 if {$argc > 2 && [lindex $argv 0] == "--title"} {25 set title [lindex $argv 1]26 set argv [lreplace $argv 0 1]27 }28 set prompt [join $argv " "]29}30 31${NS}::frame .t32${NS}::label .t.m -text $prompt -justify center -width 400px33.t.m configure -wraplength 400px34pack .t.m -side top -fill x -padx 20 -pady 20 -expand 135pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 136 37${NS}::frame .b38${NS}::frame .b.left -width 20039${NS}::button .b.yes -text Yes -command {exit 0}40${NS}::button .b.no -text No -command {exit 1}41 42pack .b.left -side left -expand 1 -fill x43pack .b.yes -side left -expand 144pack .b.no -side right -expand 1 -ipadx 545pack .b -side bottom -fill x -ipadx 20 -ipady 1546 47bind . <Key-Return> {exit 0}48bind . <Key-Escape> {exit 1}49 50if {$::tcl_platform(platform) eq {windows}} {51 set icopath [file dirname [file normalize $argv0]]52 if {[file tail $icopath] eq {git-core}} {53 set icopath [file dirname $icopath]54 }55 set icopath [file dirname $icopath]56 set icopath [file join $icopath share git git-for-windows.ico]57 if {[file exists $icopath]} {58 wm iconbitmap . -default $icopath59 }60}61 62if {$::tcl_platform(platform) eq {windows}} {63 set icopath [file dirname [file normalize $argv0]]64 if {[file tail $icopath] eq {git-core}} {65 set icopath [file dirname $icopath]66 }67 set icopath [file dirname $icopath]68 set icopath [file join $icopath share git git-for-windows.ico]69 if {[file exists $icopath]} {70 wm iconbitmap . -default $icopath71 }72}73 74wm title . $title75tk::PlaceWindow .76 