30 #include <readline/readline.h>
31 #include <readline/history.h>
40 #if RL_READLINE_VERSION >= 0x0500
41 #define completion_matches rl_completion_matches
61 static char** AttemptedCompletion(
const char* text,
int start,
int end);
62 static char* CompletionGenerator(
const char* text,
int state);
64 static char kWordBreakCharacters[];
71 char ReadLineEditor::kWordBreakCharacters[] = {
' ',
'\t',
'\n',
'"',
72 '\\',
'\'',
'`',
'@',
'.',
'>',
'<',
'=',
';',
'|',
'&',
'{',
'(',
88 rl_bind_key(
'\t', rl_insert);
90 rl_attempted_completion_function = AttemptedCompletion;
93 rl_completer_word_break_characters = kWordBreakCharacters;
94 rl_bind_key(
'\t', rl_complete);
110 result = readline(prompt);
120 if (strlen(str) == 0)
return;
122 history_set_pos(history_length-1);
123 if (current_history()) {
125 if (strcmp(current_history()->line, str) == 0) {
126 remove_history(where_history());
129 }
while (previous_history());
136 char** ReadLineEditor::AttemptedCompletion(
const char* text,
139 char** result = completion_matches(text, CompletionGenerator);
140 rl_attempted_completion_over =
true;
145 char* ReadLineEditor::CompletionGenerator(
const char* text,
int state) {
146 static unsigned current_index;
147 static Persistent<Array> current_completions;
148 Isolate* isolate = read_line_editor.isolate_;
149 Locker lock(isolate);
150 HandleScope scope(isolate);
151 Handle<Array> completions;
160 current_completions.Reset(isolate, completions);
165 if (current_index < completions->Length()) {
166 Handle<Integer> index =
Integer::New(isolate, current_index);
167 Handle<Value> str_obj = completions->Get(index);
169 String::Utf8Value str(str_obj);
172 current_completions.Reset();
static Isolate * GetCurrent()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
virtual void AddHistory(const char *str)
static Handle< Array > GetCompletions(Isolate *isolate, Handle< String > text, Handle< String > full)
static Local< Integer > New(Isolate *isolate, int32_t value)
virtual bool Open(Isolate *isolate)
static const char * kHistoryFileName
virtual Handle< String > Prompt(const char *prompt)
static const int kMaxHistoryEntries
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)