Added command options "flush -dereference" and also "cellname dereference"

to allow a cell to be flushed with dereferencing (i.e., discard any file
path attached to the cell, and use the search paths to find the cell when
it is reloaded).
This commit is contained in:
Tim Edwards 2020-12-10 12:13:48 -05:00
parent 6952e814f6
commit 2b513eb3bb
5 changed files with 35 additions and 17 deletions

View File

@ -1 +1 @@
8.3.95
8.3.96

View File

@ -881,16 +881,13 @@ CmdCellname(w, cmd)
else
cellDef = DBCellLookDef(cellname);
/* Force dereferencing */
cellDef->cd_flags |= CDDEREFERENCE;
freeMagic(cellDef->cd_file);
cellDef->cd_file = NULL;
/* Reload cell */
cmdFlushCell(cellDef);
/* Clear dereferencing */
cellDef->cd_flags &= ~CDDEREFERENCE;
/* Reload cell with dereferencing */
if (cellDef == NULL)
{
TxError("No such cell \"%s\"\n", cellname);
break;
}
cmdFlushCell(cellDef, TRUE);
SelectClear();
}
else

View File

@ -913,10 +913,12 @@ dbListLabels(scx, label, tpath, cdarg)
* Implement the "flush" command.
* Throw away all changes made within magic to the specified cell,
* and re-read it from disk. If no cell is specified, the default
* is the current edit cell.
* is the current edit cell. If "-dereference" is specified as an
* option, then re-read the cell from the search path instead of
* the file path that has been associated with the cell.
*
* Usage:
* flush [cellname]
* flush [cellname] [-dereference]
*
* Results:
* None.
@ -937,10 +939,17 @@ CmdFlush(w, cmd)
int action;
static char *actionNames[] = { "no", "yes", 0 };
char *prompt;
bool dereference = FALSE;
if (!strncmp(cmd->tx_argv[cmd->tx_argc - 1], "-deref", 6))
{
dereference = TRUE;
cmd->tx_argc--;
}
if (cmd->tx_argc > 2)
{
TxError("Usage: flush [cellname]\n");
TxError("Usage: flush [cellname] [dereference]\n");
return;
}
@ -970,7 +979,7 @@ CmdFlush(w, cmd)
return;
}
cmdFlushCell(def);
cmdFlushCell(def, dereference);
SelectClear();
TxPrintf("[Flushed]\n");
}

View File

@ -285,12 +285,15 @@ CmdInit()
*/
void
cmdFlushCell(def)
cmdFlushCell(def, force_deref)
CellDef *def;
bool force_deref;
{
CellUse *parentUse;
bool dereference;
if (def == NULL) return;
/* Disallow flushing a cell that contains the edit cell as a child */
if (EditCellUse && (EditCellUse->cu_parent == def))
{
@ -300,6 +303,15 @@ cmdFlushCell(def)
}
UndoFlush();
if (force_deref)
{
/* Force dereferencing */
def->cd_flags |= CDDEREFERENCE;
freeMagic(def->cd_file);
def->cd_file = NULL;
}
DBWAreaChanged(def, &def->cd_bbox, DBW_ALLWINDOWS,
(TileTypeBitMask *) NULL);
for (parentUse = def->cd_parents; parentUse != NULL;

View File

@ -1818,7 +1818,7 @@ cmdWriteallFunc(def, cmd)
cmdSaveCell(def, (char *) NULL, FALSE, TRUE);
break;
case 1: /* Flush */
cmdFlushCell(def);
cmdFlushCell(def, FALSE);
break;
case 2: /* Skip */
break;