mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
Compare commits
3 Commits
0a8c28bc07
...
f96ace997f
Author | SHA1 | Date | |
---|---|---|---|
f96ace997f | |||
f010d63a95 | |||
0cb1799786 |
58
display.c
58
display.c
@ -63,7 +63,6 @@ static int curcol ; /* Cursor column */
|
||||
static int vtrow = 0 ; /* Row location of SW cursor */
|
||||
static int vtcol = 0 ; /* Column location of SW cursor */
|
||||
static int lbound = 0 ; /* leftmost column of current line being displayed */
|
||||
static int taboff = 0 ; /* tab offset for display */
|
||||
|
||||
int mpresf = FALSE ; /* TRUE if message in last line */
|
||||
int scrollcount = 1 ; /* number of lines to scroll */
|
||||
@ -136,6 +135,14 @@ static void vtalloc( int maxrow, int maxcol) {
|
||||
}
|
||||
}
|
||||
|
||||
void updmargin( void) {
|
||||
term.t_margin = term.t_ncol / 10 ;
|
||||
if( term.t_margin < 3) /* t_margin - 1 enough for $ + prev before current */
|
||||
term.t_margin = 3 ;
|
||||
|
||||
term.t_scrsiz = term.t_ncol - 2 * term.t_margin ;
|
||||
}
|
||||
|
||||
void vtinit( void) {
|
||||
#ifdef SIGWINCH
|
||||
signal( SIGWINCH, sizesignal) ;
|
||||
@ -143,6 +150,7 @@ void vtinit( void) {
|
||||
|
||||
setlocale( LC_CTYPE, "") ; /* expects $LANG like en_GB.UTF-8 */
|
||||
TTopen() ; /* open the screen */
|
||||
updmargin() ;
|
||||
TTkopen() ; /* open the keyboard */
|
||||
TTrev( FALSE) ;
|
||||
vtalloc( term.t_mrow, term.t_mcol) ;
|
||||
@ -218,7 +226,7 @@ static void vtputuc( unicode_t c) {
|
||||
|
||||
if( c == '\t') {
|
||||
sane_vtputc( viewtab ? 0xBB : ' ') ; /* 0xBB: '»' */
|
||||
while( ((vtcol + taboff) % tabwidth) != 0)
|
||||
while( ((vtcol + lbound) % tabwidth) != 0)
|
||||
sane_vtputc( ' ') ;
|
||||
} else if( c < 0x20 || c == 0x7F) {
|
||||
sane_vtputc( '^') ;
|
||||
@ -460,6 +468,8 @@ static void show_line( line_p lp) {
|
||||
i += utf8_to_unicode( lp->l_text, i, len, &c) ;
|
||||
vtputuc( c) ;
|
||||
}
|
||||
|
||||
vteeol() ;
|
||||
}
|
||||
|
||||
|
||||
@ -469,9 +479,10 @@ static void show_line( line_p lp) {
|
||||
* window_p wp; window to update current line in
|
||||
*/
|
||||
static void updone( window_p wp) {
|
||||
line_p lp ;
|
||||
|
||||
/* search down the line we want */
|
||||
int sline = wp->w_toprow ; /* physical screen line to update */
|
||||
line_p lp ;
|
||||
for( lp = wp->w_linep ; lp != wp->w_dotp ; lp = lforw( lp))
|
||||
++sline ;
|
||||
|
||||
@ -484,7 +495,6 @@ static void updone( window_p wp) {
|
||||
vscreen[ sline]->v_rfcolor = wp->w_fcolor ;
|
||||
vscreen[ sline]->v_rbcolor = wp->w_bcolor ;
|
||||
#endif
|
||||
vteeol() ;
|
||||
}
|
||||
|
||||
|
||||
@ -506,14 +516,14 @@ static void updall( window_p wp) {
|
||||
/* if we are not at the end */
|
||||
show_line( lp) ;
|
||||
lp = lforw( lp) ;
|
||||
}
|
||||
} else
|
||||
vteeol() ;
|
||||
|
||||
/* on to the next one */
|
||||
#if COLOR
|
||||
vscreen[ sline]->v_rfcolor = wp->w_fcolor ;
|
||||
vscreen[ sline]->v_rbcolor = wp->w_bcolor ;
|
||||
#endif
|
||||
vteeol() ;
|
||||
++sline ;
|
||||
}
|
||||
}
|
||||
@ -524,13 +534,12 @@ static void updall( window_p wp) {
|
||||
This is the only update for simple moves.
|
||||
*/
|
||||
static void updpos( void) {
|
||||
line_p lp ;
|
||||
|
||||
/* find the current row */
|
||||
line_p lp = curwp->w_linep ;
|
||||
currow = curwp->w_toprow ;
|
||||
while( lp != curwp->w_dotp) {
|
||||
for( lp = curwp->w_linep ; lp != curwp->w_dotp ; lp = lforw( lp))
|
||||
++currow ;
|
||||
lp = lforw( lp) ;
|
||||
}
|
||||
|
||||
/* find the current column */
|
||||
curcol = 0 ;
|
||||
@ -571,7 +580,6 @@ static void upddex( void) {
|
||||
|| (curcol < term.t_ncol - 1)) {
|
||||
vtmove( i, 0) ;
|
||||
show_line( lp) ;
|
||||
vteeol() ;
|
||||
|
||||
/* this line no longer is extended */
|
||||
vscreen[ i]->v_flag &= ~VFEXT ;
|
||||
@ -798,30 +806,20 @@ static int endofline( unicode_t *s, int n) {
|
||||
|
||||
|
||||
/* updext:
|
||||
* update the extended line which the cursor is currently
|
||||
* on at a column greater than the terminal width. The line
|
||||
* will be scrolled right or left to let the user see where
|
||||
* the cursor is
|
||||
update the extended line which the cursor is currently on at a column
|
||||
greater than the terminal width. The line will be scrolled right or
|
||||
left to let the user see where the cursor is.
|
||||
*/
|
||||
static void updext( void) {
|
||||
int rcursor ; /* real cursor location */
|
||||
line_p lp ; /* pointer to current line */
|
||||
|
||||
/* calculate what column the real cursor will end up in */
|
||||
rcursor = ((curcol - term.t_ncol) % term.t_scrsiz) + term.t_margin ;
|
||||
taboff = lbound = curcol - rcursor + 1 ;
|
||||
lbound = curcol - ((curcol - term.t_ncol) % term.t_scrsiz + term.t_margin) ;
|
||||
|
||||
/* scan through the line outputing characters to the virtual screen */
|
||||
/* once we reach the left edge */
|
||||
vtmove( currow, -lbound) ; /* start scanning offscreen */
|
||||
lp = curwp->w_dotp ; /* line to output */
|
||||
show_line( lp) ;
|
||||
show_line( curwp->w_dotp) ;
|
||||
|
||||
/* truncate the virtual line, restore tab offset */
|
||||
vteeol() ;
|
||||
taboff = 0 ;
|
||||
|
||||
/* and put a '$' in column 1 */
|
||||
/* put a '$' in column 1 */
|
||||
vscreen[ currow]->v_text[ 0] = '$' ;
|
||||
}
|
||||
|
||||
@ -1329,6 +1327,12 @@ static void sizesignal( int signr) {
|
||||
static void newscreensize( int h, int w) {
|
||||
chg_width = chg_height = 0 ;
|
||||
vtfree() ;
|
||||
if( h < 3)
|
||||
h = 3 ;
|
||||
|
||||
if( w < 10)
|
||||
w = 10 ;
|
||||
|
||||
vtalloc( h, w) ;
|
||||
if( h <= term.t_mrow)
|
||||
newsize( TRUE, h) ;
|
||||
|
@ -25,6 +25,7 @@ void vtinit( void) ;
|
||||
void vtfree( void) ;
|
||||
void vttidy( void) ;
|
||||
void update( boolean force_f) ;
|
||||
void updmargin( void) ;
|
||||
void upmode( void) ;
|
||||
void movecursor( int row, int col) ;
|
||||
void mlerase( void) ;
|
||||
|
4
names.c
4
names.c
@ -50,8 +50,8 @@ const name_bind names[] = {
|
||||
{"!case-word-lower", lowerword, META | 'L'} ,
|
||||
{"!case-word-upper", upperword, META | 'U'} ,
|
||||
{" change-file-name", filename, CTLX | 'N'} ,
|
||||
{" change-screen-size", newsize, META | CTL_ | 'D'} , /* M^S */
|
||||
{" change-screen-width", newwidth, META | CTL_ | 'T'} ,
|
||||
{" change-screen-size", (fnp_t) newsize, META | CTL_ | 'D'} , /* M^S */
|
||||
{" change-screen-width", (fnp_t) newwidth, META | CTL_ | 'T'} ,
|
||||
{" clear-and-redraw", (fnp_t) redraw, CTL_ | 'L'} ,
|
||||
{" clear-message-line", (fnp_t) clrmes, 0} ,
|
||||
{" copy-region", copyregion, META | 'W'} ,
|
||||
|
122
window.c
122
window.c
@ -566,84 +566,80 @@ BINDABLE( restwnd) {
|
||||
* int f; default flag
|
||||
* int n; numeric argument
|
||||
*/
|
||||
BINDABLE( newsize) {
|
||||
window_p wp; /* current window being examined */
|
||||
window_p nextwp; /* next window to scan */
|
||||
window_p lastwp; /* last window scanned */
|
||||
int lastline; /* screen line of last line of current window */
|
||||
BBINDABLE( newsize) {
|
||||
window_p wp ; /* current window being examined */
|
||||
|
||||
/* if the command defaults, assume the largest */
|
||||
if (f == FALSE)
|
||||
if( f == FALSE)
|
||||
n = term.t_mrow ;
|
||||
|
||||
/* make sure it's in range */
|
||||
if( n < 3 || n > term.t_mrow)
|
||||
return mloutfail( "%%Screen size out of range") ;
|
||||
|
||||
if (term.t_nrow == n - 1)
|
||||
return TRUE;
|
||||
else if (term.t_nrow < n - 1) {
|
||||
|
||||
if( term.t_nrow == n - 1)
|
||||
/* no change */
|
||||
return TRUE ;
|
||||
else if( term.t_nrow < n - 1) {
|
||||
/* new size is bigger */
|
||||
/* go to the last window */
|
||||
wp = wheadp;
|
||||
while (wp->w_wndp != NULL)
|
||||
wp = wp->w_wndp;
|
||||
for( wp = wheadp ; wp->w_wndp != NULL ; wp = wp->w_wndp)
|
||||
;
|
||||
|
||||
/* and enlarge it as needed */
|
||||
wp->w_ntrows = n - wp->w_toprow - 2;
|
||||
wp->w_flag |= WFHARD | WFMODE;
|
||||
|
||||
wp->w_ntrows = n - wp->w_toprow - 2 ;
|
||||
wp->w_flag |= WFHARD | WFMODE ;
|
||||
} else {
|
||||
|
||||
/* new size is smaller */
|
||||
/* rebuild the window structure */
|
||||
assert( wheadp->w_toprow == 0) ; /* proves coverity wrong */
|
||||
nextwp = wheadp;
|
||||
wp = NULL;
|
||||
lastwp = NULL;
|
||||
while (nextwp != NULL) {
|
||||
wp = nextwp;
|
||||
nextwp = wp->w_wndp;
|
||||
window_p lastwp = NULL ;
|
||||
for( window_p nextwp = wheadp ; nextwp != NULL ; ) {
|
||||
wp = nextwp ;
|
||||
nextwp = wp->w_wndp ;
|
||||
|
||||
if( wp->w_toprow == n - 2) {
|
||||
lastwp->w_ntrows = n - lastwp->w_toprow - 2 ;
|
||||
lastwp->w_flag |= WFHARD | WFMODE ;
|
||||
}
|
||||
|
||||
/* get rid of it if it is too low */
|
||||
if (wp->w_toprow > n - 2) {
|
||||
|
||||
if( wp->w_toprow >= n - 2) {
|
||||
/* save the point/mark if needed */
|
||||
if (--wp->w_bufp->b_nwnd == 0) {
|
||||
wp->w_bufp->b_dotp = wp->w_dotp;
|
||||
wp->w_bufp->b_doto = wp->w_doto;
|
||||
wp->w_bufp->b_markp = wp->w_markp;
|
||||
wp->w_bufp->b_marko = wp->w_marko;
|
||||
if( --wp->w_bufp->b_nwnd == 0) {
|
||||
wp->w_bufp->b_dotp = wp->w_dotp ;
|
||||
wp->w_bufp->b_doto = wp->w_doto ;
|
||||
wp->w_bufp->b_markp = wp->w_markp ;
|
||||
wp->w_bufp->b_marko = wp->w_marko ;
|
||||
}
|
||||
|
||||
/* update curwp and lastwp if needed */
|
||||
if (wp == curwp)
|
||||
curwp = wheadp;
|
||||
curbp = curwp->w_bufp;
|
||||
if (lastwp != NULL)
|
||||
lastwp->w_wndp = NULL;
|
||||
if( wp == curwp) {
|
||||
curwp = wheadp ;
|
||||
curbp = curwp->w_bufp ;
|
||||
}
|
||||
|
||||
/* free the structure */
|
||||
free((char *) wp);
|
||||
wp = NULL;
|
||||
|
||||
free( wp) ;
|
||||
lastwp->w_wndp = NULL ;
|
||||
} else {
|
||||
/* need to change this window size? */
|
||||
lastline = wp->w_toprow + wp->w_ntrows - 1;
|
||||
if (lastline >= n - 2) {
|
||||
wp->w_ntrows =
|
||||
n - wp->w_toprow - 2;
|
||||
wp->w_flag |= WFHARD | WFMODE;
|
||||
/* need to change this window size? */
|
||||
int lastline = wp->w_toprow + wp->w_ntrows - 1 ;
|
||||
if( lastline >= n - 2) {
|
||||
wp->w_ntrows = n - wp->w_toprow - 2 ;
|
||||
assert( wp->w_ntrows) ;
|
||||
wp->w_flag |= WFHARD | WFMODE ;
|
||||
}
|
||||
}
|
||||
|
||||
lastwp = wp;
|
||||
lastwp = wp ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* screen is garbage */
|
||||
term.t_nrow = n - 1;
|
||||
sgarbf = TRUE;
|
||||
return TRUE;
|
||||
term.t_nrow = n - 1 ;
|
||||
sgarbf = TRUE ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
@ -652,31 +648,25 @@ BINDABLE( newsize) {
|
||||
* int f; default flag
|
||||
* int n; numeric argument
|
||||
*/
|
||||
BINDABLE( newwidth) {
|
||||
window_p wp;
|
||||
|
||||
BBINDABLE( newwidth) {
|
||||
/* if the command defaults, assume the largest */
|
||||
if (f == FALSE)
|
||||
n = term.t_mcol;
|
||||
if( f == FALSE)
|
||||
n = term.t_mcol ;
|
||||
|
||||
/* make sure it's in range */
|
||||
if (n < 10 || n > term.t_mcol)
|
||||
if( n < 10 || n > term.t_mcol)
|
||||
return mloutfail( "%%Screen width out of range") ;
|
||||
|
||||
/* otherwise, just re-width it (no big deal) */
|
||||
term.t_ncol = n;
|
||||
term.t_margin = n / 10;
|
||||
term.t_scrsiz = n - (term.t_margin * 2);
|
||||
term.t_ncol = n ;
|
||||
updmargin() ;
|
||||
|
||||
/* florce all windows to redraw */
|
||||
wp = wheadp;
|
||||
while (wp) {
|
||||
wp->w_flag |= WFHARD | WFMOVE | WFMODE;
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
/* force all windows to redraw */
|
||||
for( window_p wp = wheadp ; wp; wp = wp->w_wndp)
|
||||
wp->w_flag |= WFHARD | WFMOVE | WFMODE ;
|
||||
|
||||
return TRUE;
|
||||
sgarbf = TRUE ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
int getwpos(void)
|
||||
|
4
window.h
4
window.h
@ -55,8 +55,8 @@ extern window_p wheadp ; /* Head of list of windows */
|
||||
BINDABLE( enlargewind) ;
|
||||
BINDABLE( mvdnwind) ;
|
||||
BINDABLE( mvupwind) ;
|
||||
BINDABLE( newsize) ;
|
||||
BINDABLE( newwidth) ;
|
||||
BBINDABLE( newsize) ;
|
||||
BBINDABLE( newwidth) ;
|
||||
BINDABLE( nextwind) ;
|
||||
BINDABLE( onlywind) ;
|
||||
BINDABLE( prevwind) ;
|
||||
|
Loading…
Reference in New Issue
Block a user