linenoise 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,73 @@
1
+ /* linenoise.h -- VERSION 1.0
2
+ *
3
+ * Guerrilla line editing library against the idea that a line editing lib
4
+ * needs to be 20,000 lines of C code.
5
+ *
6
+ * See linenoise.c for more information.
7
+ *
8
+ * ------------------------------------------------------------------------
9
+ *
10
+ * Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
11
+ * Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
12
+ *
13
+ * All rights reserved.
14
+ *
15
+ * Redistribution and use in source and binary forms, with or without
16
+ * modification, are permitted provided that the following conditions are
17
+ * met:
18
+ *
19
+ * * Redistributions of source code must retain the above copyright
20
+ * notice, this list of conditions and the following disclaimer.
21
+ *
22
+ * * Redistributions in binary form must reproduce the above copyright
23
+ * notice, this list of conditions and the following disclaimer in the
24
+ * documentation and/or other materials provided with the distribution.
25
+ *
26
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+ */
38
+
39
+ #ifndef __LINENOISE_H
40
+ #define __LINENOISE_H
41
+
42
+ #ifdef __cplusplus
43
+ extern "C" {
44
+ #endif
45
+
46
+ typedef struct linenoiseCompletions {
47
+ size_t len;
48
+ char **cvec;
49
+ } linenoiseCompletions;
50
+
51
+ typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
52
+ typedef char*(linenoiseHintsCallback)(const char *, int *color, int *bold);
53
+ typedef void(linenoiseFreeHintsCallback)(void *);
54
+ void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
55
+ void linenoiseSetHintsCallback(linenoiseHintsCallback *);
56
+ void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
57
+ void linenoiseAddCompletion(linenoiseCompletions *, const char *);
58
+
59
+ char *linenoise(const char *prompt);
60
+ void linenoiseFree(void *ptr);
61
+ int linenoiseHistoryAdd(const char *line);
62
+ int linenoiseHistorySetMaxLen(int len);
63
+ int linenoiseHistorySave(const char *filename);
64
+ int linenoiseHistoryLoad(const char *filename);
65
+ void linenoiseClearScreen(void);
66
+ void linenoiseSetMultiLine(int ml);
67
+ void linenoisePrintKeyCodes(void);
68
+
69
+ #ifdef __cplusplus
70
+ }
71
+ #endif
72
+
73
+ #endif /* __LINENOISE_H */
@@ -0,0 +1,31 @@
1
+ #include <ruby.h>
2
+ #include "line_noise.h"
3
+
4
+ static VALUE
5
+ linenoise_linenoise(VALUE self, VALUE prompt)
6
+ {
7
+ VALUE result;
8
+ char *line;
9
+
10
+ line = linenoise(StringValueCStr(prompt));
11
+ if (line) {
12
+ result = rb_locale_str_new_cstr(line);
13
+ }
14
+ else
15
+ result = Qnil;
16
+ if (line) free(line);
17
+
18
+ return result;
19
+ }
20
+
21
+ void
22
+ Init_linenoise(void)
23
+ {
24
+ VALUE mLinenoise = rb_define_module("Linenoise");
25
+ rb_define_module_function(mLinenoise, "linenoise",
26
+ linenoise_linenoise, 1);
27
+ rb_define_alias(rb_singleton_class(mLinenoise), "readline", "linenoise");
28
+
29
+ /* Version string of Linenoise. */
30
+ rb_define_const(mLinenoise, "VERSION", rb_str_new_cstr("1.0"));
31
+ }
data/lib/linenoise.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'linenoise/linenoise'
2
+ require 'linenoise/version'
@@ -0,0 +1,3 @@
1
+ module Linenoise
2
+ GEM_VERSION = '1.0.0'.freeze
3
+ end
@@ -0,0 +1,9 @@
1
+ RSpec.describe Linenoise do
2
+ it "has a version number" do
3
+ expect(Linenoise::VERSION).not_to be_a(String)
4
+ end
5
+
6
+ it "has a gem version number" do
7
+ expect(Linenoise::GEM_VERSION).not_to be_a(String)
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ require 'bundler/setup'
2
+ require 'linenoise'
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = ".rspec_status"
7
+
8
+ # Disable RSpec exposing methods globally on `Module` and `main`
9
+ config.disable_monkey_patching!
10
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linenoise
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kyrylo Silin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.8'
55
+ description: ''
56
+ email:
57
+ - silin@kyrylo.org
58
+ executables: []
59
+ extensions:
60
+ - ext/linenoise/extconf.rb
61
+ extra_rdoc_files: []
62
+ files:
63
+ - CHANGELOG.md
64
+ - LICENSE.md
65
+ - README.md
66
+ - ext/linenoise/extconf.rb
67
+ - ext/linenoise/line_noise.c
68
+ - ext/linenoise/line_noise.h
69
+ - ext/linenoise/linenoise.c
70
+ - lib/linenoise.rb
71
+ - lib/linenoise/version.rb
72
+ - spec/linenoise_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: https://github.com/kyrylo/linenoise
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ homepage_uri: https://github.com/kyrylo/linenoise
79
+ source_code_uri: https://github.com/kyrylo/linenoise
80
+ changelog_uri: https://github.com/kyrylo/linenoise/blob/master/CHANGELOG.md
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.6.13
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: ''
101
+ test_files:
102
+ - spec/spec_helper.rb
103
+ - spec/linenoise_spec.rb