# HG changeset patch # User John W. Eaton # Date 1366265076 14400 # Node ID 2cf09b449d88301b0c48d6837634ea56bc0f754b # Parent 9d0ba0c088f5e7c39595e1e7974bfd8e00892d01 readline patches for windows from goffioul diff -r 9d0ba0c088f5 -r 2cf09b449d88 index.html --- a/index.html Fri Mar 01 08:39:47 2013 -0500 +++ b/index.html Thu Apr 18 02:04:36 2013 -0400 @@ -1810,7 +1810,7 @@ octave - 3.7.2 + 3.7.2+ Octave diff -r 9d0ba0c088f5 -r 2cf09b449d88 src/octave.mk --- a/src/octave.mk Fri Mar 01 08:39:47 2013 -0500 +++ b/src/octave.mk Thu Apr 18 02:04:36 2013 -0400 @@ -3,7 +3,7 @@ PKG := octave $(PKG)_IGNORE := -$(PKG)_CHECKSUM := b80caa6ac6f206cfe06f8f7dd45650074cebac2a +$(PKG)_CHECKSUM := 9a2310e30ec5ec160f716caedb98e16bd93b6d8b $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION) $(PKG)_FILE := octave-$($(PKG)_VERSION).tar.gz $(PKG)_URL := ftp://alpha.gnu.org/gnu/octave/$($(PKG)_FILE) @@ -38,3 +38,4 @@ $(MAKE) -C '$(1)/.build' -j '$(JOBS)' install $(MAKE) -C '$(1)/.build' -j '$(JOBS)' DESTDIR=$(PREFIX)/../octave install endef + diff -r 9d0ba0c088f5 -r 2cf09b449d88 src/readline-1-binding.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/readline-1-binding.patch Thu Apr 18 02:04:36 2013 -0400 @@ -0,0 +1,24 @@ +diff -uNr a/readline.c b/readline.c +--- a/readline.c 2010-07-25 17:07:40.000000000 -0400 ++++ b/readline.c 2013-04-17 20:38:42.637674309 -0400 +@@ -1154,11 +1159,19 @@ + rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line); + rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line); + +-#if defined (__MINGW32__) ++#if defined (__MINGW32__) && ! defined (_MSC_VER) + rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history); + rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history); + rl_bind_keyseq_if_unbound ("\340M", rl_forward_char); + rl_bind_keyseq_if_unbound ("\340K", rl_backward_char); ++ rl_bind_keyseq_if_unbound ("\340G", rl_beg_of_line); ++ rl_bind_keyseq_if_unbound ("\340O", rl_end_of_line); ++ rl_bind_keyseq_if_unbound ("\340S", rl_delete); ++#endif ++ ++#ifdef _MSC_VER ++ rl_bind_keyseq_if_unbound ("\033[3~", rl_delete); ++ rl_bind_keyseq_if_unbound ("\033[X", _rl_update_terminal_size); + #endif + + _rl_keymap = xkeymap; diff -r 9d0ba0c088f5 -r 2cf09b449d88 src/readline-1-display.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/readline-1-display.patch Thu Apr 18 02:04:36 2013 -0400 @@ -0,0 +1,127 @@ +diff -uNr a/display.c b/display.c +--- a/display.c 2009-09-26 14:37:33.000000000 -0400 ++++ b/display.c 2013-04-17 17:51:18.323642508 -0400 +@@ -55,6 +55,11 @@ + #include "rlprivate.h" + #include "xmalloc.h" + ++#if defined (_WIN32) ++#include ++#define hStdout GetStdHandle(STD_OUTPUT_HANDLE) ++#endif ++ + #if !defined (strchr) && !defined (__STDC__) + extern char *strchr (), *strrchr (); + #endif /* !strchr && !__STDC__ */ +@@ -1904,6 +1909,20 @@ + int cpos, dpos; /* current and desired cursor positions */ + int adjust; + ++#if defined (_WIN32) ++ CONSOLE_SCREEN_BUFFER_INFO csbi; ++ if (_rl_last_c_pos != new ++ && GetConsoleScreenBufferInfo (hStdout, &csbi)) ++ { ++ csbi.dwCursorPosition.X += new - _rl_last_c_pos; ++ if (SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition)) ++ { ++ _rl_last_c_pos = new; ++ return; ++ } ++ } ++#endif /* !_WIN32 */ ++ + woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset); + cpos = _rl_last_c_pos; + +@@ -2040,6 +2059,20 @@ + { + register int delta, i; + ++#if defined (_WIN32) ++ CONSOLE_SCREEN_BUFFER_INFO csbi; ++ if (_rl_last_v_pos != to && to <= _rl_screenheight ++ && GetConsoleScreenBufferInfo(hStdout, &csbi)) ++ { ++ csbi.dwCursorPosition.Y += to - _rl_last_v_pos; ++ if (SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition)) ++ { ++ _rl_last_v_pos = to; ++ return; ++ } ++ } ++#endif /* !_WIN32 */ ++ + if (_rl_last_v_pos == to || to > _rl_screenheight) + return; + +@@ -2318,6 +2351,17 @@ + _rl_clear_to_eol (count) + int count; + { ++#if defined (_WIN32) ++ CONSOLE_SCREEN_BUFFER_INFO csbi; ++ if (GetConsoleScreenBufferInfo (hStdout, &csbi)) ++ { ++ DWORD written; ++ FillConsoleOutputCharacter(hStdout, ' ', count, csbi.dwCursorPosition, ++ &written); ++ return; ++ } ++#endif /* !_WIN32 */ ++ + if (_rl_term_clreol) + tputs (_rl_term_clreol, 1, _rl_output_character_function); + else if (count) +@@ -2341,6 +2385,33 @@ + void + _rl_clear_screen () + { ++#if defined (_WIN32) ++ COORD coordScreen = { 0, 0 }; ++ DWORD cCharsWritten; ++ CONSOLE_SCREEN_BUFFER_INFO csbi; ++ DWORD dwConSize; ++ ++ if (GetConsoleScreenBufferInfo (hStdout, &csbi)) ++ { ++ dwConSize = csbi.dwSize.X * csbi.dwSize.Y; ++ ++ if (FillConsoleOutputCharacter (hStdout, (TCHAR) ' ', dwConSize, ++ coordScreen, &cCharsWritten)) ++ { ++ if (GetConsoleScreenBufferInfo (hStdout, &csbi)) ++ { ++ if (FillConsoleOutputAttribute (hStdout, csbi.wAttributes, ++ dwConSize, coordScreen, ++ &cCharsWritten)) ++ { ++ SetConsoleCursorPosition (hStdout, coordScreen); ++ return; ++ } ++ } ++ } ++ } ++#endif ++ + if (_rl_term_clrpag) + tputs (_rl_term_clrpag, 1, _rl_output_character_function); + else +@@ -2353,7 +2424,7 @@ + char *string; + int count, col; + { +-#if defined (__MSDOS__) || defined (__MINGW32__) ++#if defined (__MSDOS__) || (defined (__MINGW32__) && !defined (_MSC_VER)) + _rl_output_some_chars (string, count); + #else + /* DEBUGGING */ +@@ -2405,7 +2476,7 @@ + if (count > _rl_screenwidth) /* XXX */ + return; + +-#if !defined (__MSDOS__) && !defined (__MINGW32__) ++#if (!defined (__MSDOS__) && !defined (__MINGW32__)) || defined (_MSC_VER) + if (_rl_term_DC && *_rl_term_DC) + { + char *buffer; diff -r 9d0ba0c088f5 -r 2cf09b449d88 src/readline-1-input.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/readline-1-input.patch Thu Apr 18 02:04:36 2013 -0400 @@ -0,0 +1,17 @@ +diff -uNr a/input.c b/input.c +--- a/input.c 2010-05-30 18:33:01.000000000 -0400 ++++ b/input.c 2013-04-17 23:50:34.759675631 -0400 +@@ -466,7 +466,12 @@ + + #if defined (__MINGW32__) + if (isatty (fileno (stream))) +- return (getch ()); ++ { ++ int c = _getch (); ++ if (c == 0xe0) ++ rl_execute_next (_getch ()); ++ return (c); ++ } + #endif + result = read (fileno (stream), &c, sizeof (unsigned char)); + diff -r 9d0ba0c088f5 -r 2cf09b449d88 src/readline-1-sigwinch.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/readline-1-sigwinch.patch Thu Apr 18 02:04:36 2013 -0400 @@ -0,0 +1,83 @@ +diff -uNr a/readline.c b/readline.c +--- a/readline.c 2010-07-25 17:07:40.000000000 -0400 ++++ b/readline.c 2013-04-17 16:11:52.932653458 -0400 +@@ -970,6 +970,11 @@ + rl_initialized++; + RL_SETSTATE(RL_STATE_INITIALIZED); + } ++#if defined (__MINGW32__) ++ else ++ /* In case the console window has been resized outside of readline */ ++ rl_reset_screen_size (); ++#endif + + /* Initalize the current line information. */ + _rl_init_line_state (); +diff -uNr a/signals.c b/signals.c +--- a/signals.c 2011-02-11 10:53:33.000000000 -0500 ++++ b/signals.c 2013-04-17 16:07:57.476121748 -0400 +@@ -46,6 +46,11 @@ + + #include "rlprivate.h" + ++#if defined (__MINGW32__) ++# define WIN32_LEAN_AND_MEAN ++# include ++#endif ++ + #if defined (HANDLE_SIGNALS) + + #if !defined (RETSIGTYPE) +@@ -91,7 +96,7 @@ + int rl_catch_signals = 1; + + /* If non-zero, readline will install a signal handler for SIGWINCH. */ +-#ifdef SIGWINCH ++#if defined (SIGWINCH) || defined (__MINGW32__) + int rl_catch_sigwinch = 1; + #else + int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */ +@@ -422,6 +427,21 @@ + } + #endif /* SIGWINCH */ + ++#if defined (__MINGW32__) ++ if (rl_catch_sigwinch && sigwinch_set_flag == 0) ++ { ++ DWORD mode; ++ HANDLE hStdIn = GetStdHandle (STD_INPUT_HANDLE); ++ ++ if (GetConsoleMode (hStdIn, &mode)) ++ { ++ mode |= ENABLE_WINDOW_INPUT; ++ if (SetConsoleMode (hStdIn, mode)) ++ sigwinch_set_flag = 1; ++ } ++ } ++#endif ++ + return 0; + } + +@@ -467,6 +487,21 @@ + } + #endif + ++#if defined (__MINGW32__) ++ if (rl_catch_sigwinch && sigwinch_set_flag == 1) ++ { ++ DWORD mode; ++ HANDLE hStdIn = GetStdHandle (STD_INPUT_HANDLE); ++ ++ if (GetConsoleMode (hStdIn, &mode)) ++ { ++ mode &= ~ENABLE_WINDOW_INPUT; ++ if (SetConsoleMode (hStdIn, mode)) ++ sigwinch_set_flag = 0; ++ } ++ } ++#endif ++ + return 0; + } +