Introduction
Introduction Statistics Contact Development Disclaimer Help
add crop-to-region in visual mode - gramscii - A simple editor for ASCII box-an…
Log
Files
Refs
Tags
README
LICENSE
---
commit 47996e708ad2ab7e6a18633576c95e93d08e816a
parent 6d34f883ba3ce2474df90432cc4aa387e9093321
Author: KatolaZ <[email protected]>
Date: Thu, 1 Aug 2019 08:02:33 +0100
add crop-to-region in visual mode
Diffstat:
M draw.c | 7 +++++++
M gramscii.1 | 4 ++++
M gramscii.h | 3 ++-
M screen.c | 2 +-
4 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/draw.c b/draw.c
@@ -331,6 +331,13 @@ void visual_box(FILE *fc){
modified = 1;
goto vis_exit;
break;
+ case 'C':/* crop-to-region */
+ copy_lines_to_ring(0, HEIGHT-1, PRV_STATE);
+ crop_to_rect(MIN(x, orig_x), MIN(y, orig_y), M…
+ copy_lines_to_ring(0, HEIGHT-1, NEW_STATE);
+ modified = 1;
+ goto vis_exit;
+ break;
}
check_bound();
set_video(VIDEO_NRM);
diff --git a/gramscii.1 b/gramscii.1
@@ -384,6 +384,10 @@ subsequent yank/cut commands.
Fill region. gramscii will wait for a character on input and then will
fill the highlighted region with that character.
.TP 5m
+.BI C
+Crop-to-region. Crop the chart to the content of the highlighted region.
+Everything else in the screen is erased.
+.TP 5m
.BI v
leave
.B visual
diff --git a/gramscii.h b/gramscii.h
@@ -71,7 +71,7 @@ typedef struct{
#define progr_x(d) ((d) == DIR_L ? -1 : (d) == DIR_R ? 1 : 0)
#define progr_y(d) ((d) == DIR_U ? -1 : (d) == DIR_D ? 1 : 0)
-#define DEBUG 1
+/** #define DEBUG 1 **/
/** global variables **/
@@ -139,6 +139,7 @@ void erase_line(int i);
void erase_screen();
void go_to(int where);
void crop_to_nonblank();
+void crop_to_rect();
void erase_blank_lines(int y1, int y2);
/** drawing-related functions **/
diff --git a/screen.c b/screen.c
@@ -449,7 +449,7 @@ void crop_to_rect(int x1, int y1, int x2, int y2){
sprintf(screen.l[i].s, "%s", screen.l[i+y1].s + x1);
screen.l[i].lst = screen.l[i+y1].lst - x1;
}
- while (i<=y2){
+ while (i< HEIGHT){
screen.l[i].lst = -1;
screen.l[i].s[0]= '\0';
i ++;
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.