Document the problems with xio.c.
[super-star-trek.git] / src / xio.c
index ea35fb1b9ee266cc2ad7599cbc25d4af5caf986e..1ac0e2362295a0cb2b5a69fc83cc53a6aab59dd9 100644 (file)
--- a/src/xio.c
+++ b/src/xio.c
@@ -1,3 +1,20 @@
+/*
+ * Problems with this code:
+ *   1. The text window behaves like it's only a few lines high, 
+ *      scrolling in response to Return when the insertion point 
+ *      is nowhere near the last line.
+ *   2. The attempt to insert text with XawTextReplace() core dumps.
+ *   3. I haven't found a way to write a callback that triggers on Return 
+ *      and yields the line before the return.  The explanation at
+ *      http://www.linuxjunkies.org/programming/GUI/xwindow/x11/text.html
+ *      hints that this may be difficult.
+ *
+ * The functional goal is this:
+ *    1. Button pushes should be able to insert commands at the buffer's
+ *       current insertion point.
+ *    2. When a user finishes a command with Return, a callback should
+ *       receive the line of input types.
+ */
 #include <stdlib.h>
 #include <X11/Intrinsic.h>
 #include <X11/StringDefs.h>
@@ -56,10 +73,25 @@ static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data)
     exit (0);
 }
 
+static void text_append_to(Widget w, String str)
+/* append text to a specified text widget */
+{
+    XawTextBlock txtblk;
+    XawTextPosition textend = XawTextGetInsertionPoint(w);
+
+    txtblk.ptr = str;
+    txtblk.length = strlen(str);
+    txtblk.firstPos = 0;
+    txtblk.format = FMT8BIT;
+
+    XawTextReplace(w, textend, textend, &txtblk);
+}
+
 static void noargs_proc(Widget w, XtPointer client_data, XtPointer call_data)
 /* use this for commands that take no arguments */
 {
     /* currently a stub */
+    text_append_to(w, XtName(w));
     printf("Button %s pressed\n", XtName(w));
 }