@@ -51,8 +51,8 @@ interface
5151		KEY_PAGE_DOWN = #209 ;
5252		KEY_INSERT = #210 ;
5353		KEY_DELETE = #211 ;
54- 		KEY_HOME = #212 ;
55- 		KEY_END = #213 ;
54+ 		KEY_HOME = #199 ;
55+ 		KEY_END = #207 ;
5656		KEY_SHIFT_UP = #193 ;
5757		KEY_SHIFT_DOWN = #194 ;
5858		KEY_SHIFT_LEFT = #196 ;
@@ -64,6 +64,7 @@ interface
6464		InputShiftAccepted: boolean;
6565		InputJoystickEnabled: boolean;
6666		InputMouseEnabled: boolean;
67+ 		InputSpecialKeyPressed: boolean;
6768		InputKeyPressed: char;
6869		InputMouseX, InputMouseY: integer;
6970		InputMouseActivationX, InputMouseActivationY: integer;
@@ -107,20 +108,36 @@ procedure InputUpdate;
107108			InputKeyPressed := ReadKey;
108109			utf[0 ] := Byte(InputKeyPressed);
109110			{  Special keys } 
110- 			if  (InputKeyPressed = #0 ) or  (InputKeyPressed = #1 ) or  (InputKeyPressed = #2 ) then 
111- 				InputKeyBuffer := InputKeyBuffer + Chr(Ord(ReadKey) or  $80 )
111+ 			if  (InputKeyPressed = #0 ) or  (InputKeyPressed = #1 ) or  (InputKeyPressed = #2 ) then  begin 
112+ 				InputKeyBuffer := InputKeyBuffer + Chr(Ord(ReadKey) or  $80 );
113+ 				InputSpecialKeyPressed := True;
112114			{  Key corresponding to multi-byte UTF8 } 
113- 			else  if  utf[0 ] > $7F  then  begin 
115+ 			end   else  if  utf[0 ] > $7F  then  begin 
114116				i := 1 ;
115117				while  (i <= 3 ) and  ByteBool((utf[0 ] shl  i) and  %10000000 ) do  begin 
116118					utf[i] := Byte(ReadKey);
117119					inc(i);
118120				end ;
119121
120122				InputKeyBuffer := InputKeyBuffer + CodepointToCP437(UTF8ToCodepoint(utf));
121- 
122- 			end  else  {  Ordinary key } 
123+ 				InputSpecialKeyPressed := False;
124+ 			end  else  begin  {  Ordinary key, or... } 
125+ 				InputSpecialKeyPressed := False;
126+ 				{  Ugly hack for Linux console and the end key. For
127+ 				  some reason it outputs F[F[. }  
128+ 				if  (InputKeyPressed = #70 ) and  KeyPressed then  begin 
129+ 					InputKeyPressed := ReadKey;
130+ 					if  InputKeyPressed = ' [' then  begin 
131+ 						{  Get rid of the second F[. } 
132+ 						if  KeyPressed then  ReadKey;
133+ 						if  KeyPressed then  ReadKey;
134+ 
135+ 						InputKeyPressed := KEY_END;
136+ 						InputSpecialKeyPressed := True;
137+ 					end  else  InputKeyPressed := #70 ;
138+ 				end ;
123139				InputKeyBuffer := InputKeyBuffer + InputKeyPressed;
140+ 			end ;
124141			TCFlush(0 , TCIFLUSH); {  Flush the keybuffer. } 
125142		end ;
126143		if  Length(InputKeyBuffer) <> 0  then  begin 
@@ -219,6 +236,7 @@ procedure InputReadWaitKey;
219236	InputDeltaY := 0 ;
220237	InputShiftPressed := false;
221238	InputShiftAccepted := false;
239+ 	InputSpecialKeyPressed := false;
222240	InputMouseX := 0 ;
223241	InputMouseY := 0 ;
224242	InputMouseActivationX := 60 ;
0 commit comments