Using readline rl_insert_text in OS X 10.5

So, I am trying to enter the default text into user input using readline and cannot make it work with OSX 10.5:

// rl_insert_text_ex.c
// gcc -o rl_insert_text_ex rl_insert_text_ex.c -lreadline
#include <stdio.h>
#include <readline/readline.h>

int my_startup_hook(void) {
  return rl_insert_text("ponycorns");
}
int main(int argc, char *argv[]) {
  char *line;
  rl_startup_hook = (Function*) my_startup_hook;
  line = readline("What your favorite mythical animal? ");
  if (NULL == line || '\0' == *line) {
    printf("Nothing given... :(\n");
  }
  else {
    printf("That funny, I love %s too!\n", line);
  }
  return 0;
}

This code does not even compile at 10.4 (there is no definition for _rl_insert_textat 10.4, which is a bit of a chip), but it compiles at 10.5. However, the text rl_insert_text()'d is never displayed on the screen and is not returned as user input. The callback is used and rl_insert_text()returns the correct value (thanks, printf), so I'm not sure what is going on here.

I checked /usr/include/readline/readline.has well rl_insert_text():

/* supported functions */

which is vaguely located under:

/*
 * The following is not implemented
 */

Am I SOL too, or am I just doing it wrong?

+2
1

, , , readline, OS X. - Apple libedit, (-) readline. ( "editline" readline.h, OS X.)

GNU ( " " readline) GPL, ( ) , . (A) Xcode, OS X .. (B), , , Apple ( ) . , .

, , GPL'd , " " , , {BSD, MIT, Apache} .. , libedit . , , ...; -)

BTW, GPL - , {git, mercurial, bazaar} GPL, Apple, Xcode.: - (a >

: Xcode 4 git. ! , , GPL'd Xcode. , - , . , ( - , downvoter), , GPL - / , GPL ... - .

+1

Source: https://habr.com/ru/post/1712202/


All Articles