TextView.st
changeset 3417 44c33c650dc0
parent 3399 c350a2e3efee
child 3426 bbcad86d26a8
equal deleted inserted replaced
3416:02d209269ec3 3417:44c33c650dc0
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
       
    13 "{ Package: 'stx:libwidg' }"
    12 "{ Package: 'stx:libwidg' }"
    14 
    13 
    15 ListView subclass:#TextView
    14 ListView subclass:#TextView
    16 	instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine
    15 	instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine
    17 		selectionEndCol clickPos clickStartLine clickStartCol clickLine
    16 		selectionEndCol clickPos clickStartLine clickStartCol clickLine
   554 !
   553 !
   555 
   554 
   556 setupForFile:aFileName
   555 setupForFile:aFileName
   557     "setup a textView on a file; return the textView"
   556     "setup a textView on a file; return the textView"
   558 
   557 
   559     |top textView f|
   558     |textView f|
   560 
   559 
   561     textView := self setupEmpty.
   560     textView := self setupEmpty.
   562     top := textView topView.
       
   563     aFileName notNil ifTrue:[
   561     aFileName notNil ifTrue:[
   564         f := aFileName asFilename.
   562         textView setupForFile:aFileName.
   565         top label:(f baseName).
       
   566         textView contents:(f contents).
       
   567     ].
   563     ].
   568 
   564 
   569     ^ textView
   565     ^ textView
   570 
   566 
   571     "Created: 14.2.1997 / 15:21:43 / cg"
   567     "Created: / 14-02-1997 / 15:21:43 / cg"
       
   568     "Modified: / 25-10-2006 / 14:46:54 / cg"
   572 !
   569 !
   573 
   570 
   574 setupForModel:aModel
   571 setupForModel:aModel
   575     "setup a textView on a model; return the textView"
   572     "setup a textView on a model; return the textView"
   576 
   573 
   784 !
   781 !
   785 
   782 
   786 fromFile:aFileName
   783 fromFile:aFileName
   787     "take contents from a named file"
   784     "take contents from a named file"
   788 
   785 
   789     |f|
   786     self obsoleteMethodWarning.
   790 
   787     ^ self loadTextFile:aFileName.
   791     f := aFileName asFilename.
   788 
   792     self directoryForFileDialog:(f directoryName).
   789     "Modified: / 25-10-2006 / 14:47:35 / cg"
   793     self contents:(f contents)
       
   794 !
   790 !
   795 
   791 
   796 list:something
   792 list:something
   797     "set the displayed contents (a collection of strings)
   793     "set the displayed contents (a collection of strings)
   798      with redraw.
   794      with redraw.
   800 
   796 
   801     self unselect.
   797     self unselect.
   802     super list:something
   798     super list:something
   803 
   799 
   804     "Modified: 29.4.1996 / 12:13:24 / cg"
   800     "Modified: 29.4.1996 / 12:13:24 / cg"
       
   801 !
       
   802 
       
   803 loadTextFile:aFileName
       
   804     "take contents from a named file"
       
   805 
       
   806     |f|
       
   807 
       
   808     f := aFileName asFilename.
       
   809     self directoryForFileDialog:(f directoryName).
       
   810     self contents:(f contents)
       
   811 
       
   812     "Created: / 25-10-2006 / 14:44:01 / cg"
   805 !
   813 !
   806 
   814 
   807 setContents:something
   815 setContents:something
   808     "set the contents (either a string or a Collection of strings)
   816     "set the contents (either a string or a Collection of strings)
   809      dont change the position (i.e. do not scroll) or the selection."
   817      dont change the position (i.e. do not scroll) or the selection."
   834      without redraw.
   842      without redraw.
   835      Redefined since changing contents implies deselect"
   843      Redefined since changing contents implies deselect"
   836 
   844 
   837     self unselect.
   845     self unselect.
   838     super setList:something
   846     super setList:something
       
   847 !
       
   848 
       
   849 setupForFile:aFileName
       
   850     "take contents from a named file"
       
   851 
       
   852     |baseName|
       
   853 
       
   854     self loadTextFile:aFileName.
       
   855     aFileName notNil ifTrue:[
       
   856         baseName := aFileName asFilename baseName.
       
   857         self topView label:baseName.
       
   858         self defaultFileNameForFileDialog:baseName.
       
   859     ].
       
   860 
       
   861     "Created: / 25-10-2006 / 14:47:13 / cg"
   839 !
   862 !
   840 
   863 
   841 text
   864 text
   842     "for ST80 compatibility"
   865     "for ST80 compatibility"
   843 
   866 
  3895 ! !
  3918 ! !
  3896 
  3919 
  3897 !TextView class methodsFor:'documentation'!
  3920 !TextView class methodsFor:'documentation'!
  3898 
  3921 
  3899 version
  3922 version
  3900     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.272 2006-09-21 14:53:38 cg Exp $'
  3923     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.273 2006-10-25 13:03:09 cg Exp $'
  3901 ! !
  3924 ! !
  3902 
  3925 
  3903 TextView initialize!
  3926 TextView initialize!