From 5c7964baccb46f8f098e612f96503a48863cc5ff Mon Sep 17 00:00:00 2001 From: reugenio Date: Sat, 27 Dec 2025 21:47:39 +0100 Subject: [PATCH] feat(tables): Tips proactivos cada ~10s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Añade table_tips[] con 8 tips de atajos - Añade tip_index a VirtualAdvancedTableState - Rota tip cada 600 frames (~10s @ 60fps) - result.current_tip contiene tip a mostrar - Solo muestra tips con focus y sin edición activa --- src/widgets/table_core.zig | 20 +++++++++++++++++ src/widgets/virtual_advanced_table/state.zig | 3 +++ .../virtual_advanced_table.zig | 22 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/widgets/table_core.zig b/src/widgets/table_core.zig index 95302ad..3fba438 100644 --- a/src/widgets/table_core.zig +++ b/src/widgets/table_core.zig @@ -26,6 +26,26 @@ const Command = @import("../core/command.zig"); const Layout = @import("../core/layout.zig"); const Style = @import("../core/style.zig"); +// ============================================================================= +// Tips Proactivos (FASE I) +// ============================================================================= + +/// Tips de atajos de teclado para mostrar en StatusLine +/// Rotan cada ~10 segundos para enseñar atajos al usuario +pub const table_tips = [_][]const u8{ + "Tip: F2 o Space para editar celda", + "Tip: Tab/Shift+Tab navega entre celdas", + "Tip: Ctrl+N crea nuevo registro", + "Tip: Ctrl+Delete o Ctrl+B borra registro", + "Tip: Ctrl+Shift+1..9 ordena por columna", + "Tip: Ctrl+Home/End va al inicio/fin", + "Tip: Enter confirma y baja, Escape cancela", + "Tip: Al editar, tecla directa reemplaza todo", +}; + +/// Frames entre rotación de tips (~10s @ 60fps) +pub const TIP_ROTATION_FRAMES: u32 = 600; + // ============================================================================= // Tipos comunes // ============================================================================= diff --git a/src/widgets/virtual_advanced_table/state.zig b/src/widgets/virtual_advanced_table/state.zig index faa4d4c..4f30abb 100644 --- a/src/widgets/virtual_advanced_table/state.zig +++ b/src/widgets/virtual_advanced_table/state.zig @@ -126,6 +126,9 @@ pub const VirtualAdvancedTableState = struct { /// Frame counter para animaciones frame_count: u32 = 0, + /// Índice del tip actual (para tips proactivos rotativos) + tip_index: u8 = 0, + // ========================================================================= // Buffers persistentes para texto formateado (evitar stack buffer escape) // ========================================================================= diff --git a/src/widgets/virtual_advanced_table/virtual_advanced_table.zig b/src/widgets/virtual_advanced_table/virtual_advanced_table.zig index 90cba28..d56d751 100644 --- a/src/widgets/virtual_advanced_table/virtual_advanced_table.zig +++ b/src/widgets/virtual_advanced_table/virtual_advanced_table.zig @@ -145,6 +145,14 @@ pub const VirtualAdvancedTableResult = struct { /// @deprecated previous_row: ?usize = null, + // ========================================================================= + // Tips Proactivos (FASE I) + // ========================================================================= + + /// Tip actual para mostrar en StatusLine (null = sin tip) + /// Rota automáticamente cada ~10 segundos (600 frames @ 60fps) + current_tip: ?[]const u8 = null, + /// Obtiene los cambios como slice (helper para compatibilidad) pub fn getRowChanges(self: *const VirtualAdvancedTableResult) []const table_core.PendingCellChange { return self.row_changes[0..self.row_changes_count]; @@ -434,6 +442,20 @@ pub fn virtualAdvancedTableRect( } } + // ========================================================================= + // Tips Proactivos (FASE I): Rotar tips cada ~10 segundos + // ========================================================================= + list_state.frame_count +%= 1; // Wrap around en overflow + + // Solo mostrar tips si tiene focus y no está editando + if (has_focus and !list_state.isEditing()) { + // Rotar tip cada TIP_ROTATION_FRAMES frames + if (list_state.frame_count % table_core.TIP_ROTATION_FRAMES == 0) { + list_state.tip_index = @intCast((list_state.tip_index + 1) % table_core.table_tips.len); + } + result.current_tip = table_core.table_tips[list_state.tip_index]; + } + return result; }