summaryrefslogtreecommitdiff
path: root/src/c/fastforge.c
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-13 13:56:27 +0300
committerPaul Buetow <paul@buetow.org>2026-04-13 13:56:27 +0300
commit44b54fd8ccf4b9ae0a7e459b446fe183b534292b (patch)
treeaaca9d4e2f316fe7d9b3795f406d8d0d5c65113c /src/c/fastforge.c
parentd236e785c73d713fba688f5dad2624a313a194dd (diff)
v2: add delete fast from history via long-press BACK in edit window
Adds history_delete_entry() in fastforge_core.c which removes an entry at a given index by shifting the tail with memmove, zeroing the vacated slot, recomputing streaks, and persisting. Wires a long-press BACK (700ms) handler in the history edit window that calls it. Updates the hint text to inform the user. Fixed hint text buffer from [40] to [48] to fit the full string. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/c/fastforge.c')
-rw-r--r--src/c/fastforge.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/c/fastforge.c b/src/c/fastforge.c
index 2dc7cf0..7f6c360 100644
--- a/src/c/fastforge.c
+++ b/src/c/fastforge.c
@@ -106,7 +106,8 @@ static char s_history_edit_start_text[32];
static char s_history_edit_end_text[32];
static char s_history_edit_duration_text[48];
static char s_history_edit_stage_text[24];
-static char s_history_edit_hint_text[40];
+/* 45 bytes needed: "UP/DN adj SEL field\nHOLD save BACK-hold del" + NUL */
+static char s_history_edit_hint_text[48];
static char s_running_edit_start_text[32];
static char s_running_edit_elapsed_text[32];
static char s_running_edit_goal_text[32];
@@ -815,7 +816,7 @@ static void refresh_history_edit_window_content(void) {
s_history_edit_field == EDIT_FIELD_NOTE ? '>' : ' ', note_text);
snprintf(s_history_edit_stage_text, sizeof(s_history_edit_stage_text), "Badge %s",
badge_label ? badge_label : "--");
- snprintf(s_history_edit_hint_text, sizeof(s_history_edit_hint_text), "UP/DN adjust SEL field\nHOLD save");
+ snprintf(s_history_edit_hint_text, sizeof(s_history_edit_hint_text), "UP/DN adj SEL field\nHOLD save BACK-hold del");
text_layer_set_text(s_history_edit_title_layer, s_history_edit_title_text);
text_layer_set_text(s_history_edit_start_layer, s_history_edit_start_text);
@@ -940,6 +941,19 @@ static void history_edit_back_click_handler(ClickRecognizerRef recognizer, void
window_stack_remove(s_history_edit_window, true);
}
+/* Long-press BACK deletes the current entry and returns to the history list. */
+static void history_edit_delete_click_handler(ClickRecognizerRef recognizer, void *context) {
+ (void)recognizer;
+ (void)context;
+ if (!history_delete_entry(s_history_edit_index)) {
+ return;
+ }
+ s_history_edit_index = -1;
+ refresh_timer_view();
+ refresh_stats_window_content();
+ window_stack_remove(s_history_edit_window, true);
+}
+
static void history_edit_click_config_provider(void *context) {
(void)context;
window_single_click_subscribe(BUTTON_ID_UP, history_edit_up_click_handler);
@@ -947,6 +961,7 @@ static void history_edit_click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, history_edit_select_click_handler);
window_single_click_subscribe(BUTTON_ID_BACK, history_edit_back_click_handler);
window_long_click_subscribe(BUTTON_ID_SELECT, 500, history_edit_save_click_handler, NULL);
+ window_long_click_subscribe(BUTTON_ID_BACK, 700, history_edit_delete_click_handler, NULL);
}
static void running_fast_edit_apply_delta_minutes(int delta_minutes) {