2009-02-05 22:08:46 +01:00
|
|
|
#ifndef _INCLUDE_R_LINE_H_
|
|
|
|
#define _INCLUDE_R_LINE_H_
|
|
|
|
|
2010-01-30 14:02:53 +01:00
|
|
|
#include <r_types.h>
|
|
|
|
#include <r_cons.h>
|
|
|
|
#include <r_util.h>
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2011-02-05 01:07:43 +01:00
|
|
|
#define R_LINE_BUFSIZE 4096
|
2009-02-05 22:08:46 +01:00
|
|
|
#define R_LINE_HISTSIZE 256
|
|
|
|
|
2010-01-30 14:02:53 +01:00
|
|
|
typedef struct r_line_hist_t {
|
|
|
|
char **data;
|
|
|
|
int size;
|
|
|
|
int index;
|
|
|
|
int top;
|
|
|
|
int autosave;
|
|
|
|
} RLineHistory;
|
|
|
|
|
|
|
|
typedef struct r_line_buffer_t {
|
|
|
|
char data[R_LINE_BUFSIZE];
|
|
|
|
int index;
|
|
|
|
int length;
|
|
|
|
} RLineBuffer;
|
|
|
|
|
|
|
|
struct r_line_t; // ugly forward declaration
|
|
|
|
typedef int (*RLineCallback)(struct r_line_t *line);
|
|
|
|
|
|
|
|
typedef struct r_line_comp_t {
|
2011-02-10 00:55:30 +01:00
|
|
|
int argc;
|
2010-02-02 11:09:52 +01:00
|
|
|
const char **argv;
|
2010-01-30 14:02:53 +01:00
|
|
|
RLineCallback run;
|
|
|
|
} RLineCompletion;
|
|
|
|
|
|
|
|
typedef struct r_line_t {
|
|
|
|
RLineCompletion completion;
|
|
|
|
RLineHistory history;
|
|
|
|
RLineBuffer buffer;
|
|
|
|
int echo;
|
|
|
|
int has_echo;
|
|
|
|
const char *prompt;
|
|
|
|
char *clipboard;
|
2011-02-10 00:55:30 +01:00
|
|
|
int disable;
|
2010-06-25 19:47:47 +02:00
|
|
|
void *user;
|
2010-01-30 14:02:53 +01:00
|
|
|
} RLine;
|
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
#ifdef R_API
|
2010-02-18 16:36:55 +01:00
|
|
|
// XXX : Kill extern variables
|
2010-02-21 20:21:36 +01:00
|
|
|
//extern RLine r_line_instance;
|
2010-01-30 14:02:53 +01:00
|
|
|
R_API RLine *r_line_new ();
|
2010-02-18 16:36:55 +01:00
|
|
|
R_API RLine *r_line_singleton ();
|
2010-01-30 14:02:53 +01:00
|
|
|
R_API void r_line_free ();
|
2011-03-02 11:45:20 +01:00
|
|
|
R_API void r_line_set_prompt (const char *prompt);
|
2010-01-30 14:02:53 +01:00
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
R_API int r_line_hist_load(const char *file);
|
2010-01-30 14:02:53 +01:00
|
|
|
R_API char *r_line_readline();
|
2010-01-26 14:06:41 +01:00
|
|
|
/* label ?! */
|
2009-04-01 22:44:43 +00:00
|
|
|
R_API int r_line_hist_add(const char *line);
|
2009-12-24 03:17:53 +01:00
|
|
|
R_API int r_line_hist_save(const char *file);
|
|
|
|
R_API int r_line_hist_label(const char *label, void (*cb)(const char*));
|
|
|
|
R_API void r_line_label_show();
|
|
|
|
#endif
|
2009-02-05 22:08:46 +01:00
|
|
|
|
|
|
|
#endif
|