Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void processInput(char *input, int row, int column) {
- printf("\n**process input**\n");
- Cell *cell = cells[row][column];
- free(cell->input); // free old input
- cell->input = strdup(input); // copy input string
- printf("cell->input: %s (row %d, column %d) (strlen = %d)\n",
- cell->input, row, column, (int)strlen(input));
- guiSetInput(input, row, column);
- //Remove current cell from the listeners list in all cells in the listeningTo list of the current cell
- Node *node = cell->listeningTo->first;
- // printf("\t%d\t%d listening to %s will be removed\n", row, column, toCString(cell->listeningTo)); Debug
- for (; node != NULL; node = node->next) {
- Cell *curCell = (Cell*)node->value;
- removeObject(cell->listeners, curCell);
- }
- removeAll(cell->listeningTo);
- //Set new references
- references(cell->listeningTo, parse(newString(cell->input)));
- printf("\(%d\t%d) listening to %s\n", row, column, toCString(cell->listeningTo));
- node = cell->listeningTo->first;
- for (; node != NULL; node = node->next) {
- Cell *curCell = (Cell*)node->value;
- if (contains(curCell->listeners, cell) == 0) {
- append(curCell->listeners, cell);
- }
- printf("\t(%d\t%d) has listeners %s\n", curCell->row, curCell->column, toCString(curCell->listeners));
- }
- //Evaluate
- Object *evalResult = evaluate(parse(newString(cell->input)));
- cell->value = evalResult;
- char *result = "";
- if (evalResult != NULL) {
- result = toCString(evalResult);
- } else {
- result = "Could not Evaluate Input";
- }
- guiSetOutput(result, row, column);
- updateReferencedCells(cell);
- saveFile(currentFileName);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement