Example #1
0
void
fileinfo(void)
{
    long            l1, l2;
    char            buf[MAX_COLUMNS + 1];

    l1 = cntllines(Filemem, Curschar);
    l2 = cntllines(Filemem, Fileend) - 1;
    sprintf(buf, "\"%s\"%s line %ld of %ld -- %ld %% --",
	    (Filename != NULL) ? Filename : "No File",
	    Changed ? " [Modified]" : "",
	    l1, l2, (l1 * 100) / l2);
    msg(buf);
}
Example #2
0
/*
 * updateline() - like s_refresh() but only for cursor line 
 *
 * This determines whether or not we need to call s_refresh() to examine
 * the entire screen for changes. This occurs if the size of the cursor line
 * (in rows) has changed.
 */
static void
updateline(void)
{
    char           *ptr;
    int             col;
    int             size;
    int             j;

    if (RedrawingDisabled)	/* Is this the correct action ? */
	return;

    ptr = format_line(Curschar->linep->s, &col);

    size = 1 + ((col - 1) / Columns);
    if (Cline_size == size) {
	s_cursor_off();
	windgoto(Cline_row, 0);
	if (P(P_NU)) {
	    /*
	     * This should be done more efficiently. 
	     */
	    outstr(mkline(cntllines(Filemem, Curschar)));
	}
	outstr(ptr);

	j = col;
	col %= Columns;
	if ((col != 0) || (j == 0)) {
#ifdef T_END_L
	    windgoto(Cline_row + size - 1, col);
	    toutstr(T_END_L);
#else
	    for (; col < Columns; col++)
		outchar(' ');
#endif
	}
	s_cursor_on();
    } else {
	s_refresh(VALID_TO_CURSCHAR);
    }
}
Example #3
0
File: screen.c Project: kindy/vim0
void
cursupdate()
{
        LPTR *p;
        int inc, c, nlines;
        int i;
        int didinc;

        if (bufempty()) {                /* special case - file is empty */
                *Topchar  = *Filemem;
                *Curschar = *Filemem;
        } else if ( LINEOF(Curschar) < LINEOF(Topchar) ) {
                nlines = cntllines(Curschar,Topchar);
                /* if the cursor is above the top of */
                /* the screen, put it at the top of the screen.. */
                *Topchar = *Curschar;
                Topchar->index = 0;
                /* ... and, if we weren't very close to begin with, */
                /* we scroll so that the line is close to the middle. */
                if ( nlines > Rows/3 ) {
                        for (i=0, p = Topchar; i < Rows/3 ;i++, *Topchar = *p)
                                if ((p = prevline(p)) == NULL)
                                        break;
                } else
                        s_ins(0, nlines-1);
                updatescreen();
        }
        else if (LINEOF(Curschar) >= LINEOF(Botchar)) {
                nlines = cntllines(Botchar,Curschar);
                /* If the cursor is off the bottom of the screen, */
                /* put it at the top of the screen.. */
                /* ... and back up */
                if ( nlines > Rows/3 ) {
                        p = Curschar;
                        for (i=0; i < (2*Rows)/3 ;i++)
                                if ((p = prevline(p)) == NULL)
                                        break;
                        *Topchar = *p;
                } else {
                        scrollup(nlines);
                }
                updatescreen();
        }

        Cursrow = Curscol = Cursvcol = 0;
        for ( p=Topchar; p->linep != Curschar->linep ;p = nextline(p) )
                Cursrow += plines(p);

        Cline_row = Cursrow;
        Cline_size = plines(p);

        for (i=0; i <= Curschar->index ;i++) {
                c = Curschar->linep->s[i];
                /* A tab gets expanded, depending on the current column */
                if ( c == TAB && !P(P_LS) )
                        inc = P(P_TS) - (Curscol % P(P_TS));
                else
                        inc = chars[(unsigned)(c & 0xff)].ch_size;
                Curscol += inc;
                Cursvcol += inc;
                if ( Curscol >= Columns ) {
                        Curscol -= Columns;
                        Cursrow++;
                        didinc = TRUE;
                }
                else
                        didinc = FALSE;
        }
        if (didinc)
                Cursrow--;

        if (c == TAB && State == NORMAL && !P(P_LS)) {
                Curscol--;
                Cursvcol--;
        } else {
                Curscol -= inc;
                Cursvcol -= inc;
        }
        if (Curscol < 0)
                Curscol += Columns;

        if (set_want_col) {
                Curswant = Cursvcol;
                set_want_col = FALSE;
        }
}