Commit 996d01cb authored by Thierry Martinez's avatar Thierry Martinez

Tables: editable rows and columns

parent 920b1d36
......@@ -298,8 +298,6 @@ generate_body(Doc, Type) :-
\+ (
toc(Item),
\+ (
print(Item),
nl,
generate_body_item(Item, Doc, Type)
)
).
......
......@@ -676,7 +676,7 @@ delete_item(Options) :-
delete_item(Id) :-
\+ (
at_delete_goal(Id, Goal),
(
\+ (
Goal
)
),
......
......@@ -39,8 +39,6 @@ make_ode_system :-
solve(Time) :-
print(hello),
nl,
gather_headers(Headers),
gather_equations(Equations),
gather_initial_values(InitialValues),
......@@ -58,11 +56,7 @@ solve(Time) :-
time_final: Time
],
solve(Options, Table),
print(here),
nl,
add_table('numerical_simulation', Table),
print(there),
nl.
add_table('numerical_simulation', Table).
gather_headers(Headers) :-
......
......@@ -14,7 +14,6 @@ plot :-
biocham_command,
doc('plots the current trace.'),
get_plot_driver(Driver),
print(here), nl,
Driver.
......
......@@ -32,9 +32,7 @@ load_table(InputFile) :-
\+ (
filename(InputFile, Filename),
\+ (
automatic_suffix(Filename, '.csv', read, FilenameCsv),
csv_read_file(FilenameCsv, Table),
add_table(FilenameCsv, Table)
add_table_file(Filename)
)
).
......@@ -203,7 +201,7 @@ add_table(Name, Table) :-
->
declare_column(Id, 0, FirstColumnName),
\+ (
nth0(ColumnIndex, OtherColumns, ColumnName),
nth1(ColumnIndex, OtherColumns, ColumnName),
\+ (
declare_column(Id, ColumnIndex, ColumnName)
)
......@@ -270,6 +268,15 @@ columns(Id, ColumnIndex, Name) :-
:- devdoc('\\section{Private predicates}').
add_file_suffix('csv', tables:add_table_file).
add_table_file(Filename) :-
automatic_suffix(Filename, '.csv', read, FilenameCsv),
csv_read_file(FilenameCsv, Table),
add_table(FilenameCsv, Table).
declare_column(Id, ColumnIndex, Name) :-
add_item(
[parent: Id, kind: column, key: ColumnIndex, item: Name, id: ColumnId]
......@@ -292,13 +299,13 @@ perform_column_delete(ColumnId) :-
)
),
\+ (
item([parent:TableId, kind: column, item: Column, id: ColumnId]),
get_annotation(ColumnId, index, ColumnIndex),
Row =.. [row | RowItems],
nth0(ColumnIndex, RowItems, _Deleted, NewRowItems),
NewRow =.. [row | NewRowItems],
replace_item(RowId, row, RowIndex, NewRow)
item([parent:TableId, kind: column, item: Column0, id: ColumnId0]),
get_annotation(ColumnId0, index, ColumnIndex0),
ColumnIndex0 > ColumnIndex,
\+ (
ColumnIndex1 is ColumnIndex0 - 1,
replace_item(ColumnId0, column, ColumnIndex1, Column0),
set_annotation(ColumnId0, index, ColumnIndex1)
)
).
......@@ -311,8 +318,8 @@ perform_row_delete(RowId) :-
get_annotation(RowId0, index, RowIndex0),
RowIndex0 > RowIndex,
\+ (
replace_item(RowId0, row, RowIndex0, Row0),
RowIndex1 is RowIndex0 - 1,
replace_item(RowId0, row, RowIndex1, Row0),
set_annotation(RowId0, index, RowIndex1)
)
).
......
......@@ -24,18 +24,6 @@ test(
) :-
clear_model,
add_table(table, [row(1, 2, 3), row(4, 5, 6)]),
print(here),
command(delete_column(1)),
print(there),
nl,
get_table_data(Data).
test(
'delete_column',
[true(Data == [row(10, 30), row(40, 60)])]
) :-
clear_model,
add_table(table, [row(10, 20, 30), row(40, 50, 60)]),
command(delete_column(1)),
get_table_data(Data).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment