TerminalView.st
changeset 2268 e3b57c072b89
parent 2207 d352a2f0a83a
child 2341 9b19cf22a099
--- a/TerminalView.st	Thu Oct 10 09:33:05 2002 +0200
+++ b/TerminalView.st	Thu Oct 10 09:38:23 2002 +0200
@@ -14,14 +14,15 @@
 "{ Package: 'stx:libwidg2' }"
 
 TextCollector subclass:#TerminalView
-        instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
-                escapeSequenceTree currentSequence kbdMap escapeLeadingChars
-                numberOfColumns numberOfLines shellTerminateAction rangeStartLine
-                rangeEndLine state savedCursor shellCommand shellDirectory
-                filterStream localEcho translateNLToCRNL inputTranslateCRToNL'
-        classVariableNames:'Debug'
-        poolDictionaries:''
-        category:'Views-TerminalViews'
+	instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
+		escapeSequenceTree currentSequence kbdMap escapeLeadingChars
+		numberOfColumns numberOfLines shellTerminateAction rangeStartLine
+		rangeEndLine state savedCursor shellCommand shellDirectory
+		filterStream localEcho translateNLToCRNL inputTranslateCRToNL
+		autoWrapFlag'
+	classVariableNames:'Debug'
+	poolDictionaries:''
+	category:'Views-TerminalViews'
 !
 
 !TerminalView class methodsFor:'documentation'!
@@ -394,15 +395,6 @@
 
 !TerminalView methodsFor:'cursor handling'!
 
-cursorCol:col
-    "check of col is a valid cursor position; return a new col-nr if not.
-     Here, the linelength is enforced"
-
-    ^ super cursorCol:(col min:numberOfColumns)
-
-    "Modified: / 10.6.1998 / 15:09:34 / cg"
-!
-
 cursorDown:n
     cursorLine + n > list size ifTrue:[
         list := list , (Array new:n).
@@ -414,15 +406,6 @@
     "Created: / 10.6.1998 / 17:18:50 / cg"
 !
 
-cursorLine:l col:col
-    "check of col is a valid cursor position; return a new col-nr if not.
-     Here, the linelength is enforced"
-
-    ^ super cursorLine:l col:(col min:numberOfColumns)
-
-    "Modified: / 10.6.1998 / 15:09:38 / cg"
-!
-
 cursorMovementAllowed
     "return true, if the user may move the cursor around
      (via button-click, or cursor-key with selection).
@@ -482,6 +465,13 @@
     "check of col is a valid cursor position; return a new col-nr if not.
      Here, the linelength is enforced"
 
+    col > numberOfColumns ifTrue:[
+        autoWrapFlag ifTrue:[
+            self endEntry.
+            self cursorLine:(self cursorLine + 1) col:(col-numberOfColumns).
+            ^ 1.
+        ].
+    ].
     ^ col min:numberOfColumns
 
     "Modified: / 10.6.1998 / 15:09:41 / cg"
@@ -1238,6 +1228,8 @@
     trimBlankLines := true.
     localEcho := false.
     inputTranslateCRToNL := false.
+    autoWrapFlag := true.
+    "/ cursorType := #block.
 
     numberOfColumns := 80.
     numberOfLines := 24.
@@ -1623,6 +1615,16 @@
             ].
 
             stringWithOutControl notNil ifTrue:[
+                "/ characterwise, for correct wrap handling at line end
+                (cursorCol + stringWithOutControl size) >= numberOfColumns ifTrue:[
+                    self endEntry.
+                    stringWithOutControl do:[:eachCharacter |
+                        self nextPut:eachCharacter.
+                        self endEntry
+                    ].
+                    ^ self.
+                ].
+
                 Debug ifTrue:[
                     Transcript showCR:'String:<', stringWithOutControl, '>'.
                 ].
@@ -1761,7 +1763,7 @@
     "return my preferred extent - this is computed from my numberOfLines,
      numberOfCols and font size"
 
-    ^ (fontWidth * self class defaultNumberOfColumns + (leftMargin * 2))
+    ^ (fontWidth * self class defaultNumberOfColumns + (leftMargin + margin * 2))
       @ 
       ((self heightForLines:self class defaultNumberOfLines) + 8)
 
@@ -1819,7 +1821,7 @@
 !TerminalView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.105 2002-09-19 13:39:45 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.106 2002-10-10 07:38:23 penk Exp $'
 ! !
 
 TerminalView initialize!