# <20200212.1808.00>
proc About {} {
  global glob
  smart_dialog .apop[incr ::uni] .\
      [_ "About FileRunner"] \
      [list {}]\
      0 1 [_ "OK"] \
      [list -font -Adobe-Times-Medium-R-Normal--*-180-*-*-*-*-*-* \
	   tag {config tag -justify center} \
	   -borderwidth 10\
	   -flashon 0\
	   textfun About_script]
  return
}
  
proc About_script {w} {
  global glob
  set text [_ "[B "FileRunner"] version %s

 %s

[B "FileRunner"] is Free Software distributed under the 
GNU General Public License. [B "FileRunner"] comes with 
[I "ABSOLUTELY NO WARRANTY."] 
See menu Help/Copying for further details.

" $glob(displayVersion) $::Copyright]
# The line at the end (the blank one) convinces smart_dialog that
# the window should be a tad higher...
  $w tag config tag -justify center
  
  fillTextWindowOverstrike $w text tags tag bold [list {-weight bold} {}]\
italic [list {-weight bold} {-foreground red}]

  
}
#
# "B" passes back 'text' converted to bold or italic
# using overstrike coding. By default it will do bold if the
# second parm is not passed. Any value other than 'bold' will
# do italic coding. We use console encoding, i.e.:
# ESC[<code>m       <code> is one or more integers seperated with {;}
#                              characters (i.e. 10;1}
#   <code>  meaning
#     0     reset or stop all special encoding
#     1     Start Bold
#     4     Start Underline
#     22    normal intensity (or stop Bold)
#     24    Stop Underline

set ESC \u001b


proc I {text} {return [B $text 1]}

proc B {text {type bold}} {

  return "$::ESC\[[expr {$type == "bold" ? "1" : "4"}]m$text$::ESC\[0m"

  # What follows is the way to do the encoding useing overstrike...
  
  # set code [expr {$type == "bold" ? "c\b" : "_\b"}]
  # set ln [string length $text]
  # set index -1
  # set result {}
  # while {[incr index] < $ln} {
  #   append result $code [string index $text $index]
  # }
  # return $result
}
# # fillTextWindowOverstrike w var_string ?tag?
# # tag, if coded is added to each text window insert
# # This routine fills text window "w" with "var_string" while doing "overstrike"
# # formating. 'var_string' is taken to be the variable name of the string
# # We assume 'insert' is where to put the text and leave 'insert' after the text


# # fillTextWindow w var_string ?tag?
# # tag, if coded is added to each text window insert
# # This routine fills text window "w" with "var_string" while doing "overstrike"
# # formating. 'var_string' is taken to be the variable name of the string
# # We assume 'insert' is where to put the text and leave 'insert' after the text

# # first, here is a routine to parse the config(overstrike,*) code.
# # The result is a set of bold & italic ops to be combined with the
# # font and insert tags when doing overstrike. This code populates the
# # overstrike namespace with its results.
# #

# proc parseConfigOverstrike {} {
#   variable ::overstrike::boldOps
#   variable ::overstrike::italicOps
  
#   if {![info exists boldOps] || ![info exists italicOps]} {
    
#     foreach overType {bold italic} {
#       set ${overType}FontOps {}
#       set ${overType}TagOps  {}
      
#       foreach {option value} $::config(overstrike,$overType) {
# 	# frputs option value
# 	if {$option in {size weight slant underline}} {
# 	  if {"-$option" ni [set ${overType}FontOps]} {
# 	    lappend ${overType}FontOps -$option $value
# 	    # frputs  ${overType}FontOps
# 	    continue
# 	  }
# 	}
# 	if {$option in {underline background foreground borderwidth relief} &&\
# 		"-$option" ni [set ${overType}TagOps]} {
# 	  lappend ${overType}TagOps "-$option" $value
# 	  # frputs  ${overType}TagOps
# 	  continue
# 	}
# 	# If we get here we have an unrecognized option
# 	PopWarn "config(overstrike,$overType) option $option unrecognized!"
#       }
#       set ${overType}Ops [list [set ${overType}FontOps] [set ${overType}TagOps]]
#     }
#   }
#   return [list bold $boldOps italic $italicOps]
# }

# # args should be a set of doublets from the following
# # all these are optional but see below
# #
# # tags  tag list to be applied to all inserts
# # bold   [list <bold font ops>   <bold tag ops>
# # italic [list <italic font ops> <italic tag ops>
# #
# # If only one of bold or italic is supplied and the "string" requests
# # the un-supplied one an error is thrown.
# # If neither is supplied, the parsed values are used (if they don't
# # yet exist, the parse routine is called to build them.
# #
# proc fillTextWindowOverstrike {w var_string args} {
#   variable ::overstrike::boldOps
#   variable ::overstrike::italicOps

#   lassign {} overOps(tags) overOps(bold) overOps(italic)
  
#   array set overOps $args
#   if {$overOps(bold) == {} && $overOps(italic) == {}} {
#     array set overOps [parseConfigOverstrike]
#   }
#   # create the fonts and configure them
#   set cfont [$w cget -font]
#   foreach overType {bold italic} {
#     lassign $overOps($overType) ${overType}FontOps ${overType}TagOps
#     array set font [font actual $cfont]
#     # This is a bit messy, but the font size is to be added to the current, so...
#     set fsize $font(-size)
#     set font(-size) 0
#     array set font [set ${overType}FontOps]
#     set font(-size) [expr {$font(-size) + $fsize}]
#     if {[catch {font create {*}[array get font] } ${overType}ViewFont] != 0} {
#      PopWarn "Error [set ${overType}ViewFont] trying to create \"[array get font] \" "
#     }
#     # now do the tags
#     if {[catch {$w tag configure ${overType}Tag -font [set ${overType}ViewFont]\
# 		    {*}[set ${overType}TagOps]} er] != 0} {
#       PopWarn "Error $er trying to apply ${overType}TagOps to ${overType}Tag"
#     }
#     #frputs ${overType}TagOps ${overType}FontOps 
#   }
#   #
#   upvar $var_string string
#   set stringLen [string length $string]
#   set curSindex 0
#   while {$curSindex  < $stringLen} {
#     set pos [string first \b $string $curSindex]
#     if {$pos == -1} {
#       $w insert insert [string range $string $curSindex end] {*}$overOps(tags)
#       break
#     }
#     set c [string index $string $pos-1]
#     $w insert insert [string range $string $curSindex $pos-2] {*}$overOps(tags)
    
#     $w insert insert [string index $string $pos+1] \
# 	[list [expr {[string index $string $pos-1] == "_" ? "italicTag" : "boldTag"}]\
# 	     {*}$overOps(tags)]
#     set curSindex [expr {$pos + 2}]
#   }
#     # we delete the fonts now but they will live on until the window is deleted
#   font delete $boldViewFont $italicViewFont
# }
