diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-01-01 10:20:22 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-01 10:20:22 -0800 |
commit | 8f364d0094aa0c2999708dca0e1ac6fefed67837 (patch) | |
tree | 3158c5274a760b97f04257075a97c17b249a44ad /profile.c | |
parent | 91ca0d2cf669881f40a71c2ec9f05b7e5caba509 (diff) | |
download | subsurface-8f364d0094aa0c2999708dca0e1ac6fefed67837.tar.gz |
Use the Left and Right keys to switch between divecomputers
The existing code had the somewhat retarded Ctrl-C binding for displaying
the next divecomputer and no way to go back to the previous one. With this
commit we use our keyboard grab to map Left and Right to previous and next
divecomputer. Much nicer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1800,11 +1800,24 @@ static void plot_set_scale(scale_mode_t scale) } } +/* make sure you pass this the FIRST dc - it just walks the list */ +static int nr_dcs(struct divecomputer *main) +{ + int i = 1; + struct divecomputer *dc = main; + + while ((dc = dc->next) != NULL) + i++; + return i; +} + static struct divecomputer *select_dc(struct divecomputer *main) { int i = dc_number; struct divecomputer *dc = main; + while (i < 0) + i += nr_dcs(main); do { if (--i < 0) return dc; |