-
Notifications
You must be signed in to change notification settings - Fork 33
/
readline.patch
294 lines (249 loc) · 10.3 KB
/
readline.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
diff -ru a/display.c b/display.c
--- a/display.c 2015-10-28 00:00:00.000000000 - 0400
--- b/display.c 2015-10-28 00:00:00.000000000 - 0400
@@ -255,6 +255,11 @@
static int prompt_last_screen_line;
static int prompt_physical_chars;
+
+int
+rla_prompt_phys_length() {
+ return prompt_physical_chars;
+}
/* An array of indexes into the prompt string where we will break physical
screen lines. It's easier to compute in expand_prompt and use later in
diff -ru a/Makefile.in b/Makefile.in
--- a/Makefile.in 2015-07-15 00:03:32.894897704 -0400
+++ b/Makefile.in 2015-07-14 23:36:13.208157503 -0400
@@ -75,7 +75,7 @@
CTAGS = ctags -tw
CFLAGS = @CFLAGS@
-LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
+LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"' -DVIMBED_LOCATION='"${libdir}/athame_readline"' -DATHAME_VIM_BIN='"${ATHAME_VIM_BIN}"' -DATHAME_USE_JOBS_DEFAULT='${ATHAME_USE_JOBS_DEFAULT}'
CPPFLAGS = @CPPFLAGS@
DEFS = @DEFS@ @CROSS_COMPILE@
@@ -120,7 +120,7 @@
$(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
$(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
$(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \
- $(srcdir)/mbutil.c
+ $(srcdir)/mbutil.c $(srcdir)/athame.c
# The header files for this library.
HSOURCES = $(srcdir)/readline.h $(srcdir)/rldefs.h $(srcdir)/chardefs.h \
@@ -130,7 +130,7 @@
$(srcdir)/ansi_stdlib.h $(srcdir)/tcap.h $(srcdir)/rlstdc.h \
$(srcdir)/xmalloc.h $(srcdir)/rlprivate.h $(srcdir)/rlshell.h \
$(srcdir)/rltypedefs.h $(srcdir)/rlmbutil.h \
- $(srcdir)/colors.h $(srcdir)/parse-colors.h
+ $(srcdir)/colors.h $(srcdir)/parse-colors.h $(srcdir)/athame.h
HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o mbutil.o
TILDEOBJ = tilde.o
@@ -153,7 +153,7 @@
CREATED_TAGS = TAGS tags
INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h \
- rlstdc.h rlconf.h rltypedefs.h
+ rlstdc.h rlconf.h rltypedefs.h athame.h
OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/INSTALL $(srcdir)/README
OTHER_INSTALLED_DOCS = CHANGES INSTALL README
@@ -230,6 +230,13 @@
install: $(INSTALL_TARGETS)
+install-vimbed:
+ $(RM) $(DESTDIR)$(libdir)/athame_readline/vimbed.vim && $(RM) -r $(DESTDIR)$(libdir)/athame_readline
+ $(CP) -r $(srcdir)/vimbed/plugin $(DESTDIR)$(libdir)/athame_readline
+
+uninstall-vimbed:
+ $(RM) -r $(DESTDIR)$(libdir)/athame_readline
+
install-headers: installdirs ${INSTALLED_HEADERS}
for f in ${INSTALLED_HEADERS}; do \
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(includedir)/readline ; \
@@ -250,7 +257,7 @@
maybe-uninstall-pc: uninstall-pc
-install-static: installdirs $(STATIC_LIBS) install-headers install-doc ${install_examples} install-pc
+install-static: installdirs $(STATIC_LIBS) install-headers install-doc ${install_examples} install-pc install-vimbed
-$(MV) $(DESTDIR)$(libdir)/libreadline.a $(DESTDIR)$(libdir)/libreadline.old
$(INSTALL_DATA) libreadline.a $(DESTDIR)$(libdir)/libreadline.a
-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libreadline.a
@@ -264,7 +281,7 @@
$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir) $(DESTDIR)$(docdir) \
$(DESTDIR)$(pkgconfigdir)
-uninstall: uninstall-headers uninstall-doc uninstall-examples uninstall-pc
+uninstall: uninstall-headers uninstall-doc uninstall-examples uninstall-pc uninstall-vimbed
-test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS)
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
@@ -412,7 +419,7 @@
readline.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
readline.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
readline.o: history.h rlstdc.h
-readline.o: posixstat.h ansi_stdlib.h posixjmp.h
+readline.o: posixstat.h ansi_stdlib.h posixjmp.h athame.h
rltty.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
rltty.o: rltty.h
rltty.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
@@ -532,6 +539,7 @@
text.o: rlmbutil.h
vi_mode.o: rlmbutil.h
+athame.o: $(srcdir)/athame.c
bind.o: $(srcdir)/bind.c
callback.o: $(srcdir)/callback.c
compat.o: $(srcdir)/compat.c
@@ -570,6 +578,7 @@
history.o: $(srcdir)/history.c
histsearch.o: $(srcdir)/histsearch.c
+athame.o: athame.c
bind.o: bind.c
callback.o: callback.c
compat.o: compat.c
diff -ru a/readline.c b/readline.c
--- a/readline.c 2015-07-15 00:03:32.898231038 -0400
+++ b/readline.c 2015-07-15 00:07:56.201576180 -0400
@@ -67,6 +67,7 @@
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
+#include "athame.h"
#include "rlprivate.h"
#include "rlshell.h"
@@ -450,6 +451,8 @@
if (rl_pre_input_hook)
(*rl_pre_input_hook) ();
+ athame_init(fileno(rl_instream), rl_outstream);
+
RL_CHECK_SIGNALS ();
}
@@ -461,6 +464,8 @@
RL_CHECK_SIGNALS ();
+ athame_cleanup(0);
+
/* Restore the original of this history line, iff the line that we
are editing was originally in the history, AND the line has changed. */
entry = current_history ();
@@ -570,7 +575,16 @@
}
RL_SETSTATE(RL_STATE_READCMD);
- c = rl_read_key ();
+ int use_athame = athame_enabled();
+ if (use_athame)
+ {
+ c = athame_loop(fileno(rl_instream));
+ }
+ else {
+ c = rl_read_key();
+ athame_after_bypass();
+ }
+ if (!use_athame || c) {
RL_UNSETSTATE(RL_STATE_READCMD);
/* look at input.c:rl_getc() for the circumstances under which this will
@@ -630,6 +644,7 @@
lastc = c;
r = _rl_dispatch ((unsigned char)c, _rl_keymap);
+ athame_char_handled();
RL_CHECK_SIGNALS ();
/* If there was no change in _rl_last_command_was_kill, then no kill
@@ -638,6 +653,7 @@
if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
_rl_last_command_was_kill = 0;
+}
_rl_internal_char_cleanup ();
#if defined (READLINE_CALLBACKS)
diff -ru a/shlib/Makefile.in b/shlib/Makefile.in
--- a/shlib/Makefile.in 2015-07-15 00:03:32.898231038 -0400
+++ b/shlib/Makefile.in 2015-07-14 23:37:04.674826478 -0400
@@ -64,7 +64,7 @@
DESTDIR =
CFLAGS = @CFLAGS@
-LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
+LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"' -DVIMBED_LOCATION='"${libdir}/athame_readline"' -DATHAME_VIM_BIN='"${ATHAME_VIM_BIN}"' -DATHAME_USE_JOBS_DEFAULT='${ATHAME_USE_JOBS_DEFAULT}'
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@ @CFLAGS@
@@ -135,7 +135,7 @@
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \
$(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \
$(topdir)/colors.c $(topdir)/parse-colors.c \
- $(topdir)/mbutil.c
+ $(topdir)/mbutil.c $(topdir)/athame.c
# The header files for this library.
HSOURCES = $(topdir)/readline.h $(topdir)/rldefs.h $(topdir)/chardefs.h \
@@ -145,7 +145,7 @@
$(topdir)/ansi_stdlib.h $(topdir)/tcap.h $(topdir)/rlstdc.h \
$(topdir)/xmalloc.h $(topdir)/rlprivate.h $(topdir)/rlshell.h \
$(topdir)/rltypedefs.h $(topdir)/rlmbutil.h \
- $(topdir)/colors.h $(topdir)/parse-colors.h
+ $(topdir)/colors.h $(topdir)/parse-colors.h $(topdir)/athame.h
SHARED_HISTOBJ = history.so histexpand.so histfile.so histsearch.so shell.so \
mbutil.so
@@ -156,7 +156,7 @@
util.so kill.so undo.so macro.so input.so callback.so terminal.so \
text.so nls.so misc.so \
$(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) $(SHARED_COLORSOBJ) \
- xmalloc.so xfree.so compat.so
+ xmalloc.so xfree.so compat.so athame.so
##########################################################################
@@ -191,7 +191,14 @@
-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(libdir)
-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(bindir)
-install-supported: installdirs $(SHLIB_STATUS)
+install-athame:
+ $(RM) $(DESTDIR)$(libdir)/athame_readline/vimbed.vim && $(RM) -r $(DESTDIR)$(libdir)/athame_readline
+ $(CP) -r $(topdir)/vimbed/plugin $(DESTDIR)$(libdir)/athame_readline
+
+uninstall-athame:
+ $(RM) -r $(DESTDIR)$(libdir)/athame_readline
+
+install-supported: installdirs $(SHLIB_STATUS) install-athame
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
@echo install: you may need to run ldconfig
@@ -201,7 +208,7 @@
install: install-$(SHLIB_STATUS)
-uninstall-supported:
+uninstall-supported: uninstall-athame
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_HISTORY)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -V $(host_vendor) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_READLINE)
@echo uninstall: you may need to run ldconfig
@@ -341,6 +348,8 @@
xmalloc.so: ${BUILD_DIR}/config.h
xmalloc.so: $(topdir)/ansi_stdlib.h
+readline.so: $(topdir)/athame.h
+
bind.so: $(topdir)/rlshell.h
histfile.so: $(topdir)/rlshell.h
nls.so: $(topdir)/rlshell.h
@@ -427,6 +436,7 @@
colors.so: $(topdir)/rlmbutil.h
parse-colors.so: $(topdir)/rlmbutil.h
+athame.so: $(topdir)/athame.c
bind.so: $(topdir)/bind.c
callback.so: $(topdir)/callback.c
compat.so: $(topdir)/compat.c
@@ -462,6 +472,7 @@
history.so: $(topdir)/history.c
histsearch.so: $(topdir)/histsearch.c
+athame.so: athame.c
bind.so: bind.c
callback.so: callback.c
comapt.so: compat.c
diff -ru a/readline.h b/readline.h
--- a/readline.h 2015-10-29 00:00:00.000000000 -0400
+++ b/readline.h 2015-10-29 00:00:00.000000000 -0400
@@ -295,6 +295,7 @@
extern int rl_set_prompt PARAMS((const char *));
extern int rl_expand_prompt PARAMS((char *));
+extern int rla_prompt_phys_length PARAMS((void));
extern int rl_initialize PARAMS((void));
diff -ru a/callback.c b/callback.c
--- a/callback.c 2015-10-29 00:00:00.000000000 -0400
+++ b/callback.c 2015-10-29 00:00:00.000000000 -0400
@@ -26,6 +26,7 @@
#endif
#include "rlconf.h"
+#include "athame.h"
#if defined (READLINE_CALLBACKS)
@@ -311,6 +312,8 @@
rl_clear_signals ();
#endif
}
+ // If readline exits early because of a SIGINT, it still needs to cleanup athame.
+ athame_cleanup(1);
}
_rl_callback_generic_arg *