r4988: Auto commit for Debian build
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 16 May 2003 18:58:09 +0000 (18:58 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 16 May 2003 18:58:09 +0000 (18:58 +0000)
Makefile
README
changelog [new file with mode: 0644]
cl-termios.c [new file with mode: 0644]
debian/changelog
debian/docs
packages.lisp
readline.asd
readline.lisp

index 9a68259f5336dbaf2a292330578a6016d05a8931..fb4c684a0f6dc0789c4856be2e181686ab2a2d1c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,11 @@
 basename:=cl-readline
+basename2:=cl-termios
 
 all: $(basename).o
 
 all:
        gcc -fPIC -DPIC -c $(basename).c -o $(basename).o
+       gcc -fPIC -DPIC -c $(basename2).c -o $(basename2).o
        gcc -shared $(basename).o -lreadline -o $(basename).so
 
 
diff --git a/README b/README
index 2f536ac620b3b4e2a99ab176379ff2e1bb5a46af..0c252bc7f4f49b2fe6a29850892857e73b32859f 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-CL-READLINE 0.2.0
+CL-READLINE 0.3.0
 
  CL-READLINE is a simple UFFI-based wrapper for the GNU Readline
  library. 
@@ -7,24 +7,33 @@ CL-READLINE 0.2.0
  and CMUCL. Other platforms and UFFI compatible implementations should
  work, but may require tweaking.
 
 To load: 
+ To load: 
 
        (asdf:oos 'asdf:load-op 'readline)
 
-  The interface exported by the package READLINE (nicknamed RL).
+ CL-READLINE behaviour can be modified via ~/.inputrc, see GNU
+ Readline documentation for details.
 
-Functions:
 
-  READLINE &key prompt history
+API
+  (exported by "READLINE" package, nicknamed "RL")
 
-     prompt  -- a string (default "")
-     history -- a boolean (default t)
 
-     Prompt is the prompt displayed to user.
+  ADD-COMPLETION
+
+     Add a completion to the custom completion pool.
+
+
+  ADD-HISTORY string
+
+     Adds the given string to history.
+
+
+  CLEAR-COMPLETIONS
+
+     Empty the custom completion pool.
 
-     History controls whether the string read is added to history, or
-     not. Note that history is available in any case. Currently there
-     is no way to erase history.
 
   READEXPR &key primary-prompt secondary-prompt history
 
@@ -38,27 +47,41 @@ Functions:
      Primary-prompt controls the prompt of the first line,
      secondary prompt the prompt of the rest of the lines.
 
-  ADD-HISTORY string
 
-     Adds the given string to history.
+  READLINE &key prompt history
 
-  USE-FILENAME-COMPLETE
+     prompt  -- a string (default "")
+     history -- a boolean (default t)
 
-     Use the Readline's default filename-completion system.
+     Prompt is the prompt displayed to user.
 
-  USE-PACKAGE-COMPLETE name
+     History controls whether the string read is added to history, or
+     not. Note that history is available in any case. Currently there
+     is no way to erase history. Leading and trailing whitespace is trimmed
+     from string before they are added to history, and strings that consist
+     entirely of whitespace are not saved to history.
+
+     Dispite the cleanups performed on history, strings are returned as
+     read.
 
-     Insert symbols in package designated by NAME to the custom
-     completion pool, and start using the custom completion system.
 
   USE-CUSTOM-COMPLETE
 
-     Use the custom completion system.
+     Use the custom completion system. 
 
-  ADD-COMPLETION
 
-     Add a completion to the custom completion pool.
+  USE-FILENAME-COMPLETE
 
-  CLEAR-COMPLETIONS
+     Use the Readline's default filename-completion system.
 
-     Empty the custom completion pool.
+
+  USE-PACKAGE-COMPLETE name
+
+     Clear current custom completion pool, insert symbols in package
+     designated by NAME to the custom completion pool, and start using
+     the custom completion system.
+
+
+  WITHOUT-ECHO form*
+
+     Runs forms without echoing of input on screen.
diff --git a/changelog b/changelog
new file mode 100644 (file)
index 0000000..08c867e
--- /dev/null
+++ b/changelog
@@ -0,0 +1,36 @@
+2003-05-16  Nikodemus Siivola  <tsiivola@cc.hut.fi>
+
+       * README: Added documentation for WITHOUT-ECHO, and misc. doc
+       updates.
+
+       * readline.lisp ("no_echo"): New FFI definition
+       ("restore_term"): New FFI definition
+       (without-echo): New macro
+
+       * cl-termios.c: New file
+
+2003-05-08  Nikodemus Siivola  <tsiivola@cc.hut.fi>
+
+       * README (Functions): Added documentation for READEXPR.
+
+       * readline.lisp (readexpr): New function.
+
+       * libreadline.lisp: Moved c-functions to readline.lisp, as it
+       turned out that name conflict were avoidable without separate
+       packages.
+
+2003-05-06  Nikodemus Siivola  <tsiivola@cc.hut.fi>
+
+       * readline.asd (asdf:load-op): Use ASDF to load UFFI instead of
+       require.
+
+       * readline.lisp (from-foreign-string): New function.
+
+2003-05-05  Nikodemus Siivola  <tsiivola@cc.hut.fi>
+
+       * README: Added function documentation.
+       
+       * readline.lisp (readline): Fixed memory leak in FFI code.
+
+       * libreadline.lisp (readline): Changed return type.
+
diff --git a/cl-termios.c b/cl-termios.c
new file mode 100644 (file)
index 0000000..cfc9a8b
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *   Copyright (c) 2003 Nikodemus Siivola
+ *   
+ *   Permission is hereby granted, free of charge, to any person obtaining
+ *   a copy of this software and associated documentation files (the
+ *   "Software"), to deal in the Software without restriction, including
+ *   without limitation the rights to use, copy, modify, merge, publish,
+ *   distribute, sublicense, and/or sell copies of the Software, and to
+ *   permit persons to whom the Software is furnished to do so, subject to
+ *   the following conditions:
+ *   
+ *   The above copyright notice and this permission notice shall be included
+ *   in all copies or substantial portions of the Software.
+ *   
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ *   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ *   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ *   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <unistd.h>
+#include <termios.h>
+#include <stdlib.h>
+
+typedef struct {
+  struct termios *attr;
+  void *next;
+}
+state_t;
+
+state_t * stack = NULL;
+
+int
+save_term (void)
+{
+  state_t * state = malloc (sizeof (state_t));
+  struct termios * attr = malloc (sizeof (struct termios));
+  if (! (state && attr))
+    return 0;
+
+  tcgetattr (STDIN_FILENO, attr);
+
+  state->attr = attr;
+  state->next = stack;
+  stack = state;
+
+  return 1;
+}
+  
+void
+restore_term (void)
+{
+  state_t * tmp = stack;
+  if (!stack) return;
+  
+  tcsetattr (STDIN_FILENO, TCSANOW, stack->attr);
+  stack = stack->next;
+
+  free (tmp->attr);
+  free (tmp);
+}
+
+int
+no_echo (void)
+{
+  struct termios attr;  
+  if (! (isatty (STDIN_FILENO) && save_term ())) 
+    return 0;
+
+  tcgetattr (STDIN_FILENO, &attr);
+  attr.c_lflag &= ~ECHO;
+  tcsetattr (STDIN_FILENO, TCSAFLUSH, &attr);
+
+  return 1;
+}
index 32dbfabda6f876f3fbf32093fbcc69b5304d5a31..8c1207e93cc4effddf9d110ce84ce65632bd20f8 100644 (file)
@@ -1,3 +1,9 @@
+cl-readline (0.3.0-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Fri, 16 May 2003 12:55:31 -0600
+
 cl-readline (0.2.0-1) unstable; urgency=low
 
   * New upstream
index 724e0844955307c264b28a9319b65da3e99bb2c5..78dbe263ddadf99782a8ada74115e569e1e840c3 100644 (file)
@@ -1,2 +1,3 @@
 README
 TODO
+ChangeLog
index dd801cf74d63488b94ffb0fd366cf60b1ff0cd2e..51c0b1ae4e3d3dc7d89f3c6102cc083da09ae5e4 100644 (file)
    clear-completions
    readline
    readexpr
-   repl
    use-package-complete
    use-custom-complete
    use-filename-complete
+   without-echo
    ))
 
-(uffi:load-foreign-library "/usr/lib/cl-readline/cl-readline.so"
+(uffi:load-foreign-library "/lib/libreadline.so.4"
+                          :module "readline")
+
+(uffi:load-foreign-library "cl-readline.o"
                           :module "cl-readline")
 
+(uffi:load-foreign-library "cl-termios.o"
+                          :module "cl-termios")
+
index 835529c8be55f385de01154b46a882d8947a83fa..ea2c86b02efa5c20011284b5194a98ca2577be2f 100644 (file)
@@ -25,3 +25,4 @@
     :components ((:file "packages")
                 (:file "readline" :depends-on ("packages"))))
 
+
index 95c460f235689d2629427a40d1f57de72a0a39b2..ea2dedef0de5c5794710d9691403208eba6608ce 100644 (file)
 (defun readline (&key (prompt "") (history t))
   "Read a line from current TTY with line-editing."
   (with-cstring (c-prompt prompt)
-    (let ((str (string-trim *whitespace*
-                           (convert-and-free-foreign-string (c-readline c-prompt)))))
-      (when (and history (not (string= "" str)))
-       (add-history str))
+    (let* ((str (convert-and-free-foreign-string (c-readline c-prompt)))
+          (str2 (string-trim *whitespace* str)))
+      (when (and history (not (string= "" str2)))
+       (add-history str2))
       str)))
 
-(defun readexpr (&key (primary-prompt "=> ") (secondary-prompt "|     ") (history t))
+(defun readexpr (&key
+                (primary-prompt "=> ")
+                (secondary-prompt "|     ")
+                (history t))
   "Read an expression from current TTY with line-editing."
   (let (expr)
     (do* ((str (readline :prompt primary-prompt :history history)
                        (read in nil nil))))
          expr))))
 
+;;
+;; Termios
+;;
 
-    
+(def-function "no_echo"
+    ()
+  :module "cl-termios"
+  :returning :void)
+
+(def-function "restore_term"
+    ()
+  :module "cl-termios"
+  :returning :void)
+
+(defmacro without-echo (&body forms)
+  `(unwind-protect
+    (progn
+      (no-echo)
+      ,@forms)
+    (restore-term)))