forked from sbinet/go-readline
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreadline_go.go
100 lines (77 loc) · 2.11 KB
/
readline_go.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// This is a basic implementation that doesn't rely on libreadline.
// Used for Windows, where you probably don't have the library, but can be disabled via 'libreadline' tag:
//
// build -tags libreadline
// +build !linux,!darwin,!libreadline
package readline
import (
"bufio"
"io"
"os"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
// Read a line
func ReadLine(prompt *string) *string {
//readline allows an empty prompt(NULL)
if prompt != nil && len(*prompt) > 0 {
io.WriteString(os.Stdout, *prompt)
}
if !scanner.Scan() {
return nil
}
s := scanner.Text()
if s == "\x04" { // ^D
return nil
}
return &s
}
// Add line to history
func AddHistory(s string) {
}
// Parse and execute single line of a readline init file.
func ParseAndBind(s string) {
}
// Parse a readline initialization file.
// The default filename is the last filename used.
func ReadInitFile(s string) error {
return nil
}
// Load a readline history file.
// The default filename is ~/.history.
func ReadHistoryFile(s string) error {
return nil
}
var (
HistoryLength = -1
)
// Save a readline history file.
// The default filename is ~/.history.
func WriteHistoryFile(s string) error {
return nil
}
// Set the readline word delimiters for tab-completion
func SetCompleterDelims(break_chars string) {
}
// Get the readline word delimiters for tab-completion
func GetCompleterDelims() string {
return ""
}
// Get the current readline buffer
func GetLineBuffer() string {
return ""
}
// The signature for the rl_completion_entry_function callback
type go_compentry_func_t func(text string, state int) string
// The signature for the rl_attempted_completion_function callback
type go_completion_func_t func(text string, start, end int) []string
// Call rl_completion_matches with the Go (compentry_function) callback
func CompletionMatches(text string, cbk go_compentry_func_t) []string {
return nil
}
// Set rl_completion_entry_function
func SetCompletionEntryFunction(cbk go_compentry_func_t) {
}
// Set rl_attempted_completion_function
func SetAttemptedCompletionFunction(cbk func(text string, start, end int) []string) {
}
/* EOF */