ListView.st
changeset 6186 f0026b792a12
parent 6179 85ed7184791d
child 6213 19e9bfd31785
equal deleted inserted replaced
6185:11a10868443b 6186:f0026b792a12
   837 
   837 
   838     "Modified: / 25-07-2012 / 12:00:54 / cg"
   838     "Modified: / 25-07-2012 / 12:00:54 / cg"
   839 !
   839 !
   840 
   840 
   841 at:lineNr
   841 at:lineNr
   842     "retrieve a line; return nil if beyond end-of-text.
   842     "retrieve a line's item; 
   843      this allows textViews to be used like collections in some places."
   843      return nil if beyond end-of-text.
       
   844      this allows textViews to be used like collections in some places.
       
   845      Notice: for text lists, this returns strings (same as listAt:);
       
   846      for non-text lists, the item is returned."
   844 
   847 
   845     list isNil ifTrue:[^ nil].
   848     list isNil ifTrue:[^ nil].
   846     (lineNr between:1 and:self size) ifFalse:[^ nil].
   849     (lineNr between:1 and:self size) ifFalse:[^ nil].
   847     ^ list at:lineNr
   850     ^ list at:lineNr
       
   851 
       
   852     "Modified (comment): / 18-07-2017 / 13:35:26 / cg"
   848 !
   853 !
   849 
   854 
   850 at:index put:aString
   855 at:index put:aString
   851     "change a line and redisplay"
   856     "change a line and redisplay"
   852 
   857 
  1209 !
  1214 !
  1210 
  1215 
  1211 listAt:lineNr
  1216 listAt:lineNr
  1212     "given a lineNumber, return the corresponding string
  1217     "given a lineNumber, return the corresponding string
  1213      This is used for accessing; i.e. for non-string entries, this
  1218      This is used for accessing; i.e. for non-string entries, this
  1214      returns the corresponding string."
  1219      returns the corresponding string.
       
  1220      Use #at: to get to the real item (if it is not a string)"
  1215 
  1221 
  1216     |l|
  1222     |l|
  1217 
  1223 
  1218     list isNil ifTrue:[^ nil].
       
  1219     (lineNr between:1 and:self size) ifFalse:[^ nil].
       
  1220     l := self at:lineNr.
  1224     l := self at:lineNr.
  1221     l isNil ifTrue:[^ l].
  1225     l isNil ifTrue:[^ l].
  1222     ^ self visibleStringFrom:l "/ l asString
  1226     ^ self visibleStringFrom:l "/ l asString
  1223 
  1227 
  1224     "Modified: 7.9.1995 / 15:54:59 / claus"
  1228     "Modified: / 07-09-1995 / 15:54:59 / claus"
       
  1229     "Modified: / 18-07-2017 / 13:35:54 / cg"
  1225 !
  1230 !
  1226 
  1231 
  1227 removeFromIndex:startLineNr toIndex:endLineNr
  1232 removeFromIndex:startLineNr toIndex:endLineNr
  1228     "delete some lines"
  1233     "delete some lines"
  1229 
  1234