X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/66abbf4d0da4532ef0e109b144ebf8aa09d40886..13c7f2fb8fc0619c8da1b5c8a697f7894479b070:/Display.cpp diff --git a/Display.cpp b/Display.cpp index 1881ccd..bd646bb 100644 --- a/Display.cpp +++ b/Display.cpp @@ -1,20 +1,20 @@ /* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2012 Jay Freeman (saurik) + * Copyright (C) 2009-2013 Jay Freeman (saurik) */ -/* GNU Lesser General Public License, Version 3 {{{ */ +/* GNU General Public License, Version 3 {{{ */ /* - * Cycript is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. + * Cycript is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. * - * Cycript is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. + * Cycript is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License + * You should have received a copy of the GNU General Public License * along with Cycript. If not, see . **/ /* }}} */ @@ -28,6 +28,8 @@ #include #endif +#if RL_READLINE_VERSION >= 0x0600 + #include #include "Highlight.hpp" @@ -36,6 +38,11 @@ typedef std::complex CYCursor; +extern "C" int rl_display_fixed; +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_; @@ -72,9 +79,6 @@ CYCursor CYDisplayOutput(int (*put)(int), int width, const char *data, ssize_t o case CYIgnoreStart: CYDisplayOutput_(put, data); - ++offset; - break; - case CYIgnoreEnd: ++offset; break; @@ -90,8 +94,6 @@ CYCursor CYDisplayOutput(int (*put)(int), int width, const char *data, ssize_t o } } - - return point; } void CYDisplayMove_(char *negative, char *positive, int offset) { @@ -114,12 +116,11 @@ void CYDisplayMove(CYCursor target) { current_ = target; } -void CYDisplayStart(int meta) { - rl_prep_terminal(meta); - current_ = CYCursor(); -} - void CYDisplayUpdate() { + rl_display_fixed = 1; + rl_redisplay(); + current_ = CYCursor(_rl_last_v_pos, _rl_last_c_pos); + #if RL_READLINE_VERSION >= 0x0600 const char *prompt(rl_display_prompt); #else @@ -140,20 +141,22 @@ void CYDisplayUpdate() { CYDisplayMove(CYCursor()); CYDisplayOutput(putchar, width, prompt); - CYCursor target(CYDisplayOutput(putchar, width, stream.str().c_str(), rl_point)); - if (target.imag() == 0) - putp(cursor_down); + _rl_vis_botlin = current_.real(); + + if (current_.imag() == 0) + CYDisplayOutput(putchar, width, " "); putp(clr_eos); - CYDisplayMove(target); + CYDisplayMove(target); fflush(stdout); + _rl_last_v_pos = current_.real(); + _rl_last_c_pos = current_.imag(); + width_ = width; point_ = rl_point; } -void CYDisplayFinish() { - rl_deprep_terminal(); -} +#endif