root/lib/readline/readline.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pn_readline
  2. Potion_Init_readline

#include <stdlib.h>
#include <stdio.h>
#include <potion.h>
#include "linenoise.h"

PN pn_readline(Potion *P, PN cl, PN self, PN start) {
  char *line = linenoise(PN_STR_PTR(start));
  PN r;
  if (line == NULL) return PN_NIL;

  linenoiseHistoryLoad("history.txt");
  linenoiseHistoryAdd(line);
  linenoiseHistorySave("history.txt");
  r = potion_str(P, line);
  free(line);
  return r;
}

void Potion_Init_readline(Potion *P) {
  potion_method(P->lobby, "readline", pn_readline, "start=S");
}

/* [<][>][^][v][top][bottom][index][help] */