#include <readline/readline.h>
 #endif
 
+#if RL_READLINE_VERSION >= 0x0600
+
 #include <sys/ioctl.h>
 
 #include "Highlight.hpp"
 
 typedef std::complex<int> CYCursor;
 
+extern "C" int _rl_vis_botlin;
+extern "C" int _rl_last_c_pos;
+extern "C" int _rl_last_v_pos;
+
 CYCursor current_;
 int width_;
 size_t point_;
     CYDisplayOutput(putchar, width, prompt);
     CYCursor target(CYDisplayOutput(putchar, width, stream.str().c_str(), rl_point));
 
+    _rl_vis_botlin = current_.real();
+    _rl_last_c_pos = current_.imag();
+    _rl_last_v_pos = target.real();
+
+    // XXX: readline crashes trying to avoid an empty line if this is left at 0 :(
+    if (_rl_last_c_pos == 0)
+        _rl_last_c_pos = 1;
+
     if (current_.imag() == 0)
         CYDisplayOutput(putchar, width, " ");
     putp(clr_eos);
 void CYDisplayFinish() {
     rl_deprep_terminal();
 }
+
+#endif