URI: 
       add crop-to-region in visual mode - gramscii - A simple editor for ASCII box-and-arrow charts
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 47996e708ad2ab7e6a18633576c95e93d08e816a
   DIR parent 6d34f883ba3ce2474df90432cc4aa387e9093321
  HTML Author: KatolaZ <katolaz@freaknet.org>
       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(-)
       ---
   DIR 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), 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);
   DIR 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
   DIR 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 **/
   DIR 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 ++;