1 TextCollector subclass:#TerminalView |
1 TextCollector subclass:#TerminalView |
2 instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences |
2 instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences |
3 escapeSequenceTree currentSequence currentTree kbdMap |
3 escapeSequenceTree currentSequence currentTree kbdMap |
4 escapeLeadingChars numberOfColumns numberOfLines |
4 escapeLeadingChars numberOfColumns numberOfLines |
5 shellTerminateAction rangeStartLine rangeEndLine' |
5 shellTerminateAction rangeStartLine rangeEndLine state' |
6 classVariableNames:'' |
6 classVariableNames:'' |
7 poolDictionaries:'' |
7 poolDictionaries:'' |
8 category:'Views-TerminalViews' |
8 category:'Views-TerminalViews' |
9 ! |
9 ! |
10 |
10 |
133 |
133 |
134 openShell |
134 openShell |
135 "start a shell on a pseudo-TTY, open a terminalView on it |
135 "start a shell on a pseudo-TTY, open a terminalView on it |
136 (i.e. this is kind of an xterm)" |
136 (i.e. this is kind of an xterm)" |
137 |
137 |
138 ^ self startShellIn:nil |
138 ^ self openShellIn:nil |
139 |
139 |
140 " |
140 " |
141 VT100TerminalView openShell |
141 VT100TerminalView openShell |
142 " |
142 " |
143 |
143 |
144 "Modified: / 20.7.1998 / 18:28:26 / cg" |
144 "Modified: / 21.7.1998 / 18:24:55 / cg" |
145 ! |
145 ! |
146 |
146 |
147 openShellIn:aDirectory |
147 openShellIn:aDirectory |
148 "start a shell on a pseudo-TTY, open a terminalView on it |
148 "start a shell on a pseudo-TTY, open a terminalView on it |
149 (i.e. this is kind of an xterm)" |
149 (i.e. this is kind of an xterm)" |
692 ] do:[ |
697 ] do:[ |
693 |buffer n| |
698 |buffer n| |
694 |
699 |
695 outStream readWait. |
700 outStream readWait. |
696 (self sensor hasKeyPressEventFor:self) ifTrue:[ |
701 (self sensor hasKeyPressEventFor:self) ifTrue:[ |
697 Processor yield |
702 (self sensor eventCount > 10) ifTrue:[ |
|
703 "/ give terminalView a chance to |
|
704 "/ send out the character. |
|
705 Delay waitForSeconds:0.1. |
|
706 ] |
698 ] ifFalse:[ |
707 ] ifFalse:[ |
699 buffer := String new:1024. |
708 buffer := String new:1024. |
700 n := outStream nextAvailableBytes:1024 into:buffer startingAt:1. |
709 n := outStream nextAvailableBytes:1024 into:buffer startingAt:1. |
701 |
710 |
702 n > 0 ifTrue:[ |
711 n > 0 ifTrue:[ |
703 self pushEvent:#processInput:n: with:buffer with:n. |
712 self pushEvent:#processInput:n: with:buffer with:n. |
|
713 (self sensor eventCount > 50) ifTrue:[ |
|
714 [self sensor eventCount > 10] whileTrue:[ |
|
715 "/ give terminalView a chance to |
|
716 "/ catch up. |
|
717 Delay waitForSeconds:0.1. |
|
718 ] |
|
719 ]. |
704 ] ifFalse:[ |
720 ] ifFalse:[ |
705 n == 0 ifTrue:[ |
721 n == 0 ifTrue:[ |
706 outStream atEnd ifTrue:[ |
722 outStream atEnd ifTrue:[ |
707 outStream close. outStream := nil. |
723 outStream close. outStream := nil. |
708 inStream close. inStream := nil. |
724 inStream close. inStream := nil. |
907 ! ! |
924 ! ! |
908 |
925 |
909 !TerminalView methodsFor:'processing - input'! |
926 !TerminalView methodsFor:'processing - input'! |
910 |
927 |
911 processInput:buffer n:count |
928 processInput:buffer n:count |
|
929 |sensor| |
|
930 |
912 self hideCursor. |
931 self hideCursor. |
913 1 to:count do:[:i | |
932 |
914 self nextPut:(buffer at:i). |
933 access critical:[ |
915 ]. |
934 |i i2 s crnlFollows| |
916 |
935 |
917 (self sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
936 i := 1. |
918 self endEntry. |
937 [i <= count] whileTrue:[ |
919 self showCursor. |
938 (state == 0) ifTrue:[ |
920 "/ self makeCursorVisible. |
939 "/ in initial state. |
|
940 "/ quick scan forward for next control character ... |
|
941 i2 := buffer indexOfControlCharacterStartingAt:i. |
|
942 i2 == 0 ifTrue:[ |
|
943 "/ no control characters - simply append all |
|
944 "/ to the outstanding lines ... |
|
945 s := buffer copyFrom:i to:count. |
|
946 i := count + 1. "/ leave loop. |
|
947 crnlFollows := false. |
|
948 ] ifFalse:[ |
|
949 i2 > i ifTrue:[ |
|
950 s := buffer copyFrom:i to:i2-1. |
|
951 i := i2. "/ proceed withcontrol character |
|
952 crnlFollows := false. |
|
953 i < (count - 1) ifTrue:[ |
|
954 (buffer at:i) == Character return ifTrue:[ |
|
955 (buffer at:i+1) == Character nl ifTrue:[ |
|
956 crnlFollows := true. |
|
957 i := i + 2. |
|
958 ] |
|
959 ] |
|
960 ]. |
|
961 ] |
|
962 ]. |
|
963 ]. |
|
964 |
|
965 s notNil ifTrue:[ |
|
966 currentEmphasis notNil ifTrue:[ |
|
967 s := s emphasizeAllWith:currentEmphasis |
|
968 ]. |
|
969 |
|
970 outstandingLine size > 0 ifTrue:[ |
|
971 outstandingLine := outstandingLine , s. |
|
972 ] ifFalse:[ |
|
973 outstandingLine := s. |
|
974 ]. |
|
975 crnlFollows ifTrue:[ |
|
976 outstandingLines isNil ifTrue:[ |
|
977 outstandingLines := OrderedCollection with:outstandingLine |
|
978 ] ifFalse:[ |
|
979 outstandingLines add:outstandingLine. |
|
980 ]. |
|
981 outstandingLine := ''. |
|
982 ]. |
|
983 s := nil. |
|
984 |
|
985 collecting ifTrue:[ |
|
986 flushPending ifFalse:[ |
|
987 self installDelayedUpdate |
|
988 ] ifTrue:[ |
|
989 "/ outstandingLines size > collectSize ifTrue:[ |
|
990 "/ self endEntry |
|
991 "/ ] |
|
992 ] |
|
993 ] ifFalse:[ |
|
994 self endEntry |
|
995 ]. |
|
996 ] ifFalse:[ |
|
997 "/ no chunk to append (in an escape sequence) |
|
998 "/ must handle individual characters |
|
999 "/ to update the state machine. |
|
1000 self nextPut:(buffer at:i). |
|
1001 i := i + 1. |
|
1002 ] |
|
1003 ]. |
|
1004 |
|
1005 ]. |
|
1006 |
|
1007 (sensor := self sensor) notNil ifTrue:[ |
|
1008 (sensor hasEvent:#processInput:n: for:self) ifFalse:[ |
|
1009 self endEntry. |
|
1010 self showCursor. |
|
1011 "/ self makeCursorVisible. |
|
1012 ] ifTrue:[ |
|
1013 outstandingLines size > collectSize ifTrue:[ |
|
1014 self endEntry. |
|
1015 self showCursor. |
|
1016 "/ self makeCursorVisible. |
|
1017 "/ redraw |
|
1018 windowGroup notNil ifTrue:[ |
|
1019 windowGroup processRealExposeEventsFor:self. |
|
1020 ] |
|
1021 ]. |
|
1022 ] |
921 ]. |
1023 ]. |
922 |
1024 |
923 "Created: / 10.6.1998 / 17:26:09 / cg" |
1025 "Created: / 10.6.1998 / 17:26:09 / cg" |
924 "Modified: / 20.6.1998 / 19:18:07 / cg" |
1026 "Modified: / 21.7.1998 / 19:30:18 / cg" |
925 ! ! |
1027 ! ! |
926 |
1028 |
927 !TerminalView methodsFor:'queries'! |
1029 !TerminalView methodsFor:'queries'! |
928 |
1030 |
929 preferredExtent |
1031 preferredExtent |