poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] Add completer member to commands


From: John Darrington
Subject: [PATCH 3/4] Add completer member to commands
Date: Thu, 14 Nov 2019 13:26:50 +0100

        * src/pk-cmd.h (completer_t): New typedef.
        (pk_cmd) [completer]: New member;
---
 ChangeLog    | 5 +++++
 src/pk-cmd.h | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 654ed62..daf7212 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2019-11-13 John Darrington <address@hidden>
 
+       * src/pk-cmd.h (completer_t): New typedef.
+       (pk_cmd) [completer]: New member;
+
+2019-11-13 John Darrington <address@hidden>
+
        * src/pkl-env.h (pkl_ast_node_iter): New struct.
        (pkl_env_iter_begin): New declaration.
        (pkl_env_iter_next): New declaration.
diff --git a/src/pk-cmd.h b/src/pk-cmd.h
index c864251..fa9107e 100644
--- a/src/pk-cmd.h
+++ b/src/pk-cmd.h
@@ -63,6 +63,12 @@ typedef int (*pk_cmd_fn) (int argc, struct pk_cmd_arg 
argv[], uint64_t uflags);
 #define PK_CMD_F_REQ_IO 0x1  /* Command requires an IO space.  */
 #define PK_CMD_F_REQ_W  0x2  /* Command requires a writable IO space.  */
 
+/* This is the same as rl_compentry_func_t from readline.h
+   Unfortunately #including readline.h here causes bad things
+   to happen, because it defines lots of macros conflicting
+   with ones used elsewhere.  */
+typedef char* (*completer_t) (const char *, int);
+
 struct pk_cmd
 {
   /* Name of the command.  It is a NULL-terminated string composed by
@@ -80,6 +86,9 @@ struct pk_cmd
   pk_cmd_fn handler;
   /* Usage message.  */
   const char *usage;
+  /* The completion generator which generates arguments/operands
+     for this command.  */
+  completer_t completer;
 };
 
 /* Parse STR and execute a command.  */
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]