TextView.st
changeset 2836 de07d386cfe8
parent 2835 efe44fb65536
child 2846 41c2cefc6c4c
equal deleted inserted replaced
2835:efe44fb65536 2836:de07d386cfe8
    18 		clickCol clickCount expandingTop wordStartCol wordStartLine
    18 		clickCol clickCount expandingTop wordStartCol wordStartLine
    19 		wordEndCol wordEndLine selectionFgColor selectionBgColor
    19 		wordEndCol wordEndLine selectionFgColor selectionBgColor
    20 		selectStyle directoryForFileDialog defaultFileNameForFileDialog
    20 		selectStyle directoryForFileDialog defaultFileNameForFileDialog
    21 		externalEncoding contentsWasSaved searchAction lastSearchPattern
    21 		externalEncoding contentsWasSaved searchAction lastSearchPattern
    22 		lastSearchIgnoredCase lastSearchDirection
    22 		lastSearchIgnoredCase lastSearchDirection
    23 		parenthesisSpecification dropSource dragIsActive'
    23 		parenthesisSpecification dropSource dragIsActive saveAction'
    24 	classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor
    24 	classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor
    25 		DefaultSelectionBackgroundColor
    25 		DefaultSelectionBackgroundColor
    26 		DefaultAlternativeSelectionForegroundColor
    26 		DefaultAlternativeSelectionForegroundColor
    27 		DefaultAlternativeSelectionBackgroundColor MatchDelayTime
    27 		DefaultAlternativeSelectionBackgroundColor MatchDelayTime
    28 		WordSelectCatchesBlanks ST80Selections LastSearchPatterns
    28 		WordSelectCatchesBlanks ST80Selections LastSearchPatterns
   701     "set the dictionary which specifies which characters are opening, which are closing
   701     "set the dictionary which specifies which characters are opening, which are closing
   702      and which are ignored characters w.r.t. parenthesis matching.
   702      and which are ignored characters w.r.t. parenthesis matching.
   703      See the classes initialize method for a useful value."
   703      See the classes initialize method for a useful value."
   704 
   704 
   705     parenthesisSpecification := aDictionary
   705     parenthesisSpecification := aDictionary
       
   706 !
       
   707 
       
   708 saveAction:something
       
   709     saveAction := something.
   706 ! !
   710 ! !
   707 
   711 
   708 !TextView methodsFor:'accessing-contents'!
   712 !TextView methodsFor:'accessing-contents'!
   709 
   713 
   710 contents:newContents selected:selectedBoolean
   714 contents:newContents selected:selectedBoolean
  1497     "Modified: 22.1.1997 / 11:57:53 / cg"
  1501     "Modified: 22.1.1997 / 11:57:53 / cg"
  1498 !
  1502 !
  1499 
  1503 
  1500 initialize
  1504 initialize
  1501     super initialize.
  1505     super initialize.
       
  1506     self initializeSaveAction.
  1502     contentsWasSaved := false.
  1507     contentsWasSaved := false.
  1503     dragIsActive     := false.
  1508     dragIsActive     := false.
  1504 
  1509 
  1505     parenthesisSpecification isNil ifTrue:[
  1510     parenthesisSpecification isNil ifTrue:[
  1506         parenthesisSpecification := DefaultParenthesisSpecification.
  1511         parenthesisSpecification := DefaultParenthesisSpecification.
  1509     "I handle menus myself"
  1514     "I handle menus myself"
  1510     menuHolder := menuPerformer := self.
  1515     menuHolder := menuPerformer := self.
  1511 
  1516 
  1512     "/ on default allow drag
  1517     "/ on default allow drag
  1513     self allowDrag:true.
  1518     self allowDrag:true.
       
  1519 !
       
  1520 
       
  1521 initializeSaveAction
       
  1522     saveAction := [ self openSaveDialog ]
  1514 ! !
  1523 ! !
  1515 
  1524 
  1516 !TextView methodsFor:'menu actions'!
  1525 !TextView methodsFor:'menu actions'!
  1517 
  1526 
  1518 appendTo:aFileName
  1527 appendTo:aFileName
  1687     ].
  1696     ].
  1688 
  1697 
  1689     "Modified: / 17.5.1998 / 20:07:59 / cg"
  1698     "Modified: / 17.5.1998 / 20:07:59 / cg"
  1690 !
  1699 !
  1691 
  1700 
  1692 save
  1701 openSaveDialog
  1693     "save contents into a file 
  1702     "Ask user for filename using a fileSelectionBox
  1694      - ask user for filename using a fileSelectionBox."
  1703      and save contents into that file."
  1695 
  1704 
  1696     Dialog
  1705     Dialog
  1697         requestSaveFileName:(resources string:'Save contents in:') 
  1706         requestSaveFileName:(resources string:'Save contents in:') 
  1698         default:defaultFileNameForFileDialog 
  1707         default:defaultFileNameForFileDialog 
  1699         fromDirectory:directoryForFileDialog 
  1708         fromDirectory:directoryForFileDialog 
  1700         action:[:fileName | self saveAs:fileName] 
  1709         action:[:fileName | self saveAs:fileName] 
  1701         appendAction:[:fileName | self appendTo:fileName]
  1710         appendAction:[:fileName | self appendTo:fileName]
  1702 
  1711 !
  1703 "/    |fileBox fileName|
  1712 
  1704 "/
  1713 save
  1705 "/true ifTrue:[
  1714     "save contents into a file 
  1706 "/    fileName := FileDialog 
  1715      - ask user for filename using a fileSelectionBox."
  1707 "/                    requestFileName:(resources string:'Save contents in:') 
  1716 
  1708 "/                    default:(defaultFileNameForFileDialog ifNotNil:[defaultFileNameForFileDialog asString])
  1717     saveAction notNil ifTrue:[
  1709 "/                    ok:(resources string:'Save') 
  1718         saveAction value
  1710 "/                    abort:nil 
  1719     ]
  1711 "/                    version:nil 
       
  1712 "/                    ifFail:nil 
       
  1713 "/                    pattern:nil 
       
  1714 "/                    fromDirectory:directoryForFileDialog 
       
  1715 "/                    whenBoxCreatedEvaluate:[:dialog | dialog appendButtonVisibleHolder value:true].
       
  1716 "/
       
  1717 "/    fileName size > 0 ifTrue:[
       
  1718 "/self halt.
       
  1719 "/        self saveAs:fileName.    
       
  1720 "/    ].
       
  1721 "/    ^ self.
       
  1722 "/].
       
  1723 "/    fileBox := FileSaveBox
       
  1724 "/                    title:(resources string:'Save contents in:')
       
  1725 "/                    okText:(resources string:'Save')
       
  1726 "/                    abortText:(resources string:'Cancel')
       
  1727 "/                    action:[:fileName | self saveAs:fileName].
       
  1728 "/    fileBox appendAction:[:fileName | self appendTo:fileName].
       
  1729 "/    directoryForFileDialog notNil ifTrue:[
       
  1730 "/        fileBox directory:directoryForFileDialog
       
  1731 "/    ].
       
  1732 "/    defaultFileNameForFileDialog notNil ifTrue:[
       
  1733 "/        fileBox initialText:defaultFileNameForFileDialog asString
       
  1734 "/    ].
       
  1735 "/    fileBox showAtPointer.
       
  1736 "/
       
  1737 "/    directoryForFileDialog := fileBox directory.  "/ remember for next time
       
  1738 "/
       
  1739 "/    fileBox destroy.
       
  1740 "/
       
  1741 "/    "Modified: 16.4.1997 / 20:49:26 / cg"
       
  1742 !
  1720 !
  1743 
  1721 
  1744 saveAs:fileName
  1722 saveAs:fileName
  1745     "save the contents into a file named fileName"
  1723     "save the contents into a file named fileName"
  1746  
  1724  
  3732 ! !
  3710 ! !
  3733 
  3711 
  3734 !TextView class methodsFor:'documentation'!
  3712 !TextView class methodsFor:'documentation'!
  3735 
  3713 
  3736 version
  3714 version
  3737     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.221 2004-01-14 16:04:21 cg Exp $'
  3715     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.222 2004-01-14 17:02:40 cg Exp $'
  3738 ! !
  3716 ! !
  3739 
  3717 
  3740 TextView initialize!
  3718 TextView initialize!