Every line in a multiline textentry widget is supposed to have an addtional zero termination so take that into account when computing line offsets.
diff --git a/contiki/ctk/ctk-conio-service.c b/contiki/ctk/ctk-conio-service.c
index 9f7dcf1..f80bc18 100644
--- a/contiki/ctk/ctk-conio-service.c
+++ b/contiki/ctk/ctk-conio-service.c
@@ -29,7 +29,7 @@
  *
  * This file is part of the "ctk" console GUI toolkit for cc65
  *
- * $Id: ctk-conio-service.c,v 1.10 2005/05/04 22:04:35 oliverschmidt Exp $
+ * $Id: ctk-conio-service.c,v 1.11 2005/05/05 20:54:16 oliverschmidt Exp $
  *
  */
 
@@ -187,7 +187,7 @@
 	}
       }
       ++ypos;
-      text += w->w;
+      text += w->widget.textentry.len + 1;
     }
     revers(0);
     break;
diff --git a/contiki/ctk/ctk-conio.c b/contiki/ctk/ctk-conio.c
index 6e3fd28..e25d09c 100644
--- a/contiki/ctk/ctk-conio.c
+++ b/contiki/ctk/ctk-conio.c
@@ -29,7 +29,7 @@
  *
  * This file is part of the "ctk" console GUI toolkit for cc65
  *
- * $Id: ctk-conio.c,v 1.22 2005/05/04 22:04:35 oliverschmidt Exp $
+ * $Id: ctk-conio.c,v 1.23 2005/05/05 20:54:16 oliverschmidt Exp $
  *
  */
 
@@ -186,7 +186,7 @@
 	}
       }
       ++ypos;
-      text += w->w;
+      text += w->widget.textentry.len + 1;
     }
     revers(0);
     break;
diff --git a/contiki/ctk/ctk-term.c b/contiki/ctk/ctk-term.c
index 15fd3fd..c731440 100644
--- a/contiki/ctk/ctk-term.c
+++ b/contiki/ctk/ctk-term.c
@@ -508,7 +508,7 @@
 	}
       }
       ++ypos;
-      text += w->w;
+      text += w->widget.textentry.len + 1;
     }
     revers(0);
     break;
diff --git a/contiki/ctk/ctk-vncserver.c b/contiki/ctk/ctk-vncserver.c
index 8c7e409..856e9eb 100644
--- a/contiki/ctk/ctk-vncserver.c
+++ b/contiki/ctk/ctk-vncserver.c
@@ -41,7 +41,7 @@
  *
  * This file is part of the "ctk" console GUI toolkit for cc65
  *
- * $Id: ctk-vncserver.c,v 1.15 2005/05/04 22:04:35 oliverschmidt Exp $
+ * $Id: ctk-vncserver.c,v 1.16 2005/05/05 20:54:16 oliverschmidt Exp $
  *
  */
 
@@ -463,7 +463,7 @@
 	}
       }
       ++ypos;
-      text += w->w;
+      text += w->widget.textentry.len + 1;
     }
     revers(0);
     break;
diff --git a/contiki/ctk/ctk.c b/contiki/ctk/ctk.c
index f5c5fcc..2523d1e 100644
--- a/contiki/ctk/ctk.c
+++ b/contiki/ctk/ctk.c
@@ -43,7 +43,7 @@
  *
  * This file is part of the Contiki operating system.
  *
- * $Id: ctk.c,v 1.49 2005/05/04 23:05:37 oliverschmidt Exp $
+ * $Id: ctk.c,v 1.50 2005/05/05 20:54:16 oliverschmidt Exp $
  *
  */
 
@@ -1239,7 +1239,7 @@
   typos = t->ypos;
   tlen = t->len;
 
-  cptr = &t->text[txpos + typos * tlen];
+  cptr = &t->text[txpos + typos * (tlen + 1)];
       
   switch(c) {
   case CH_CURS_LEFT:
diff --git a/contiki/ctk/ctk.h b/contiki/ctk/ctk.h
index d38e4a4..9707791 100644
--- a/contiki/ctk/ctk.h
+++ b/contiki/ctk/ctk.h
@@ -43,7 +43,7 @@
  *
  * This file is part of the Contiki desktop OS.
  *
- * $Id: ctk.h,v 1.23 2005/05/04 21:50:17 oliverschmidt Exp $
+ * $Id: ctk.h,v 1.24 2005/05/05 20:54:16 oliverschmidt Exp $
  *
  */
 
@@ -229,7 +229,9 @@
  *
  * \param e The text entry widget to be cleared.
  */
-#define CTK_TEXTENTRY_CLEAR(e) do {memset((e)->text, 0, (e)->len); (e)->xpos = 0; (e)->ypos = 0;} while(0);
+#define CTK_TEXTENTRY_CLEAR(e) \
+	do { memset((e)->text, 0, (e)->h * ((e)->len + 1)); \
+	     (e)->xpos = 0; (e)->ypos = 0; } while(0)
 
 typedef unsigned char (* ctk_textentry_input)(ctk_arch_key_t c,
 					      struct ctk_textentry *t);
@@ -668,7 +670,7 @@
 		    char *title);
 void ctk_window_clear(struct ctk_window *w);
 void ctk_window_open(struct ctk_window *w);
-#define ctk_window_move(w,xpos,ypos) do {(w)->x=xpos; (w)->y=ypos;}while(0)
+#define ctk_window_move(w,xpos,ypos) do { (w)->x=xpos; (w)->y=ypos; } while(0)
 void ctk_window_close(struct ctk_window *w);
 void ctk_window_redraw(struct ctk_window *w);
 #define ctk_window_isopen(w) ((w)->next != NULL)