Index: gcalctool/calctool.h
===================================================================
--- gcalctool/calctool.h	(revision 1689)
+++ gcalctool/calctool.h	(working copy)
@@ -549,7 +549,6 @@
 void mptanh(int *, int *);
 
 void make_exp(char *number, int t[MP_SIZE]);
+void exp_replace(char *text);
 
-
-
 #endif /*CALCTOOL_H*/
Index: gcalctool/functions.c
===================================================================
--- gcalctool/functions.c	(revision 1689)
+++ gcalctool/functions.c	(working copy)
@@ -332,7 +332,7 @@
 }
 
 
-static void
+void
 exp_replace(char *text)
 {
     struct exprm_state *e = get_state();
Index: gcalctool/ce_tokeniser.l
===================================================================
--- gcalctool/ce_tokeniser.l	(revision 1689)
+++ gcalctool/ce_tokeniser.l	(working copy)
@@ -49,50 +49,50 @@
 
 %%
 
-"Abs" {return tABS;}
-"Acosh" {return tACOSH;}
-"Acos" {return tACOS;}
-"And" {return tAND;}
-"Ans" {return tANS;}
-"Asinh" {return tASINH;}
-"Asin" {return tASIN;}
-"Atanh" {return tATANH;}
-"Atan" {return tATAN;}
-"Cbrt" {return tCBRT;}
-"Chs" {return tCHS;}
-"Clr" {return tCLR;}
-"Cosh" {return tCOSH;}
-"Cos" {return tCOS;}
-"Ctrm" {return tCTRM;}
-"Ddb" {return tDDB;}
-"Eng" {return tEXP;}
-"Frac" {return tFRAC;}
-"Fv" {return tFV;}
-"Int" {return tINT;}
-"Ln" {return tLN;}
-"Log" {return tLOG10;}
-"Mod" {return tMOD;}
-"Not" {return tNOT;}
-"Or" {return tOR;}
-"Pi" {return tPI;}
-"Pmt" {return tPMT;}
-"Pv" {return tPV;}
-"Rand" {return tRAND;}
-"Rate" {return tRATE;}
-"Rcl" {return tRCL;}
-"Sinh" {return tSINH;}
-"Sin" {return tSIN;}
-"Sln" {return tSLN;}
-"Sqrt" {return tSQRT;}
-"Sto" {return tSTO;}
-"Syd" {return tSYD;}
-"Tanh" {return tTANH;}
-"Tan" {return tTAN;}
-"Term" {return tTERM;}
-"u16" {return tU16;}
-"u32" {return tU32;}
-"Xnor" {return tXNOR;}
-"Xor" {return tXOR;}
+"abs"|"Abs"|"ABS" {return tABS;}
+"acosh"|"Acosh"|"ACOSH" {return tACOSH;}
+"acos"|"Acos"|"ACOS" {return tACOS;}
+"and"|"And"|"AND" {return tAND;}
+"ans"|"Ans"|"ANS" {return tANS;}
+"asinh"|"Asinh"|"ASINH" {return tASINH;}
+"asin"|"Asin"|"ASIN" {return tASIN;}
+"atanh"|"Atanh"|"ATANH" {return tATANH;}
+"atan"|"Atan"|"ATAN" {return tATAN;}
+"cbrt"|"Cbrt"|"CBRT" {return tCBRT;}
+"chs"|"Chs"|"CHS" {return tCHS;}
+"clr"|"Clr"|"CLR" {return tCLR;}
+"cosh"|"Cosh"|"COSH" {return tCOSH;}
+"cos"|"Cos"|"COS" {return tCOS;}
+"ctrm"|"Ctrm"|"CTRM" {return tCTRM;}
+"dbg"|"Ddb"|"DDB" {return tDDB;}
+"eng"|"Eng"|"ENG" {return tEXP;}
+"frac"|"Frac"|"FRAC" {return tFRAC;}
+"fv"|"Fv"|"FV" {return tFV;}
+"int"|"Int"|"INT" {return tINT;}
+"ln"|"Ln"|"LN" {return tLN;}
+"log"|"Log"|"LOG" {return tLOG10;}
+"mod"|"Mod"|"MOD" {return tMOD;}
+"not"|"Not"|"NOT" {return tNOT;}
+"or"|"Or"|"OR" {return tOR;}
+"pi"|"Pi"|"PI" {return tPI;}
+"pmt"|"Pmt"|"PMT" {return tPMT;}
+"pv"|"Pv"|"PV" {return tPV;}
+"rand"|"Rand"|"RAND" {return tRAND;}
+"rate"|"Rate"|"RATE" {return tRATE;}
+"rcl"|"Rcl"|"RCL" {return tRCL;}
+"sinh"|"Sinh"|"SINH" {return tSINH;}
+"sin"|"Sin"|"SIN" {return tSIN;}
+"sln"|"Sln"|"SLN" {return tSLN;}
+"sqrt"|"Sqrt"|"SQRT" {return tSQRT;}
+"sto"|"Sto"|"STO" {return tSTO;}
+"syd"|"Syd"|"SYD" {return tSYD;}
+"tanh"|"Tanh"|"TANH" {return tTANH;}
+"tan"|"Tan"|"TAN" {return tTAN;}
+"term"|"Term"|"TERM" {return tTERM;}
+"u16"|"u16"|"U16" {return tU16;}
+"u32"|"u32"|"U32" {return tU32;}
+"xnor"|"Xnor"|"XNOR" {return tXNOR;}
+"xor"|"Xor"|"XOR" {return tXOR;}
 
 "R"{DEC}+ {
 celval.integer = atoi(yytext+1);  
Index: gcalctool/gtk.c
===================================================================
--- gcalctool/gtk.c	(revision 1689)
+++ gcalctool/gtk.c	(working copy)
@@ -178,6 +178,7 @@
 static gboolean dismiss_rframe(GtkWidget *, GdkEvent *, gpointer);
 static gboolean dismiss_spframe(GtkWidget *, GdkEvent *, gpointer);
 static gboolean kframe_key_press_cb(GtkWidget *, GdkEventKey *, gpointer);
+static gboolean display_focus_out_cb(GtkWidget *widget, GdkEventKey *event, gpointer data);
 static gboolean mouse_button_cb(GtkWidget *, GdkEventButton *, gpointer);
 static gboolean spframe_key_cb(GtkWidget *, GdkEventKey *, gpointer);
 
@@ -1360,8 +1361,8 @@
     char *hn;
     GError *error;
     GtkWidget *event_box, *view_widget;
-    GtkTextBuffer *buffer;
     AtkObject *aob;
+    PangoFontDescription *font_desc;
 
     v->tool_label = NULL;
     if (v->titleline == NULL) {
@@ -1443,11 +1444,19 @@
 
     event_box = gtk_event_box_new();
     X->display_item = gtk_text_view_new();
+
+    font_desc = pango_font_description_from_string("Serif 15");
+    gtk_widget_modify_font(X->display_item, font_desc);
+    pango_font_description_free(font_desc);
+
     gtk_widget_set_name(X->display_item, "displayitem");
     g_signal_connect(G_OBJECT(X->display_item), "button_release_event",
                      G_CALLBACK(mouse_button_cb),
                      NULL);
 
+    g_signal_connect(G_OBJECT(X->display_item), "focus_out_event",
+                     G_CALLBACK(display_focus_out_cb), NULL);
+
     /* Detect when populating the right-click menu to enable pasting */
     g_signal_connect(G_OBJECT(X->display_item), "populate-popup",
                      G_CALLBACK(buffer_populate_popup_cb), NULL);
@@ -1455,12 +1464,9 @@
     gtk_text_view_set_justification(GTK_TEXT_VIEW(X->display_item),
                                     GTK_JUSTIFY_RIGHT);
     gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(X->display_item), GTK_WRAP_NONE);
-    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(X->display_item));
-    gtk_text_buffer_create_tag(buffer, "x-large", "scale", PANGO_SCALE_X_LARGE, 
-                               NULL);			       
 
     gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(X->display_item), TRUE);
-    gtk_text_view_set_editable(GTK_TEXT_VIEW(X->display_item), FALSE);
+    gtk_text_view_set_editable(GTK_TEXT_VIEW(X->display_item), (v->syntax == exprs));
     aob = gtk_widget_get_accessible(GTK_WIDGET(X->display_item));
     atk_object_set_description(aob, "Result Region");
 
@@ -2213,12 +2219,57 @@
     return(FALSE);
 }
 
+
+void
+get_expr_from_display()
+{
+    char *text;
+    GtkTextBuffer *buffer;
+    GtkTextIter start, end;
+
+    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(X->display_item));
+    gtk_text_buffer_get_bounds(buffer, &start, &end);
+    
+    text = gtk_text_buffer_get_text(
+                 gtk_text_view_get_buffer(GTK_TEXT_VIEW(X->display_item)),
+                                 &start,
+                                 &end,
+                                 FALSE);
+    exp_replace(text);
+}
+
+
+static gboolean
+display_focus_out_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+    if (v->syntax == exprs) {
+        get_expr_from_display();
+    } 
+
+    fprintf(stderr, "kframe_focus_out_cb: focus out of display.\n");
+
+    return(FALSE);
+}
+
+
 /*ARGSUSED*/
 static gboolean
 kframe_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
     int retval = FALSE;
 
+    if (gtk_widget_is_focus(X->display_item) && (v->syntax == exprs)) {
+
+        if ((event->keyval == GDK_equal) || 
+            (event->keyval == GDK_KP_Enter) || 
+            (event->keyval == GDK_Return) || 
+            (event->keyval == GDK_equal)) {
+            get_expr_from_display();
+        } else {
+            return(FALSE);
+        }
+    }
+
     if (check_for_localized_numeric_point(event->keyval) == TRUE) {
         event->state = 0;
         event->keyval = GDK_KP_Decimal;
@@ -3180,12 +3231,7 @@
         if (minimize_changes) {
             if (len1 < len2 && strncmp(text, str, len1) == 0) {
                 /* Text insertion */
-                gtk_text_buffer_insert_with_tags_by_name(buffer,
-                                                         &end,
-                                                         str + len1,
-                                                         -1,
-                                                         "x-large",
-                                                         NULL);
+                gtk_text_buffer_insert(buffer, &end, str + len1, -1);
                 done = TRUE;
             } else if (len1 > len2 && strncmp(text, str, len2) == 0) {
                /* Text deletion */
@@ -3199,12 +3245,7 @@
         if (!done) {
             gtk_text_buffer_delete(buffer, &start, &end);
 
-            gtk_text_buffer_insert_with_tags_by_name(buffer,
-                                                     &end,
-                                                     str,
-                                                     -1,
-                                                     "x-large",
-                                                     NULL);
+            gtk_text_buffer_insert(buffer, &end, str, -1);
         }
     }
     scroll_right();
@@ -3227,12 +3268,7 @@
 
     gtk_text_buffer_delete(buffer, &start, &end);
     
-    gtk_text_buffer_insert_with_tags_by_name(buffer,
-					     &end,
-					     str,
-					     -1,
-					     "x-large",
-					     NULL);
+    gtk_text_buffer_insert(buffer, &end, str, -1);
     scroll_right();
     g_free(text);
 }
