X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/dd05902964547b2fe566f8c3131d7d1ff622ce44..8964aa089c709fbf370be623d75a204480b26b3c:/Display.cpp diff --git a/Display.cpp b/Display.cpp index fbca8df..d76ac1f 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 . **/ /* }}} */ @@ -72,9 +72,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,19 +87,25 @@ CYCursor CYDisplayOutput(int (*put)(int), int width, const char *data, ssize_t o } } +} - return point; +void CYDisplayMove_(char *negative, char *positive, int offset) { + if (offset < 0) + putp(tparm(negative, -offset)); + else if (offset > 0) + putp(tparm(positive, offset)); } void CYDisplayMove(CYCursor target) { - int offset(target.real() - current_.real()); + CYCursor offset(target - current_); - if (offset < 0) - putp(tparm(parm_up_cursor, -offset)); - else if (offset > 0) - putp(tparm(parm_down_cursor, offset)); + CYDisplayMove_(parm_up_cursor, parm_down_cursor, offset.real()); + + if (char *parm = tparm(column_address, target.imag())) + putp(parm); + else + CYDisplayMove_(parm_left_cursor, parm_right_cursor, offset.imag()); - putp(tparm(column_address, target.imag())); current_ = target; } @@ -127,19 +130,18 @@ void CYDisplayUpdate() { if (width_ != width) { current_ = CYCursor(); CYDisplayOutput(NULL, width, prompt); - CYDisplayOutput(NULL, width, buffer, point_); + current_ = CYDisplayOutput(NULL, width, buffer, point_); } CYDisplayMove(CYCursor()); CYDisplayOutput(putchar, width, prompt); - CYCursor target(CYDisplayOutput(putchar, width, stream.str().c_str(), rl_point)); - if (target.imag() == 0) - putp(cursor_down); + if (current_.imag() == 0) + CYDisplayOutput(putchar, width, " "); putp(clr_eos); - CYDisplayMove(target); + CYDisplayMove(target); fflush(stdout); width_ = width;