コード例 #1
0
ファイル: clink_rl.c プロジェクト: hello-xk/kiwi
//------------------------------------------------------------------------------
static int startup_hook()
{
    static int initialised = 0;
    if (!initialised)
    {
        // This is a bit of a hack. Ideally we should take care of this in
        // the termcap functions.
        _rl_term_forward_char = "\013";
        _rl_term_clreol = "\001";

        rl_redisplay_function = display;
        rl_getc_function = getc_impl;

        rl_completer_quote_characters = "\"";
        rl_ignore_some_completions_function = postprocess_matches;
        rl_basic_word_break_characters = " <>|";
        rl_completer_word_break_characters = " <>|";
        rl_completion_display_matches_hook = display_matches;
        rl_attempted_completion_function = alternative_matches;

        rl_add_funmap_entry("clink-completion-shim", completion_shim);
        rl_add_funmap_entry("clear-line", clear_line);
        rl_add_funmap_entry("paste-from-clipboard", paste_from_clipboard);

        initialise_lua();
        load_history();
        rl_re_read_init_file(0, 0);
        rl_visible_stats = 0;               // serves no purpose under win32.

        initialised = 1;
    }
    
    return 0;
}
コード例 #2
0
ファイル: rl.c プロジェクト: HTshandou/clink
//------------------------------------------------------------------------------
static int initialise_hook()
{
    rl_redisplay_function = display;
    rl_getc_function = getc_impl;

    // Invalid filename characters; <>|?*:"\/
    _rl_comment_begin = "::";
    rl_completer_quote_characters = "\"";
    rl_ignore_some_completions_function = postprocess_matches;
    rl_basic_word_break_characters = " <>|=;&";
    rl_completer_word_break_characters = (char*)rl_basic_word_break_characters;
    rl_attempted_completion_function = alternative_matches;
    if (rl_completion_display_matches_hook == NULL)
    {
        rl_completion_display_matches_hook = display_matches;
    }

    rl_basic_quote_characters = "\"";
    rl_filename_quote_characters = " %=;&^";

    rl_add_funmap_entry("clink-completion-shim", completion_shim);
    rl_add_funmap_entry("clink-menu-completion-shim", menu_completion_shim);

    clink_register_rl_funcs();
    initialise_rl_scroller();

    rl_re_read_init_file(0, 0);
    rl_visible_stats = 0;               // serves no purpose under win32.

    return 0;
}
コード例 #3
0
ファイル: ridl.c プロジェクト: mgalloy/ridl
/**
   rIDL main loop.
*/
int main(int argc, char *argv[]) {
  ridl_handleswitches(argc, argv, 1);

  IDL_INIT_DATA init_data;
  init_data.options = ridl_options;
  init_data.clargs.argc = argc;
  init_data.clargs.argv = argv;

  ridl_welcome();

  IDL_UicbRegInitTextDone(ridl_inittextdone);

  if (!IDL_Initialize(&init_data)) {
    ridl_warning("failed to initialize Callable IDL session.\n");
    return(EXIT_FAILURE);
  }

  IDL_ExitRegister(ridl_exit_handler);
  IDL_UicbRegExitDone(ridl_exit);
  IDL_UicbRegShowCompileErr(ridl_show_compile_error);
  IDL_UicbRegPromptChange(ridl_changeprompt);
  IDL_UicbRegDeathHint(ridl_deathhint);
  IDL_UicbRegWorkingDirChange(ridl_changewdir);

  // TODO: will need to use something like this to fix ticket #1, but this
  //       will crash now; this specifies a routine that will be called when
  //       IDL needs to do a readline (as in RIDL_STOPTEST)
  IDL_UicbRegRlineFromKbrd(ridl_readline_callback);

  ridl_handleswitches(argc, argv, 0);

  ridl_cmdnumber = ridl_initialize_history() + 1;

  if (!(msg_block = IDL_MessageDefineBlock("RIDL_MSG_BLOCK",
                                           IDL_CARRAY_ELTS(msg_arr),
                                           msg_arr))) return(1);

  IDL_GetUserInfo(&user_info);
  ridl_changewdir(user_info.wd);
  IDL_ExecuteStr("!prompt = !prompt");  // triggers prompt to be set
  IDL_ExecuteStr("!path = filepath('', subdir=['share', 'idl'], root=getenv('RIDL_DIR')) + path_sep(/search_path) + !path");

  // handle functions called by rIDL (instead of compile_opt strictarr)
  IDL_ExecuteStr("forward_function ridl_class_hierarchy_helper, ridl_cmp_version, ridl_getfields, ridl_getmethods, ridl_getroutines, ridl_getuserroutines, ridl_launcheditor, ridl_preflocation");

  rl_readline_name = "rIDL";
  ridl_completion_init();
  rl_attempted_completion_function = ridl_completion;
  ridl_get_userdefinedroutines_list();
  IDL_UicbRegPathChange(ridl_changepath);

  ridl_read_preferences();

  // load -pref filename if present on the command line
  if (preferences_file_set) {
    // TODO: make this work (doing a PREF_SET will not change the preferences
    // values unless COMMIT is set, but doing so will change the user's
    // preferences file permanently); how to change preferences just for this
    // session of IDL?

    //char *pref_set_format = "pref_set, filename='%s'";
    //char *pref_set_cmd = (char *)malloc(strlen(pref_set_format) - 2 + strlen(preferences_filename) + 1);
    //sprintf(pref_set_cmd, pref_set_format, preferences_filename);
    //int error = IDL_ExecuteStr(pref_set_cmd);
    //free(pref_set_cmd);
  }

  // handle -rt or -em options if one of them was present on the command line
  if (runtime_exec) {
    int error = IDL_RuntimeExec(runtime_filename);
    return(IDL_Cleanup(IDL_FALSE));
  }

  // handle -e option if it was present on the command line
  if (execute_cmd) {
    int error = IDL_ExecuteStr(cmd);
    return(IDL_Cleanup(IDL_FALSE));
  }

  // execute batch file if present on the command line
  if (execute_batch_file) {
    ridl_execute_batch_file(batch_file);
  }

  ridl_updateprompt();

  rl_event_hook = ridl_event_hook;

  // bind these commands to keys in an Readline configuration file, i.e.,
  // like ~/.inputrc (an example inputrc is given in the src/ directory of the
  // distribution)
  int f;
  for (f = 0; f < N_FUNMAP_FUNCTIONS; f++) {
    rl_add_funmap_entry(funmap_function_names[f], funmap_functions[f]);
  }

  while (1) {
    char *line = ridl_readline();

    ridl_getevents();

    int error = ridl_executeline(line, 1);

    free(line);
  }

  return(EXIT_FAILURE);
}
コード例 #4
0
ファイル: lua.c プロジェクト: genba/clink
//------------------------------------------------------------------------------
lua_State* initialise_lua()
{
    static int once = 0;
    int i;
    int path_hash;
    char buffer[1024];
    struct luaL_Reg clink_native_methods[] = {
        { "chdir", change_dir },
        { "execute", lua_execute },
        { "find_dirs", find_dirs },
        { "find_files", find_files },
        { "get_console_aliases", get_console_aliases },
        { "get_cwd", get_cwd },
        { "get_env", get_env },
        { "get_env_var_names", get_env_var_names },
        { "get_host_process", get_host_process },
        { "get_rl_variable", get_rl_variable },
        { "get_screen_info", get_screen_info },
        { "get_setting_int", get_setting_int },
        { "get_setting_str", get_setting_str },
        { "is_dir", is_dir },
        { "is_rl_variable_true", is_rl_variable_true },
        { "lower", to_lowercase },
        { "matches_are_files", matches_are_files },
        { "slash_translation", slash_translation },
        { "suppress_char_append", suppress_char_append },
        { "suppress_quoting", suppress_quoting },
        { NULL, NULL }
    };

    if (g_lua != NULL)
    {
        return g_lua;
    }

    // Initialise Lua.
    g_lua = luaL_newstate();
    luaL_openlibs(g_lua);

    // Add our API.
    lua_createtable(g_lua, 0, 0);
    lua_setglobal(g_lua, "clink");

    lua_getglobal(g_lua, "clink");
    luaL_setfuncs(g_lua, clink_native_methods, 0);
    lua_pop(g_lua, 1);

    // Load all the .lua files alongside the dll and in the script folder.
    if (g_inject_args.script_path[0] == '\0')
    {
        get_dll_dir(buffer, sizeof_array(buffer));
    }
    else
    {
        buffer[0] = '\0';
        str_cat(buffer, g_inject_args.script_path, sizeof_array(buffer));
    }

    path_hash = hash_string(buffer);
    i = (int)strlen(buffer);

    str_cat(buffer, "/clink.lua", sizeof_array(buffer));
    load_lua_script(buffer);

    buffer[i] = '\0';
    load_lua_scripts(buffer);

    get_config_dir(buffer, sizeof(buffer));
    if (hash_string(buffer) != path_hash)
    {
        load_lua_scripts(buffer);
    }

    if (!once)
    {
        rl_add_funmap_entry("reload-lua-state", reload_lua_state);
        once = 1;
    }

    return g_lua;
}
コード例 #5
0
ファイル: inputwin.c プロジェクト: darth-cequella/profanity
static void
_inp_rl_addfuncs(void)
{
    rl_add_funmap_entry("prof_win_1", _inp_rl_win_1_handler);
    rl_add_funmap_entry("prof_win_2", _inp_rl_win_2_handler);
    rl_add_funmap_entry("prof_win_3", _inp_rl_win_3_handler);
    rl_add_funmap_entry("prof_win_4", _inp_rl_win_4_handler);
    rl_add_funmap_entry("prof_win_5", _inp_rl_win_5_handler);
    rl_add_funmap_entry("prof_win_6", _inp_rl_win_6_handler);
    rl_add_funmap_entry("prof_win_7", _inp_rl_win_7_handler);
    rl_add_funmap_entry("prof_win_8", _inp_rl_win_8_handler);
    rl_add_funmap_entry("prof_win_9", _inp_rl_win_9_handler);
    rl_add_funmap_entry("prof_win_0", _inp_rl_win_0_handler);
    rl_add_funmap_entry("prof_win_prev", _inp_rl_win_prev_handler);
    rl_add_funmap_entry("prof_win_next", _inp_rl_win_next_handler);
    rl_add_funmap_entry("prof_win_pageup", _inp_rl_win_pageup_handler);
    rl_add_funmap_entry("prof_win_pagedown", _inp_rl_win_pagedown_handler);
    rl_add_funmap_entry("prof_subwin_pageup", _inp_rl_subwin_pageup_handler);
    rl_add_funmap_entry("prof_subwin_pagedown", _inp_rl_subwin_pagedown_handler);
    rl_add_funmap_entry("prof_win_clear", _inp_rl_win_clear_handler);
}