aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2016-05-10 12:28:13 -0400
committerJesse Luehrs <doy@tozt.net>2016-05-10 12:28:13 -0400
commit60b5d0e7b18bf3adbfa7124664a13da2780fe683 (patch)
tree6b34f06bae4decfa353f8a42b12b6dadf203c807
parent1cba6ae0d947c1e3ac98f0e865096cbe1a4d6659 (diff)
downloadrunes-60b5d0e7b18bf3adbfa7124664a13da2780fe683.tar.gz
runes-60b5d0e7b18bf3adbfa7124664a13da2780fe683.zip
these don't need to be public
-rw-r--r--src/display.c122
-rw-r--r--src/display.h4
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