diff options
| author | KatolaZ <katolaz@freaknet.org> | 2019-07-27 08:31:24 +0100 | 
|---|---|---|
| committer | KatolaZ <katolaz@freaknet.org> | 2019-07-27 08:31:24 +0100 | 
| commit | a99759398841d86928c7ad4d8248f907765cbeb2 (patch) | |
| tree | 5adb05a273e0532be2665e8ae95a8b4042809213 /screen.c | |
| parent | b38ed132a7df231fc08ce384d8559e6648fdd0cc (diff) | |
add crop-to-visible function (C)
Diffstat (limited to 'screen.c')
| -rw-r--r-- | screen.c | 30 | 
1 files changed, 27 insertions, 3 deletions
| @@ -197,6 +197,26 @@ void update_current(){  	fflush(stdout);  } +void erase_blank_lines(int y1, int y2){ +	int j; +	if (y1 > y2){ +		y1 ^= y2; +		y2 ^= y1; +		y1 ^= y2; +	} +	 +	for (; y1 <= y2; y1++){ +		j = screen[y1].lst;  +		while (j>=0 && isblank(screen[y1].s[j])) +			j--; +		if (j<0){ +			screen[y1].lst = -1; +			screen[y1].s[0] = '\0'; +		} +	} +} + +  void erase_line(int i){  	screen[i].lst = -1;  	screen[i].s[0] = '\0'; @@ -446,13 +466,16 @@ void find_nonblank_rect(int *x1, int *y1, int *x2, int *y2){  		*y2 = i;  		if (i < *y1)  			*y1 = i; -		if (screen[i].lst > *x2) -			*x2 = screen[i].lst;  		j = 0; -		while(j <= screen[i].lst && isblank(first=screen[i].s[j])) +		while((j <= screen[i].lst)  && isblank(first=screen[i].s[j]))  			j++;  		if (j < *x1)  			*x1 = j; +		j = screen[i].lst; +		while(isblank(screen[i].s[j])) +			j--; +		if (j > *x2) +			*x2 = j;  	}  } @@ -478,6 +501,7 @@ void crop_to_nonblank(){  	fprintf(stderr, "crop rectangle: (%d, %d)-(%d, %d)\n", x1, y1, x2, y2);  #endif  	crop_to_rect(x1, y1, x2, y2); +	modified=1;  	redraw();  } | 
