diff -ur scilab-4.1.1/routines/console/zzledt.c scilab-4.1.1/routines/console/zzledt.c
--- scilab-4.1.1/routines/console/zzledt.c	2005-01-05 10:58:18.000000000 +0000
+++ scilab-4.1.1/routines/console/zzledt.c	2007-11-02 20:03:39.000000000 +0000
@@ -104,6 +104,13 @@
 #define RIGHT_ARROW           0x014d
 #define SEARCH_BACKWARD       0x015e
 #define SEARCH_FORWARD        0x0160
+
+//added by oliford 30/7/7
+#define HOME_KEY              0x0200
+#define END_KEY               0x0201
+#define INSERT_KEY            0x0202
+#define DELETE_KEY            0x0203
+
 #define HOME                  0x0001  /* control-A */
 #define ENDS                  0x0005  /* control-E */
 #define LDEL                  0x0015  /* control-U */
@@ -135,7 +142,8 @@
 #define SV_BUF_SIZE 5000
 
 
-#define N_SEQS       6      /* number of special sequences */
+//#define N_SEQS       6      /* number of special sequences */
+#define N_SEQS       12      /* number of special sequences */
 #define MAX_SEQ_LEN  10     /* max chars in special termcap seqs */
 #define ESC          0x01b
 /* declare and define initial sequences. They
@@ -146,9 +154,18 @@
   { 0x1b, 0x5b, 0x44, 0x00 },   /* left arrow */
   { 0x1b, 0x5b, 0x43, 0x00 },    /* right arrow */
   { 0x1b, 0x3c, 0x00, 0x00 },   /* search backward*/
-  { 0x1b, 0x3e, 0x00, 0x00 }    /* search forward */
+  { 0x1b, 0x3e, 0x00, 0x00 },   /* search forward */
+//added by oliford 30/7/7
+  { 0x1b, 0x48, 0x00, 0x00 },   /* home */
+  { 0x1b, 0x46, 0x00, 0x00 },   /* end */
+  { 0x1b, 0x5b, 0x32, 0x7e, 0x00 },   /* insert */
+  { 0x1b, 0x5b, 0x33, 0x7e, 0x00 },   /* delete */
+  { 0x1b, 0x4F, 0x48, 0x00 },   /* another home*/
+  { 0x1b, 0x4F, 0x46,  0x00 }   /* another end */
+
 };
-static int key_map[] = {UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, SEARCH_BACKWARD, SEARCH_FORWARD};
+//static int key_map[] = {UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, SEARCH_BACKWARD, SEARCH_FORWARD};
+static int key_map[] = {UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, SEARCH_BACKWARD, SEARCH_FORWARD, HOME_KEY,END_KEY,INSERT_KEY,DELETE_KEY,HOME_KEY,END_KEY };
 
 
 static char yank_buf[WK_BUF_SIZE + 1];/* yank buffer for copy/paste */
@@ -375,17 +392,20 @@
 	  }
 	  break;
 
+	case HOME_KEY:
 	case HOME:
 	  backspace(cursor); /* move to beginning of the line */
 	  cursor = 0;
 	  break;
 
+	case END_KEY:
 	case ENDS:  /* move to end of line */
 	  while(cursor < cursor_max) {
 	    PutChar(wk_buf[cursor++]);
 	  }
 	  break;
 
+	case INSERT_KEY:
 	case INS: /* toggle insert/overwrite flag */
 	  insert_flag = !insert_flag;
 	  break;
@@ -397,21 +417,25 @@
 	  };
 	  break;
 	   
+	case DELETE_KEY:
 	case CTRL_D: /* delete next character*/
 	  if(cursor == cursor_max) {
-	    /* reminder that backing up over edge */
+	    // reminder that backing up over edge 
 	    PutChar(BEL);
 	    break;
 	  }
-	  move_left(&wk_buf[cursor]);
+/*	  move_left(&wk_buf[cursor]);
 	  cursor_max--;
-	  /* and write rest of line to end */
+	  // and write rest of line to end 
 	  display_string(&wk_buf[cursor]);
-	  /* erase extra character now at end. */
+	  // erase extra character now at end. 
 	  erase_nchar(1);
-	  /* backspace to proper cursor position */
+	  // backspace to proper cursor position 
 	  backspace(cursor_max - cursor);
-	  break;
+	  break; */
+
+    	  PutChar(wk_buf[cursor++]);
+	
 
 	case DEL: /* backspace with delete */
 	case BS:
@@ -586,7 +610,7 @@
 	  cursor++;
 	}
 	else {
-	  if(insert_flag) {
+	  if(insert_flag || cursor == cursor_max) {
 	    /* insert mode, move rest of line right and
 	     * add character at cursor */
 	    move_right(&wk_buf[cursor], WK_BUF_SIZE - cursor);
@@ -775,6 +799,15 @@
   /* get next character, gotten in cbreak mode so no wait for <cr> */
   i = GetCharOrEvent(interrupt);/* i=-1 if return on an event */
 
+  /*// code by oliford (2/11/7) to find key seqeunces to add to "special sequence" block
+    // warning: this kills bash afterwards sometimes
+    for(j=0;j<30;j++){
+	i = GetCharOrEvent(interrupt);
+	printf("%i ",i);
+  }
+  exit(3);*/
+
+
   /* if more than one character */
   if(i == ESC) {
     /* translate control code sequences to codes over 100 hex */
@@ -793,6 +826,7 @@
   /* initialize pointer array */
   for(i = 0; i < N_SEQS; i++)
     pstr[i] = &seqs[i][0];
+
   /* examine all pstrings one char at a time */
   for(j=0; j++ < MAX_SEQ_LEN;) {
 
diff -ur scilab-4.1.1/routines/xsci/jpc_inter.c scilab-4.1.1/routines/xsci/jpc_inter.c
--- scilab-4.1.1/routines/xsci/jpc_inter.c	2006-07-12 10:11:20.000000000 +0100
+++ scilab-4.1.1/routines/xsci/jpc_inter.c	2007-07-30 17:25:23.000000000 +0100
@@ -253,7 +253,7 @@
     fflush(stdout); 
     fflush(stderr); 
 #ifdef WITH_TK 
-    flushTKEvents();
+  //  flushTKEvents(); // seems to cause the lockup
 #endif 
     /* Initialize masks  */
     select_mask = Select_mask_ref;
