| File macros/readline.m4 changed (mode: 100644) (index 872fe0a..457d62b) |
| ... |
... |
AH_TEMPLATE([HAS_READLINE], |
| 44 |
44 |
[ Defined if found readline ]) |
[ Defined if found readline ]) |
| 45 |
45 |
|
|
| 46 |
46 |
AC_DEFUN([AC_CHECK_READLINE],[ |
AC_DEFUN([AC_CHECK_READLINE],[ |
| 47 |
|
search_readline=false |
|
|
47 |
|
search_readline=true |
| 48 |
48 |
has_readline=false |
has_readline=false |
| 49 |
49 |
|
|
| 50 |
50 |
dnl CFLAGS=${CFLAGS--O} |
dnl CFLAGS=${CFLAGS--O} |
| |
| ... |
... |
dnl CFLAGS=${CFLAGS--O} |
| 72 |
72 |
AC_SEARCH_READLINE() |
AC_SEARCH_READLINE() |
| 73 |
73 |
fi |
fi |
| 74 |
74 |
|
|
|
75 |
|
if $has_readline |
|
76 |
|
then |
|
77 |
|
AC_READLINE_VERSION() |
|
78 |
|
if test $readline_version -ge 5 |
|
79 |
|
then |
|
80 |
|
AC_DEFINE(HAS_READLINE) |
|
81 |
|
else |
|
82 |
|
AC_MSG_RESULT(Readline version $readline_version is too old; needs at least version 5) |
|
83 |
|
fi |
|
84 |
|
fi |
|
85 |
|
|
|
86 |
|
|
| 75 |
87 |
|
|
| 76 |
88 |
]) |
]) |
| 77 |
89 |
|
|
| |
| ... |
... |
AC_DEFUN([AC_READLINE], [ |
| 87 |
99 |
READLINE_LIBS="$3" |
READLINE_LIBS="$3" |
| 88 |
100 |
READLINE_INCLUDES="$4" |
READLINE_INCLUDES="$4" |
| 89 |
101 |
search_readline=false |
search_readline=false |
| 90 |
|
AC_DEFINE(HAS_READLINE) |
|
| 91 |
102 |
has_readline=true |
has_readline=true |
| 92 |
103 |
fi |
fi |
| 93 |
104 |
fi |
fi |
| 94 |
105 |
]) |
]) |
| 95 |
106 |
|
|
| 96 |
107 |
AC_DEFUN([AC_SEARCH_READLINE], [ |
AC_DEFUN([AC_SEARCH_READLINE], [ |
| 97 |
|
AC_CHECKING("location of readline.h file") |
|
|
108 |
|
AC_CHECKING(location of readline.h file) |
| 98 |
109 |
|
|
| 99 |
110 |
AC_READLINE(/usr/include, readline.h, -lreadline,, "readline on /usr/include") |
AC_READLINE(/usr/include, readline.h, -lreadline,, "readline on /usr/include") |
| 100 |
111 |
AC_READLINE(/usr/include/readline, readline.h, -lreadline, -I/usr/include/readline, "readline on /usr/include/readline") |
AC_READLINE(/usr/include/readline, readline.h, -lreadline, -I/usr/include/readline, "readline on /usr/include/readline") |
| 101 |
112 |
AC_READLINE(/usr/local/include, readline.h, -L/usr/local/lib -lreadline, -I/usr/local/include, "readline on /usr/local") |
AC_READLINE(/usr/local/include, readline.h, -L/usr/local/lib -lreadline, -I/usr/local/include, "readline on /usr/local") |
| 102 |
113 |
AC_READLINE(/usr/local/include/readline, readline.h, -L/usr/local/lib -L/usr/local/lib/readline -lreadline, -I/usr/local/include/readline, "readline on /usr/local/include/readline") |
AC_READLINE(/usr/local/include/readline, readline.h, -L/usr/local/lib -L/usr/local/lib/readline -lreadline, -I/usr/local/include/readline, "readline on /usr/local/include/readline") |
| 103 |
114 |
] ) |
] ) |
|
115 |
|
|
|
116 |
|
AC_DEFUN([AC_READLINE_VERSION], [ |
|
117 |
|
AC_CHECKING(for readline version) |
|
118 |
|
readline_version=unknown |
|
119 |
|
cat > conftest.$ac_ext <<EOF |
|
120 |
|
[#]line __oline__ "configure" |
|
121 |
|
#include "confdefs.h" |
|
122 |
|
#include <readline.h> |
|
123 |
|
#undef VERSION |
|
124 |
|
VERSION:RL_VERSION_MAJOR.RL_VERSION_MINOR |
|
125 |
|
EOF |
|
126 |
|
if (eval "$ac_cpp $READLINE_INCLUDES conftest.$ac_ext") 2>&AC_FD_CC | |
|
127 |
|
egrep "VERSION:" >conftest.out 2>&1; then |
|
128 |
|
changequote(,)dnl |
|
129 |
|
readline_version=`cat conftest.out|sed -e 's/ //g' -e 's/^VERSION://' -e 's/\..*$//'` |
|
130 |
|
changequote([,])dnl |
|
131 |
|
fi |
|
132 |
|
rm -rf conftest* |
|
133 |
|
AC_MSG_RESULT($readline_version) |
|
134 |
|
] ) |
| File src/readlinewrapper.c changed (mode: 100644) (index ca82f48..53c9051) |
| ... |
... |
int rlhistorypos = 0; |
| 11 |
11 |
char * |
char * |
| 12 |
12 |
readlinewrapper(char *prompt) |
readlinewrapper(char *prompt) |
| 13 |
13 |
{ |
{ |
|
14 |
|
/* number of keys pressed */ |
|
15 |
|
int numkeys = 0; |
| 14 |
16 |
/* initial buffer for the read line */ |
/* initial buffer for the read line */ |
| 15 |
17 |
char *buf = xmalloc(1024); |
char *buf = xmalloc(1024); |
| 16 |
18 |
/* start coords of input line */ |
/* start coords of input line */ |
| |
| ... |
... |
readlinewrapper(char *prompt) |
| 44 |
46 |
strcpy(rlhistory[rlhistorylen - 1], buf); |
strcpy(rlhistory[rlhistorylen - 1], buf); |
| 45 |
47 |
/* call history to be present */ |
/* call history to be present */ |
| 46 |
48 |
if (CallReadlineHistory) |
if (CallReadlineHistory) |
|
49 |
|
{ |
| 47 |
50 |
ungetch(KEY_UP); |
ungetch(KEY_UP); |
|
51 |
|
numkeys = -1; |
|
52 |
|
} |
| 48 |
53 |
|
|
| 49 |
54 |
while (key != '\n') |
while (key != '\n') |
| 50 |
55 |
{ |
{ |
| |
| ... |
... |
readlinewrapper(char *prompt) |
| 101 |
106 |
/* recall value from history to input buf */ |
/* recall value from history to input buf */ |
| 102 |
107 |
strcpy(buf, rlhistory[rlhistorypos - 1]); |
strcpy(buf, rlhistory[rlhistorypos - 1]); |
| 103 |
108 |
} |
} |
| 104 |
|
if (cursor > strlen(buf)) |
|
| 105 |
|
cursor = strlen(buf); |
|
|
109 |
|
cursor = strlen(buf); |
|
110 |
|
numkeys = -1; |
| 106 |
111 |
break; |
break; |
| 107 |
112 |
/* forwards-history call */ |
/* forwards-history call */ |
| 108 |
113 |
case KEY_DOWN: |
case KEY_DOWN: |
| |
| ... |
... |
readlinewrapper(char *prompt) |
| 112 |
117 |
rlhistorypos++; |
rlhistorypos++; |
| 113 |
118 |
strcpy(buf, rlhistory[rlhistorypos - 1]); |
strcpy(buf, rlhistory[rlhistorypos - 1]); |
| 114 |
119 |
} |
} |
| 115 |
|
if (cursor > strlen(buf)) |
|
| 116 |
|
cursor = strlen(buf); |
|
|
120 |
|
cursor = strlen(buf); |
|
121 |
|
numkeys = -1; |
| 117 |
122 |
break; |
break; |
| 118 |
123 |
/* eliminate nonprintable chars */ |
/* eliminate nonprintable chars */ |
| 119 |
124 |
case '\n': |
case '\n': |
| |
| ... |
... |
readlinewrapper(char *prompt) |
| 133 |
138 |
default: |
default: |
| 134 |
139 |
if (key >= 32) |
if (key >= 32) |
| 135 |
140 |
{ |
{ |
|
141 |
|
/* if this is the first key, delete the buffer */ |
|
142 |
|
if (numkeys==0 && cursor!=0) |
|
143 |
|
{ |
|
144 |
|
for (i=0; buf[i]!=0; i++) |
|
145 |
|
buf[i] = 0; |
|
146 |
|
cursor = 0; |
|
147 |
|
/* and empty the line */ |
|
148 |
|
move(origy, origx); |
|
149 |
|
for (i = origx; i < maxx; i++) |
|
150 |
|
addch(' '); |
|
151 |
|
move(origy, origx + cursor); |
|
152 |
|
} |
|
153 |
|
|
| 136 |
154 |
/* if the cursor is not at the last pos */ |
/* if the cursor is not at the last pos */ |
| 137 |
155 |
if (strlen(buf + cursor)) |
if (strlen(buf + cursor)) |
| 138 |
156 |
{ |
{ |
| |
| ... |
... |
readlinewrapper(char *prompt) |
| 160 |
178 |
addstr(buf); |
addstr(buf); |
| 161 |
179 |
move(origy, origx + cursor); |
move(origy, origx + cursor); |
| 162 |
180 |
|
|
|
181 |
|
numkeys++; |
|
182 |
|
|
| 163 |
183 |
} |
} |
| 164 |
184 |
strcpy(rlhistory[rlhistorylen - 1], buf); |
strcpy(rlhistory[rlhistorylen - 1], buf); |
| 165 |
185 |
if (strlen(buf)) |
if (strlen(buf)) |
| File src/utils.c changed (mode: 100644) (index 59bd05d..3632b9e) |
| ... |
... |
char *pinfo_re_pattern = 0; |
| 21 |
21 |
int pinfo_re_offset = -1; |
int pinfo_re_offset = -1; |
| 22 |
22 |
#endif |
#endif |
| 23 |
23 |
|
|
| 24 |
|
/* |
|
| 25 |
|
* Readline does not work well here. VT100 screen is ruined then. |
|
| 26 |
|
* |
|
| 27 |
|
* But if you want enable readline at compile time |
|
| 28 |
|
* [ ./configure --with-readline ] |
|
| 29 |
|
* |
|
| 30 |
|
*/ |
|
| 31 |
|
|
|
| 32 |
24 |
#ifdef HAS_READLINE |
#ifdef HAS_READLINE |
| 33 |
25 |
#include <readline/readline.h> |
#include <readline/readline.h> |
| 34 |
26 |
#include <readline/history.h> |
#include <readline/history.h> |
| |
| ... |
... |
checkfilename(char *filename) |
| 216 |
208 |
} |
} |
| 217 |
209 |
} |
} |
| 218 |
210 |
|
|
|
211 |
|
#ifdef HAS_READLINE |
|
212 |
|
/* custom function that readline will use to display text */ |
|
213 |
|
void |
|
214 |
|
my_rl_display() |
|
215 |
|
{ |
|
216 |
|
/* go to the bottom line, empty it, and print the prompt and buffer */ |
|
217 |
|
attrset(bottomline); |
|
218 |
|
mymvhline(maxy - 1, 0, ' ', maxx); |
|
219 |
|
move(maxy-1,0); |
|
220 |
|
printw("%s%s", rl_prompt, rl_line_buffer); |
|
221 |
|
refresh(); |
|
222 |
|
} |
|
223 |
|
#endif |
|
224 |
|
|
| 219 |
225 |
char * |
char * |
| 220 |
226 |
getstring(char *prompt) |
getstring(char *prompt) |
| 221 |
227 |
{ |
{ |
| 222 |
|
/* |
|
| 223 |
|
* As above -- readline is dangerous ;) |
|
| 224 |
|
* But if you want enable readline at compile time |
|
| 225 |
|
* [ ./configure --with-readline ] |
|
| 226 |
|
* |
|
| 227 |
|
*/ |
|
| 228 |
|
|
|
| 229 |
|
#ifndef HAS_READLINE |
|
| 230 |
|
|
|
| 231 |
|
move(maxy - 1, 0); |
|
| 232 |
|
return readlinewrapper(prompt); |
|
|
228 |
|
char *buf; |
| 233 |
229 |
|
|
| 234 |
|
#else |
|
|
230 |
|
#ifdef HAS_READLINE |
| 235 |
231 |
|
|
| 236 |
|
char *buf; |
|
| 237 |
|
TERMINAL *term = cur_term; |
|
| 238 |
232 |
curs_set(1); |
curs_set(1); |
| 239 |
233 |
move(maxy - 1, 0); |
move(maxy - 1, 0); |
| 240 |
234 |
refresh(); |
refresh(); |
| 241 |
|
sigblock(sigmask(SIGINT) | sigmask(SIGPIPE)); |
|
|
235 |
|
|
|
236 |
|
rl_readline_name = PACKAGE; |
|
237 |
|
|
|
238 |
|
/* set display function for readline to my_rl_display and call readline */ |
|
239 |
|
rl_redisplay_function = my_rl_display; |
| 242 |
240 |
buf = readline(prompt); |
buf = readline(prompt); |
| 243 |
|
cur_term = term; |
|
| 244 |
|
sigblock(sigmask(SIGPIPE)); |
|
| 245 |
|
add_history(buf); |
|
|
241 |
|
if (buf && *buf) |
|
242 |
|
add_history(buf); |
|
243 |
|
|
| 246 |
244 |
curs_set(0); |
curs_set(0); |
| 247 |
|
return buf; |
|
|
245 |
|
|
|
246 |
|
#else |
|
247 |
|
|
|
248 |
|
move(maxy - 1, 0); |
|
249 |
|
buf = readlinewrapper(prompt); |
|
250 |
|
|
| 248 |
251 |
#endif |
#endif |
| 249 |
252 |
|
|
|
253 |
|
return buf; |
| 250 |
254 |
} |
} |
| 251 |
255 |
|
|
| 252 |
256 |
void |
void |