TextView.st
changeset 2856 bc6bb86d4d2e
parent 2854 b9fcff924892
child 2859 588afdab446c
equal deleted inserted replaced
2855:71f7c83269fe 2856:bc6bb86d4d2e
   634     "Created: / 19.6.1998 / 00:22:08 / cg"
   634     "Created: / 19.6.1998 / 00:22:08 / cg"
   635 ! !
   635 ! !
   636 
   636 
   637 !TextView methodsFor:'accessing'!
   637 !TextView methodsFor:'accessing'!
   638 
   638 
       
   639 characterEncoding:encodingSymOrNil
       
   640     "define how the contents is encoded internally.
       
   641      For now, this should be the same encoding as my fonts encoding (otherwise, mappings would
       
   642      occur when drawing).
       
   643      This is (currently) only passed down from the fileBrowser,
       
   644      and required when japanese/chinese/korean text is edited.
       
   645      (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
       
   646 
       
   647     characterEncoding := encodingSymOrNil
       
   648 !
       
   649 
   639 characterPositionOfSelection
   650 characterPositionOfSelection
   640     "return the character index of the first character in the selection.
   651     "return the character index of the first character in the selection.
   641      Returns 0 if there is no selection."
   652      Returns 0 if there is no selection."
   642 
   653 
   643     selectionStartLine isNil ifTrue:[^ 0].
   654     selectionStartLine isNil ifTrue:[^ 0].
   684 
   695 
   685 externalEncoding:encodingSymOrNil
   696 externalEncoding:encodingSymOrNil
   686     "define how the contents should be encoded when saved
   697     "define how the contents should be encoded when saved
   687      via the 'save / save as' dialog.
   698      via the 'save / save as' dialog.
   688      This is (currently) only passed down from the fileBrowser,
   699      This is (currently) only passed down from the fileBrowser,
   689      and required when japanese/chines/korean text is edited.
   700      and required when japanese/chinese/korean text is edited.
   690      (encoding is one of #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
   701      (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
   691 
   702 
   692     externalEncoding := encodingSymOrNil
   703     externalEncoding := encodingSymOrNil
   693 !
   704 !
   694 
   705 
   695 parenthesisSpecification
   706 parenthesisSpecification
  3619 selection
  3630 selection
  3620     "return the selection as a collection of (line-)strings.
  3631     "return the selection as a collection of (line-)strings.
  3621      If the selection ends in a full line, the last entry in the returned
  3632      If the selection ends in a full line, the last entry in the returned
  3622      collection will be an empty string."
  3633      collection will be an empty string."
  3623 
  3634 
       
  3635     |sel|
       
  3636 
  3624     selectionStartLine isNil ifTrue:[^ nil].
  3637     selectionStartLine isNil ifTrue:[^ nil].
  3625     ^ self textFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol
  3638     sel := self textFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol.
       
  3639     characterEncoding ~~ #'iso8859-1' ifTrue:[
       
  3640         sel := sel encodeFrom:characterEncoding into:#'unicode'
       
  3641     ].
       
  3642     ^ sel
  3626 
  3643 
  3627     "Modified: / 22.2.2000 / 23:54:54 / cg"
  3644     "Modified: / 22.2.2000 / 23:54:54 / cg"
  3628 !
  3645 !
  3629 
  3646 
  3630 selectionAsString
  3647 selectionAsString
  3712 ! !
  3729 ! !
  3713 
  3730 
  3714 !TextView class methodsFor:'documentation'!
  3731 !TextView class methodsFor:'documentation'!
  3715 
  3732 
  3716 version
  3733 version
  3717     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.224 2004-02-10 09:32:45 cg Exp $'
  3734     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.225 2004-02-10 17:05:01 cg Exp $'
  3718 ! !
  3735 ! !
  3719 
  3736 
  3720 TextView initialize!
  3737 TextView initialize!