Sha256: 8bb93ce6cd3c942ad66ef9d92520bbb8a18b9570556d490898628e8b934ba1e0

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

#include <ruby.h>
#include "line_noise.h"

static VALUE
linenoise_linenoise(VALUE self, VALUE prompt)
{
  VALUE result;
  char *line;

  line = linenoise(StringValueCStr(prompt));
  if (line) {
    result = rb_locale_str_new_cstr(line);
  }
  else
    result = Qnil;
  if (line) free(line);

  return result;
}

void
Init_linenoise(void)
{
  VALUE mLinenoise = rb_define_module("Linenoise");
  rb_define_module_function(mLinenoise, "linenoise",
			    linenoise_linenoise, 1);
  rb_define_alias(rb_singleton_class(mLinenoise), "readline", "linenoise");

  /* Version string of Linenoise. */
  rb_define_const(mLinenoise, "VERSION", rb_str_new_cstr("1.0"));
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
linenoise-1.0.0 ext/linenoise/linenoise.c