if (local_prompt_prefix)
free (local_prompt_prefix);
local_prompt = local_prompt_prefix = (char *)0;
- last_invisible = 0;
+ last_invisible = visible_length = 0;
if (prompt == 0 || *prompt == 0)
return (0);
if (local_len > 0)
{
+ temp = local_len + out + 2;
+ if (temp >= line_size)
+ {
+ line_size = (temp + 1024) - (temp % 1024);
+ visible_line = xrealloc (visible_line, line_size);
+ line = invisible_line = xrealloc (invisible_line, line_size);
+ }
strncpy (line + out, local_prompt, local_len);
out += local_len;
}
}
pmtlen = strlen (prompt_this_line);
+ temp = pmtlen + out + 2;
+ if (temp >= line_size)
+ {
+ line_size = (temp + 1024) - (temp % 1024);
+ visible_line = xrealloc (visible_line, line_size);
+ line = invisible_line = xrealloc (invisible_line, line_size);
+ }
strncpy (line + out, prompt_this_line, pmtlen);
out += pmtlen;
line[out] = '\0';
#define CHECK_LPOS() \
do { \
- lpos++; \
- if (lpos >= screenwidth) \
- { \
- inv_lbreaks[++newlines] = out; \
- lpos = 0; \
- } \
+ lpos++; \
+ if (lpos >= screenwidth) \
+ { \
+ inv_lbreaks[++newlines] = out; \
+ lpos = 0; \
+ } \
} while (0)
/* inv_lbreaks[i] is where line i starts in the buffer. */
else if (c == '\t')
{
register int temp, newout;
+
+#if 0
newout = (out | (int)7) + 1;
+#else
+ newout = out + 8 - lpos % 8;
+#endif
temp = newout - out;
if (lpos + temp >= screenwidth)
{
}
#endif
else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
- {
- line[out++] = '\0'; /* XXX - sentinel */
- inv_lbreaks[++newlines] = out;
- lpos = 0;
- }
+ {
+ line[out++] = '\0'; /* XXX - sentinel */
+ inv_lbreaks[++newlines] = out;
+ lpos = 0;
+ }
else if (CTRL_CHAR (c) || c == RUBOUT)
{
line[out++] = '^';
{
_rl_move_vert (cursor_linenum);
/* If we moved up to the line with the prompt using term_up,
- the physical cursor position on the screen stays the same,
- but the buffer position needs to be adjusted to account
- for invisible characters. */
+ the physical cursor position on the screen stays the same,
+ but the buffer position needs to be adjusted to account
+ for invisible characters. */
if (cursor_linenum == 0 && wrap_offset)
- _rl_last_c_pos += wrap_offset;
+ _rl_last_c_pos += wrap_offset;
}
/* We have to reprint the prompt if it contains invisible
if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
_rl_last_c_pos <= last_invisible && local_prompt)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
if (term_cr)
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_output_some_chars (local_prompt, nleft);
_rl_last_c_pos = nleft;
}
ndisp = c_pos - wrap_offset;
nleft = visible_length + wrap_offset;
/* Where the new cursor position will be on the screen. This can be
- longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
+ longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset);
t = screenwidth / 3;
/* If the number of characters had already exceeded the screenwidth,
- last_lmargin will be > 0. */
+ last_lmargin will be > 0. */
/* If the number of characters to be displayed is more than the screen
- width, compute the starting offset so that the cursor is about
- two-thirds of the way across the screen. */
+ width, compute the starting offset so that the cursor is about
+ two-thirds of the way across the screen. */
if (phys_c_pos > screenwidth - 2)
{
lmargin = c_pos - (2 * t);
lmargin = nleft;
}
else if (ndisp < screenwidth - 2) /* XXX - was -1 */
- lmargin = 0;
+ lmargin = 0;
else if (phys_c_pos < 1)
{
/* If we are moving back towards the beginning of the line and
lmargin = nleft;
}
else
- lmargin = last_lmargin;
+ lmargin = last_lmargin;
/* If the first character on the screen isn't the first character
in the display line, indicate this with a special character. */
line[lmargin] = '<';
/* If SCREENWIDTH characters starting at LMARGIN do not encompass
- the whole line, indicate that with a special characters at the
- right edge of the screen. If LMARGIN is 0, we need to take the
- wrap offset into account. */
+ the whole line, indicate that with a special character at the
+ right edge of the screen. If LMARGIN is 0, we need to take the
+ wrap offset into account. */
t = lmargin + M_OFFSET (lmargin, wrap_offset) + screenwidth;
if (t < out)
- line[t - 1] = '>';
+ line[t - 1] = '>';
if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
{
\new first difference
All are character pointers for the sake of speed. Special cases for
- no differences, as well as for end of line additions must be handeled.
+ no differences, as well as for end of line additions must be handled.
Could be made even smarter, but this works well enough */
static void
_rl_last_c_pos = 1; /* XXX */
_rl_last_v_pos++;
if (old[0] && new[0])
- old[0] = new[0];
+ old[0] = new[0];
}
/* Find first difference. */
term_cr && lendiff > visible_length && _rl_last_c_pos > 0 &&
od > lendiff && _rl_last_c_pos < last_invisible)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif /* !__MSDOS__ */
_rl_output_some_chars (local_prompt, lendiff);
_rl_last_c_pos = lendiff;
}
lendiff needs to be adjusted. */
if (current_line == 0 && !_rl_horizontal_scroll_mode &&
current_invis_chars != visible_wrap_offset)
- {
- temp = visible_wrap_offset - current_invis_chars;
- lendiff += temp;
- }
+ lendiff += visible_wrap_offset - current_invis_chars;
/* Insert (diff (len (old), len (new)) ch. */
temp = ne - nfd;
/* At the end of a line the characters do not have to
be "inserted". They can just be placed on the screen. */
/* However, this screws up the rest of this block, which
- assumes you've done the insert because you can. */
+ assumes you've done the insert because you can. */
_rl_output_some_chars (nfd, lendiff);
_rl_last_c_pos += lendiff;
}
_rl_last_c_pos += temp;
}
lendiff = (oe - old) - (ne - new);
- if (_rl_term_autowrap && current_line < inv_botlin)
- space_to_eol (lendiff);
- else
- _rl_clear_to_eol (lendiff);
+ if (lendiff)
+ {
+ if (_rl_term_autowrap && current_line < inv_botlin)
+ space_to_eol (lendiff);
+ else
+ _rl_clear_to_eol (lendiff);
+ }
}
}
}
register char *temp = visible_line;
while (*temp)
- *temp++ = '\0';
+ *temp++ = '\0';
}
rl_on_new_line ();
forced_display++;
putc (data[i], rl_outstream);
#endif /* HACK_TERMCAP_MOTION */
}
- else if (_rl_last_c_pos != new)
+ else if (_rl_last_c_pos > new)
_rl_backspace (_rl_last_c_pos - new);
_rl_last_c_pos = new;
}
{
int row, col;
+ i = fflush (rl_outstream); /* make sure the cursor pos is current! */
ScreenGetCursor (&row, &col);
ScreenSetCursor ((row + to - _rl_last_v_pos), col);
+ delta = i;
}
#else /* !__GO32__ */
static int saved_visible_length;
void
-_rl_save_prompt ()
+rl_save_prompt ()
{
saved_local_prompt = local_prompt;
saved_local_prefix = local_prompt_prefix;
}
void
-_rl_restore_prompt ()
+rl_restore_prompt ()
{
if (local_prompt)
free (local_prompt);
int len;
char *pmt;
- _rl_save_prompt ();
+ rl_save_prompt ();
if (saved_local_prompt == 0)
{
len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
pmt = xmalloc (len + 2);
if (len)
- strcpy (pmt, rl_prompt);
+ strcpy (pmt, rl_prompt);
pmt[len] = pchar;
pmt[len+1] = '\0';
}
len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
pmt = xmalloc (len + 2);
if (len)
- strcpy (pmt, saved_local_prompt);
+ strcpy (pmt, saved_local_prompt);
pmt[len] = pchar;
pmt[len+1] = '\0';
local_prompt = savestring (pmt);
void
_rl_clear_screen ()
{
-#if !defined (__GO32__)
+#if defined (__GO32__)
+ ScreenClear (); /* FIXME: only works in text modes */
+ ScreenSetCursor (0, 0); /* term_clrpag is "cl" which homes the cursor */
+#else
if (term_clrpag)
tputs (term_clrpag, 1, _rl_output_character_function);
else
int count;
{
#if defined (__GO32__)
+#ifndef __DJGPP__
int row, col, width;
char *row_start;
row_start = ScreenPrimary + (row * width);
memcpy (row_start + col + count, row_start + col, width - col - count);
-
+#endif /* !__DJGPP__ */
/* Place the text on the screen. */
_rl_output_some_chars (string, count);
#else /* !_GO32 */
delete_chars (count)
int count;
{
+#if !defined (__DJGPP__)
#if defined (__GO32__)
int row, col, width;
char *row_start;
tputs (term_dc, 1, _rl_output_character_function);
}
#endif /* !__GO32__ */
+#endif /* !__DJGPP__ */
}
void
{
if (term_cr)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif /* !__MSDOS__ */
_rl_last_c_pos = 0;
}
}
the right thing happens if we have wrapped to a new screen line. */
if (term_cr)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif /* !__MSDOS__ */
_rl_last_c_pos = 0;
+#if defined (__MSDOS__)
+ space_to_eol (screenwidth);
+ putc ('\r', rl_outstream);
+#else
if (term_clreol)
tputs (term_clreol, 1, _rl_output_character_function);
else
space_to_eol (screenwidth);
tputs (term_cr, 1, _rl_output_character_function);
}
+#endif
if (_rl_last_v_pos > 0)
_rl_move_vert (0);
}
_rl_move_vert (_rl_vis_botlin);
_rl_vis_botlin = 0;
fflush (rl_outstream);
- rl_restart_output ();
+ rl_restart_output (1, 0);
}
}
+
+void
+_rl_erase_entire_line ()
+{
+ cr ();
+ _rl_clear_to_eol (0);
+ cr ();
+ fflush (rl_outstream);
+}