comparison src/readline-1-display.patch @ 2980:2cf09b449d88

readline patches for windows from goffioul
author John W. Eaton <jwe@octave.org>
date Thu, 18 Apr 2013 02:04:36 -0400
parents
children 4ce61d3172f0
comparison
equal deleted inserted replaced
2978:9d0ba0c088f5 2980:2cf09b449d88
1 diff -uNr a/display.c b/display.c
2 --- a/display.c 2009-09-26 14:37:33.000000000 -0400
3 +++ b/display.c 2013-04-17 17:51:18.323642508 -0400
4 @@ -55,6 +55,11 @@
5 #include "rlprivate.h"
6 #include "xmalloc.h"
7
8 +#if defined (_WIN32)
9 +#include <windows.h>
10 +#define hStdout GetStdHandle(STD_OUTPUT_HANDLE)
11 +#endif
12 +
13 #if !defined (strchr) && !defined (__STDC__)
14 extern char *strchr (), *strrchr ();
15 #endif /* !strchr && !__STDC__ */
16 @@ -1904,6 +1909,20 @@
17 int cpos, dpos; /* current and desired cursor positions */
18 int adjust;
19
20 +#if defined (_WIN32)
21 + CONSOLE_SCREEN_BUFFER_INFO csbi;
22 + if (_rl_last_c_pos != new
23 + && GetConsoleScreenBufferInfo (hStdout, &csbi))
24 + {
25 + csbi.dwCursorPosition.X += new - _rl_last_c_pos;
26 + if (SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition))
27 + {
28 + _rl_last_c_pos = new;
29 + return;
30 + }
31 + }
32 +#endif /* !_WIN32 */
33 +
34 woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
35 cpos = _rl_last_c_pos;
36
37 @@ -2040,6 +2059,20 @@
38 {
39 register int delta, i;
40
41 +#if defined (_WIN32)
42 + CONSOLE_SCREEN_BUFFER_INFO csbi;
43 + if (_rl_last_v_pos != to && to <= _rl_screenheight
44 + && GetConsoleScreenBufferInfo(hStdout, &csbi))
45 + {
46 + csbi.dwCursorPosition.Y += to - _rl_last_v_pos;
47 + if (SetConsoleCursorPosition(hStdout, csbi.dwCursorPosition))
48 + {
49 + _rl_last_v_pos = to;
50 + return;
51 + }
52 + }
53 +#endif /* !_WIN32 */
54 +
55 if (_rl_last_v_pos == to || to > _rl_screenheight)
56 return;
57
58 @@ -2318,6 +2351,17 @@
59 _rl_clear_to_eol (count)
60 int count;
61 {
62 +#if defined (_WIN32)
63 + CONSOLE_SCREEN_BUFFER_INFO csbi;
64 + if (GetConsoleScreenBufferInfo (hStdout, &csbi))
65 + {
66 + DWORD written;
67 + FillConsoleOutputCharacter(hStdout, ' ', count, csbi.dwCursorPosition,
68 + &written);
69 + return;
70 + }
71 +#endif /* !_WIN32 */
72 +
73 if (_rl_term_clreol)
74 tputs (_rl_term_clreol, 1, _rl_output_character_function);
75 else if (count)
76 @@ -2341,6 +2385,33 @@
77 void
78 _rl_clear_screen ()
79 {
80 +#if defined (_WIN32)
81 + COORD coordScreen = { 0, 0 };
82 + DWORD cCharsWritten;
83 + CONSOLE_SCREEN_BUFFER_INFO csbi;
84 + DWORD dwConSize;
85 +
86 + if (GetConsoleScreenBufferInfo (hStdout, &csbi))
87 + {
88 + dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
89 +
90 + if (FillConsoleOutputCharacter (hStdout, (TCHAR) ' ', dwConSize,
91 + coordScreen, &cCharsWritten))
92 + {
93 + if (GetConsoleScreenBufferInfo (hStdout, &csbi))
94 + {
95 + if (FillConsoleOutputAttribute (hStdout, csbi.wAttributes,
96 + dwConSize, coordScreen,
97 + &cCharsWritten))
98 + {
99 + SetConsoleCursorPosition (hStdout, coordScreen);
100 + return;
101 + }
102 + }
103 + }
104 + }
105 +#endif
106 +
107 if (_rl_term_clrpag)
108 tputs (_rl_term_clrpag, 1, _rl_output_character_function);
109 else
110 @@ -2353,7 +2424,7 @@
111 char *string;
112 int count, col;
113 {
114 -#if defined (__MSDOS__) || defined (__MINGW32__)
115 +#if defined (__MSDOS__) || (defined (__MINGW32__) && !defined (_MSC_VER))
116 _rl_output_some_chars (string, count);
117 #else
118 /* DEBUGGING */
119 @@ -2405,7 +2476,7 @@
120 if (count > _rl_screenwidth) /* XXX */
121 return;
122
123 -#if !defined (__MSDOS__) && !defined (__MINGW32__)
124 +#if (!defined (__MSDOS__) && !defined (__MINGW32__)) || defined (_MSC_VER)
125 if (_rl_term_DC && *_rl_term_DC)
126 {
127 char *buffer;