Commit graph

17 commits

Author SHA1 Message Date
08b10486d2 feat(table_core,virtual_table): Propagate injection info on commit
RowCommitInfo now includes:
- is_injected: bool (was this an injected row)
- injection_index: ?usize (where it was injected)

buildCommitInfo() copies these from RowEditBuffer.

VirtualAdvancedTable sets result.injection_committed and
result.injection_row_idx when committing an injected row,
for both Tab navigation and selection change commits.

This allows the panel to know when to INSERT vs UPDATE and
handle the special case of locally injected rows.
2025-12-28 02:27:44 +01:00
40743b98d2 feat(table_core): Add injection support to RowEditBuffer
- Add is_injected: bool to distinguish injected rows
- Add injection_index: ?usize for insertion position
- Add startInjectedEdit() method for Ctrl+N between lines
- Update startEdit/clear to reset new fields
2025-12-28 02:19:04 +01:00
2a92c7530c feat(table_core): DRY planTabNavigation for Excel-style Tab commit
- Add planTabNavigation() in table_core.zig: central function for Tab navigation with auto-commit
- Uses row_id comparison (not indices) to detect row changes - robust for virtual tables
- Returns TabAction enum: move, move_with_commit, exit, exit_with_commit
- Integrates in virtual_advanced_table.zig with RowIdGetter wrapper
- Removes obsolete tab_out commit logic
- Fix: Tab at end of ghost row now commits before wrap

🤖 Generated with Claude Code
2025-12-28 01:50:22 +01:00
ef30cc7d1b fix(table_core): Show pending values from RowEditBuffer in render
Fix Tab showing empty cell after editing:
- Add edit_buffer field to DrawRowsConfig
- drawRowsWithDataSource now checks RowEditBuffer before DataSource
- VirtualAdvancedTable passes row_edit_buffer to render

Priority: RowEditBuffer (user typed) > DataSource (DB/memory)
2025-12-27 23:00:09 +01:00
5c7964bacc feat(tables): Tips proactivos cada ~10s
- 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
2025-12-27 21:47:47 +01:00
dc82340381 feat(table_core): Selection on focus Excel-style
- Añade selection_start/selection_end a CellEditState
- F2/Space selecciona todo el texto al entrar en edición
- Typing con selección reemplaza texto seleccionado
- Backspace/Delete borra selección si existe
- Flechas/Home/End limpian selección
- Dibuja highlight azul en ambas tablas (Advanced + Virtual)
2025-12-27 21:41:42 +01:00
aed811a102 feat(table_core): Brain-in-Core - processTableEvents() unifica toda lógica de teclado
Arquitectura diseñada por Gemini:
- TODA la lógica de decisión en table_core.zig
- Widgets solo pasan eventos y reaccionan a flags
- Cualquier tabla nueva hereda automáticamente

Cambios:
- TableEventResult: struct con TODOS los flags de acciones
- processTableEvents(): función maestra que procesa teclado
- Soporta: navegación, CRUD (Ctrl+N/B/Del), ordenación (Ctrl+Shift+1-9), edición
- VirtualAdvancedTable refactorizado al patrón Brain-in-Core
- Nuevos campos result: insert_row_requested, delete_row_requested, sort_column_index
2025-12-27 21:07:17 +01:00
7642ffe7f7 feat(table_core): Dirty tracking visual - blend naranja para filas con cambios pendientes
- Añadido dirty_row_id: ?i64 a DrawRowsConfig
- drawRowsWithDataSource aplica blendColor(state_modified, 0.25) si dirty
- VirtualAdvancedTable pasa row_edit_buffer.row_id cuando has_changes
2025-12-27 20:54:53 +01:00
a9caa522a1 refactor(tables): FASE 6 - Unificar scrollbars en table_core
- Añadido VerticalScrollbarParams y drawVerticalScrollbar
- Añadido HorizontalScrollbarParams y drawHorizontalScrollbar
- AdvancedTable y VirtualAdvancedTable ahora usan funciones unificadas
- Elimina duplicación de código de renderizado de scrollbars
2025-12-27 19:52:05 +01:00
08ffcdbac5 refactor(tables): FASE 4.5 - AdvancedTable usa drawRowsWithDataSource
- Añadir RowState enum a table_core.zig
- Añadir getRowState a TableDataSource.VTable (opcional)
- Añadir colores de estado a RowRenderColors
- Añadir draw_row_borders a DrawRowsConfig
- Añadir getRowState a MemoryDataSource
- Nueva función handleRowClicks() separando input de rendering
- AdvancedTable usa drawRowsWithDataSource (sin bucle for propio)
- Eliminar drawRow() y drawStateIndicator() locales (~160 líneas)

Objetivo cumplido: un solo bloque de código para renderizar filas
2025-12-27 18:52:31 +01:00
b8199aec38 refactor(tables): FASE 4 - Add unified drawRowsWithDataSource
Add unified row rendering function to table_core.zig that uses
TableDataSource interface for data access.

Changes:
- Add ColumnRenderDef, RowRenderColors, DrawRowsConfig types
- Add drawRowsWithDataSource() unified rendering function
- Update VirtualAdvancedTable.drawRows to use unified function
  with PagedDataSource

Note: AdvancedTable not yet integrated due to additional complexity
(state indicators, click handling interleaved with drawing).
See PLAN_REFACTOR_TABLES_CONTINUIDAD.md for details.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 18:02:45 +01:00
473bbdb648 feat(table_core): Add TableDataSource interface (FASE 3)
- TableDataSource: vtable interface for data abstraction
- getCellValueInto: buffer-based pattern to avoid memory issues
- getRowCount, getRowId: basic data access methods
- isCellEditable, invalidate: optional methods
- makeTableDataSource: helper to create from concrete types
- isGhostRow: convenience method for new row detection

This interface enables unified rendering for both memory and
paginated tables while enforcing safe memory patterns.
2025-12-27 17:13:38 +01:00
6819919060 refactor(table_core): Add CellEditState + NavigationState for composition
- Delete obsolete 'table_core (conflicted).zig'
- Add memory ownership protocol documentation
- Add CellEditState: embeddable edit state with buffer, cursor, escape handling
- Add NavigationState: embeddable nav state with active_col, scroll, Tab methods
- Maintains backward compatibility with existing EditState
2025-12-27 16:11:24 +01:00
d16019d54f feat(table_core): RowEditBuffer + commit al abandonar fila (Excel-style)
- RowEditBuffer: acumula cambios de fila antes de commit
- checkRowChangeAndCommit(): detecta cambio fila + commit automático
- buildCommitInfo(), isGhostRow(), NEW_ROW_ID
- VirtualAdvancedTableState: row_edit_buffer field
- VirtualAdvancedTableResult: row_committed, row_changes[], etc.
- Comportamiento: Tab entre celdas acumula, cambiar fila hace commit
2025-12-27 14:58:01 +01:00
49cf12f7b9 refactor(table_core): Unify EditKeyboardResult with NavigateDirection and handled flag
- Add NavigateDirection enum (none, next_cell, prev_cell, next_row, prev_row)
- Replace navigate_next/navigate_prev bools with single navigate field
- Add 'handled' flag to prevent double processing of Tab
- Add Up/Down arrow handling for row navigation
- Use getKeyEvents() loop instead of keyPressed() for consistency
2025-12-27 12:09:47 +01:00
27b69cfcde refactor(table_core): Move Tab navigation logic to shared module (Norma #7 DRY)
ANTES: calculateNextCell/calculatePrevCell duplicados en:
  - AdvancedTableState
  - VirtualAdvancedTableState

AHORA: Lógica común en table_core.zig:
  - calculateNextCell() - calcula siguiente celda (Tab)
  - calculatePrevCell() - calcula celda anterior (Shift+Tab)
  - toggleSort() - alterna ordenación de columna
  - TabNavigateResult, CellPosition, SortDirection, SortToggleResult

Ambos widgets usan table_core, adaptando el resultado a su modelo:
  - AdvancedTable: selected_row/selected_col (índices)
  - VirtualAdvancedTable: selected_id + active_col (ID + columna)

Tests añadidos para calculateNextCell, calculatePrevCell, toggleSort
2025-12-27 01:49:56 +01:00
47fc5b28f7 refactor(tables): Add table_core.zig with shared rendering functions
- New module: table_core.zig with common table rendering logic
- drawCellActiveIndicator(): visual indicator for selected cell  
- detectDoubleClick(): timing-based double-click detection
- handleEditingKeyboard(): common keyboard handling for editing
- blendColor(), startsWithIgnoreCase(): utilities

VirtualAdvancedTable now uses table_core:
- Active cell indicator in drawRows (visible highlight on selected cell)
- Double-click detection in handleMouseClick
- Added state fields: last_click_time, last_click_row, last_click_col

AdvancedTable changes:
- Improved cell active indicator (alpha 0.35, double border)
- Added double-click fields to state
- Space starts editing with empty value
- Alphanumeric keys start editing in editable cells
2025-12-26 17:53:16 +01:00