Skip to content

Commit

Permalink
Together with readline 6.2 port Closes JuliaLang#11
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Apr 9, 2012
1 parent 4a443ec commit de1f8be
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ $(READLINE_OBJ_SOURCE): readline-$(READLINE_VER)/configure
$(MAKE) $(jPARALLEL_BUILD_JOBS) $(READLINE_CFLAGS)
touch $@
$(READLINE_OBJ_TARGET): $(READLINE_OBJ_SOURCE)
$(MAKE) $(jPARALLEL_BUILD_JOBS) -C readline-$(READLINE_VER) install
$(MAKE) $(jPARALLEL_BUILD_JOBS) -C readline-$(READLINE_VER) $(READLINE_CFLAGS) install
touch $@

clean-readline:
Expand Down
22 changes: 11 additions & 11 deletions external/readline-win.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef WIN_H
#define WIN_H

#include <stdio.h>
#define fprintf jl_printf
#define fflush (void)
#define putc jl_putc
#define fwrite(ptr,size,count,stream) jl_write(stream,ptr,size*count)
//#define fileno -1//

#endif // WIN_H
#ifndef READLINE_WIN_H
#define READLINE_WIN_H

#include <stdio.h>
#define fprintf jl_printf
#define fflush (void)
#define putc jl_putc
#define fwrite(ptr,size,count,stream) jl_write(stream,ptr,size*count)
//#define fileno -1//

#endif // WIN_H
15 changes: 10 additions & 5 deletions ui/repl-readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ void jl_input_line_callback(char *input)
if (rl_ast != NULL) {
doprint = !ends_with_semicolon(input);
add_history_permanent(input);
#ifdef __WIN32__
ios_putc('\r', ios_stdout);
#endif
ios_putc('\n', ios_stdout);
free(input);
}
Expand Down Expand Up @@ -512,11 +515,12 @@ static void init_rl(void)
rl_bind_key_in_map('\r', return_callback, keymaps[i]);
rl_bind_key_in_map('\n', newline_callback, keymaps[i]);
rl_bind_key_in_map('\v', line_kill_callback, keymaps[i]);
rl_bind_key_in_map(127, backspace_callback, keymaps[i]);
rl_bind_key_in_map('\b', backspace_callback, keymaps[i]);
rl_bind_key_in_map('\001', line_start_callback, keymaps[i]);
rl_bind_key_in_map('\005', line_end_callback, keymaps[i]);
rl_bind_key_in_map('\002', left_callback, keymaps[i]);
rl_bind_key_in_map('\006', right_callback, keymaps[i]);
rl_bind_keyseq_in_map("\033[3~",delete_callback, keymaps[i]);
rl_bind_keyseq_in_map("\e[A", up_callback, keymaps[i]);
rl_bind_keyseq_in_map("\e[B", down_callback, keymaps[i]);
rl_bind_keyseq_in_map("\e[D", left_callback, keymaps[i]);
Expand All @@ -530,20 +534,23 @@ static void init_rl(void)
#endif
}

#ifndef __WIN32__ //Requires RL 5.0 on windows and RL 6.2 otherwise
extern int _rl_echoing_p;

void jl_prep_terminal (int meta_flag)
{
#ifndef __WIN32__
struct termios beforeRl_in = ((uv_tty_t*)jl_stdin_tty)->orig_termios;
struct termios beforeRl_out = ((uv_tty_t*)jl_stdout_tty)->orig_termios;
#endif
//terminal is prepped by libuv
_rl_echoing_p=1;
rl_prep_terminal(1);
uv_tty_set_mode((uv_tty_t*)jl_stdout_tty,1);
uv_tty_set_mode((uv_tty_t*)jl_stdin_tty,1);
#ifndef __WIN32__
((uv_tty_t*)jl_stdin_tty)->orig_termios=beforeRl_in;
((uv_tty_t*)jl_stdout_tty)->orig_termios=beforeRl_out;
#endif
}

/* Restore the terminal's normal settings and modes. */
Expand All @@ -552,17 +559,15 @@ void jl_deprep_terminal ()
rl_deprep_terminal();
uv_tty_reset_mode();
}
#endif

void init_repl_environment(void)
{
#ifdef __WIN32__
rl_outstream=(void*)jl_stdout_tty;
#else
#endif
rl_prep_terminal(1);
rl_prep_term_function=&jl_prep_terminal;
rl_deprep_term_function=&jl_deprep_terminal;
#endif
prompt_length = strlen(prompt_plain);
rl_catch_signals = 0;
init_history();
Expand Down

0 comments on commit de1f8be

Please sign in to comment.