- Timestamp:
- Dec 4, 2009 5:09:43 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/browsecif.tcl
- Property rcs:date changed from 2002/09/05 18:24:04 to 2002/09/05 21:03:37
- Property rcs:lines changed from +151 -41 to +313 -122
- Property rcs:rev changed from 1.2 to 1.3
r646 r650 1 #!/usr/bin/wish2 1 # $Id$ 3 2 … … 433 432 434 433 434 set CIF(undolist) {} 435 set CIF(redolist) {} 435 436 set pos 1.0 436 437 set blocks 0 … … 712 713 eval $CIF(tree) delete [$CIF(tree) nodes root] 713 714 catch {unset CIFtreeindex} 714 pack forget $CIF( EditSaveButton) $CIF(AddtoLoopButton) \715 pack forget $CIF(AddtoLoopButton) \ 715 716 $CIF(LoopSpinBox) $CIF(DeleteLoopEntry) 716 717 # delete old contents of frame 717 718 set frame [$CIF(displayFrame) getframe] 718 719 eval destroy [grid slaves $frame] 720 set CIF(widgetlist) {} 719 721 # reset the scrollbars 720 722 $CIF(tree) see 0 … … 735 737 if {[lsearch $selected $n] != -1} {set open 1} 736 738 $CIF(tree) insert end root block$n -text "_data_$blockname" \ 737 -open $open -image [Bitmap::get copy]739 -open $open -image [Bitmap::get folder] 738 740 739 741 # show errors, if any … … 747 749 if {[lsearch $looplist $name] == -1} { 748 750 $CIF(tree) insert end block$n [incr num] -text $name \ 749 -image [Bitmap::get f older] -data block$n751 -image [Bitmap::get file] -data block$n 750 752 set CIFtreeindex(block${n}$name) $num 751 753 } … … 767 769 $CIF(tree) insert end block$n block${n}$loop \ 768 770 -text "$loop ($catlist)" \ 769 -image [Bitmap::get file] -data "block$n loop"771 -image [Bitmap::get copy] -data "block$n loop" 770 772 set CIFtreeindex(block${n}$loop) block${n}$loop 771 773 foreach name [lsort [set block${n}($loop)]] { 772 774 $CIF(tree) insert end block${n}$loop [incr num] -text $name \ 773 -image [Bitmap::get f older] -data "block$n $loop"775 -image [Bitmap::get file] -data "block$n $loop" 774 776 set CIFtreeindex(block${n}$name) $num 775 777 } … … 826 828 827 829 pack [frame $pane.f] -fill x 828 set CIF(EditSaveButton) [button $pane.f.b -text "Save Changes" -state disabled \829 -command "SaveCIFedits"]830 830 set CIF(AddtoLoopButton) [button $pane.f.l -text "Add to loop"] 831 831 set CIF(DeleteLoopEntry) [button $pane.f.d -text "Delete loop entry" \ … … 840 840 # Warn to save changes that are not saved in a file 841 841 proc CheckForCIFEdits {} { 842 #puts "CheckForCIFEdits [info level [expr [info level]-1]]" 842 843 global CIF 843 if {$CIF(entry_changed) != ""} { 844 set ans [MyMessageBox -parent . -title "Discard Changes?" \ 845 -message "You have changed this entry. Do you want to keep or discard this edit?" \ 846 -icon question -type {Save Discard} -default Save] 847 if {$ans == "save"} { 848 SaveCIFedits 849 # did this save anything? 850 if {$CIF(entry_changed) != ""} { 851 # if not, don't allow the mode/loop value to change 852 set CIF(editmode) 1 853 catch { 854 $CIF(LoopSpinBox) setvalue @$CIF(lastLoopIndex) 855 } 856 return 1 857 } 858 } else { 859 set CIF(entry_changed) {} 860 $CIF(EditSaveButton) config -state disabled 844 set errorlist {} 845 set errorflag 0 846 set msg "The following edits cannot be saved due to errors:\n" 847 foreach widget $CIF(widgetlist) { 848 CheckChanges $widget 1 849 if {$CIF(errormsg) != ""} { 850 set errorflag 1 851 foreach err $CIF(errormsg) { 852 append msg " " $err \n 853 } 854 } 855 856 } 857 if {$errorflag} { 858 append msg \n {Do you want to make corrections, or discard these edits?} 859 set ans [MyMessageBox -parent . -title "Invalid edits" \ 860 -message $msg -icon error -type "Correct Discard" \ 861 -default correct] 862 if {$ans == "correct"} { 863 # if not, don't allow the mode/loop value to change 864 set CIF(editmode) 1 865 catch { 866 $CIF(LoopSpinBox) setvalue @$CIF(lastLoopIndex) 867 } 868 return 1 861 869 } 862 870 } … … 867 875 # shows the contents data name or a loop 868 876 proc showCIFbyTreeID {name} { 877 if {[CheckForCIFEdits]} return 878 869 879 global CIF 870 if {[CheckForCIFEdits]} return871 880 set pointer [$CIF(tree) itemcget $name -data] 872 881 set dataname [lindex [$CIF(tree) itemcget $name -text] 0] 882 set CIF(lastShownTreeID) $name 873 883 showCIFbyDataname $pointer $dataname 874 884 } 875 885 876 886 proc showCIFbyDataname {pointer dataname "loopindex {}"} { 877 if {[CheckForCIFEdits]} return 878 global CIF 887 global CIF CIFtreeindex 879 888 set CIF(lastShownItem) [list $pointer $dataname] 880 # include a save button881 if {$CIF(editmode)} {882 pack $CIF(EditSaveButton) -side left883 } else {884 pack forget $CIF(EditSaveButton)885 }886 889 pack forget $CIF(AddtoLoopButton) $CIF(LoopSpinBox) $CIF(DeleteLoopEntry) 887 890 … … 915 918 # get number of elements for first name 916 919 set names [llength [set ${block}([lindex $looplist 0])]] 920 # can't delete the only entry 921 if {$names == 1 && $CIF(editmode)} { 922 $CIF(DeleteLoopEntry) configure -state disabled 923 } else { 924 $CIF(DeleteLoopEntry) configure -state normal 925 } 917 926 $CIF(LoopSpinBox) configure -range "1 $names 1" \ 918 927 -command "ShowLoopVar ${block} $dataname" \ 919 928 -modifycmd "ShowLoopVar ${block} $dataname" 929 set CIF(lastLoopIndex) {} 920 930 if {$loopindex == ""} { 921 931 $CIF(LoopSpinBox) setvalue first … … 946 956 set frame0 [$frame.0 getframe] 947 957 grid columnconfig $frame0 2 -weight 1 958 if {[set l [llength [set ${block}($dataname)]]] > 100} { 959 grid [label $frame0.a$i -justify left \ 960 -text "$dataname has $l entries, too many to display by column" \ 961 ] -sticky w -column 0 -row $i 962 return 963 } 948 964 foreach mark [set ${block}($dataname)] { 949 965 incr i … … 981 997 proc RepeatLastshowCIFvalue {} { 982 998 global CIF 999 if {[CheckForCIFEdits]} return 1000 set lastLoopIndex $CIF(lastLoopIndex) 1001 983 1002 catch { 984 1003 eval showCIFbyDataname $CIF(lastShownItem) 1004 # if we are in a loop, display the element 1005 if {[lindex [lindex $CIF(lastShownItem) 0] 1] == "loop"} { 1006 $CIF(LoopSpinBox) setvalue @$lastLoopIndex 1007 ShowLoopVar [lindex [lindex $CIF(lastShownItem) 0] 0] \ 1008 [lindex $CIF(lastShownItem) 1] 1009 } 1010 985 1011 } 986 1012 } … … 991 1017 global $array CIF 992 1018 # check for unsaved changes here 993 if {[CheckForCIFEdits]} return 1019 if {$CIF(lastLoopIndex) != ""} { 1020 if {[CheckForCIFEdits]} return 1021 } 994 1022 995 1023 set looplist [set ${array}($loop)] … … 1029 1057 } 1030 1058 set CIFinfoArr($widget) [lreplace $CIFinfoArr($widget) 2 2 $index] 1031 $CIF(EditSaveButton) config -state disabled1032 1059 } else { 1033 1060 [$frame.$i getframe].l config -text $value … … 1325 1352 set v $item 1326 1353 # remove s.u., if allowed & present 1354 set vals [ParseSU $item] 1355 if {[set v [lindex $vals 0]] == "."} { 1356 return "error: value $item is not a valid number for $dataname" 1357 } 1327 1358 if {$esd} { 1328 regsub {\([0-9]+\)} $v {} v 1329 } 1330 if [catch {expr $v}] {return "error: value $item is not a valid number for $dataname"} 1359 if {[lindex $vals 1] == "."} { 1360 return "error: value $item for $dataname has an invalid uncertainty (esd)" 1361 } 1362 } elseif {[llength $vals] == 2} { 1363 return "error: $item is invalid for $dataname, an uncertainty (esd) is not allowed" 1364 } 1365 1366 # now validate the range 1331 1367 if {$range != ""} { 1332 1368 # is there a decimal point in the range? … … 1340 1376 if {$min != ""} { 1341 1377 if {$v < $min} { 1342 return "error: value $item is too small for $dataname "1378 return "error: value $item is too small for $dataname (allowed range $range)" 1343 1379 } 1344 1380 } 1345 1381 if {$max != ""} { 1346 1382 if {$v > $max} { 1347 return "error: value $item is too big for $dataname "1383 return "error: value $item is too big for $dataname(allowed range $range)" 1348 1384 } 1349 1385 } 1350 1386 } 1351 1387 } 1388 return {} 1352 1389 } 1353 1390 … … 1387 1424 1388 1425 lappend CIF(widgetlist) $widget 1426 set CIFinfoArr($widget) {} 1389 1427 1390 1428 if $CIF(editmode) { … … 1394 1432 set widgetinfo [list $dataname $block 0] 1395 1433 } 1434 set CIFeditArr($widget) $value 1435 set CIFinfoArr($widget) $widgetinfo 1436 1396 1437 if {$type == "n"} { 1397 set CIFeditArr($widget) $value1398 set CIFinfoArr($widget) $widgetinfo1399 1438 entry $widget -justify left -textvariable CIFeditArr($widget) 1400 1439 bind $widget <Leave> "CheckChanges $widget" … … 1406 1445 } 1407 1446 } elseif {$elist != ""} { 1408 set CIFeditArr($widget) $value1409 set CIFinfoArr($widget) $widgetinfo1410 1447 set enum {} 1411 1448 foreach e $elist { … … 1429 1466 $widget insert end $value 1430 1467 bind $widget <Leave> "CheckChanges $widget" 1431 set CIFeditArr($widget) $value1432 set CIFinfoArr($widget) $widgetinfo1433 1468 if {$nlines > 1} { 1434 1469 grid $ws -sticky nsew -column 1 -row $row … … 1451 1486 1452 1487 # this is called to see if the user has changed the value for a CIF 1453 # data item. If the value has changed, the "Save Changes" button is 1454 # made active. 1455 proc CheckChanges {widget} { 1488 # data item and to validate it. 1489 # save the change if $save is 1 1490 # return 1 if the widget contents has changed 1491 proc CheckChanges {widget "save 0"} { 1456 1492 global CIFeditArr CIFinfoArr CIF 1457 foreach {dataname block index} $CIFinfoArr($widget) {} 1493 1494 set CIF(errormsg) {} 1495 1496 if {![winfo exists $widget]} return 1497 1498 set dataname {} 1499 catch { 1500 foreach {dataname block index} $CIFinfoArr($widget) {} 1501 } 1502 # if this widget is a label, the info above will not be defined & checks are not needed 1503 if {$dataname == ""} {return 0} 1504 1458 1505 global ${block} 1459 1506 set mark [lindex [set ${block}($dataname)] $index] 1460 set orig [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1507 if {$mark == ""} return 1508 set orig [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1509 1510 # validate the entry 1511 set error {} 1461 1512 set err {} 1462 1513 switch [winfo class $widget] { 1463 1514 Text { 1464 set current [ $widget get 1.0 end]1515 set current [string trim [$widget get 1.0 end]] 1465 1516 set l 0 1466 1517 foreach line [set linelist [split $current \n]] { 1467 1518 incr l 1468 if {[string length $line] > 80} {lappend err $l} 1519 if {[string length $line] > 80} { 1520 lappend err $l 1521 lappend error "Error: line $l for $dataname is >80 characters" 1522 } 1469 1523 } 1470 1524 if {$err != ""} { … … 1474 1528 $widget tag config error -foreground red 1475 1529 } else { 1476 $widget tag delete error 1530 $widget tag delete error 1477 1531 } 1478 1532 # see if box should expand … … 1500 1554 if {$err != "" && \ 1501 1555 [string tolower [lindex $err 0]] != "warning:"} { 1556 lappend error $err 1502 1557 $widget config -fg red 1503 1558 } else { … … 1508 1563 set current $CIFeditArr($widget) 1509 1564 } 1565 Label { 1566 return 0 1567 } 1510 1568 } 1511 1569 if {[string trim $orig] != [string trim $current]} { 1512 if {$CIF(autosave_edits) && $err == ""} { 1513 lappend CIF(entry_changed) $widget 1514 SaveCIFedits 1515 return 1516 } 1517 if {[string first $widget $CIF(entry_changed)] == -1} { 1518 lappend CIF(entry_changed) $widget 1519 } 1520 $CIF(EditSaveButton) config -state normal 1521 } 1570 if {$err != ""} { 1571 set CIF(errormsg) $error 1572 } elseif {$save} { 1573 SaveCIFedits $widget 1574 return 0 1575 } 1576 return 1 1577 } 1578 return 0 1522 1579 } 1523 1580 1524 1581 # save the CIF edits into the CIF text widget 1525 proc SaveCIFedits { } {1582 proc SaveCIFedits {widget} { 1526 1583 global CIFeditArr CIFinfoArr CIF 1527 # validate the entries 1528 set error {} 1529 foreach widget $CIF(entry_changed) { 1530 foreach {dataname block index} $CIFinfoArr($widget) {} 1531 global ${block} 1532 set mark [lindex [set ${block}($dataname)] $index] 1533 set orig [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1534 switch [winfo class $widget] { 1535 Text { 1536 set current [$widget get 1.0 end] 1537 set l 0 1538 foreach line [split $current \n] { 1539 incr l 1540 if {[string length $line] > 80} { 1541 lappend error "Error: line $l for $dataname is >80 characters" 1542 } 1543 } 1544 } 1545 Entry { 1546 set current [string trim [$widget get]] 1547 set err [ValidateCIFItem [lindex $CIFinfoArr($widget) 0] $current] 1548 if {$err != "" && [lindex $err 0] != "warning:"} { 1549 lappend error $err 1550 } 1551 } 1552 } 1553 } 1554 if {$error != ""} { 1555 set msg "The attempted changes cannot be saved due to:\n" 1556 foreach err $error { 1557 append msg " " $err \n 1558 } 1559 append msg \n {Please correct and then press "Save Changes"} 1560 MyMessageBox -parent . -title "Invalid Changes?" \ 1561 -message $msg -icon error -type Continue -default continue 1562 return 1563 } 1564 foreach widget $CIF(entry_changed) { 1565 foreach {dataname block index} $CIFinfoArr($widget) {} 1566 global ${block} 1567 set mark [lindex [set ${block}($dataname)] $index] 1568 switch [winfo class $widget] { 1569 Text { 1570 set value [string trim [$widget get 1.0 end]] 1571 } 1572 Entry { 1573 set value [string trim [$widget get]] 1574 } 1575 Menubutton { 1576 set value $CIFeditArr($widget) 1577 } 1578 } 1579 ReplaceMarkedText $CIF(txt) $mark $value 1580 incr CIF(changes) 1581 } 1582 set CIF(entry_changed) {} 1583 $CIF(EditSaveButton) config -state disabled 1584 pack $CIF(EditSaveButton) -side left 1584 1585 foreach {dataname block index} $CIFinfoArr($widget) {} 1586 global ${block} 1587 set mark [lindex [set ${block}($dataname)] $index] 1588 set orig [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1589 switch [winfo class $widget] { 1590 Text { 1591 set current [string trim [$widget get 1.0 end]] 1592 } 1593 Entry { 1594 set current [string trim [$widget get]] 1595 } 1596 Menubutton { 1597 set current $CIFeditArr($widget) 1598 } 1599 } 1600 # save for undo & clear the redo list 1601 set CIF(redolist) {} 1602 if {[lindex [lindex $CIF(lastShownItem) 0] 1] == "loop"} { 1603 lappend CIF(undolist) [list $mark $orig \ 1604 $CIF(lastShownItem) $CIF(lastShownTreeID) $CIF(lastLoopIndex)] 1605 } else { 1606 lappend CIF(undolist) [list $mark $orig \ 1607 $CIF(lastShownItem) $CIF(lastShownTreeID)] 1608 } 1609 # count it 1610 incr CIF(changes) 1611 # make the change 1612 ReplaceMarkedText $CIF(txt) $mark $current 1585 1613 } 1586 1614 … … 1602 1630 set epos $line.0 1603 1631 $CIF(txt) insert $epos \n 1632 1604 1633 # insert a ? token for each entry & add to marker list for each variable 1634 set addlist {} 1605 1635 foreach var $looplist { 1606 incr CIF(changes)1607 1636 # go to next line? 1608 1637 if {[string length \ … … 1619 1648 $CIF(txt) mark gravity $CIF(markcount).r right 1620 1649 set epos [$CIF(txt) index "$epos + 2c"] 1650 set index [llength [set ${block}($var)]] 1621 1651 lappend ${block}($var) $CIF(markcount) 1622 } 1652 lappend addlist [list $CIF(markcount) $var $index $block] 1653 } 1654 incr CIF(changes) 1655 lappend CIF(undolist) [list "loop add" $addlist \ 1656 $CIF(lastShownItem) $CIF(lastShownTreeID) $CIF(lastLoopIndex)] 1657 set CIF(redolist) {} 1658 1623 1659 # now show the value we have added 1624 1660 set frame [$CIF(displayFrame) getframe] … … 1629 1665 ShowLoopVar $block $loop 1630 1666 $CIF(txt) configure -state disabled 1667 $CIF(DeleteLoopEntry) configure -state normal 1631 1668 } 1632 1669 … … 1675 1712 1676 1713 $CIF(txt) configure -state normal 1714 set deletelist {} 1677 1715 foreach widget $CIF(widgetlist) { 1678 1716 foreach {dataname block index} $CIFinfoArr($widget) {} 1679 1717 global $block 1680 1718 set mark [lindex [set ${block}($dataname)] $index] 1719 set orig [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1720 lappend deletelist [list $mark $dataname $index $block $orig] 1681 1721 $CIF(txt) delete $mark.l $mark.r 1682 1722 set ${block}($dataname) [lreplace [set ${block}($dataname)] $index $index] 1683 1723 } 1724 set CIF(redolist) {} 1725 lappend CIF(undolist) [list "loop delete" $deletelist \ 1726 $CIF(lastShownItem) $CIF(lastShownTreeID) $CIF(lastLoopIndex)] 1727 # count it 1728 incr CIF(changes) 1729 1684 1730 $CIF(txt) configure -state disabled 1685 1731 … … 1687 1733 incr max -1 1688 1734 $CIF(LoopSpinBox) configure -range "1 $max 1" 1689 $CIF(LoopSpinBox) setvalue last 1735 if {$index >= $max} {set index $max; incr index -1} 1736 $CIF(LoopSpinBox) setvalue @$index 1737 if {$max == 1} {$CIF(DeleteLoopEntry) configure -state disabled} 1738 # don't check for changes 1739 set CIF(lastLoopIndex) {} 1740 ShowLoopVar $block [lindex $CIF(lastShownItem) 1] 1690 1741 } 1691 1742 … … 1716 1767 } 1717 1768 1769 proc UndoChanges {} { 1770 global CIF 1771 # save any current changes, if possible 1772 if {[CheckForCIFEdits]} return 1773 # are there edits to undo? 1774 if {[llength $CIF(undolist)] == 0} return 1775 1776 foreach {mark orig lastShownItem lastShownTreeID lastLoopIndex} \ 1777 [lindex $CIF(undolist) end] {} 1778 1779 if {[llength $mark] == 1} { 1780 # get the edited value 1781 set edited [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1782 # make the change back 1783 ReplaceMarkedText $CIF(txt) $mark $orig 1784 # add this undo to the redo list 1785 lappend CIF(redolist) [list $mark $edited $lastShownItem \ 1786 $lastShownTreeID $lastLoopIndex] 1787 } elseif {[lindex $mark 1] == "add"} { 1788 set deletelist {} 1789 $CIF(txt) configure -state normal 1790 foreach m $orig { 1791 foreach {mark dataname index block} $m {} 1792 # get the inserted value 1793 set edited [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1794 $CIF(txt) delete $mark.l $mark.r 1795 lappend deletelist [list $mark $dataname $index $block $edited] 1796 global $block 1797 set ${block}($dataname) [lreplace [set ${block}($dataname)] $index $index] 1798 } 1799 $CIF(txt) configure -state disabled 1800 # add this action to the redo list 1801 lappend CIF(redolist) [list "loop delete" $deletelist \ 1802 $lastShownItem $lastShownTreeID $lastLoopIndex] 1803 } elseif {[lindex $mark 1] == "delete"} { 1804 set addlist {} 1805 foreach m $orig { 1806 foreach {mark dataname index block orig} $m {} 1807 # make the change back 1808 ReplaceMarkedText $CIF(txt) $mark $orig 1809 lappend addlist [list $mark $dataname $index $block] 1810 global $block 1811 set ${block}($dataname) [linsert [set ${block}($dataname)] $index $mark] 1812 } 1813 # show the entry that was added 1814 set lastLoopIndex $index 1815 # add this last entry to the redo list 1816 lappend CIF(redolist) [list "loop add" $addlist \ 1817 $lastShownItem $lastShownTreeID $lastLoopIndex] 1818 } 1819 1820 # drop the action from the undo list 1821 set CIF(undolist) [lreplace $CIF(undolist) end end] 1822 # count back 1823 incr CIF(changes) -1 1824 # scroll on the tree 1825 $CIF(tree) see $lastShownTreeID 1826 eval showCIFbyDataname $lastShownItem 1827 1828 # if we are in a loop, display the element 1829 if {[lindex [lindex $lastShownItem 0] 1] == "loop"} { 1830 $CIF(LoopSpinBox) setvalue @$lastLoopIndex 1831 ShowLoopVar [lindex [lindex $lastShownItem 0] 0] \ 1832 [lindex $lastShownItem 1] 1833 } 1834 } 1835 1836 1837 proc RedoChanges {} { 1838 global CIF 1839 # save any current changes, if possible 1840 if {[CheckForCIFEdits]} return 1841 # are there edits to redo? 1842 if {[llength $CIF(redolist)] == 0} return 1843 1844 foreach {mark edited lastShownItem lastShownTreeID lastLoopIndex} \ 1845 [lindex $CIF(redolist) end] {} 1846 1847 if {[llength $mark] == 1} { 1848 # get the edited value 1849 set orig [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1850 # make the change back 1851 ReplaceMarkedText $CIF(txt) $mark $edited 1852 # add this action back to the undo list 1853 lappend CIF(undolist) [list $mark $orig $lastShownItem \ 1854 $lastShownTreeID $lastLoopIndex] 1855 # count up 1856 incr CIF(changes) 1857 } elseif {[lindex $mark 1] == "add"} { 1858 set deletelist {} 1859 $CIF(txt) configure -state normal 1860 foreach m $edited { 1861 foreach {mark dataname index block} $m {} 1862 # get the inserted value 1863 set edited [StripQuotes [$CIF(txt) get $mark.l $mark.r]] 1864 $CIF(txt) delete $mark.l $mark.r 1865 lappend deletelist [list $mark $dataname $index $block $edited] 1866 global $block 1867 set ${block}($dataname) [lreplace [set ${block}($dataname)] $index $index] 1868 } 1869 $CIF(txt) configure -state disabled 1870 # add this action back to the undo list 1871 lappend CIF(undolist) [list "loop delete" $deletelist \ 1872 $lastShownItem $lastShownTreeID $lastLoopIndex] 1873 # count up 1874 incr CIF(changes) 1875 } elseif {[lindex $mark 1] == "delete"} { 1876 set addlist {} 1877 foreach m $edited { 1878 foreach {mark dataname index block orig} $m {} 1879 # make the change back 1880 ReplaceMarkedText $CIF(txt) $mark $orig 1881 lappend addlist [list $mark $dataname $index $block] 1882 global $block 1883 set ${block}($dataname) [linsert [set ${block}($dataname)] $index $mark] 1884 } 1885 # show the entry that was added 1886 set lastLoopIndex $index 1887 # add this action back to the undo list 1888 lappend CIF(undolist) [list "loop add" $addlist \ 1889 $lastShownItem $lastShownTreeID $lastLoopIndex] 1890 # count up 1891 incr CIF(changes) 1892 } 1893 1894 # drop the action from the redo list 1895 set CIF(redolist) [lreplace $CIF(redolist) end end] 1896 # scroll on the tree 1897 $CIF(tree) see $lastShownTreeID 1898 eval showCIFbyDataname $lastShownItem 1899 1900 # if we are in a loop, display the element 1901 if {[lindex [lindex $lastShownItem 0] 1] == "loop"} { 1902 $CIF(LoopSpinBox) setvalue @$lastLoopIndex 1903 ShowLoopVar [lindex [lindex $lastShownItem 0] 0] \ 1904 [lindex $lastShownItem 1] 1905 } 1906 } 1907 1718 1908 # initialize misc variables 1719 set CIF(entry_changed) {}1720 1909 set CIF(changes) 0 1721 1910 set CIF(widgetlist) {} 1722 1911 set CIF(lastShownItem) {} 1723 1912 set CIF(lastLoopIndex) {} 1724 set CIF(autosave_edits) 01725 1913 set CIF(editmode) 0 1914 set CIF(undolist) {} 1915 set CIF(redolist) {} 1916 set CIF(treeSelectedList) {}
Note: See TracChangeset
for help on using the changeset viewer.