void clTreeCtrlPanel::OnRenameFile(wxCommandEvent& event) { wxArrayString files, folders; wxArrayTreeItemIds fileItems, folderItems; GetSelections(folders, folderItems, files, fileItems); if(files.empty()) return; // Prompt and rename each file for(size_t i = 0; i < files.size(); ++i) { wxFileName oldname(files.Item(i)); wxString newname = ::clGetTextFromUser(_("Rename File"), _("New Name:"), oldname.GetFullName(), wxStrlen(oldname.GetName())); if(!newname.IsEmpty() && (newname != oldname.GetFullName())) { clTreeCtrlData* d = GetItemData(fileItems.Item(i)); if(d) { wxFileName oldpath = d->GetPath(); wxFileName newpath = oldpath; newpath.SetFullName(newname); if(::wxRenameFile(oldpath.GetFullPath(), newpath.GetFullPath(), false)) { DoRenameItem(fileItems.Item(i), oldname.GetFullName(), newname); } } } } }
bool MgCmdManagerImpl::setCommand(const MgMotion* sender, const char* name, MgStorage* s) { if (strcmp(name, "@draw") == 0) { // 将 @draw 换成上一次绘图命令名 name = _drawcmd.empty() ? "splines" : _drawcmd.c_str(); } MgCommand* cmd = findCommand(name); if (!cmd) { cmd = sender->view->getCmdSubject()->createCommand(sender, name); if (cmd) { _cmds[name] = cmd; LOGD("createCommand %d: %s", (int)_cmds.size(), name); } } if (strcmp(name, "erase") == 0 && _cmdname == "select") { // 在选择命令中点橡皮擦 MgSelection *sel = getSelection(); if (sel && sel->deleteSelection(sender)) { // 直接删除选中的图形 return false; // 不切换到橡皮擦命令 } } cancel(sender); bool ret = false; std::string oldname(_cmdname); if (cmd) { _cmdname = cmd->getName(); ret = cmd->initialize(sender, s); if (!ret) { _cmdname = oldname; } else if (cmd->isDrawingCommand()) { _drawcmd = _cmdname; } } else { if (strcmp(name, "erasewnd") == 0) { eraseWnd(sender); } else { _cmdname = "select"; cmd = findCommand(_cmdname.c_str()); cmd->initialize(sender, s); } } if (MgBaseShape::minTol().equalPoint() < 1e-5) { MgBaseShape::minTol().setEqualPoint(sender->view->xform()->displayToModel(1.f, true)); } if (oldname != _cmdname) { sender->view->commandChanged(); } return ret; }
static void commit(Joblist_t* job, register char* s) { register char* t; register char* v; register Rule_t* r; Stat_t st; if (t = strrchr(s, '/')) { *t = 0; if (r = bindfile(NiL, s, 0)) { if (!r->view) { *t = '/'; return; } if (*(v = r->name) != '/') { sfprintf(internal.nam, "%s/%s", state.view[r->view].root, v); v = sfstruse(internal.nam); } if (stat(v, &st)) r = 0; } if (r || state.targetcontext && (!r || !r->time) && (st.st_mode = (S_IRWXU|S_IRWXG|S_IRWXO)) && tmxsetmtime(&st, state.start)) { /* * why not mkdir -p here? */ commit(job, s); if (((job->flags & CO_ALWAYS) || state.exec && state.touch) && (mkdir(s, st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) || stat(s, &st))) error(1, "%s: cannot create target directory %s", job->target->name, s); if (state.mam.out) { Sfio_t* tmp = sfstropen(); sfprintf(tmp, "mkdir %s", s); dumpaction(state.mam.out, MAMNAME(job->target), sfstruse(tmp), NiL); sfstrclose(tmp); } r = makerule(s); if (r->dynamic & D_alias) oldname(r); r->view = 0; r->time = tmxgetmtime(&st); if (r->dynamic & D_scanned) unbind(NiL, (char*)r, NiL); } *t = '/'; } }