TerminalView.st
branchjv
changeset 5247 90655676e59b
parent 5237 e532570a2549
parent 5244 005f195c0795
child 5250 a4da316f8065
equal deleted inserted replaced
5241:599ff1102334 5247:90655676e59b
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1998 by eXept Software AG
     4  COPYRIGHT (c) 1998 by eXept Software AG
     3               All Rights Reserved
     5               All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
  1266 
  1268 
  1267     "Modified: / 11.6.1998 / 22:51:48 / cg"
  1269     "Modified: / 11.6.1998 / 22:51:48 / cg"
  1268 ! !
  1270 ! !
  1269 
  1271 
  1270 !TerminalView methodsFor:'functions'!
  1272 !TerminalView methodsFor:'functions'!
       
  1273 
       
  1274 autoMargin:aBoolean
       
  1275     "set/clear autowrap at end of line (not yet fully implemented).
       
  1276      This may come from a CSI sequence, or set programmatically."
       
  1277 
       
  1278     autoWrapFlag := aBoolean
       
  1279 !
  1271 
  1280 
  1272 doBackspace
  1281 doBackspace
  1273     self cursorLeft.
  1282     self cursorLeft.
  1274     self replaceCharAtCursor:(Character space).
  1283     self replaceCharAtCursor:(Character space).
  1275     self cursorLeft.
  1284     self cursorLeft.
  2303 "/].
  2312 "/].
  2304 "/self showCursor.
  2313 "/self showCursor.
  2305 "/^ self.
  2314 "/^ self.
  2306 
  2315 
  2307     access critical:[
  2316     access critical:[
  2308         |index controlCharIndex stringWithOutControl crnlFollows|
  2317         |index controlCharIndex stringWithOutControl crnlFollows 
       
  2318          nFit nCharsInLine charIdx oldCollectSize|
  2309 
  2319 
  2310         index := 1.
  2320         index := 1.
  2311         [index <= count] whileTrue:[
  2321         [index <= count] whileTrue:[
  2312             stringWithOutControl := nil.
  2322             stringWithOutControl := nil.
  2313 
  2323 
  2348                     Error handle:[:ex |
  2358                     Error handle:[:ex |
  2349                     ] do:[
  2359                     ] do:[
  2350                         stringWithOutControl := stringWithOutControl utf8Decoded
  2360                         stringWithOutControl := stringWithOutControl utf8Decoded
  2351                     ].
  2361                     ].
  2352                 ].
  2362                 ].
  2353                 (cursorCol + outstandingLine size + stringWithOutControl size) >= numberOfColumns ifTrue:[
  2363                 nCharsInLine := stringWithOutControl size.
       
  2364                 (autoWrapFlag 
       
  2365                     and:[ (cursorCol + outstandingLine size + nCharsInLine) >= numberOfColumns ]
       
  2366                 ) ifTrue:[
       
  2367                     charIdx := 1.
       
  2368                     nFit := numberOfColumns - outstandingLine size - cursorCol - 1.
       
  2369                     nFit > 0 ifTrue:[
       
  2370                         access critical:[
       
  2371                             outstandingLine size > 0 ifTrue:[
       
  2372                                 outstandingLine := outstandingLine , (stringWithOutControl copyTo:nFit).
       
  2373                             ] ifFalse:[
       
  2374                                 outstandingLine := (stringWithOutControl copyTo:nFit).
       
  2375                             ].
       
  2376                         ].
       
  2377                         charIdx := nFit + 1.
       
  2378                     ].
       
  2379                     "/ Transcript show:'idx: '; show:charIdx; show:' n:'; showCR:nCharsInLine.
       
  2380                     oldCollectSize := collectSize.
       
  2381                     collectSize := 32*1024.
  2354                     "/ characterwise, for correct wrap handling at line end
  2382                     "/ characterwise, for correct wrap handling at line end
  2355                     stringWithOutControl do:[:eachCharacter |
  2383                     [charIdx <= nCharsInLine] whileTrue:[
       
  2384                         |eachCharacter|
       
  2385                         
       
  2386                         eachCharacter := stringWithOutControl at:charIdx.
  2356                         self nextPut:eachCharacter.
  2387                         self nextPut:eachCharacter.
  2357                         self endEntry.
  2388 "/                        self endEntry.
  2358                         cursorCol >= numberOfColumns ifTrue:[ 
  2389                         cursorCol >= numberOfColumns ifTrue:[ 
       
  2390                             "/ self endEntry.
  2359                             self validateCursorCol:cursorCol inLine:cursorLine.
  2391                             self validateCursorCol:cursorCol inLine:cursorLine.
       
  2392                             "/ Transcript show:'col now: '; showCR:cursorCol.
       
  2393                             nFit := numberOfColumns - cursorCol - charIdx.
       
  2394                             "/ Transcript show:'nFit now: '; showCR:nFit.
  2360                         ].
  2395                         ].
       
  2396                         charIdx := charIdx + 1.
  2361                     ].
  2397                     ].
  2362                     crnlFollows ifTrue:[
  2398                     crnlFollows ifTrue:[
  2363                         self nextPut:Character return.
  2399                         self nextPut:Character return.
  2364                         self nextPut:Character nl.
  2400                         self nextPut:Character nl.
  2365                     ].
  2401                     ].
  2366                     self endEntry.
  2402                     self endEntry.
       
  2403                     collectSize := oldCollectSize.
  2367                 ] ifFalse:[
  2404                 ] ifFalse:[
  2368 
  2405 
  2369                     Debug ifTrue:[
  2406                     Debug ifTrue:[
  2370                         Transcript showCR:'String:<', stringWithOutControl, '>'.
  2407                         Transcript showCR:'String:<', stringWithOutControl, '>'.
  2371                         stringWithOutControl do:[:ch |
  2408                         stringWithOutControl do:[:ch |