17 numberOfColumns numberOfLines shellTerminateAction rangeStartLine |
17 numberOfColumns numberOfLines shellTerminateAction rangeStartLine |
18 rangeEndLine state savedCursor shellCommand shellDirectory |
18 rangeEndLine state savedCursor shellCommand shellDirectory |
19 filterStream recorderStream localEcho translateNLToCRNL |
19 filterStream recorderStream localEcho translateNLToCRNL |
20 inputTranslateCRToNL inputTranslateBackspaceToDelete autoWrapFlag |
20 inputTranslateCRToNL inputTranslateBackspaceToDelete autoWrapFlag |
21 masterWindow alternateKeypadMode noColors |
21 masterWindow alternateKeypadMode noColors |
22 sizeOfOutstandingInputToBeProcessed' |
22 sizeOfOutstandingInputToBeProcessed lineEditMode lineBuffer |
|
23 lineBufferCursorPosition lineBufferHistory |
|
24 lineBufferHistoryPosition' |
23 classVariableNames:'Debug DebugKeyboard' |
25 classVariableNames:'Debug DebugKeyboard' |
24 poolDictionaries:'' |
26 poolDictionaries:'' |
25 category:'Views-TerminalViews' |
27 category:'Views-TerminalViews' |
26 ! |
28 ! |
27 |
29 |
805 " |
814 " |
806 |
815 |
807 "Modified: / 25-01-2012 / 10:43:06 / cg" |
816 "Modified: / 25-01-2012 / 10:43:06 / cg" |
808 ! |
817 ! |
809 |
818 |
|
819 keyPressInLineEditMode:aKey |
|
820 "readline alike line editing. |
|
821 return true, if the character was processed, |
|
822 false if not. Then, the caller should proceed as usual." |
|
823 |
|
824 |clearLine| |
|
825 |
|
826 clearLine := |
|
827 [ |
|
828 lineBufferCursorPosition-1 timesRepeat:[ self deleteCharBeforeCursor ]. |
|
829 (lineBuffer size-(lineBufferCursorPosition-1)) timesRepeat:[ self deleteCharAtCursor]. |
|
830 ]. |
|
831 |
|
832 "/ in lineEditMode, defer sending to the pty, until a newline is entered |
|
833 lineBuffer isNil ifTrue:[ |
|
834 lineBuffer := String new. |
|
835 lineBufferCursorPosition := 1. |
|
836 ]. |
|
837 |
|
838 aKey isCharacter ifTrue:[ |
|
839 lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-1) |
|
840 , aKey |
|
841 , (lineBuffer copyFrom:lineBufferCursorPosition). |
|
842 self insertCharAtCursor:aKey. |
|
843 lineBufferCursorPosition := lineBufferCursorPosition + 1. |
|
844 ^ true. |
|
845 ]. |
|
846 aKey == #Return ifTrue:[ |
|
847 "/ as the pty is in echo mode, |
|
848 "/ we should either disable echo for the following, |
|
849 "/ or remove from the textview and let the program redraw them. |
|
850 "/ the second alternative looks easier for now... |
|
851 clearLine value. |
|
852 |
|
853 lineBuffer do:[:ch | |
|
854 self sendCharacter:ch. |
|
855 ]. |
|
856 inputTranslateCRToNL ifTrue:[ |
|
857 self sendCharacter:(Character nl). |
|
858 ] ifFalse:[ |
|
859 self sendCharacter:(Character return). |
|
860 ]. |
|
861 lineBufferHistory isNil ifTrue:[ |
|
862 lineBufferHistory := OrderedCollection new. |
|
863 ]. |
|
864 lineBufferHistory addLast:lineBuffer. |
|
865 lineBufferHistoryPosition := lineBufferHistory size + 1. |
|
866 lineBuffer := nil. |
|
867 ^ true. |
|
868 ]. |
|
869 |
|
870 aKey == #BackSpace ifTrue:[ |
|
871 lineBufferCursorPosition > 1 ifFalse:[ |
|
872 self beep. |
|
873 ^ true |
|
874 ]. |
|
875 lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-2) |
|
876 , (lineBuffer copyFrom:lineBufferCursorPosition). |
|
877 self deleteCharBeforeCursor. |
|
878 lineBufferCursorPosition := lineBufferCursorPosition - 1. |
|
879 ^ true. |
|
880 ]. |
|
881 |
|
882 aKey == #CursorLeft ifTrue:[ |
|
883 lineBufferCursorPosition > 1 ifFalse:[ |
|
884 self beep. |
|
885 ^ true |
|
886 ]. |
|
887 lineBufferCursorPosition := lineBufferCursorPosition - 1. |
|
888 self cursorLeft. |
|
889 ^ true. |
|
890 ]. |
|
891 aKey == #CursorRight ifTrue:[ |
|
892 lineBufferCursorPosition < lineBuffer size ifFalse:[ |
|
893 self beep. |
|
894 ^ true |
|
895 ]. |
|
896 lineBufferCursorPosition := lineBufferCursorPosition + 1. |
|
897 self cursorRight. |
|
898 ^ true. |
|
899 ]. |
|
900 aKey == #CursorUp ifTrue:[ |
|
901 lineBufferHistoryPosition > 1 ifFalse:[ |
|
902 self beep. |
|
903 ^ true |
|
904 ]. |
|
905 |
|
906 "/ remember the current lineBuffer |
|
907 lineBufferHistoryPosition > lineBufferHistory size ifTrue:[ |
|
908 lineBufferHistory add:lineBuffer. |
|
909 ] ifFalse:[ |
|
910 lineBufferHistory at:lineBufferHistoryPosition put:lineBuffer. |
|
911 ]. |
|
912 clearLine value. |
|
913 |
|
914 lineBufferHistoryPosition := lineBufferHistoryPosition - 1. |
|
915 lineBuffer := lineBufferHistory at:lineBufferHistoryPosition. |
|
916 self insertStringAtCursor:lineBuffer. |
|
917 lineBufferCursorPosition := lineBuffer size + 1. |
|
918 ^ true. |
|
919 ]. |
|
920 aKey == #CursorDown ifTrue:[ |
|
921 lineBufferHistoryPosition < lineBufferHistory size ifFalse:[ |
|
922 self beep. |
|
923 ^ true |
|
924 ]. |
|
925 |
|
926 "/ remember the current lineBuffer |
|
927 lineBufferHistory at:lineBufferHistoryPosition put:lineBuffer. |
|
928 clearLine value. |
|
929 |
|
930 lineBufferHistoryPosition := lineBufferHistoryPosition + 1. |
|
931 lineBuffer := lineBufferHistory at:lineBufferHistoryPosition. |
|
932 self insertStringAtCursor:lineBuffer. |
|
933 lineBufferCursorPosition := lineBuffer size + 1. |
|
934 ^ true. |
|
935 ]. |
|
936 ^ false. |
|
937 ! |
|
938 |
810 shellTerminated |
939 shellTerminated |
811 "shell has terminated" |
940 "shell has terminated" |
812 |
941 |
813 "/Delay waitForSeconds:10. |
942 "/Delay waitForSeconds:10. |
814 [self readAnyAvailableData > 0] whileTrue:[Delay waitForSeconds:0.1]. |
943 [self readAnyAvailableData > 0] whileTrue:[Delay waitForSeconds:0.1]. |