From 60b5d0e7b18bf3adbfa7124664a13da2780fe683 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 10 May 2016 12:28:13 -0400 Subject: these don't need to be public --- src/display.c | 122 +++++++++++++++++++++++++++++----------------------------- src/display.h | 4 -- 2 files changed, 62 insertions(+), 64 deletions(-) diff --git a/src/display.c b/src/display.c index ffc5dac..e2ae94c 100644 --- a/src/display.c +++ b/src/display.c @@ -23,6 +23,10 @@ static void runes_display_draw_glyphs( RunesTerm *t, cairo_pattern_t *pattern, struct vt100_cell **cells, size_t len, int row, int col); static int runes_display_glyphs_are_monospace(RunesTerm *t, int width); +static int runes_display_loc_is_selected(RunesTerm *t, struct vt100_loc loc); +static int runes_display_loc_is_between( + struct vt100_loc loc, + struct vt100_loc start, struct vt100_loc end); void runes_display_init(RunesDisplay *display, char *font_name) { @@ -153,66 +157,6 @@ void runes_display_draw_cursor(RunesTerm *t) } } -int runes_display_loc_is_selected(RunesTerm *t, struct vt100_loc loc) -{ - RunesDisplay *display = t->display; - struct vt100_loc start = display->selection_start; - struct vt100_loc end = display->selection_end; - - if (!display->has_selection) { - return 0; - } - - if (loc.row == start.row) { - int start_max_col; - - start_max_col = vt100_screen_row_max_col(t->scr, start.row); - if (start.col > start_max_col) { - start.col = t->scr->grid->max.col; - } - } - - if (loc.row == end.row) { - int end_max_col; - - end_max_col = vt100_screen_row_max_col(t->scr, end.row); - if (end.col > end_max_col) { - end.col = t->scr->grid->max.col; - } - } - - return runes_display_loc_is_between(t, loc, start, end); -} - -int runes_display_loc_is_between( - RunesTerm *t, struct vt100_loc loc, - struct vt100_loc start, struct vt100_loc end) -{ - UNUSED(t); - - if (end.row < start.row || (end.row == start.row && end.col < start.col)) { - struct vt100_loc tmp; - - tmp = start; - start = end; - end = tmp; - } - - if (loc.row < start.row || loc.row > end.row) { - return 0; - } - - if (loc.row == start.row && loc.col < start.col) { - return 0; - } - - if (loc.row == end.row && loc.col >= end.col) { - return 0; - } - - return 1; -} - void runes_display_cleanup(RunesDisplay *display) { cairo_pattern_destroy(display->buffer); @@ -451,3 +395,61 @@ static int runes_display_glyphs_are_monospace(RunesTerm *t, int width) } return 1; } + +static int runes_display_loc_is_selected(RunesTerm *t, struct vt100_loc loc) +{ + RunesDisplay *display = t->display; + struct vt100_loc start = display->selection_start; + struct vt100_loc end = display->selection_end; + + if (!display->has_selection) { + return 0; + } + + if (loc.row == start.row) { + int start_max_col; + + start_max_col = vt100_screen_row_max_col(t->scr, start.row); + if (start.col > start_max_col) { + start.col = t->scr->grid->max.col; + } + } + + if (loc.row == end.row) { + int end_max_col; + + end_max_col = vt100_screen_row_max_col(t->scr, end.row); + if (end.col > end_max_col) { + end.col = t->scr->grid->max.col; + } + } + + return runes_display_loc_is_between(loc, start, end); +} + +static int runes_display_loc_is_between( + struct vt100_loc loc, + struct vt100_loc start, struct vt100_loc end) +{ + if (end.row < start.row || (end.row == start.row && end.col < start.col)) { + struct vt100_loc tmp; + + tmp = start; + start = end; + end = tmp; + } + + if (loc.row < start.row || loc.row > end.row) { + return 0; + } + + if (loc.row == start.row && loc.col < start.col) { + return 0; + } + + if (loc.row == end.row && loc.col >= end.col) { + return 0; + } + + return 1; +} diff --git a/src/display.h b/src/display.h index 427ddb3..97247ab 100644 --- a/src/display.h +++ b/src/display.h @@ -29,10 +29,6 @@ void runes_display_init(RunesDisplay *display, char *font_name); void runes_display_set_context(RunesTerm *t, cairo_t *cr); void runes_display_draw_screen(RunesTerm *t); void runes_display_draw_cursor(RunesTerm *t); -int runes_display_loc_is_selected(RunesTerm *t, struct vt100_loc loc); -int runes_display_loc_is_between( - RunesTerm *t, struct vt100_loc loc, - struct vt100_loc start, struct vt100_loc end); void runes_display_cleanup(RunesDisplay *display); #endif -- cgit v1.2.3-54-g00ecf