Minsky
minsky.tcl File Reference

Go to the source code of this file.

Namespaces

 tk
 
 tk::mac
 

Functions

 setFname name
 
 value.value args
 
 attachTraceProc namesp
 
 traceProc args
 
 tcl_exit args
 
 setCursor cur
 
 setBackgroundColour bgc
 
 tk_focusPrev win
 
 tk_focusNext win
 
 deiconify widget
 
 showPreferences
 
 generateBookmarkMenu
 
 addBookMark
 
 invokeButton button
 
 autoRepeatButton button
 
 setSimulationDelay delay
 
 imageFileTypes
 
 setExportResolutionFactor setter
 
 renderImage filename type surf
 
 exportCanvas
 
 getLogVars
 
 logVarsOK
 
 getClipboard
 
 togglePaste
 
 undo delta
 
 cut
 
 dimensionsDialog
 
 rewriteTimeComboBox comboBox
 
 dimFormatPopdown comboBox type onSelect
 
 pasteAt
 
 buttonBar window okProc
 
 okAction okProc window
 
 cancelWin window
 
 ensureWindowVisible window
 
 textEntryPopup win init okproc
 
 addTab window label surface
 
 hoverMouseTab tabId
 
 wrapHoverMouseTab tabId op x y
 
 tabContext x y X Y
 
 setScrollBars
 
 panCanvas offsx offsy
 
 scrollCanvases xyview args
 
 runstop
 
 step
 
 simulate
 
 reset
 
 populateRecentFiles
 
 openFile
 
 autoBackupName
 
 openNamedFile ofname
 
 insertFile
 
 importMDL
 
 recentreCanvas
 
 fileTypes defaultExtension
 
 save
 
 saveAs
 
 newSystem
 
 toggleImplicitSolver
 
 invokeOKorCancel window
 
 deiconifyRKDataForm
 
 closeRKDataForm
 
 setRKparms
 
 closePreferencesForm
 
 setPreferenceParms
 
 topLevelHelp
 
 helpContext x y
 
 helpFor x y
 
 canvasHelp
 
 openURL URL
 
 help topic
 
 aboutMinsky
 
 deleteSubsidiaryTopLevels
 
 exit
 
 bgerror x
 
 unknown procname args
 
 ifDef var
 
 addEvent event window button height state width x y delta keysym subwindow
 
 startRecording filename
 
 stopRecording
 
 toggleRecording
 
 checkRecordingVersion ver
 
 replay
 
 tk::SetFocusGrab grab focus
 
 tk::mac::OpenDocument args
 
 tk::mac::ShowPreferences
 
 tk::mac::ShowHelp
 

Function Documentation

◆ aboutMinsky()

aboutMinsky

Definition at line 1717 of file minsky.tcl.

1717 proc aboutMinsky {} {
1718  tk_messageBox -message "
1719  Minsky [minskyVersion]\n
1720  Version used to save file [fileVersion]\n
1721  Tcl/Tk [info tclversion]\n
1722  Ravel [ravelVersion]
1723 " -detail "
1724  Minsky is FREE software, distributed under the
1725  GNU General Public License. It comes with ABSOLUTELY NO WARRANTY.
1726  See http://www.gnu.org/licenses/ for details
1727 
1728  Some icons from the Antü Plasma Suita are licensed under Creative
1729  Commons Attribution-Share Alike 3.0 Unported license
1730  (https://creativecommons.org/licenses/by-sa/3.0/deed.en).
1731 
1732  Ravel is copyright Ravelation Pty Ltd. A separate license needs to
1733  be purchased to use Ravel. See https://ravelation.hpcoders.com.au
1734 
1735 Thanks to following Minsky Unicorn sponsors:
1736  Edward McDaniel
1737  Travis Kimmel
1738  "
1739 }

◆ addBookMark()

addBookMark

Definition at line 508 of file minsky.tcl.

References buttonBar(), ensureWindowVisible(), and pack().

508 proc addBookMark {} {
509  toplevel .bookMarkDialog
510  frame .bookMarkDialog.name
511  label .bookMarkDialog.name.text -text "Bookmark name"
512  entry .bookMarkDialog.name.val
513  pack .bookMarkDialog.name.text .bookMarkDialog.name.val -side left
514  pack .bookMarkDialog.name
515  buttonBar .bookMarkDialog {
516  minsky.canvas.model.addBookmark [.bookMarkDialog.name.val get]
517  }
518  ensureWindowVisible .bookMarkDialog
519  wm transient .bookMarkDialog
520  focus .bookMarkDialog.name.val
521  grab set .bookMarkDialog
522 }
Here is the call graph for this function:

◆ addEvent()

addEvent   event window button height state width x y delta keysym subwindow  

Definition at line 1854 of file minsky.tcl.

References ifDef().

1854 proc addEvent {event window button height state width x y delta keysym subwindow} {
1855  global eventRecord eventRecording
1856  if {$eventRecording && [info exists eventRecord] && [llength [file channels $eventRecord]]} {
1857  set rec "event generate $window $event "
1858  foreach option {button height state width x y delta keysym} {
1859  # for some reason, the logic misses this one
1860  if {($event=="<Key>" || $event=="<KeyRelease>") && $option=="delta"} continue
1861  append rec [ifDef $option]
1862  }
1863  puts $eventRecord $rec
1864  }
1865 }
Here is the call graph for this function:

◆ addTab()

addTab   window label surface  

Definition at line 973 of file minsky.tcl.

973 proc addTab {window label surface} {
974  image create cairoSurface rendered$window -surface $surface
975  ttk::frame .$window
976  global canvasHeight canvasWidth tabSurface helpTopics
977  label .$window.canvas -image rendered$window -height $canvasHeight -width $canvasWidth
978  .tabs add .$window -text $label -padding 0
979  set tabSurface($label) $surface
980  set helpTopics(.$window) tabs:$label
981 }

◆ attachTraceProc()

attachTraceProc   namesp  

Definition at line 112 of file minsky.tcl.

References attachTraceProc().

Referenced by attachTraceProc().

112 proc attachTraceProc {namesp} {
113  foreach p [info commands $namesp*] {
114  if {$p ne "::traceProc"} {
115  trace remove execution $p enterstep traceProc
116  trace add execution $p enterstep traceProc
117  }
118  }
119  # recursively process child namespaces
120  foreach n [namespace children $namesp] {
121  attachTraceProc ${n}::
122  }
123 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ autoBackupName()

autoBackupName

Definition at line 1375 of file minsky.tcl.

Referenced by exit(), newSystem(), openNamedFile(), and save().

1375 proc autoBackupName {} {
1376  global fname
1377  return "$fname#"
1378 }
Here is the caller graph for this function:

◆ autoRepeatButton()

autoRepeatButton   button  

Definition at line 534 of file minsky.tcl.

Referenced by invokeButton().

534 proc autoRepeatButton button {
535  after 500 invokeButton $button
536 }
Here is the caller graph for this function:

◆ bgerror()

bgerror   x  

Definition at line 1785 of file minsky.tcl.

1785  proc bgerror x {}

◆ buttonBar()

buttonBar   window okProc  

Definition at line 910 of file minsky.tcl.

References pack().

Referenced by addBookMark(), bookmarkAt(), CSVImportDialog(), csvImportDialogOK(), lockSpecificHandles(), penStyles(), setDimension(), setExportResolutionFactor(), setupPickDimMenu(), setupPickMenu(), and textEntryPopup().

910 proc buttonBar {window okProc} {
911  frame $window.buttonBar
912  button $window.buttonBar.ok -text "OK" -command "okAction \{$okProc\} $window"
913  button $window.buttonBar.cancel -text "Cancel" -command "cancelWin $window"
914  pack $window.buttonBar.cancel $window.buttonBar.ok -side left
915  pack $window.buttonBar -side top
916  bind $window <Key-Return> "$window.buttonBar.ok invoke"
917  bind $window <Key-Escape> "$window.buttonBar.cancel invoke"
918 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cancelWin()

cancelWin   window  

Definition at line 929 of file minsky.tcl.

Referenced by csvImportDialogOK(), and okAction().

929 proc cancelWin window {
930  grab release $window
931  destroy $window
932 }
Here is the caller graph for this function:

◆ canvasHelp()

canvasHelp

Definition at line 1676 of file minsky.tcl.

References get_pointer_x(), get_pointer_y(), and help().

Referenced by helpFor().

1676 proc canvasHelp {} {
1677  set x [get_pointer_x .wiring.canvas]
1678  set y [get_pointer_y .wiring.canvas]
1679  if [getItemAt $x $y] {
1680  help [minsky.canvas.item.classType]
1681  } elseif [getWireAt $x $y] {
1682  help wire
1683  } else {help DesignCanvas}
1684 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkRecordingVersion()

checkRecordingVersion   ver  

Definition at line 1888 of file minsky.tcl.

1888 proc checkRecordingVersion ver {
1889  if {$ver!=[minskyVersion]} {
1890  tk_messageBox -icon warning -message "Recording version $ver differs from current Minsky version [minskyVersion]" -detail "Recording may not replay correctly"
1891  }
1892 }

◆ closePreferencesForm()

closePreferencesForm

Definition at line 1591 of file minsky.tcl.

1591 proc closePreferencesForm {} {
1592  destroy .preferencesForm
1593 }

◆ closeRKDataForm()

closeRKDataForm

Definition at line 1580 of file minsky.tcl.

1580 proc closeRKDataForm {} {
1581  grab release .rkDataForm
1582  wm withdraw .rkDataForm
1583 }

◆ cut()

cut

Definition at line 756 of file minsky.tcl.

Referenced by deleteKey(), and minsky::GodleyTableEditor::keyPress().

756 proc cut {} {
757  minsky.cut
758 }
Here is the caller graph for this function:

◆ deiconify()

deiconify   widget  

Definition at line 265 of file minsky.tcl.

Referenced by deiconifyRKDataForm(), initRandom(), setDimension(), setupPickDimMenu(), setupPickMenu(), and showPreferences().

265 proc deiconify {widget} {
266  wm deiconify $widget
267  after idle "wm deiconify $widget; raise $widget; focus -force $widget"
268 }
Here is the caller graph for this function:

◆ deiconifyRKDataForm()

deiconifyRKDataForm

Definition at line 1540 of file minsky.tcl.

References deiconify(), and pack().

1540 proc deiconifyRKDataForm {} {
1541  if {![winfo exists .rkDataForm]} {
1542  global rkVarInput rkVars
1543  toplevel .rkDataForm
1544  wm resizable .rkDataForm 0 0
1545 
1546  set row 0
1547 
1548  grid [label .rkDataForm.label$row -text "Simulation parameters"] -column 1 -columnspan 999 -pady 10
1549  incr row 10
1550 
1551  foreach {var text} $rkVars {
1552  set rowdict($text) $row
1553  grid [label .rkDataForm.label$row -text $text] -column 10 -row $row -sticky e
1554  grid [entry .rkDataForm.text$row -width 20 -textvariable rkVarInput($var)] -column 20 -row $row -sticky ew
1555  incr row 10
1556  }
1557  grid [label .rkDataForm.implicitlabel -text "Implicit solver"] -column 10 -row $row -sticky e
1558  grid [checkbutton .rkDataForm.implicitcheck -variable implicitSolver -command toggleImplicitSolver] -column 20 -row $row -sticky ew
1559 
1560  set rkVarInput(initial_focus) ".rkDataForm.text$rowdict(Min Step Size)"
1561  frame .rkDataForm.buttonBar
1562  button .rkDataForm.buttonBar.ok -text OK -command {setRKparms; closeRKDataForm}
1563  button .rkDataForm.buttonBar.cancel -text cancel -command {closeRKDataForm}
1564  pack .rkDataForm.buttonBar.ok [label .rkDataForm.buttonBar.spacer -width 2] .rkDataForm.buttonBar.cancel -side left -pady 10
1565  grid .rkDataForm.buttonBar -column 1 -row 999 -columnspan 999
1566 
1567  bind .rkDataForm <Key-Return> {invokeOKorCancel .rkDataForm.buttonBar}
1568 
1569  wm title .rkDataForm "Simulation parameters"
1570  # help bindings
1571  bind .rkDataForm <F1> {help RungeKutta}
1572  global helpTopics
1573  set helpTopics(.rkDataForm) RungeKutta
1574  bind .rkDataForm <<contextMenu>> {helpContext %X %Y}
1575  } else {
1576  deiconify .rkDataForm
1577  }
1578 }
Here is the call graph for this function:

◆ deleteSubsidiaryTopLevels()

deleteSubsidiaryTopLevels

Definition at line 1742 of file minsky.tcl.

Referenced by newSystem(), and undo().

1742 proc deleteSubsidiaryTopLevels {} {
1743  global globals
1744 
1745  canvas.defaultRotation 0
1746  set globals(godley_tables) {}
1747 
1748  foreach w [info commands .godley*] {destroy $w}
1749  foreach w [info commands .plot*] {destroy $w}
1750  foreach image [image names] {
1751  if [regexp ".plot.*|godleyImage.*|groupImage.*|varImage.*|opImage.*|plot_image.*" $image] {
1752  image delete $image
1753  }
1754  }
1755 }
Here is the caller graph for this function:

◆ dimensionsDialog()

dimensionsDialog

Definition at line 760 of file minsky.tcl.

References dimFormatPopdown().

760 proc dimensionsDialog {} {
761  populateMissingDimensions
762  toplevel .dimensions
763  grid [button .dimensions.cancel -text Cancel -command "destroy .dimensions"] \
764  [button .dimensions.ok -text OK -command {
765  set colRows [grid size .dimensions]
766  for {set i 2} {$i<[lindex $colRows 1]} {incr i} {
767  set dim [.dimensions.g${i}_dim get]
768  if {$dim!=""} {
769  set d [dimensions.@elem $dim]
770  $d.type [.dimensions.g${i}_type get]
771  if [info exists timeFormatStrings([.dimensions.g${i}_units get])] {
772  $d.units $timeFormatStrings([.dimensions.g${i}_units get])
773  } else {
774  $d.units [.dimensions.g${i}_units get]
775  }
776  }
777  }
778  imposeDimensions
779  destroy .dimensions
780  reset
781  }]
782  grid [label .dimensions.g1_dim -text Dimension] \
783  [label .dimensions.g1_type -text Type]\
784  [label .dimensions.g1_units -text "Units/Format"]
785  tooltip .dimensions.g1_units "Value type: enter a unit string, eg m/s; time type: enter a strftime format string, eg %Y-%m-%d %H:%M:%S, or %Y-Q%Q"
786 
787  set colRows [grid size .dimensions]
788  for {set i [lindex $colRows 1]} {$i<[dimensions.size]+3} {incr i} {
789  grid [entry .dimensions.g${i}_dim] \
790  [ttk::combobox .dimensions.g${i}_type -state readonly \
791  -values {string value time}] \
792  [ttk::combobox .dimensions.g${i}_units \
793  -postcommand "dimFormatPopdown .dimensions.g${i}_units \[.dimensions.g${i}_type get\] {}"
794  ]
795  }
796  set i 2
797  foreach dim [dimensions.#keys] {
798  set d [dimensions.@elem $dim]
799  .dimensions.g${i}_dim delete 0 end
800  .dimensions.g${i}_dim insert 0 $dim
801  .dimensions.g${i}_type set [$d.type]
802  .dimensions.g${i}_units delete 0 end
803  .dimensions.g${i}_units insert 0 [$d.units]
804  dimFormatPopdown .dimensions.g${i}_units [$d.type] {}
805  incr i
806  }
807 }
Here is the call graph for this function:

◆ dimFormatPopdown()

dimFormatPopdown   comboBox type onSelect  

Definition at line 850 of file minsky.tcl.

Referenced by csvImportButton1Up(), dimensionsDialog(), and setDimension().

850 proc dimFormatPopdown {comboBox type onSelect} {
851  global timeFormatStrings
852  switch $type {
853  string {
854  $comboBox configure -values {}
855  $comboBox set {}
856  bind $comboBox <<ComboboxSelected>> $onSelect
857  }
858  value {
859  $comboBox configure -values {}
860  bind $comboBox <<ComboboxSelected>> $onSelect
861  }
862  time {
863  $comboBox configure -values [lsort [array names timeFormatStrings]]
864  bind $comboBox <<ComboboxSelected>> "rewriteTimeComboBox $comboBox; $onSelect"
865  }
866  }
867 }
Here is the caller graph for this function:

◆ ensureWindowVisible()

ensureWindowVisible   window  

Definition at line 934 of file minsky.tcl.

Referenced by addBookMark(), addConstantOrVariable(), editItem(), editVar(), getLogVars(), initRandom(), lockSpecificHandles(), postNote(), setDimension(), setupPickDimMenu(), setupPickMenu(), showPreferences(), and textEntryPopup().

934 proc ensureWindowVisible window {
935  if {![winfo ismapped $window]} {
936  tkwait visibility $window
937  }
938 }
Here is the caller graph for this function:

◆ exit()

exit

Definition at line 1757 of file minsky.tcl.

References autoBackupName(), save(), and tcl_exit().

Referenced by handleSignal().

1757 proc exit {} {
1758  # check if the model has been saved yet
1759  if {[edited]} {
1760  switch [tk_messageBox -message "Save before exiting?" -type yesnocancel] {
1761  yes save
1762  no {file delete -- [autoBackupName]}
1763  cancel {return -level [info level]}
1764  }
1765  }
1766 
1767 
1768  # if we have a valid rc file location, write out the directory of
1769  # the last file loaded
1770  global rcfile workDir backgroundColour preferences recentFiles
1771  if {$rcfile!=""} {
1772  set rc [open $rcfile w]
1773  puts $rc "set workDir $workDir"
1774  puts $rc "set canvasWidth [winfo width .wiring.canvas]"
1775  puts $rc "set canvasHeight [winfo height .wiring.canvas]"
1776  puts $rc "set backgroundColour $backgroundColour"
1777  foreach p [array names preferences] {
1778  puts $rc "set preferences($p) \{$preferences($p)\}"
1779  }
1780  puts $rc {minsky.defaultFont $preferences(defaultFont)}
1781  puts $rc "set recentFiles \{$recentFiles\}"
1782  close $rc
1783  }
1784  # why is this needed?
1785  proc bgerror x {}
1786  tcl_exit
1787 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exportCanvas()

exportCanvas

Definition at line 646 of file minsky.tcl.

References imageFileTypes(), and renderImage().

646 proc exportCanvas {} {
647  global workDir type fname preferences tabSurface
648 
649  set fileTypes [imageFileTypes]
650  lappend fileTypes {"LaTeX" .tex TEXT} {"Matlab" .m TEXT}
651  set f [tk_getSaveFile -filetypes $fileTypes \
652  -initialdir $workDir -typevariable type -initialfile [file rootname [file tail $fname]]]
653  if {$f==""} return
654  set workDir [file dirname $f]
655  # extract the surface name from the current tab, for #912
656  set surf [lindex [.tabs tabs] [.tabs index current]].canvas
657  if [renderImage $f $type $tabSurface([.tabs tab current -text])] return
658  if {[string match -nocase *.tex "$f"]} {
659  latex "$f" $preferences(wrapLaTeXLines)
660  } elseif {[string match -nocase *.m "$f"]} {
661  matlab "$f"
662  } else {
663  switch $type {
664  "LaTeX" {latex "$f.tex" $preferences(wrapLaTeXLines)}
665  "Matlab" {matlab "$f.m"}
666  }
667  }
668 }
Here is the call graph for this function:

◆ fileTypes()

fileTypes   defaultExtension  

Definition at line 1461 of file minsky.tcl.

Referenced by group::save(), save(), saveAs(), and saveSelection().

1461 proc fileTypes {defaultExtension} {
1462  if {$defaultExtension==".rvl"} {
1463  return {{"Ravel" .rvl TEXT} {"Minsky" .mky TEXT} {"All Files" * TEXT}}
1464  } else {
1465  return {{"Minsky" .mky TEXT} {"Ravel" .rvl TEXT} {"All Files" * TEXT}}
1466  }
1467 }
Here is the caller graph for this function:

◆ generateBookmarkMenu()

generateBookmarkMenu

Definition at line 494 of file minsky.tcl.

494 proc generateBookmarkMenu {} {
495  .menubar.bookmarks delete 0 end
496  .menubar.bookmarks add command -label "Bookmark this position" -command addBookMark
497  .menubar.bookmarks.deleteMenu delete 0 end
498  .menubar.bookmarks add cascade -label "Delete ..." -menu .menubar.bookmarks.deleteMenu
499  .menubar.bookmarks add separator
500  set p 0
501  foreach i [minsky.canvas.model.bookmarkList] {
502  .menubar.bookmarks add command -label $i -command "canvas.model.gotoBookmark $p; canvas.requestRedraw"
503  .menubar.bookmarks.deleteMenu add command -label $i -command "canvas.model.deleteBookmark $p"
504  incr p
505  }
506 }

◆ getClipboard()

getClipboard

Definition at line 727 of file minsky.tcl.

Referenced by canvasContext(), godleyContext(), toggleGodleyPaste(), and togglePaste().

727 proc getClipboard {} {
728  set contents ""
729  catch {clipboard get -type UTF8_STRING} contents
730  return contents
731 }
Here is the caller graph for this function:

◆ getLogVars()

getLogVars

Definition at line 671 of file minsky.tcl.

References ensureWindowVisible(), and pack().

671 proc getLogVars {} {
672  global varNames allLogVars varIds
673  set varNames {}
674  set varIds {}
675  set allLogVars 0
676  toplevel .logVars
677  frame .logVars.buttons
678  button .logVars.buttons.ok -text OK -command logVarsOK
679  checkbutton .logVars.buttons.all -text All -variable allLogVars -command {
680  .logVars.selection.selection selection [expr $allLogVars?"set":"clear"] 0 end
681  }
682  pack .logVars.buttons.ok .logVars.buttons.all -side left
683 
684  foreach v [variableValues.#keys] {
685  if {![regexp "^constant:" $v]} {
686  getValue $v
687  lappend varNames [minsky.value.name]
688  lappend varIds $v
689  }
690  }
691  frame .logVars.selection
692  listbox .logVars.selection.selection -listvariable varNames -selectmode extended -height 30 -yscrollcommand ".logVars.selection.vscroll set" -selectforeground blue
693  scrollbar .logVars.selection.vscroll -orient vertical -command ".logVars.selection.selection yview"
694  pack .logVars.selection.selection -fill both -side left -expand y
695  pack .logVars.selection.vscroll -fill y -side left -expand y
696  pack .logVars.buttons .logVars.selection
697 
698  ensureWindowVisible .logVars
699  grab set .logVars
700  wm transient .logVars
701 }
Here is the call graph for this function:

◆ help()

help   topic  

Definition at line 1705 of file minsky.tcl.

References openURL().

Referenced by canvasHelp(), helpFor(), and tk::mac::ShowHelp().

1705 proc help {topic} {
1706  global minskyHome externalLabel
1707  # replace "Introduction" to framed toplevel document
1708  # TODO - see if it is possible to wrap the deep links with a framed service
1709  if {$topic=="Introduction"} {
1710  set URL "file://$minskyHome/library/help/minsky.html"
1711  } else {
1712  set URL "file://$minskyHome/library/help/minsky$externalLabel($topic)"
1713  }
1714  openURL $URL
1715 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ helpContext()

helpContext   x y  

Definition at line 1657 of file minsky.tcl.

1657 proc helpContext {x y} {
1658  .contextHelp delete 0 end
1659  .contextHelp add command -label Help -command "helpFor $x $y"
1660  tk_popup .contextHelp $x $y
1661 }

◆ helpFor()

helpFor   x y  

Definition at line 1664 of file minsky.tcl.

References canvasHelp(), and help().

Referenced by topLevelHelp().

1664 proc helpFor {x y} {
1665  global helpTopics
1666  set win [winfo containing $x $y]
1667  if {$win==".wiring.canvas"} {
1668  canvasHelp
1669  } elseif [info exists helpTopics($win)] {
1670  help $helpTopics($win)
1671  } else {
1672  help Introduction
1673  }
1674 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hoverMouseTab()

hoverMouseTab   tabId  

Definition at line 990 of file minsky.tcl.

References get_pointer_x(), and get_pointer_y().

990 proc hoverMouseTab {tabId} {
991  set tab [lindex [.tabs tabs] [.tabs index current]]
992  $tabId.displayDelayedTooltip [get_pointer_x $tab.canvas] [get_pointer_y $tab.canvas]
993 }
Here is the call graph for this function:

◆ ifDef()

ifDef   var  

Definition at line 1845 of file minsky.tcl.

Referenced by addEvent().

1845 proc ifDef {var} {
1846  upvar $var v
1847  if {$v!="??"} {
1848  return "-$var $v "
1849  } else {
1850  return ""
1851  }
1852 }
Here is the caller graph for this function:

◆ imageFileTypes()

imageFileTypes

Definition at line 604 of file minsky.tcl.

Referenced by exportCanvas(), exportGodley(), and exportItemAsImg().

604 proc imageFileTypes {} {
605  global tcl_platform
606  set fileTypes {{"SVG" .svg TEXT} {"PDF" .pdf TEXT} {"Postscript" .eps TEXT} {"Portable Network Graphics" .png TEXT}}
607  if {$tcl_platform(platform)=="windows"} {lappend fileTypes {"EMF" .emf TEXT}}
608  return $fileTypes
609 }
Here is the caller graph for this function:

◆ importMDL()

importMDL

Definition at line 1420 of file minsky.tcl.

References newSystem().

1420 proc importMDL {} {
1421  global workDir
1422  newSystem
1423  set fname [tk_getOpenFile -multiple 1 -filetypes {
1424  {Vensim {.mdl}} {All {.*}}} -initialdir $workDir]
1425  eval importVensim $fname
1426  minsky.model.autoLayout
1427 }
Here is the call graph for this function:

◆ insertFile()

insertFile

Definition at line 1413 of file minsky.tcl.

1413 proc insertFile {} {
1414  global workDir
1415  set fname [tk_getOpenFile -multiple 1 -filetypes {
1416  {Minsky {.mky}} {Ravel {.rvl}} {XML {.xml}} {All {.*}}} -initialdir $workDir]
1417  eval insertGroupFromFile $fname
1418 }

◆ invokeButton()

invokeButton   button  

Definition at line 525 of file minsky.tcl.

References autoRepeatButton().

525 proc invokeButton button {
526  global buttonPressed
527  if {$buttonPressed} {
528  $button invoke
529  update
530  autoRepeatButton $button
531  }
532 }
Here is the call graph for this function:

◆ invokeOKorCancel()

invokeOKorCancel   window  

Definition at line 1520 of file minsky.tcl.

1520 proc invokeOKorCancel {window} {
1521  if [string equal [focus] "$window.cancel"] {
1522  $window.cancel invoke
1523  } else {
1524  $window.ok invoke
1525  }
1526 }

◆ logVarsOK()

logVarsOK

Definition at line 703 of file minsky.tcl.

703 proc logVarsOK {} {
704  global workDir varIds
705  set indices [.logVars.selection.selection curselection]
706 
707  foreach i $indices {lappend vars [lindex $varIds $i]}
708  logVarList $vars
709  destroy .logVars
710  openLogFile [tk_getSaveFile -defaultextension .dat -initialdir $workDir]
711 }

◆ newSystem()

newSystem

Definition at line 1490 of file minsky.tcl.

References autoBackupName(), deleteSubsidiaryTopLevels(), recentreCanvas(), reset(), and save().

Referenced by importMDL(), openNamedFile(), and replay().

1490 proc newSystem {} {
1491  doPushHistory 0
1492  if {[edited]} {
1493  switch [tk_messageBox -message "Save?" -type yesnocancel] {
1494  yes save
1495  no {}
1496  cancel {return -level [info level]}
1497  }
1498  }
1499  catch {reset}
1500  clearAllMapsTCL
1501  pushFlags
1503  clearHistory
1504  model.setZoom 1
1506  global fname progName
1507  set fname ""
1508  file delete [autoBackupName]
1509  wm title . "$progName: New System"
1510  popFlags
1511  doPushHistory 1
1512 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ okAction()

okAction   okProc window  

Definition at line 920 of file minsky.tcl.

References cancelWin().

920 proc okAction {okProc window} {
921  if [catch $okProc msg] {
922  tk_messageBox -icon error -parent $window -message $msg
923  raise $window
924  return
925  }
926  cancelWin $window
927 }
Here is the call graph for this function:

◆ openFile()

openFile

Definition at line 1368 of file minsky.tcl.

References openNamedFile().

1368 proc openFile {} {
1369  global fname workDir preferences
1370  set ofname [tk_getOpenFile -multiple 1 -filetypes {
1371  {Minsky {.mky}} {Ravel {.rvl}} {XML {.xml}} {All {.*}}} -initialdir $workDir]
1372  if [string length $ofname] {eval openNamedFile $ofname}
1373 }
Here is the call graph for this function:

◆ openNamedFile()

openNamedFile   ofname  

Definition at line 1379 of file minsky.tcl.

References autoBackupName(), newSystem(), recentreCanvas(), and setFname().

Referenced by tk::mac::OpenDocument(), and openFile().

1379 proc openNamedFile {ofname} {
1380  global fname workDir preferences
1381  newSystem
1382  setFname $ofname
1383 
1384  if {[file exists [autoBackupName]] && [tk_messageBox -message "Auto save file exists, do you wish to load it" -type yesno]=="yes"} {
1385  eval minsky.load {[autoBackupName]}
1386  } else {
1387  eval minsky.load {$ofname}
1388  file delete -- [autoBackupName]
1389  }
1390  # setting simulationDelay causes the edited (dirty) flag to be set, amongst other things
1391  pushFlags
1392  doPushHistory 0
1393  setAutoSaveFile [autoBackupName]
1394 
1395  # minsky.load resets minsky.multipleEquities and other preference, so restore preferences
1396  minsky.multipleEquities $preferences(multipleEquities)
1397  setGodleyDisplayValue $preferences(godleyDisplay) $preferences(godleyDisplayStyle)
1398 
1400 
1401  .controls.simSpeed set [simulationDelay]
1402  # force update canvas size to ensure model is displayed correctly
1403  update
1404  canvas.requestRedraw
1405  # not sure why this is needed, but initial draw doesn't happen without it
1406  event generate .wiring.canvas <Expose>
1407  update
1408  doPushHistory 1
1409  pushHistory
1410  popFlags
1411 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openURL()

openURL   URL  

Definition at line 1686 of file minsky.tcl.

Referenced by help().

1686 proc openURL {URL} {
1687  global tcl_platform
1688  if {[tk windowingsystem]=="win32"} {
1689  shellOpen $URL
1690  } elseif {$tcl_platform(os)=="Darwin"} {
1691  exec open $URL
1692  } elseif [catch {exec xdg-open $URL &}] {
1693  # try a few likely suspects
1694  foreach browser {firefox konqueror seamonkey opera} {
1695  set browserNotFound [catch {exec $browser $URL &}]
1696  if {!$browserNotFound} break
1697  }
1698  if $browserNotFound {
1699  tk_messageBox -detail "Unable to find a working web browser,
1700 please consult $URL" -type ok -icon warning
1701  }
1702  }
1703 }
Here is the caller graph for this function:

◆ panCanvas()

panCanvas   offsx offsy  

Definition at line 1084 of file minsky.tcl.

References setScrollBars().

Referenced by findDefinition(), and scrollCanvases().

1084 proc panCanvas {offsx offsy} {
1085  global preferences
1086  switch [lindex [.tabs tabs] [.tabs index current]] {
1087  .wiring {
1088  minsky.canvas.model.moveTo $offsx $offsy
1089  canvas.requestRedraw
1090  }
1091  .equations {
1092  equationDisplay.offsx $offsx
1093  equationDisplay.offsy $offsy
1094  equationDisplay.requestRedraw
1095  }
1096  .parameters {
1097  parameterTab.offsx $offsx
1098  parameterTab.offsy $offsy
1099  parameterTab.requestRedraw
1100  }
1101  .variables {
1102  variableTab.offsx $offsx
1103  variableTab.offsy $offsy
1104  variableTab.requestRedraw
1105  }
1106  .plts {
1107  plotTab.offsx $offsx
1108  plotTab.offsy $offsy
1109  plotTab.requestRedraw
1110  }
1111  .gdlys {
1112  godleyTab.offsx $offsx
1113  godleyTab.offsy $offsy
1114  godleyTab.requestRedraw
1115  }
1116  }
1118 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pasteAt()

pasteAt

Definition at line 869 of file minsky.tcl.

References get_pointer_x(), and get_pointer_y().

869 proc pasteAt {} {
870  minsky.paste
871  canvas.mouseMove [get_pointer_x .wiring.canvas] [get_pointer_y .wiring.canvas]
872 }
Here is the call graph for this function:

◆ populateRecentFiles()

populateRecentFiles

Definition at line 1353 of file minsky.tcl.

Referenced by setFname().

1353 proc populateRecentFiles {} {
1354  global recentFiles preferences
1355  .menubar.file.recent delete 0 end
1356  if {[llength $recentFiles]>$preferences(nRecentFiles)} {
1357  set recentFiles [lreplace $recentFiles $preferences(nRecentFiles) end]
1358  }
1359  foreach f $recentFiles {
1360  .menubar.file.recent insert 0 command -label "[file tail $f]" \
1361  -command "openNamedFile \"[regsub -all {\\} $f /]\""
1362  }
1363 }
Here is the caller graph for this function:

◆ recentreCanvas()

recentreCanvas

Definition at line 1430 of file minsky.tcl.

Referenced by newSystem(), openNamedFile(), and startRecording().

1430 proc recentreCanvas {} {
1431  switch [lindex [.tabs tabs] [.tabs index current]] {
1432  .wiring {canvas.recentre}
1433  .equations {
1434  equationDisplay.offsx 0
1435  equationDisplay.offsy 0
1436  equationDisplay.requestRedraw
1437  }
1438  .parameters {
1439  parameterTab.offsx 0
1440  parameterTab.offsy 0
1441  parameterTab.requestRedraw
1442  }
1443  .variables {
1444  variableTab.offsx 0
1445  variableTab.offsy 0
1446  variableTab.requestRedraw
1447  }
1448  .plts {
1449  plotTab.offsx 0
1450  plotTab.offsy 0
1451  plotTab.requestRedraw
1452  }
1453  .gdlys {
1454  godleyTab.offsx 0
1455  godleyTab.offsy 0
1456  godleyTab.requestRedraw
1457  }
1458  }
1459 }
Here is the caller graph for this function:

◆ renderImage()

renderImage   filename type surf  

Definition at line 621 of file minsky.tcl.

Referenced by exportCanvas(), exportGodley(), and exportItemAsImg().

621 proc renderImage {filename type surf} {
622  global tcl_platform
623  if [string match -nocase *.svg "$filename"] {
624  $surf.renderToSVG "$filename"
625  } elseif [string match -nocase *.pdf "$filename"] {
626  $surf.renderToPDF "$filename"
627  } elseif {[string match -nocase *.ps "$filename"] || [string match -nocase *.eps "$filename"]} {
628  $surf.renderToPS "$filename"
629  } elseif {[string match -nocase *.png "$filename"]} {
630  $surf.renderToPNG "$filename"
631  } elseif {$tcl_platform(platform)=="windows" && [string match -nocase *.emf "$filename"]} {
632  $surf.renderToEMF "$filename"
633  } else {
634  switch $type {
635  "SVG" {$surf.renderToSVG "$filename.svg"}
636  "PDF" {$surf.renderToPDF "$filename.pdf"}
637  "PNG" {$surf.renderToPNG "$filename.png"}
638  "EMF" {$surf.renderToEMF "$filename.emf"}
639  "Postscript" {$surf.renderToPS "$filename.eps"}
640  default {return false}
641  }
642  }
643  return true
644 }
Here is the caller graph for this function:

◆ replay()

replay

Definition at line 1897 of file minsky.tcl.

References newSystem(), runstop(), and stopRecording().

1897 proc replay {} {
1898  global recordingReplay eventRecordR workDir eventRecording
1899  if $eventRecording {stopRecording; set eventRecording 0}
1900  if {$recordingReplay} {
1901  # ensures consistent IDs are allocated
1902  set fname [tk_getOpenFile -filetypes {{"TCL scripts" .tcl TEXT} {"All Files" * }} \
1903  -defaultextension .tcl -initialdir $workDir]
1904  if {[string length $fname]>0} {
1905  set eventRecordR [eval open {$fname} r]
1906  newSystem
1907  if {![running]} runstop
1908  } else {
1909  if [running] {runstop}
1910  set recordingReplay 0
1911  }
1912  }
1913 }
Here is the call graph for this function:

◆ reset()

reset

Definition at line 1325 of file minsky.tcl.

References stopRecording().

Referenced by minsky::Optional< minsky::ShowSlice >::assign(), csvImportDialogOK(), doubleButton(), minsky::EvalOpPtr::EvalOpPtr(), minsky::Minsky::load(), newSystem(), minsky::Optional< minsky::ShowSlice >::operator*(), minsky::Minsky::requestReset(), minsky::Minsky::resetIfFlagged(), minsky::VariablePtr::retype(), and minsky::anonymous_namespace{addon.cc}::AddOnMinsky::run().

1325 proc reset {} {
1326  global recordingReplay eventRecordR simLogging eventRecording
1327  if {$eventRecording} {
1328  set eventRecording 0
1330  return
1331  }
1332  running 0
1333  if {$recordingReplay} {
1334  seek $eventRecordR 0 start
1335  model.clear
1336  canvas.requestRedraw
1337  } else {
1338  set tstep 0
1339  set simLogging 0
1340  closeLogFile
1341  # delay throwing exception to allow display to be updated
1342  set err [catch minsky.reset result]
1343  .controls.statusbar configure -text "t: 0 Δt: 0"
1344  .controls.run configure -image runButton
1345 
1346  redrawAllGodleyTables
1347  return -code $err $result
1348  }
1349 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rewriteTimeComboBox()

rewriteTimeComboBox   comboBox  

Definition at line 842 of file minsky.tcl.

842 proc rewriteTimeComboBox {comboBox} {
843  global timeFormatStrings
844  if [info exists timeFormatStrings([$comboBox get])] {
845  $comboBox set $timeFormatStrings([$comboBox get])
846  }
847 }

◆ runstop()

runstop

Definition at line 1266 of file minsky.tcl.

References simulate(), and step().

Referenced by replay(), and step().

1266 proc runstop {} {
1267  global classicMode
1268  if [running] {
1269  running 0
1270  doPushHistory 1
1271  if {$classicMode} {
1272  .controls.run configure -text run
1273  } else {
1274  .controls.run configure -image runButton
1275  }
1276  } else {
1277  running 1
1278  doPushHistory 0
1279  if {$classicMode} {
1280  .controls.run configure -text stop
1281  } else {
1282  .controls.run configure -image stopButton
1283  }
1284  step
1285  simulate
1286  }
1287 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

save

Definition at line 1469 of file minsky.tcl.

References autoBackupName(), fileTypes(), and setFname().

Referenced by exit(), newSystem(), minsky::anonymous_namespace{addon.cc}::AddOnMinsky::outOfMemoryHandler(), and saveAs().

1469 proc save {} {
1470  global fname workDir
1471  set ext [minsky.model.defaultExtension]
1472  if {![string length $fname]} {
1473  setFname [tk_getSaveFile -defaultextension $ext -initialdir $workDir \
1474  -filetypes [fileTypes $ext]]}
1475  if [string length $fname] {
1476  set workDir [file dirname $fname]
1477  eval minsky.save {$fname}
1478  file delete -- [autoBackupName]
1479  }
1480 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveAs()

saveAs

Definition at line 1482 of file minsky.tcl.

References fileTypes(), save(), and setFname().

1482 proc saveAs {} {
1483  global fname workDir
1484  set ext [minsky.model.defaultExtension]
1485  setFname [tk_getSaveFile -defaultextension $ext -initialdir $workDir \
1486  -filetypes [fileTypes $ext]]
1487  if [string length $fname] save
1488 }
Here is the call graph for this function:

◆ scrollCanvases()

scrollCanvases   xyview args  

Definition at line 1122 of file minsky.tcl.

References panCanvas().

1122 proc scrollCanvases {xyview args} {
1123  set win [lindex [.tabs tabs] [.tabs index current]]
1124  set ww [winfo width $win]
1125  set wh [winfo height $win]
1126  switch $win {
1127  .wiring {
1128  set x [minsky.canvas.model.x]
1129  set y [minsky.canvas.model.y]
1130  set w [expr 10*$ww]
1131  set h [expr 10*$wh]
1132  set x1 [expr 0.5*$w]
1133  set y1 [expr 0.5*$h]
1134  }
1135  .equations {
1136  set x [equationDisplay.offsx]
1137  set y [equationDisplay.offsy]
1138  set x1 0
1139  set y1 0
1140  set w [equationDisplay.width]
1141  set h [equationDisplay.height]
1142  }
1143  .parameters {
1144  set x [parameterTab.offsx]
1145  set y [parameterTab.offsy]
1146  set w [expr 10*$ww]
1147  set h [expr 10*$wh]
1148  set x1 [expr 0.5*$w]
1149  set y1 [expr 0.5*$h]
1150  }
1151  .variables {
1152  set x [variableTab.offsx]
1153  set y [variableTab.offsy]
1154  set w [expr 10*$ww]
1155  set h [expr 10*$wh]
1156  set x1 [expr 0.5*$w]
1157  set y1 [expr 0.5*$h]
1158  }
1159  .plts {
1160  set x [plotTab.offsx]
1161  set y [plotTab.offsy]
1162  set w [expr 10*$ww]
1163  set h [expr 10*$wh]
1164  set x1 [expr 0.5*$w]
1165  set y1 [expr 0.5*$h]
1166  }
1167  .gdlys {
1168  set x [godleyTab.offsx]
1169  set y [godleyTab.offsy]
1170  set w [expr 10*$ww]
1171  set h [expr 10*$wh]
1172  set x1 [expr 0.5*$w]
1173  set y1 [expr 0.5*$h]
1174  }
1175  }
1176  switch [lindex $args 0] {
1177  moveto {
1178  switch $xyview {
1179  xview {panCanvas [expr $x1-$w*[lindex $args 1]] $y}
1180  yview {panCanvas $x [expr $y1-$h*[lindex $args 1]]}
1181  }
1182  }
1183  scroll {
1184  switch [lindex $args 2] {
1185  units {set incr [expr [lindex $args 1]*0.01]}
1186  # page corresponds to one full screens worth
1187  pages {set incr [expr [lindex $args 1]*0.1]}
1188  }
1189  switch $xyview {
1190  xview {panCanvas [expr $x-$incr*$w] $y}
1191  yview {panCanvas $x [expr $y-$incr*$h]}
1192  }
1193  }
1194  }
1195 }
Here is the call graph for this function:

◆ setBackgroundColour()

setBackgroundColour   bgc  

Definition at line 189 of file minsky.tcl.

189 proc setBackgroundColour bgc {
190  global backgroundColour
191  set backgroundColour $bgc
192  tk_setPalette $bgc
193  # tk_setPalette doesn't understand ttk widgets
194  ttk::style configure TNotebook -background $backgroundColour
195  ttk::style configure TNotebook.Tab -background $backgroundColour
196  ttk::style map TNotebook.Tab -background "selected $bgc active $bgc"
197  if [winfo exists .controls.runmode] {.controls.runmode configure -selectcolor $bgc}
198 }

◆ setCursor()

setCursor   cur  

Definition at line 151 of file minsky.tcl.

151 proc setCursor {cur} {}

◆ setExportResolutionFactor()

setExportResolutionFactor   setter  

Definition at line 611 of file minsky.tcl.

References buttonBar(), and pack().

611 proc setExportResolutionFactor {setter} {
612  toplevel .resolutionFactor
613  wm title .resolutionFactor "Export resolution scale factor"
614  ttk::spinbox .resolutionFactor.value -from 1 -to 1000 -increment 1
615  pack .resolutionFactor.value
616  .resolutionFactor.value set [$setter.resolutionScaleFactor]
617  buttonBar .resolutionFactor "$setter.resolutionScaleFactor \[.resolutionFactor.value get\]"
618 }
Here is the call graph for this function:

◆ setFname()

setFname   name  

Definition at line 92 of file minsky.tcl.

References populateRecentFiles().

Referenced by openNamedFile(), save(), and saveAs().

92 proc setFname {name} {
93  global fname workDir progName
94  if [string length $name] {
95  set fname $name
96  set workDir [file dirname $name]
97  catch {wm title . "$progName: $fname"}
98  }
99 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPreferenceParms()

setPreferenceParms

Definition at line 1595 of file minsky.tcl.

References setGodleyDisplay().

1595 proc setPreferenceParms {} {
1596  global preferencesVars preferences preferences_input
1597 
1598  foreach var [array names preferences_input] {
1599  set preferences($var) $preferences_input($var)
1600  }
1601  defaultFont $preferences(defaultFont)
1602  multipleEquities $preferences(multipleEquities)
1604  if {$preferences(focusFollowsMouse)} {
1605  tk_focusFollowsMouse
1606  # Make tab traversal possible within a window that is given focus by only clicking on it (no focusFollowsMouse). For ticket 901.
1607  } else {
1608  set old [bind all <Enter>]
1609  set script {
1610  if {"%d" eq "NotifyAncestor" || "%d" eq "NotifyNonlinear" \
1611  || "%d" eq "NotifyInferior"} {
1612  tk::FocusOK %W
1613  }
1614  }
1615  if {$old ne ""} {
1616  bind all <Enter> "$old; $script"
1617  } else {
1618  bind all <Enter> $script
1619  }
1620  }
1621 }
Here is the call graph for this function:

◆ setRKparms()

setRKparms

Definition at line 1585 of file minsky.tcl.

1585 proc setRKparms {} {
1586  global rkVars rkVarInput
1587  foreach {var text} $rkVars { $var $rkVarInput($var)}
1588 }

◆ setScrollBars()

setScrollBars

Definition at line 1037 of file minsky.tcl.

Referenced by panCanvas().

1037 proc setScrollBars {} {
1038  switch [lindex [.tabs tabs] [.tabs index current]] {
1039  .wiring {
1040  set x0 [expr (10000-[minsky.canvas.model.x])/20000.0]
1041  set y0 [expr (10000-[minsky.canvas.model.y])/20000.0]
1042  .hscroll set $x0 [expr $x0+[winfo width .wiring.canvas]/20000.0]
1043  .vscroll set $y0 [expr $y0+[winfo height .wiring.canvas]/20000.0]
1044  }
1045  .equations {
1046  if {[equationDisplay.width]>0} {
1047  set x0 [expr [equationDisplay.offsx]/[equationDisplay.width]]
1048  .hscroll set $x0 [expr $x0+[winfo width .wiring.canvas]/[equationDisplay.width]]
1049  } else {.hscroll set 0 1}
1050  if {[equationDisplay.height]>0} {
1051  set y0 [expr [equationDisplay.offsx]/[equationDisplay.height]]
1052  .vscroll set $y0 [expr $y0+[winfo height .wiring.canvas]/[equationDisplay.height]]
1053  } else {.vscroll set 0 1}
1054  }
1055  .parameters {
1056  set x0 [expr (10000-[parameterTab.offsx])/20000.0]
1057  set y0 [expr (10000-[parameterTab.offsy])/20000.0]
1058  .hscroll set $x0 [expr $x0+[winfo width .parameters.canvas]/20000.0]
1059  .vscroll set $y0 [expr $y0+[winfo height .parameters.canvas]/20000.0]
1060  }
1061  .variables {
1062  set x0 [expr (10000-[variableTab.offsx])/20000.0]
1063  set y0 [expr (10000-[variableTab.offsy])/20000.0]
1064  .hscroll set $x0 [expr $x0+[winfo width .variables.canvas]/20000.0]
1065  .vscroll set $y0 [expr $y0+[winfo height .variables.canvas]/20000.0]
1066  }
1067  .plts {
1068  set x0 [expr (10000-[plotTab.offsx])/20000.0]
1069  set y0 [expr (10000-[plotTab.offsy])/20000.0]
1070  .hscroll set $x0 [expr $x0+[winfo width .plts.canvas]/20000.0]
1071  .vscroll set $y0 [expr $y0+[winfo height .plts.canvas]/20000.0]
1072  }
1073  .gdlys {
1074  set x0 [expr (10000-[godleyTab.offsx])/20000.0]
1075  set y0 [expr (10000-[godleyTab.offsy])/20000.0]
1076  .hscroll set $x0 [expr $x0+[winfo width .gdlys.canvas]/20000.0]
1077  .vscroll set $y0 [expr $y0+[winfo height .gdlys.canvas]/20000.0]
1078  }
1079  }
1080 }
Here is the caller graph for this function:

◆ setSimulationDelay()

setSimulationDelay   delay  

Definition at line 538 of file minsky.tcl.

538 proc setSimulationDelay {delay} {
539  # on loading a model, slider is adjusted, which causes
540  # simulationDelay to be set unnecessarily, marking the model
541  # dirty
542  if {$delay != [simulationDelay]} {
543  pushFlags
544  simulationDelay $delay
545  popFlags
546  }
547 }

◆ showPreferences()

showPreferences

Definition at line 333 of file minsky.tcl.

References deiconify(), ensureWindowVisible(), and pack().

Referenced by tk::mac::ShowPreferences().

333 proc showPreferences {} {
334  if [winfo exists .preferencesForm] return
335  global preferences_input preferences preferencesVars
336  foreach var [array names preferences] {
337  set preferences_input($var) $preferences($var)
338  }
339 
340  toplevel .preferencesForm
341  wm resizable .preferencesForm 0 0
342 
343  set row 0
344 
345  grid [label .preferencesForm.label$row -text "Preferences"] -column 1 -columnspan 999 -pady 10
346  incr row 10
347 
348  # pad the left and right
349  grid [frame .preferencesForm.f1] -column 1 -row 1 -rowspan 999 -padx 10
350  grid [frame .preferencesForm.f2] -column 999 -row 1 -rowspan 999 -padx 10
351 
352 
353  foreach {var text default type} $preferencesVars {
354  set rowdict($text) $row
355 
356  grid [label .preferencesForm.label$row -text $text] -column 10 -row $row -sticky e -pady 5
357 
358  switch $type {
359  text {
360  grid [entry .preferencesForm.text$row -width 20 -textvariable preferences_input($var)] -column 20 -row $row -sticky ew -columnspan 999
361  }
362  bool {
363  grid [checkbutton .preferencesForm.cb$row -variable preferences_input($var)] -row $row -column 20 -sticky w
364  }
365  font {
366  grid [ttk::combobox .preferencesForm.font -textvariable preferences_input($var) -values [lsort [listFonts]] -state readonly] -row $row -column 20 -sticky w
367  image create cairoSurface fontSampler -surface minsky.fontSampler
368  grid [label .preferencesForm.fontSample -image fontSampler -width 150 -height 20] -row $row -column 30 -sticky w
369  bind .preferencesForm.font <<ComboboxSelected>> {
370  defaultFont [.preferencesForm.font get]
371  fontSampler.requestRedraw
372  canvas.requestRedraw
373  }
374  }
375  default {
376  if {[llength $type] > 1} {
377  switch [lindex $type 0] {
378  enum {
379  set column 20
380  foreach {valtext val} [lrange $type 1 end] {
381  grid [radiobutton .preferencesForm.rb${row}v$column -text $valtext -variable preferences_input($var) -value $val] -row $row -column $column
382  incr column
383  }
384  }
385  }
386  } else { error "unknown preferences widget $type"}
387  }
388  }
389 
390  incr row 10
391  }
392 
393  set preferences(initial_focus) ".preferencesForm.cb$rowdict(Godley Table Show Values)"
394 
395  frame .preferencesForm.buttonBar
396  button .preferencesForm.buttonBar.ok -text OK -command {setPreferenceParms; closePreferencesForm; redrawAllGodleyTables}
397  button .preferencesForm.buttonBar.cancel -text cancel -command {closePreferencesForm}
398  pack .preferencesForm.buttonBar.ok [label .preferencesForm.buttonBar.spacer -width 2] .preferencesForm.buttonBar.cancel -side left -pady 10
399  grid .preferencesForm.buttonBar -column 1 -row 999 -columnspan 999
400 
401  bind .preferencesForm <Key-Return> {invokeOKorCancel .preferencesForm.buttonBar}
402 
403  wm title .preferencesForm "Preferences"
404 
405  deiconify .preferencesForm
406  update idletasks
407  ::tk::TabToWindow $preferences(initial_focus)
408  ensureWindowVisible .preferencesForm
409  grab set .preferencesForm
410  wm transient .preferencesForm .
411 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ simulate()

simulate

Definition at line 1311 of file minsky.tcl.

Referenced by runstop().

1311 proc simulate {} {
1312  uplevel #0 {
1313  if [running] {
1314  set d [expr int(pow(10,$delay/4.0))]
1315  after $d {
1316  if [running] {
1317  step
1318  simulate
1319  }
1320  }
1321  }
1322  }
1323 }
Here is the caller graph for this function:

◆ startRecording()

startRecording   filename  

Definition at line 1867 of file minsky.tcl.

References recentreCanvas().

Referenced by toggleRecording().

1867 proc startRecording {filename} {
1868  if {[string length $filename]>0} {
1869  minsky.startRecording $filename
1871  }
1872 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ step()

step

Definition at line 1289 of file minsky.tcl.

References runstop().

Referenced by minsky::VariableValue::incrSlider(), and runstop().

1289 proc step {} {
1290  global recordingReplay eventRecordR simTMax simTStart
1291  if {$recordingReplay} {
1292  if {[gets $eventRecordR cmd]>=0} {
1293  eval $cmd
1294  update
1295  } else {
1296  runstop
1297  }
1298  } else {
1299  # run simulation
1300  global preferences
1301  if {[catch minsky.step errMsg options] && [running]} {runstop}
1302  if {[minsky.t0]>[t] || [minsky.tmax]<[t]} {runstop}
1303  .controls.statusbar configure -text "t: [t] Δt: [format %g [deltaT]]"
1304  if $preferences(godleyDisplay) redrawAllGodleyTables
1305  update
1306  return -options $options $errMsg
1307  }
1308 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopRecording()

stopRecording

Definition at line 1874 of file minsky.tcl.

Referenced by replay(), reset(), and toggleRecording().

1874 proc stopRecording {} {
1875  minsky.stopRecording
1876 }
Here is the caller graph for this function:

◆ tabContext()

tabContext   x y X Y  

Definition at line 1003 of file minsky.tcl.

1003 proc tabContext {x y X Y} {
1004  switch [lindex [.tabs tabs] [.tabs index current]] {
1005  .variables {
1006  .variables.context delete 0 end
1007  set r [variableTab.rowY $y]
1008  switch [variableTab.clickType $x $y] {
1009  background {}
1010  internal {
1011  set varName [variableTab.getVarName $r]
1012  .variables.context add command -label "Remove $varName from tab" -command "variableTab.toggleVarDisplay $r; variableTab.requestRedraw"
1013  }
1014  }
1015  tk_popup .variables.context $X $Y
1016  }
1017  .plts {
1018  .plts.context delete 0 end
1019  if [getPlotTabItemAt $x $y] {
1020  .plts.context add command -label "Remove plot from tab" -command "plotTab.togglePlotDisplay; plotTab.requestRedraw"
1021  }
1022  tk_popup .plts.context $X $Y
1023  }
1024  }
1025 }

◆ tcl_exit()

tcl_exit   args  

Definition at line 141 of file minsky.tcl.

Referenced by exit().

141  proc tcl_exit {args} {
142  # disable coverage testing
143  proc traceProc {args} {}
144  cov.close
145  eval tcl_exit2 $args
146  }
Here is the caller graph for this function:

◆ textEntryPopup()

textEntryPopup   win init okproc  

Definition at line 944 of file minsky.tcl.

References buttonBar(), ensureWindowVisible(), and pack().

Referenced by renameIntegralInstances(), renameVariableInstances(), and textInput().

944 proc textEntryPopup {win init okproc} {
945  if {![winfo exists $win]} {
946  toplevel $win
947  entry $win.entry
948  pack $win.entry -side top -ipadx 50
949  buttonBar $win $okproc
950  } else {
951  wm deiconify $win
952  }
953  $win.entry delete 0 end
954  $win.entry insert 0 $init
955  wm transient $win
956  focus $win.entry
958  grab set $win
959 
960 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tk_focusNext()

tk_focusNext   win  

Definition at line 207 of file minsky.tcl.

207 proc tk_focusNext {win} {return $win}

◆ tk_focusPrev()

tk_focusPrev   win  

Definition at line 206 of file minsky.tcl.

206 proc tk_focusPrev {win} {return $win}

◆ toggleImplicitSolver()

toggleImplicitSolver

Definition at line 1514 of file minsky.tcl.

1514 proc toggleImplicitSolver {} {
1515  global implicitSolver
1516  implicit $implicitSolver
1517 }

◆ togglePaste()

togglePaste

Definition at line 739 of file minsky.tcl.

References getClipboard().

739 proc togglePaste {} {
740  if {[getClipboard]==""} {
741  .menubar.edit entryconfigure "Paste" -state disabled
742  } else {
743  .menubar.edit entryconfigure "Paste" -state normal
744  }
745 }
Here is the call graph for this function:

◆ toggleRecording()

toggleRecording

Definition at line 1878 of file minsky.tcl.

References startRecording(), and stopRecording().

1878 proc toggleRecording {} {
1879  global eventRecording workDir
1880  if $eventRecording {
1881  startRecording [tk_getSaveFile -filetypes {{"TCL scripts" .tcl TEXT} {"All Files" * }}\
1882  -defaultextension .tcl -initialdir $workDir]
1883  } else {
1885  }
1886 }
Here is the call graph for this function:

◆ topLevelHelp()

topLevelHelp

Definition at line 1652 of file minsky.tcl.

References helpFor().

1652 proc topLevelHelp {} {
1653  helpFor [winfo pointerx .] [winfo pointery .]
1654 }
Here is the call graph for this function:

◆ traceProc()

traceProc   args  

Definition at line 125 of file minsky.tcl.

125 proc traceProc {args} {
126  array set frameInfo [info frame -2]
127  if {[info exists frameInfo(proc)]&&[info exists frameInfo(line)]} {
128  cov.add $frameInfo(proc) $frameInfo(line)
129  }
130  if {[info exists frameInfo(file)]&&[info exists frameInfo(line)]} {
131  cov.add $frameInfo(file) $frameInfo(line)
132  }
133 }

◆ undo()

undo   delta  

Definition at line 747 of file minsky.tcl.

References deleteSubsidiaryTopLevels().

747 proc undo {delta} {
748  # do not record changes to state from the undo command
749  doPushHistory 0
750  minsky.undo $delta
751  minsky.canvas.requestRedraw
753  doPushHistory 1
754 }
Here is the call graph for this function:

◆ unknown()

unknown   procname args  

Definition at line 1818 of file minsky.tcl.

1818 proc unknown {procname args} {
1819  #delegate in case a getter hasn't correctly called its get
1820  global getters
1821  if [regexp ^wiringGroup\. $procname] {
1822  # delegate to minsky (ie global group)
1823  eval [regsub ^wiringGroup $procname minsky] $args
1824  } elseif [regexp ^([join $getters |])\. $procname] {
1825  eval wiringGroup.$procname $args
1826  } else {
1827  eval ecolab_unknown $procname $args
1828  }
1829 }

◆ value.value()

value.value   args  

Definition at line 105 of file minsky.tcl.

Referenced by editVar().

105 proc value.value {args} {
106  if [llength $args] {
107  return [minsky.value.value [lindex $args 0]]
108  } else {
109  return [minsky.value.value 0]
110  }
111 }
Here is the caller graph for this function:

◆ wrapHoverMouseTab()

wrapHoverMouseTab   tabId op x y  

Definition at line 996 of file minsky.tcl.

996 proc wrapHoverMouseTab {tabId op x y} {
997  after cancel hoverMouseTab $tabId
998  # ignore any exceptions
999  catch {$tabId.$op $x $y}
1000  after 3000 hoverMouseTab $tabId
1001 }