summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw.c7
-rw-r--r--gramscii.14
-rw-r--r--gramscii.h3
-rw-r--r--screen.c2
4 files changed, 14 insertions, 2 deletions
diff --git a/draw.c b/draw.c
index 1e73719..ec44c2f 100644
--- 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), MAX(x, orig_x), MAX(y, orig_y));
+ 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
index f3ec80e..39faa09 100644
--- 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
index 7aa9f62..9b95a4e 100644
--- 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
index 9a0ccb3..d0310eb 100644
--- 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 ++;