p2  0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
readline.c
Go to the documentation of this file.
1 
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include "p2.h"
7 #include "linenoise.h"
8 
9 PN pn_readline(Potion *P, PN cl, PN self, PN start) {
10  char *line = linenoise(PN_STR_PTR(start));
11  PN r;
12  if (line == NULL) return PN_NIL;
13 
14  linenoiseHistoryLoad("history.txt");
15  linenoiseHistoryAdd(line);
16  linenoiseHistorySave("history.txt");
17  r = potion_str(P, line);
18  free(line);
19  return r;
20 }
21 
23  potion_method(P->lobby, "readline", pn_readline, "start=S");
24 }
PN potion_str(Potion *, const char *)
Definition: string.c:33
void Potion_Init_readline(Potion *P)
Definition: readline.c:22
#define potion_method(RCV, MSG, FN, SIG)
Definition: potion.h:789
PN lobby
root namespace
Definition: potion.h:657
PN pn_readline(Potion *P, PN cl, PN self, PN start)
Definition: readline.c:9
the global interpreter state P. currently singleton (not threads yet)
Definition: potion.h:653
The p2 API.
volatile _PN PN
Definition: potion.h:81
#define PN_NIL
Definition: potion.h:139
#define PN_STR_PTR(x)
Definition: potion.h:222