diff command-window.cpp @ 14:1e5a1e15fa56

clean up header files, more small readline changes
author John W. Eaton <jwe@octave.org>
date Thu, 23 May 2019 18:41:04 -0400
parents 894be158b32d
children 79783f3e2017
line wrap: on
line diff
--- a/command-window.cpp	Thu May 23 18:26:35 2019 -0400
+++ b/command-window.cpp	Thu May 23 18:41:04 2019 -0400
@@ -2,9 +2,6 @@
 #include <sstream>
 #include <string>
 
-#include <cstdlib>
-#include <cstring>
-
 #include <QApplication>
 #include <QKeyEvent>
 #include <QTextDocument>
@@ -20,6 +17,8 @@
 
 namespace calc
 {
+  // vvvvv readline vvvvv
+
   // We could eliminate this global variable and the global
   // command_window::the_command_window variable if readline callbacks
   // could be defined as C++ lambda functions.  Then the lambdas could
@@ -28,8 +27,6 @@
 
   static int available_char = 0;
 
-  // vvvvv readline vvvvv
-
   static int getc (FILE *)
   {
     int tmp = available_char;
@@ -85,6 +82,11 @@
 
   static void readline_init (void)
   {
+    // What we really want here is a readline object that we could
+    // create in the command_window constructor.
+
+    // We might also want the option of shared history?
+
     rl_initialize ();
 
     rl_getc_function = getc;
@@ -99,6 +101,14 @@
   static void readline_fini (void)
   {
     rl_callback_handler_remove ();
+
+    rl_getc_function = nullptr;
+    rl_redisplay_function = nullptr;
+    rl_prep_term_function = nullptr;
+    rl_deprep_term_function = nullptr;
+    rl_completion_display_matches_hook = nullptr;
+
+    // Is there a function that undoes readline initialization?
   }
 
   // ^^^^^ readline ^^^^^