本文整理汇总了C++中read_history函数的典型用法代码示例。如果您正苦于以下问题:C++ read_history函数的具体用法?C++ read_history怎么用?C++ read_history使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_history函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HHVM_FUNCTION
static bool HHVM_FUNCTION(readline_read_history,
const String& filename /* = null */) {
if (filename.isNull()) {
return read_history(nullptr) == 0;
} else {
return read_history(filename.data()) == 0;
}
}
示例2: HHVM_FUNCTION
static bool HHVM_FUNCTION(readline_read_history,
const Variant& filename /* = null */) {
if (filename.isNull()) {
return read_history(nullptr) == 0;
} else {
auto const filenameString = filename.toString();
return read_history(filenameString.data()) == 0;
}
}
示例3: edit_init
int edit_init(void (*cmd_cb)(void *ctx, char *cmd),
void (*eof_cb)(void *ctx),
char ** (*completion_cb)(void *ctx, const char *cmd, int pos),
void *ctx, const char *history_file, const char *ps)
{
edit_cb_ctx = ctx;
edit_cmd_cb = cmd_cb;
edit_eof_cb = eof_cb;
edit_completion_cb = completion_cb;
rl_attempted_completion_function = readline_completion;
if (history_file) {
read_history(history_file);
stifle_history(100);
}
eloop_register_read_sock(STDIN_FILENO, edit_read_char, NULL, NULL);
if (ps) {
size_t blen = os_strlen(ps) + 3;
char *ps2 = os_malloc(blen);
if (ps2) {
os_snprintf(ps2, blen, "%s> ", ps);
rl_callback_handler_install(ps2, readline_cmd_handler);
os_free(ps2);
return 0;
}
}
rl_callback_handler_install("> ", readline_cmd_handler);
return 0;
}
示例4: console_init_history
static int console_init_history(const char *histfile)
{
int ret = 0;
#ifdef HAVE_READLINE
int max_history_length;
using_history();
/*
* First truncate the history size to an reasonable size.
*/
max_history_length = (me) ? me->history_length : 100;
history_truncate_file(histfile, max_history_length);
/*
* Read the content of the history file into memory.
*/
ret = read_history(histfile);
/*
* Tell the completer that we want a complete.
*/
rl_completion_entry_function = dummy_completion_function;
rl_attempted_completion_function = readline_completion;
rl_filename_completion_desired = 0;
stifle_history(max_history_length);
#endif
return ret;
}
示例5: main
gint
main (gint argc, gchar **argv)
{
cli_infos_t *cli_infos;
setlocale (LC_ALL, "");
cli_infos = cli_infos_init (argc - 1, argv + 1);
/* Execute command, if connection status is ok */
if (cli_infos) {
if (cli_infos->mode == CLI_EXECUTION_MODE_INLINE) {
loop_once (cli_infos, argc - 1, argv + 1);
} else {
gchar *filename;
filename = configuration_get_string (cli_infos->config,
"HISTORY_FILE");
read_history (filename);
using_history ();
loop_run (cli_infos);
write_history (filename);
}
}
cli_infos_free (cli_infos);
return 0;
}
示例6: lua_interactive
int lua_interactive (int argc, char * argv[])
{
int error = 0;
char * line;
lua_State * L;
char history_filename[256];
snprintf(history_filename, 256, "%s/%s",
getenv("HOME"), LUA_HISTORY_FILENAME);
L = luaL_newstate();
lua_rt_init(L, argc, argv);
read_history(history_filename);
while (1) {
line = readline("X) ");
add_history(line);
stifle_history(LUA_HISTORY_LINES);
write_history(history_filename);
error = luaL_dostring(L, line);
if (error) {
line = (char *) luaL_checkstring(L, -1);
printf("%s\n", line);
}
fflush(stdout);
}
return 0;
}
示例7: lua_rl_init
/* Initialize readline library. */
static void lua_rl_init(lua_State *L)
{
char *s;
lua_rl_L = L;
/* This allows for $if lua ... $endif in ~/.inputrc. */
rl_readline_name = "lua";
/* Break words at every non-identifier character except '.' and ':'. */
rl_completer_word_break_characters =
(char *)"\t\r\n !\"#$%&'()*+,-/;<=>[email protected][\\]^`{|}~";
rl_completer_quote_characters = "\"'";
#if RL_READLINE_VERSION < 0x0600
rl_completion_append_character = '\0';
#endif
rl_attempted_completion_function = lua_rl_complete;
rl_initialize();
/* Start using history, optionally set history size and load history file. */
using_history();
if ((s = getenv("LUA_HISTSIZE")) &&
(lua_rl_histsize = atoi(s))) stifle_history(lua_rl_histsize);
if (!(lua_rl_hist = getenv("LUA_HISTORY"))) {
char *ss = (char*)malloc((strlen(getenv("HOME"))+13)*sizeof(char));
strcpy(ss,getenv("HOME"));
lua_rl_hist = strcat(ss, "/.luahistory");
}
read_history(lua_rl_hist);
}
示例8: load_history
/* Load the history list from the history file. */
void
load_history ()
{
char *hf;
/* Truncate history file for interactive shells which desire it.
Note that the history file is automatically truncated to the
size of HISTSIZE if the user does not explicitly set the size
differently. */
set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE"));
stupidly_hack_special_variables ("HISTFILESIZE");
/* Read the history in HISTFILE into the history list. */
hf = get_string_value ("HISTFILE");
if (hf && *hf)
{
struct stat buf;
if (stat (hf, &buf) == 0)
{
read_history (hf);
using_history ();
history_lines_in_file = where_history ();
}
}
}
示例9: readline_init
static void readline_init(void) {
rl_readline_name = "augtool";
rl_attempted_completion_function = readline_completion;
rl_completion_entry_function = readline_path_generator;
/* Set up persistent history */
char *home_dir = get_home_dir(getuid());
char *history_dir = NULL;
if (home_dir == NULL)
goto done;
if (xasprintf(&history_dir, "%s/.augeas", home_dir) < 0)
goto done;
if (mkdir(history_dir, 0755) < 0 && errno != EEXIST)
goto done;
if (xasprintf(&history_file, "%s/history", history_dir) < 0)
goto done;
stifle_history(500);
read_history(history_file);
done:
free(home_dir);
free(history_dir);
}
示例10: clipit_init
/* Startup calls and initializations */
static void clipit_init() {
/* Create clipboard */
primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
g_timeout_add(CHECK_INTERVAL, item_check, NULL);
/* Read preferences */
read_preferences();
/* Read history */
if (prefs.save_history)
read_history();
/* Bind global keys */
keybinder_init();
keybinder_bind(prefs.history_key, history_hotkey, NULL);
keybinder_bind(prefs.actions_key, actions_hotkey, NULL);
keybinder_bind(prefs.menu_key, menu_hotkey, NULL);
keybinder_bind(prefs.search_key, search_hotkey, NULL);
keybinder_bind(prefs.offline_key, offline_hotkey, NULL);
/* Create status icon */
if (!prefs.no_icon)
{
#ifdef HAVE_APPINDICATOR
create_app_indicator(1);
#else
status_icon = gtk_status_icon_new_from_icon_name("clipit-trayicon");
gtk_status_icon_set_tooltip((GtkStatusIcon*)status_icon, _("Clipboard Manager"));
g_signal_connect((GObject*)status_icon, "button_press_event", (GCallback)status_icon_clicked, NULL);
#endif
}
}
示例11: jtag_load_history
static void
jtag_load_history( void )
{
char *home = getenv( "HOME" );
char *file;
using_history();
if (!home)
return;
file = malloc( strlen(home) + strlen(JTAGDIR) + strlen(HISTORYFILE) + 3 ); /* 2 x "/" and trailing \0 */
if (!file)
return;
strcpy( file, home );
strcat( file, "/" );
strcat( file, JTAGDIR );
strcat( file, "/" );
strcat( file, HISTORYFILE );
read_history( file );
free( file );
}
示例12: main
int main( int argc, char **argv )
{
char file[MAX_FILENAME_LEN + 1];
char *line, *prompt="> ";
int i;
if ( argc == 2 )
ystrncpy( file, argv[1], MAX_FILENAME_LEN );
else
yerror( "missing filename\n" );
restores( file );
prints();
restorer( file );
for( i = 0; i < status.datan; i++ )
readdata( status.dataf[i], i );
port = gp_open( "400x400" );
using_history();
stifle_history(1000);
sprintf( historyfile, "%s/%s", getenv("HOME"), HISTORYFILE );
if ( !access (historyfile, R_OK) )
if ( read_history(historyfile) )
perror( "reading history" );
while (1) {
line=readline( prompt );
if ( line ) {
add_history( line );
parser( line );
} else printf( "\n" );
}
return 0;
}
示例13: Yap_InitReadline
bool Yap_InitReadline(Term enable) {
// don't call readline within emacs
if (Yap_Embedded)
return false;
if (!(GLOBAL_Stream[StdInStream].status & Tty_Stream_f) ||
getenv("INSIDE_EMACS") || enable != TermTrue) {
if (GLOBAL_Flags)
setBooleanGlobalPrologFlag(READLINE_FLAG, false);
return false;
}
GLOBAL_Stream[StdInStream].u.irl.buf = NULL;
GLOBAL_Stream[StdInStream].u.irl.ptr = NULL;
GLOBAL_Stream[StdInStream].status |= Readline_Stream_f;
#if _WIN32
rl_instream = stdin;
#endif
// rl_outstream = stderr;
using_history();
const char *s = Yap_AbsoluteFile("~/.YAP.history", true);
history_file = s;
if (read_history(s) != 0) {
FILE *f = fopen(s, "a");
if (f) {
fclose(f);
}
}
rl_readline_name = "YAP Prolog";
rl_attempted_completion_function = prolog_completion;
// rl_prep_terminal(1);
if (GLOBAL_Flags)
setBooleanGlobalPrologFlag(READLINE_FLAG, true);
return Yap_ReadlineOps(GLOBAL_Stream + StdInStream);
}
示例14: main
int main(int argc, char **argv)
{
mudlle_init();
define_string_vector("argv", (const char *const *)argv, argc);
#ifdef USE_READLINE
bool is_tty = isatty(0);
if (is_tty)
{
using_history();
read_history(HISTORY_FILE);
rl_bind_key('\t', rl_insert);
if (atexit(history_exit))
perror("atexit(history_exit)");
}
#endif
struct oport *out = make_file_oport(stdout);
struct session_context context;
session_start(&context,
&(const struct session_info){
.mout = out,
.merr = out,
.maxseclevel = MAX_SECLEVEL });
示例15: stopping
Console::Console(QString _name, CommandInterpreter *_interpreter) :
stopping(false),
name(_name),
interpreter(_interpreter)
{
QObject::connect(this, SIGNAL(read(QString)),
interpreter, SLOT(handleString(QString)));
QObject::connect(interpreter, SIGNAL(write(QString)),
this, SLOT(write(QString)));
QObject::connect(interpreter, SIGNAL(writeAsync(QString)),
this, SLOT(writeAsync(QString)));
QObject::connect(interpreter, SIGNAL(exit()), this, SLOT(quit()));
/** allow conditional parsing of the inputrc file */
rl_readline_name = name.toAscii();
/** tell the completer that we want a crack first. */
rl_console = this;
rl_attempted_completion_function = &Console::ConsoleCompletion;
rl_event_hook = poll;
rl_catch_signals = 0;
// rl_set_keyboard_input_timeout(100000);
using_history();
historyFile = QDir::homePath() + QString("/.%1_history").arg(name);
QFile file(historyFile);
if (!file.exists()) {
// create file
file.open(QIODevice::ReadWrite);
file.close();
}
read_history(historyFile.toAscii().constData());
// rl_bind_key('\t', readline_completion);
}