comparison src/libvterm/src/rect.h @ 20518:a4652d7ec99f v8.2.0813

patch 8.2.0813: libvterm code is slightly different from upstream Commit: https://github.com/vim/vim/commit/591cec8366e87a172495c362477cbf5de8d399f0 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 22 22:06:06 2020 +0200 patch 8.2.0813: libvterm code is slightly different from upstream Problem: libvterm code is slightly different from upstream. Solution: Use upstream text to avoid future merge problems. Mainly comment style changes.
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 May 2020 22:15:04 +0200
parents 811a12a78164
children ac9464a32606
comparison
equal deleted inserted replaced
20517:a7c6cd0d7ba0 20518:a4652d7ec99f
3 */ 3 */
4 4
5 #define STRFrect "(%d,%d-%d,%d)" 5 #define STRFrect "(%d,%d-%d,%d)"
6 #define ARGSrect(r) (r).start_row, (r).start_col, (r).end_row, (r).end_col 6 #define ARGSrect(r) (r).start_row, (r).start_col, (r).end_row, (r).end_col
7 7
8 // Expand dst to contain src as well 8 /* Expand dst to contain src as well */
9 static void rect_expand(VTermRect *dst, VTermRect *src) 9 static void rect_expand(VTermRect *dst, VTermRect *src)
10 { 10 {
11 if(dst->start_row > src->start_row) dst->start_row = src->start_row; 11 if(dst->start_row > src->start_row) dst->start_row = src->start_row;
12 if(dst->start_col > src->start_col) dst->start_col = src->start_col; 12 if(dst->start_col > src->start_col) dst->start_col = src->start_col;
13 if(dst->end_row < src->end_row) dst->end_row = src->end_row; 13 if(dst->end_row < src->end_row) dst->end_row = src->end_row;
14 if(dst->end_col < src->end_col) dst->end_col = src->end_col; 14 if(dst->end_col < src->end_col) dst->end_col = src->end_col;
15 } 15 }
16 16
17 // Clip the dst to ensure it does not step outside of bounds 17 /* Clip the dst to ensure it does not step outside of bounds */
18 static void rect_clip(VTermRect *dst, VTermRect *bounds) 18 static void rect_clip(VTermRect *dst, VTermRect *bounds)
19 { 19 {
20 if(dst->start_row < bounds->start_row) dst->start_row = bounds->start_row; 20 if(dst->start_row < bounds->start_row) dst->start_row = bounds->start_row;
21 if(dst->start_col < bounds->start_col) dst->start_col = bounds->start_col; 21 if(dst->start_col < bounds->start_col) dst->start_col = bounds->start_col;
22 if(dst->end_row > bounds->end_row) dst->end_row = bounds->end_row; 22 if(dst->end_row > bounds->end_row) dst->end_row = bounds->end_row;
23 if(dst->end_col > bounds->end_col) dst->end_col = bounds->end_col; 23 if(dst->end_col > bounds->end_col) dst->end_col = bounds->end_col;
24 // Ensure it doesn't end up negatively-sized 24 /* Ensure it doesn't end up negatively-sized */
25 if(dst->end_row < dst->start_row) dst->end_row = dst->start_row; 25 if(dst->end_row < dst->start_row) dst->end_row = dst->start_row;
26 if(dst->end_col < dst->start_col) dst->end_col = dst->start_col; 26 if(dst->end_col < dst->start_col) dst->end_col = dst->start_col;
27 } 27 }
28 28
29 // True if the two rectangles are equal 29 /* True if the two rectangles are equal */
30 static int rect_equal(VTermRect *a, VTermRect *b) 30 static int rect_equal(VTermRect *a, VTermRect *b)
31 { 31 {
32 return (a->start_row == b->start_row) && 32 return (a->start_row == b->start_row) &&
33 (a->start_col == b->start_col) && 33 (a->start_col == b->start_col) &&
34 (a->end_row == b->end_row) && 34 (a->end_row == b->end_row) &&
35 (a->end_col == b->end_col); 35 (a->end_col == b->end_col);
36 } 36 }
37 37
38 // True if small is contained entirely within big 38 /* True if small is contained entirely within big */
39 static int rect_contains(VTermRect *big, VTermRect *small) 39 static int rect_contains(VTermRect *big, VTermRect *small)
40 { 40 {
41 if(small->start_row < big->start_row) return 0; 41 if(small->start_row < big->start_row) return 0;
42 if(small->start_col < big->start_col) return 0; 42 if(small->start_col < big->start_col) return 0;
43 if(small->end_row > big->end_row) return 0; 43 if(small->end_row > big->end_row) return 0;
44 if(small->end_col > big->end_col) return 0; 44 if(small->end_col > big->end_col) return 0;
45 return 1; 45 return 1;
46 } 46 }
47 47
48 // True if the rectangles overlap at all 48 /* True if the rectangles overlap at all */
49 static int rect_intersects(VTermRect *a, VTermRect *b) 49 static int rect_intersects(VTermRect *a, VTermRect *b)
50 { 50 {
51 if(a->start_row > b->end_row || b->start_row > a->end_row) 51 if(a->start_row > b->end_row || b->start_row > a->end_row)
52 return 0; 52 return 0;
53 if(a->start_col > b->end_col || b->start_col > a->end_col) 53 if(a->start_col > b->end_col || b->start_col > a->end_col)