mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Readline osx compatibility
This commit is contained in:
parent
51a5426006
commit
5954c0d2fe
@ -133,8 +133,8 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
|
||||
[AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
|
||||
PKG_CHECK_MODULES([curl], [libcurl], [],
|
||||
[AC_MSG_ERROR([libcurl is required for profanity])])
|
||||
AC_CHECK_LIB([readline], [main], [],
|
||||
[AC_MSG_ERROR([libreadline is required for profanity])])
|
||||
###AC_CHECK_LIB([readline], [main], [],
|
||||
### [AC_MSG_ERROR([libreadline is required for profanity])])
|
||||
|
||||
AS_IF([test "x$PLATFORM" = xosx], [LIBS="-lcurl $LIBS"])
|
||||
|
||||
@ -234,6 +234,11 @@ AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS"
|
||||
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
|
||||
LIBS="$glib_LIBS $curl_LIBS $libnotify_LIBS $LIBS"
|
||||
|
||||
LIBS="-lreadline $LIBS"
|
||||
AM_CPPFLAGS="-I/usr/local/opt/readline/include $AM_CPPFLAGS"
|
||||
AM_LDFLAGS="-L/usr/local/opt/readline/lib $AM_LDFLAGS"
|
||||
AC_SUBST(AM_LDFLAGS)
|
||||
|
||||
AC_SUBST(AM_CFLAGS)
|
||||
AC_SUBST(AM_CPPFLAGS)
|
||||
|
||||
|
@ -94,6 +94,10 @@ ui_init(void)
|
||||
{
|
||||
log_info("Initialising UI");
|
||||
initscr();
|
||||
nonl();
|
||||
cbreak();
|
||||
noecho();
|
||||
leaveok(stdscr, FALSE);
|
||||
keypad(stdscr, TRUE);
|
||||
if (prefs_get_boolean(PREF_MOUSE)) {
|
||||
mousemask(ALL_MOUSE_EVENTS, NULL);
|
||||
|
@ -92,10 +92,9 @@ _printable(const wint_t ch)
|
||||
static void
|
||||
cb_linehandler(char *line)
|
||||
{
|
||||
if (*line) {
|
||||
if (line && *line) {
|
||||
add_history(line);
|
||||
}
|
||||
rl_redisplay();
|
||||
cmd_result = cmd_process_input(line);
|
||||
free(line);
|
||||
}
|
||||
@ -103,7 +102,7 @@ cb_linehandler(char *line)
|
||||
int
|
||||
prof_rl_getc(FILE *filein)
|
||||
{
|
||||
int ch = rl_getc(filein);
|
||||
int ch = getc(stdin);
|
||||
if (_printable(ch)) {
|
||||
cmd_reset_autocomplete();
|
||||
}
|
||||
@ -128,14 +127,12 @@ tab_handler(int count, int key)
|
||||
if (result) {
|
||||
rl_replace_line(result, 0);
|
||||
rl_point = rl_end;
|
||||
inp_write(result, rl_point);
|
||||
}
|
||||
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||
char *result = cmd_autocomplete(rl_line_buffer);
|
||||
if (result) {
|
||||
rl_replace_line(result, 0);
|
||||
rl_point = rl_end;
|
||||
inp_write(result, rl_point);
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,15 +293,19 @@ startup_hook(void)
|
||||
void
|
||||
create_input_window(void)
|
||||
{
|
||||
/*
|
||||
#ifdef NCURSES_REENTRANT
|
||||
set_escdelay(25);
|
||||
#else
|
||||
ESCDELAY = 25;
|
||||
#endif
|
||||
*/
|
||||
p_rl_timeout.tv_sec = 0;
|
||||
p_rl_timeout.tv_usec = inp_timeout * 1000;
|
||||
rl_startup_hook = startup_hook;
|
||||
|
||||
rl_readline_name = "profanity";
|
||||
rl_getc_function = prof_rl_getc;
|
||||
rl_startup_hook = startup_hook;
|
||||
rl_callback_handler_install(NULL, cb_linehandler);
|
||||
|
||||
signal(SIGWINCH, resize_signal_handler);
|
||||
@ -314,7 +315,6 @@ create_input_window(void)
|
||||
keypad(inp_win, TRUE);
|
||||
wmove(inp_win, 0, 0);
|
||||
|
||||
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
@ -433,6 +433,8 @@ inp_readline(void)
|
||||
|
||||
if (FD_ISSET(fileno(rl_instream), &fds)) {
|
||||
rl_callback_read_char();
|
||||
cons_debug("LINE: %s", rl_line_buffer);
|
||||
cons_debug("POS : %d", rl_point);
|
||||
|
||||
if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') {
|
||||
prof_handle_activity();
|
||||
@ -494,4 +496,4 @@ _inp_win_update_virtual(void)
|
||||
int wrows, wcols;
|
||||
getmaxyx(stdscr, wrows, wcols);
|
||||
pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user