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
This commit is contained in:
parent
6dbaecc485
commit
40743b98d2
1 changed files with 27 additions and 1 deletions
|
|
@ -1297,7 +1297,7 @@ pub const PendingCellChange = struct {
|
||||||
/// Buffer para acumular cambios de una fila antes de commit
|
/// Buffer para acumular cambios de una fila antes de commit
|
||||||
/// Usado por los states de los widgets, procesado por funciones de table_core
|
/// Usado por los states de los widgets, procesado por funciones de table_core
|
||||||
pub const RowEditBuffer = struct {
|
pub const RowEditBuffer = struct {
|
||||||
/// ID de la fila siendo editada (NEW_ROW_ID si es ghost row)
|
/// ID de la fila siendo editada (NEW_ROW_ID si es ghost row o inyectada)
|
||||||
row_id: i64 = NEW_ROW_ID,
|
row_id: i64 = NEW_ROW_ID,
|
||||||
|
|
||||||
/// Índice de fila (para navegación)
|
/// Índice de fila (para navegación)
|
||||||
|
|
@ -1309,6 +1309,12 @@ pub const RowEditBuffer = struct {
|
||||||
/// Hay cambios pendientes
|
/// Hay cambios pendientes
|
||||||
has_changes: bool = false,
|
has_changes: bool = false,
|
||||||
|
|
||||||
|
/// True si es una fila inyectada (Ctrl+N entre líneas)
|
||||||
|
is_injected: bool = false,
|
||||||
|
|
||||||
|
/// Índice donde se insertó la fila inyectada (null si no es inyección)
|
||||||
|
injection_index: ?usize = null,
|
||||||
|
|
||||||
/// Buffers de valores por columna (almacenamiento fijo)
|
/// Buffers de valores por columna (almacenamiento fijo)
|
||||||
value_buffers: [MAX_PENDING_COLUMNS][MAX_CELL_VALUE_LEN]u8 = undefined,
|
value_buffers: [MAX_PENDING_COLUMNS][MAX_CELL_VALUE_LEN]u8 = undefined,
|
||||||
|
|
||||||
|
|
@ -1327,6 +1333,24 @@ pub const RowEditBuffer = struct {
|
||||||
self.row_index = row_index;
|
self.row_index = row_index;
|
||||||
self.is_new_row = is_new;
|
self.is_new_row = is_new;
|
||||||
self.has_changes = false;
|
self.has_changes = false;
|
||||||
|
self.is_injected = false;
|
||||||
|
self.injection_index = null;
|
||||||
|
self.change_count = 0;
|
||||||
|
for (0..MAX_PENDING_COLUMNS) |i| {
|
||||||
|
self.changed_cols[i] = false;
|
||||||
|
self.value_lens[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Inicializa buffer para una fila inyectada (Ctrl+N entre líneas)
|
||||||
|
/// insertion_idx es el índice visual donde aparece la fila nueva
|
||||||
|
pub fn startInjectedEdit(self: *RowEditBuffer, insertion_idx: usize) void {
|
||||||
|
self.row_id = NEW_ROW_ID;
|
||||||
|
self.row_index = insertion_idx;
|
||||||
|
self.is_new_row = true;
|
||||||
|
self.has_changes = false;
|
||||||
|
self.is_injected = true;
|
||||||
|
self.injection_index = insertion_idx;
|
||||||
self.change_count = 0;
|
self.change_count = 0;
|
||||||
for (0..MAX_PENDING_COLUMNS) |i| {
|
for (0..MAX_PENDING_COLUMNS) |i| {
|
||||||
self.changed_cols[i] = false;
|
self.changed_cols[i] = false;
|
||||||
|
|
@ -1365,6 +1389,8 @@ pub const RowEditBuffer = struct {
|
||||||
self.row_index = 0;
|
self.row_index = 0;
|
||||||
self.is_new_row = false;
|
self.is_new_row = false;
|
||||||
self.has_changes = false;
|
self.has_changes = false;
|
||||||
|
self.is_injected = false;
|
||||||
|
self.injection_index = null;
|
||||||
self.change_count = 0;
|
self.change_count = 0;
|
||||||
for (0..MAX_PENDING_COLUMNS) |i| {
|
for (0..MAX_PENDING_COLUMNS) |i| {
|
||||||
self.changed_cols[i] = false;
|
self.changed_cols[i] = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue