1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-06-27 12:15:25 +00:00

Insure writing on message line does not exceed terminal size.

This commit is contained in:
Renaud 2015-01-22 20:26:22 +08:00
parent daa6395128
commit 09d5907f9e

View File

@ -159,9 +159,7 @@ void vtfree(void)
*/
void vttidy(void)
{
mlerase();
movecursor(term.t_nrow, 0);
TTflush();
mlerase() ; /* ends with movecursor( term.t_nrow, 0) and TTflush() */
TTclose();
TTkclose();
#ifdef PKCODE
@ -1309,12 +1307,9 @@ void movecursor(int row, int col)
* is not considered to be part of the virtual screen. It always works
* immediately; the terminal buffer is flushed via a call to the flusher.
*/
void mlerase(void)
{
void mlerase( void) {
movecursor( term.t_nrow, 0) ;
if (discmd == FALSE)
return;
if( discmd != FALSE) {
#if COLOR
TTforg( 7) ;
TTbacg( 0) ;
@ -1326,13 +1321,24 @@ void mlerase(void)
for( i = 1 ; i < term.t_ncol ; i++)
TTputc(' ') ;
movecursor( term.t_nrow, 1) ; /* force the move! */
movecursor( term.t_nrow, 0) ;
}
TTflush();
mpresf = FALSE ;
}
TTflush() ;
}
static void mlputc( char c) {
if( ttcol < term.t_ncol) {
TTputc( c) ;
++ttcol ;
}
}
/*
* Write a message into the message line. Keep track of the physical cursor
* position. A small class of printf like format items is handled. Assumes the
@ -1366,10 +1372,9 @@ void mlwrite(const char *fmt, ...)
va_start(ap, fmt);
while ((c = *fmt++) != 0) {
if (c != '%') {
TTputc(c);
++ttcol;
} else {
if (c != '%')
mlputc( c) ;
else {
c = *fmt++;
switch (c) {
case 'd':
@ -1401,8 +1406,7 @@ void mlwrite(const char *fmt, ...)
break ;
default:
TTputc(c);
++ttcol;
mlputc( c) ;
}
}
}
@ -1439,7 +1443,7 @@ void mlforce( char *s) {
static void mlputs( char *s) {
int c ;
while ((c = *s++) != 0) {
while( ((c = *s++) != 0) && (ttcol < term.t_ncol)) {
TTputc( c) ;
++ttcol ;
}
@ -1449,14 +1453,13 @@ static void mlputs( char *s) {
* Write out an integer, in the specified radix. Update the physical cursor
* position.
*/
static void mlputi(int i, int r)
{
static void mlputi( int i, int r) {
int q ;
static char hexdigits[] = "0123456789ABCDEF" ;
if( i < 0) {
i = -i ;
TTputc('-');
mlputc( '-') ;
}
q = i / r ;
@ -1464,20 +1467,18 @@ static void mlputi(int i, int r)
if( q != 0)
mlputi( q, r) ;
TTputc(hexdigits[i % r]);
++ttcol;
mlputc( hexdigits[ i % r]) ;
}
/*
* do the same except as a long integer.
*/
static void mlputli(long l, int r)
{
static void mlputli( long l, int r) {
long q ;
if( l < 0) {
l = -l ;
TTputc('-');
mlputc( '-') ;
}
q = l / r ;
@ -1485,8 +1486,7 @@ static void mlputli(long l, int r)
if( q != 0)
mlputli( q, r) ;
TTputc((int) (l % r) + '0');
++ttcol;
mlputc( (int) (l % r) + '0') ;
}
/*
@ -1494,8 +1494,7 @@ static void mlputli(long l, int r)
*
* int s; scaled integer to output
*/
static void mlputf(int s)
{
static void mlputf( int s) {
int i ; /* integer portion of number */
int f ; /* fractional portion of number */
@ -1505,10 +1504,9 @@ static void mlputf(int s)
/* send out the integer portion */
mlputi( i, 10) ;
TTputc('.');
TTputc((f / 10) + '0');
TTputc((f % 10) + '0');
ttcol += 3;
mlputc('.') ;
mlputc((f / 10) + '0') ;
mlputc((f % 10) + '0') ;
}
#if RAINBOW