aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/selection.cpp13
-rw-r--r--core/selection.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/core/selection.cpp b/core/selection.cpp
index 92bb631fc..6b5dfe726 100644
--- a/core/selection.cpp
+++ b/core/selection.cpp
@@ -210,3 +210,16 @@ std::vector<dive *> getDiveSelection()
}
return res;
}
+
+// Select the first dive that is visible
+extern "C" void select_newest_visible_dive()
+{
+ for (int i = dive_table.nr - 1; i >= 0; --i) {
+ dive *d = dive_table.dives[i];
+ if (!d->hidden_by_filter)
+ return setSelection({ d }, d);
+ }
+
+ // No visible dive -> deselect all
+ setSelection({}, nullptr);
+}
diff --git a/core/selection.h b/core/selection.h
index e990a697c..a390f0dd7 100644
--- a/core/selection.h
+++ b/core/selection.h
@@ -19,6 +19,7 @@ extern void deselect_dive(struct dive *dive);
extern struct dive *first_selected_dive(void);
extern struct dive *last_selected_dive(void);
extern bool consecutive_selected(void);
+extern void select_newest_visible_dive();
#if DEBUG_SELECTION_TRACKING
extern void dump_selection(void);