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