MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / executeMacroCB

Method executeMacroCB

src/csvapplication.cpp:2346–2390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2344
2345
2346void CsvApplication::executeMacroCB(Fl_Widget *, void *data) {
2347 int row_top, row_bottom, col_top, col_bottom;
2348 int winIndex = app.getTopWindow();
2349 std::tuple<int, int, int, int> selection;
2350 std::tuple<int, std::string> executeReturn;
2351 std::tuple<Fl_Text_Buffer *, Fl_Text_Display *, Fl_Text_Display *> *widgets = (std::tuple<Fl_Text_Buffer *, Fl_Text_Display *, Fl_Text_Display *> *) data;
2352 std::string source = ((Fl_Text_Buffer *) std::get<0>(*widgets))->text();
2353 void *logVoid = ((void *) std::get<1>(*widgets));
2354 Fl_Text_Display *logDisplay = (Fl_Text_Display *) logVoid;
2355
2356 #ifdef DEBUG
2357 printf("logDisplay: %p\n", (void *)logDisplay);
2358 #endif
2359 fflush(stdout);
2360
2361
2362 // TODO Check if macro source is shorter than TCRUNCHER_PREF_VALUE_MAX_LENGTH
2363 // TODO Save to `macros` before execution – seems already be done
2364
2365 windows[winIndex].grid->get_selection(row_top, col_top, row_bottom, col_bottom);
2366 selection = std::make_tuple(row_top, col_top, row_bottom, col_bottom);
2367
2368 app.showImWorkingWindow("Executing Macro ...");
2369 windows[winIndex].addUndoStateTable("Execute Macro");
2370 bool isChanged = windows[winIndex].isChanged();
2371 windows[winIndex].setChanged(true);
2372 windows[winIndex].setUsed(true);
2373
2374 logDisplay->buffer()->text( "Executing macro ...\n" );
2375 Fl::check();
2376 executeReturn = macro.execute( windows[winIndex].table, selection, source, logVoid );
2377 app.hideImWorkingWindow();
2378 if( std::get<0>(executeReturn) == -1 ) {
2379 // error
2380 logDisplay->buffer()->text( std::get<1>(executeReturn).c_str() );
2381 } else if( std::get<0>(executeReturn) == 0 ) {
2382 // table data not modified: reset undo state
2383 windows[winIndex].removeLastUndoState();
2384 windows[winIndex].setChanged(isChanged);
2385 }
2386 logDisplay->buffer()->append( "Done.\n" );
2387
2388 windows[winIndex].grid->redraw();
2389 Fl::check();
2390}
2391void CsvApplication::insertLoopButtonCB(Fl_Widget *, void *data) {
2392 std::tuple<Fl_Text_Buffer *, Fl_Text_Display *, Fl_Text_Editor *> *widgets = (std::tuple<Fl_Text_Buffer *, Fl_Text_Display *, Fl_Text_Editor *> *) data;
2393 int pos = (std::get<2>(*widgets))->insert_position();

Callers

nothing calls this directly

Calls 11

checkFunction · 0.85
getTopWindowMethod · 0.80
showImWorkingWindowMethod · 0.80
addUndoStateTableMethod · 0.80
isChangedMethod · 0.80
setChangedMethod · 0.80
setUsedMethod · 0.80
executeMethod · 0.80
hideImWorkingWindowMethod · 0.80
removeLastUndoStateMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected