summaryrefslogtreecommitdiffstats
path: root/lib/libedit/refresh.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libedit/refresh.c')
-rw-r--r--lib/libedit/refresh.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c
index 08f1336..7255654 100644
--- a/lib/libedit/refresh.c
+++ b/lib/libedit/refresh.c
@@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -33,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: refresh.c,v 1.16 2001/01/10 07:45:42 jdolecek Exp $
+ * $NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -47,6 +43,7 @@ __FBSDID("$FreeBSD$");
*/
#include "sys.h"
#include <stdio.h>
+#include <ctype.h>
#include <unistd.h>
#include <string.h>
@@ -58,24 +55,24 @@ private void re_insert (EditLine *, char *, int, int, char *, int);
private void re_delete(EditLine *, char *, int, int, int);
private void re_fastputc(EditLine *, int);
private void re__strncopy(char *, char *, size_t);
-private void re__copy_and_pad(char *, char *, size_t);
+private void re__copy_and_pad(char *, const char *, size_t);
#ifdef DEBUG_REFRESH
-private void re_printstr(EditLine *, char *, char *, char *);
+private void re_printstr(EditLine *, const char *, char *, char *);
#define __F el->el_errfile
#define ELRE_ASSERT(a, b, c) do \
- if (a) { \
+ if (/*CONSTCOND*/ a) { \
(void) fprintf b; \
c; \
} \
- while (0)
+ while (/*CONSTCOND*/0)
#define ELRE_DEBUG(a, b) ELRE_ASSERT(a,b,;)
/* re_printstr():
* Print a string on the debugging pty
*/
private void
-re_printstr(EditLine *el, char *str, char *f, char *t)
+re_printstr(EditLine *el, const char *str, char *f, char *t)
{
ELRE_DEBUG(1, (__F, "%s:\"", str));
@@ -96,8 +93,6 @@ private void
re_addc(EditLine *el, int c)
{
- c = (unsigned char)c;
-
if (isprint(c)) {
re_putc(el, c, 1);
return;
@@ -208,6 +203,14 @@ re_refresh(EditLine *el)
el->el_refresh.r_cursor.h = 0;
el->el_refresh.r_cursor.v = 0;
+ if (el->el_line.cursor >= el->el_line.lastchar) {
+ if (el->el_map.current == el->el_map.alt
+ && el->el_line.lastchar != el->el_line.buffer)
+ el->el_line.cursor = el->el_line.lastchar - 1;
+ else
+ el->el_line.cursor = el->el_line.lastchar;
+ }
+
cur.h = -1; /* set flag in case I'm not set */
cur.v = 0;
@@ -317,7 +320,6 @@ re_goto_bottom(EditLine *el)
{
term_move_to_line(el, el->el_refresh.r_oldcv);
- term__putc('\r');
term__putc('\n');
re_clear_display(el);
term__flush();
@@ -330,7 +332,8 @@ re_goto_bottom(EditLine *el)
*/
private void
/*ARGSUSED*/
-re_insert(EditLine *el, char *d, int dat, int dlen, char *s, int num)
+re_insert(EditLine *el __unused,
+ char *d, int dat, int dlen, char *s, int num)
{
char *a, *b;
@@ -373,7 +376,8 @@ re_insert(EditLine *el, char *d, int dat, int dlen, char *s, int num)
*/
private void
/*ARGSUSED*/
-re_delete(EditLine *el, char *d, int dat, int dlen, int num)
+re_delete(EditLine *el __unused,
+ char *d, int dat, int dlen, int num)
{
char *a, *b;
@@ -906,9 +910,9 @@ re_update_line(EditLine *el, char *old, char *new, int i)
* Copy string and pad with spaces
*/
private void
-re__copy_and_pad(char *dst, char *src, size_t width)
+re__copy_and_pad(char *dst, const char *src, size_t width)
{
- int i;
+ size_t i;
for (i = 0; i < width; i++) {
if (*src == '\0')
@@ -932,6 +936,14 @@ re_refresh_cursor(EditLine *el)
char *cp, c;
int h, v, th;
+ if (el->el_line.cursor >= el->el_line.lastchar) {
+ if (el->el_map.current == el->el_map.alt
+ && el->el_line.lastchar != el->el_line.buffer)
+ el->el_line.cursor = el->el_line.lastchar - 1;
+ else
+ el->el_line.cursor = el->el_line.lastchar;
+ }
+
/* first we must find where the cursor is... */
h = el->el_prompt.p_pos.h;
v = el->el_prompt.p_pos.v;
@@ -939,7 +951,7 @@ re_refresh_cursor(EditLine *el)
/* do input buffer to el->el_line.cursor */
for (cp = el->el_line.buffer; cp < el->el_line.cursor; cp++) {
- c = (unsigned char)*cp;
+ c = *cp;
h++; /* all chars at least this long */
if (c == '\n') {/* handle newline in data part too */
@@ -1054,8 +1066,8 @@ re_fastaddc(EditLine *el)
re_fastputc(el, c);
} else {
re_fastputc(el, '\\');
- re_fastputc(el, (int) ((((unsigned int) c >> 6) & 7) + '0'));
- re_fastputc(el, (int) ((((unsigned int) c >> 3) & 7) + '0'));
+ re_fastputc(el, (int)(((((unsigned int)c) >> 6) & 3) + '0'));
+ re_fastputc(el, (int)(((((unsigned int)c) >> 3) & 7) + '0'));
re_fastputc(el, (c & 7) + '0');
}
term__flush();
OpenPOWER on IntegriCloud