void EditFiles::viewModule(OovStringRef const fn, int lineNum) { FilePath moduleName(fn, FP_File); FilePath cppExt("cpp", FP_Ext); FilePath hExt("h", FP_Ext); bool header = moduleName.matchExtension(hExt); bool source = moduleName.matchExtension(cppExt); if(header || source) { moduleName.appendExtension("h"); if(header) viewFile(moduleName, lineNum); else viewFile(moduleName, 1); moduleName.appendExtension("cpp"); if(source) viewFile(moduleName, lineNum); else viewFile(moduleName, 1); } else { viewFile(fn, lineNum); } }
void EditFiles::viewModule(OovStringRef const fn, int lineNum) { FilePath moduleName(fn, FP_File); bool header = isCppHeader(fn); bool source = isCppSource(fn); if(header || source) { moduleName.appendExtension("h"); if(header) viewFile(moduleName, lineNum); else viewFile(moduleName, 1); moduleName.appendExtension("cpp"); if(source) viewFile(moduleName, lineNum); else viewFile(moduleName, 1); } else { viewFile(fn, lineNum); } }
void KTNEFMain::contextMenuEvent( QContextMenuEvent *event ) { QList<KTNEFAttach *> list = mView->getSelection(); if ( !list.count() ) { return; } QAction *view = 0; QAction *viewWith = 0; QAction *prop = 0; KMenu *menu = new KMenu(); if ( list.count() == 1 ) { view = menu->addAction( KIcon( "document-open" ), i18nc( "@action:inmenu", "View" ) ); viewWith = menu->addAction( i18nc( "@action:inmenu", "View With..." ) ); menu->addSeparator(); } QAction *extract = menu->addAction( i18nc( "@action:inmenu", "Extract" ) ); QAction *extractTo = menu->addAction( KIcon( "archive-extract" ), i18nc( "@action:inmenu", "Extract To..." ) ); if ( list.count() == 1 ) { menu->addSeparator(); prop = menu->addAction( KIcon( "document-properties" ), i18nc( "@action:inmenu", "Properties" ) ); } QAction *a = menu->exec( event->globalPos(), 0 ); if ( a ) { if ( a == view ) { viewFile(); } else if ( a == viewWith ) { viewFileAs(); } else if ( a == extract ) { extractFile(); } else if ( a == extractTo ) { extractFileTo(); } else if ( a == prop ) { propertiesFile(); } } delete menu; }
int main(int argc, char *argv[]) { int status = 0; int argNumber = 0; setlocale(LC_ALL, getenv(ENV_LANG)); textdomain("more"); if (argc < 2) { usage(argv[0]); return (status = ERR_ARGUMENTCOUNT); } // Get screen parameters screenColumns = textGetNumColumns(); screenRows = textGetNumRows(); // Loop through all of our file name arguments for (argNumber = 1; argNumber < argc; argNumber ++) { // Make sure the name isn't NULL if (!argv[argNumber]) return (status = ERR_NULLPARAMETER); status = viewFile(argv[argNumber]); if (status < 0) { errno = status; perror(argv[0]); if (argNumber < (argc - 1)) continue; else return (status); } } // Return success return (status = 0); }
void EditFiles::idleHighlight() { timeval curTime; gettimeofday(&curTime, NULL); if(curTime.tv_sec != mLastHightlightIdleUpdate.tv_sec || abs(curTime.tv_usec - mLastHightlightIdleUpdate.tv_usec) > 300) { OovString fn; size_t offset; for(auto &view : mFileViews) { FileEditView &editView = view->getFileEditView(); if(editView.idleHighlight()) { editView.getFindTokenResults(fn, offset); } } if(fn.length() > 0) { viewFile(fn, offset); } mLastHightlightIdleUpdate = curTime; } }
void KTNEFMain::setupActions() { KStandardAction::quit( this, SLOT(close()), actionCollection() ); KAction *action = KStandardAction::keyBindings( this, SLOT(slotConfigureKeys()), actionCollection() ); action->setWhatsThis( i18nc( "@info:whatsthis", "You will be presented with a dialog where you can configure " "the application-wide shortcuts." ) ); KStandardAction::configureToolbars( this, SLOT(slotEditToolbars()), actionCollection() ); // File menu KStandardAction::open( this, SLOT(openFile()), actionCollection() ); // Action menu KAction *openAction = actionCollection()->addAction( "view_file" ); openAction->setText( i18nc( "@action:inmenu", "View" ) ); openAction->setIcon( KIcon( "document-open" ) ); connect( openAction, SIGNAL(triggered()), this, SLOT(viewFile()) ); KAction *openAsAction = actionCollection()->addAction( "view_file_as" ); openAsAction->setText( i18nc( "@action:inmenu", "View With..." ) ); connect( openAsAction, SIGNAL(triggered()), this, SLOT(viewFileAs()) ); KAction *extractAction = actionCollection()->addAction( "extract_file" ); extractAction->setText( i18nc( "@action:inmenu", "Extract" ) ); connect( extractAction, SIGNAL(triggered()), this, SLOT(extractFile()) ); KAction *extractToAction = actionCollection()->addAction( "extract_file_to" ); extractToAction->setText( i18nc( "@action:inmenu", "Extract To..." ) ); extractToAction->setIcon( KIcon( "archive-extract" ) ); connect( extractToAction, SIGNAL(triggered()), this, SLOT(extractFileTo()) ); KAction *extractAllToAction = actionCollection()->addAction( "extract_all_files" ); extractAllToAction->setText( i18nc( "@action:inmenu", "Extract All To..." ) ); extractAllToAction->setIcon( KIcon( "archive-extract" ) ); connect( extractAllToAction, SIGNAL(triggered()), this, SLOT(extractAllFiles()) ); KAction *filePropsAction = actionCollection()->addAction( "properties_file" ); filePropsAction->setText( i18nc( "@action:inmenu", "Properties" ) ); filePropsAction->setIcon( KIcon( "document-properties" ) ); connect( filePropsAction, SIGNAL(triggered()), this, SLOT(propertiesFile())); KAction *messPropsAction = actionCollection()->addAction( "msg_properties" ); messPropsAction->setText( i18nc( "@action:inmenu", "Message Properties" ) ); connect( messPropsAction, SIGNAL(triggered()), this, SLOT(slotShowMessageProperties()) ); KAction *messShowAction = actionCollection()->addAction( "msg_text" ); messShowAction->setText( i18nc( "@action:inmenu", "Show Message Text" ) ); messShowAction->setIcon( KIcon( "document-preview-archive" ) ); connect( messShowAction, SIGNAL(triggered()), this, SLOT(slotShowMessageText()) ); KAction *messSaveAction = actionCollection()->addAction( "msg_save" ); messSaveAction->setText( i18nc( "@action:inmenu", "Save Message Text As..." ) ); messSaveAction->setIcon( KIcon( "document-save" ) ); connect( messSaveAction, SIGNAL(triggered()), this, SLOT(slotSaveMessageText()) ); actionCollection()->action( "view_file" )->setEnabled( false ); actionCollection()->action( "view_file_as" )->setEnabled( false ); actionCollection()->action( "extract_file" )->setEnabled( false ); actionCollection()->action( "extract_file_to" )->setEnabled( false ); actionCollection()->action( "extract_all_files" )->setEnabled( false ); actionCollection()->action( "properties_file" )->setEnabled( false ); // Options menu KAction *defFolderAction = actionCollection()->addAction( "options_default_dir" ); defFolderAction->setText( i18nc( "@action:inmenu", "Default Folder..." ) ); defFolderAction->setIcon( KIcon( "folder-open" ) ); connect( defFolderAction, SIGNAL(triggered()), this, SLOT(optionDefaultDir()) ); }
void KTNEFMain::viewDoubleClicked( QTreeWidgetItem *item ) { if ( item && item->isSelected() ) { viewFile(); } }
void readKeyboard(void) { struct dir_node *currentNode; unsigned char key; bool decision = false; key = toupper(cgetc()); switch((int)key) { case HK_FORMATTER: if(loadOverlay(7)) { formatDisk(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } break; case HK_BASIC_VIEWER: if(loadOverlay(6)) { viewFileAsBASIC(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } break; case HK_HEX_EDIT: if(loadOverlay(5)) { hexEditCurrentFile(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } break; case CH_ENTER: currentNode = getSelectedNode(selectedPanel); if(isDirectory(selectedPanel)) { enterDirectory(selectedPanel); } else if(currentNode != NULL) { sprintf(filePath, "%s/%s", selectedPanel->path, currentNode->name); if(currentNode->type == 0x06 || currentNode->type == 0xFF) { saveScreen(); decision = writeYesNo("Confirm", quit_message, 1); retrieveScreen(); if(decision == true) { exec(filePath, NULL); } } else if(currentNode->type == 0xFC) { if(loadOverlay(6)) { viewFileAsBASIC(selectedPanel); clrscr(); writeMenuBar(); reloadPanels(); } } else { if(loadOverlay(1)) viewFile(filePath); } } break; case KEY_F4: rereadSelectedPanel(); break; case KEY_F3: selectDrive(selectedPanel); rereadSelectedPanel(); break; case HK_SELECT: selectCurrentFile(); break; #ifdef __APPLE2ENH__ case CH_CURS_UP: #else case CH_CURS_LEFT: #endif moveSelectorUp(selectedPanel); break; #ifdef __APPLE2ENH__ case CH_CURS_DOWN: #else case CH_CURS_RIGHT: #endif moveSelectorDown(selectedPanel); break; #ifdef __APPLE2ENH__ case CH_CURS_LEFT: if(selectedPanel == &rightPanelDrive && strlen(leftPanelDrive.path) > 0) { selectedPanel = &leftPanelDrive; writeSelectorPosition(&leftPanelDrive, '>'); writeSelectorPosition(&rightPanelDrive, ' '); writeCurrentFilename(selectedPanel); } break; case CH_CURS_RIGHT: if(selectedPanel == &leftPanelDrive && strlen(rightPanelDrive.path) > 0) { selectedPanel = &rightPanelDrive; writeSelectorPosition(&leftPanelDrive, ' '); writeSelectorPosition(&rightPanelDrive, '>'); writeCurrentFilename(selectedPanel); } break; #endif case HK_SWITCH_PANEL: if(selectedPanel == &leftPanelDrive && strlen(rightPanelDrive.path) > 0) { selectedPanel = &rightPanelDrive; writeSelectorPosition(&leftPanelDrive, ' '); writeSelectorPosition(&rightPanelDrive, '>'); writeCurrentFilename(selectedPanel); } else if(selectedPanel == &rightPanelDrive && strlen(leftPanelDrive.path) > 0) { selectedPanel = &leftPanelDrive; writeSelectorPosition(&leftPanelDrive, '>'); writeSelectorPosition(&rightPanelDrive, ' '); writeCurrentFilename(selectedPanel); } break; case KEY_SH_PLUS: enterDirectory(selectedPanel); break; case KEY_SH_MINUS: case CH_ESC: leaveDirectory(selectedPanel); break; //case 188: // C= C - Command Menu // writeMenu(command); // break; //case 182: // C= L - Left Menu // writeMenu(left); // break; //case 178: // C= R - Right Menu // writeMenu(right); // break; //case 187: // C= F - File Menu // writeMenu(file); // break; //case 185: // C= O - Options Menu // writeMenu(options); // break; case HK_REREAD_LEFT: rereadDrivePanel(left); break; case HK_REREAD_RIGHT: rereadDrivePanel(right); break; case HK_DRIVE_LEFT: writeDriveSelectionPanel(left); break; case HK_DRIVE_RIGHT: writeDriveSelectionPanel(right); break; case HK_SELECT_ALL: selectAllFiles(selectedPanel, true); break; case HK_DESELECT_ALL: selectAllFiles(selectedPanel, false); break; case KEY_F1: if(loadOverlay(1)) writeHelpPanel(); break; case KEY_F2: quit(); break; case KEY_F5: if(loadOverlay(4)) copyFiles(); break; case HK_RENAME: case KEY_F6: if(loadOverlay(4)) renameFile(); break; case HK_DELETE: case KEY_F8: if(loadOverlay(4)) deleteFiles(); break; //case KEY_AT: // inputCommand(); // break; case KEY_F7: if(loadOverlay(4)) makeDirectory(); break; case HK_TO_TOP: moveTop(selectedPanel); break; case HK_TO_BOTTOM: moveBottom(selectedPanel); break; case HK_PAGE_UP: movePageUp(selectedPanel); break; case HK_PAGE_DOWN: movePageDown(selectedPanel); break; case HK_WRITE_DISK_IMAGE: if(loadOverlay(3)) writeDiskImage(); break; case HK_CREATE_DISK_IMAGE: if(loadOverlay(3)) createDiskImage(); break; case HK_COPY_DISK: if(loadOverlay(2)) copyDisk(); break; default: //writeStatusBarf("%c", key); break; } }
bool generateViews(const std::string & outputFile) { std::ofstream viewsContent(outputFile, std::ofstream::out); viewsContent << "#include \"" << applicationName << ".h\"" << std::endl; viewsContent << "namespace webmvcpp" << std::endl; viewsContent << "{" << std::endl << std::endl; viewsContent << std::endl; std::string viewsPath = webApplicationPath + "/views"; std::string mainContent; std::ifstream mainPageFile(viewsPath + "/main.html"); if (!mainPageFile.is_open()) return false; mainPageFile.seekg(0, std::ios::end); std::streampos fileSize = mainPageFile.tellg(); mainPageFile.seekg(0, std::ios::beg); mainContent.resize((unsigned int)fileSize); mainPageFile.read(&mainContent[0], fileSize); DIR *cntrlsDir = opendir(viewsPath.c_str()); if (!cntrlsDir) return false; std::map<std::string, view_control> controls; while (dirent *entry = readdir(cntrlsDir)) { if (entry->d_type == DT_DIR) continue; std::string fileName = entry->d_name; std::vector<std::string> splittedName = utils::split_string(fileName, '.'); if ((splittedName.size() < 2) || (splittedName[splittedName.size() - 1] != "ctrl")) continue; std::string filePath = viewsPath + "/" + fileName; std::ifstream ctrlFile(filePath); if (!ctrlFile.is_open()) continue; std::string controlTextFileContent; std::string ctrlLine; while (std::getline(ctrlFile, ctrlLine)) { controlTextFileContent += ctrlLine; } std::map<std::string, std::string> CntrlCodeBlocks; size_t controlBlockPos = controlTextFileContent.find(WEBMVC_VIEWCONTROL, 0); size_t controlEndBlockPos = controlTextFileContent.rfind(WEBMVC_VIEWCONTROL_CLOSED, controlTextFileContent.length() - 1); if (controlBlockPos == std::string::npos || controlEndBlockPos == std::string::npos) continue; size_t controlParametersPos = controlBlockPos + std::string(WEBMVC_VIEWCONTROL).length(); size_t controlParametersEndPos = controlTextFileContent.find(WEBMVC_BLOCK_END, controlParametersPos); if (controlParametersEndPos == std::string::npos) continue; std::string parameters = controlTextFileContent.substr(controlParametersPos, controlParametersEndPos - controlParametersPos); if (parameters.length() == 0) continue; size_t controlContentPos = controlParametersEndPos + 1; // sizeof WEBMVC_BLOCK_END view_control control; control.content = controlTextFileContent.substr(controlContentPos, controlEndBlockPos - controlContentPos); control.parameters = utils::split_string(parameters, ':'); std::string controlname = control.parameters[0]; control.parameters.erase(control.parameters.begin()); controls.insert(std::pair<std::string, view_control>(controlname, control)); } closedir(cntrlsDir); DIR *cntrlrsDir = opendir(viewsPath.c_str()); if (!cntrlrsDir) return false; std::list<std::string> entries; while (dirent *entry = readdir(cntrlrsDir)) { if (entry->d_type != DT_DIR || strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue; std::string controller = entry->d_name; std::string ctrlPath = viewsPath + "/" + controller; std::string controllerContent = mainContent; std::ifstream cntrlrContentPageFile(viewsPath + "/main.html"); if (cntrlrContentPageFile.is_open()) { cntrlrContentPageFile.seekg(0, std::ios::end); std::streampos fileSize = cntrlrContentPageFile.tellg(); cntrlrContentPageFile.seekg(0, std::ios::beg); controllerContent.resize((unsigned int)fileSize); cntrlrContentPageFile.read(&controllerContent[0], fileSize); } DIR *cntrlDir = opendir(ctrlPath.c_str()); if (!cntrlDir) continue; while (dirent *ctrlEntry = readdir(cntrlDir)) { if (ctrlEntry->d_type != DT_REG) continue; std::vector<std::string> splittedFileName = utils::split_string(ctrlEntry->d_name, '.'); if (splittedFileName.size() == 2 && splittedFileName.back() == "html") { std::string page = splittedFileName[0]; std::string pageUrl = std::string("/") + controller + "/" + page; std::string viewFilePath = ctrlPath + "/" + ctrlEntry->d_name; std::ifstream viewFile(viewFilePath); if (!viewFile.is_open()) continue; viewFile.seekg(0, std::ios::end); std::streampos fileSize = viewFile.tellg(); viewFile.seekg(0, std::ios::beg); std::string viewFilePageContent; viewFilePageContent.resize((unsigned int)fileSize); viewFile.read(&viewFilePageContent[0], fileSize); std::map<std::string, std::string> pageBlocks; for (size_t blockPos = viewFilePageContent.find(WEBMVC_VIEWDATA, 0); blockPos != std::string::npos; blockPos = viewFilePageContent.find(WEBMVC_VIEWDATA, blockPos)) { blockPos += std::string(WEBMVC_VIEWDATA).length(); size_t endBlockNamePos = viewFilePageContent.find(WEBMVC_BLOCK_END, blockPos); if (blockPos == std::string::npos) break; std::string pageBlockName = viewFilePageContent.substr(blockPos, endBlockNamePos - blockPos); blockPos = endBlockNamePos + std::string(WEBMVC_BLOCK_END).length(); size_t endBlockBlockPos = viewFilePageContent.find(WEBMVC_VIEWDATA_CLOSED, blockPos); std::string pageBlockContent = viewFilePageContent.substr(blockPos, endBlockBlockPos - blockPos); pageBlocks.insert(std::pair<std::string, std::string>(pageBlockName, pageBlockContent)); blockPos = endBlockBlockPos + std::string(WEBMVC_CLOSEBLOCK_END).length(); } std::string currentPageContent = utils::multiply_replace_string(controllerContent, WEBMVC_VIEWDATA, std::string(WEBMVC_CLOSEBLOCK_END), pageBlocks); std::string pageContent; { size_t prevPos = 0; size_t curPos = 0; while ((curPos = currentPageContent.find(WEBMVC_VIEWCONTROL, curPos)) != std::string::npos) { pageContent += currentPageContent.substr(prevPos, curPos - prevPos); curPos += std::string(WEBMVC_VIEWCONTROL).length(); size_t blockEnd = currentPageContent.find(WEBMVC_CLOSEBLOCK_END, curPos); if (blockEnd == std::string::npos) break; std::string ctrlParamsStr = currentPageContent.substr(curPos, blockEnd - curPos); std::vector<std::string> ctrlParams = utils::split_string(ctrlParamsStr, ':'); if (ctrlParams.size() == 0) break; std::string ctrlName = ctrlParams[0]; ctrlParams.erase(ctrlParams.begin()); std::map<std::string, view_control>::iterator ctrlIt = controls.find(ctrlName); if (ctrlIt == controls.end() || ctrlIt->second.parameters.size() != ctrlParams.size()) break; if (ctrlIt->second.parameters.size() == 0) { pageContent += ctrlIt->second.content; } else { std::ostringstream ctrlCode; ctrlCode << "{%{" << std::endl; for (unsigned int i = 0; i < ctrlIt->second.parameters.size(); ++i) { ctrlCode << " std::string " << ctrlIt->second.parameters[i] << " = \"" << ctrlParams[i] << "\";" << std::endl; } ctrlCode << "%}" << std::endl; ctrlCode << ctrlIt->second.content << std::endl; ctrlCode << "{%" << std::endl; ctrlCode << "}%}" << std::endl; pageContent += ctrlCode.str(); } curPos = blockEnd + std::string(WEBMVC_CLOSEBLOCK_END).length(); prevPos = curPos; } size_t contentLength = currentPageContent.length(); if (prevPos != contentLength) { pageContent += currentPageContent.substr(prevPos, contentLength - prevPos); } } viewsContent << std::endl << "view_handler(" + controller + ", " + page + ", [](const http_request & request, variant_map & session, mvc_view_data & viewData) -> std::string {" << std::endl; viewsContent << " std::ostringstream pageContent;" << std::endl; pageContent = utils::multiply_replace_string(pageContent, "{$", "}", "{%= viewData[\"", "\"] %}"); size_t htmlBlockBegin = 0; for (size_t codeBlockPos = pageContent.find("{%", 0); codeBlockPos != std::string::npos; codeBlockPos = pageContent.find("{%", codeBlockPos)) { codeBlockPos += 2; // "{%" size_t endCodeBlockPos = pageContent.find("%}", codeBlockPos); if (endCodeBlockPos == std::string::npos) break; std::string codeBlock = pageContent.substr(codeBlockPos, endCodeBlockPos - codeBlockPos); codeBlockPos -= 2; // "{%" endCodeBlockPos += 2; //"%}" viewsContent << "pageContent << " + utils::to_cHexString(pageContent.substr(htmlBlockBegin, codeBlockPos - htmlBlockBegin)) + "; " << std::endl; codeBlockPos = endCodeBlockPos; htmlBlockBegin = endCodeBlockPos; //"%}" if (codeBlock.length() > 0 && codeBlock[0] == '=') viewsContent << "pageContent << " + codeBlock.substr(1) + ";" << std::endl; else viewsContent << std::endl << codeBlock << ";" << std::endl; } if (htmlBlockBegin != pageContent.length()) viewsContent << "pageContent << " + utils::to_cHexString(pageContent.substr(htmlBlockBegin)) + "; " << std::endl; viewsContent << " return pageContent.str();" << std::endl; viewsContent << "});" << std::endl; } } closedir(cntrlDir); } closedir(cntrlrsDir); viewsContent << std::endl << std::endl << "}"; viewsContent.close(); return true; }
void CMainWindow::initButtons() { connect(ui->btnView, &QPushButton::clicked, this, &CMainWindow::viewFile); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("F3"), this, SLOT(viewFile()), 0, Qt::WidgetWithChildrenShortcut))); connect(ui->btnEdit, &QPushButton::clicked, this, &CMainWindow::editFile); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("F4"), this, SLOT(editFile()), 0, Qt::WidgetWithChildrenShortcut))); connect(ui->btnCopy, &QPushButton::clicked, this, &CMainWindow::copySelectedFiles); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("F5"), this, SLOT(copySelectedFiles()), 0, Qt::WidgetWithChildrenShortcut))); connect(ui->btnMove, &QPushButton::clicked, this, &CMainWindow::moveSelectedFiles); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("F6"), this, SLOT(moveSelectedFiles()), 0, Qt::WidgetWithChildrenShortcut))); connect(ui->btnNewFolder, &QPushButton::clicked, this, &CMainWindow::createFolder); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("F7"), this, SLOT(createFolder()), 0, Qt::WidgetWithChildrenShortcut))); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("Shift+F7"), this, SLOT(createFile()), 0, Qt::WidgetWithChildrenShortcut))); connect(ui->btnDelete, &QPushButton::clicked, this, &CMainWindow::deleteFiles); connect(ui->btnDelete, &QPushButton::customContextMenuRequested, this, &CMainWindow::showRecycleBInContextMenu); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("F8"), this, SLOT(deleteFiles()), 0, Qt::WidgetWithChildrenShortcut))); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("Delete"), this, SLOT(deleteFiles()), 0, Qt::WidgetWithChildrenShortcut))); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("Shift+F8"), this, SLOT(deleteFilesIrrevocably()), 0, Qt::WidgetWithChildrenShortcut))); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("Shift+Delete"), this, SLOT(deleteFilesIrrevocably()), 0, Qt::WidgetWithChildrenShortcut))); // Command line ui->commandLine->setSelectPreviousItemShortcut(QKeySequence("Ctrl+E")); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("Ctrl+E"), this, SLOT(selectPreviousCommandInTheCommandLine()), 0, Qt::WidgetWithChildrenShortcut))); _shortcuts.push_back(std::shared_ptr<QShortcut>(new QShortcut(QKeySequence("Esc"), this, SLOT(clearCommandLineAndRestoreFocus()), 0, Qt::WidgetWithChildrenShortcut))); }
int Object::doSpecial(Player* player) { BaseRoom* room = player->getRoomParent(); Socket* sock = player->getSock(); char str[80], str2[160]; unsigned int i=0; switch(special) { case SP_MAPSC: strcpy(str, getCName()); for(i=0; i<strlen(str); i++) if(str[i] == ' ') str[i] = '_'; sprintf(str2, "%s/%s.txt", Path::Sign, str); if(flagIsSet(O_LOGIN_FILE)) viewLoginFile(player->getSock(), str2); else viewFile(player->getSock(), str2); break; case SP_COMBO: char str[80]; int dmg, i; str[0] = damage.getSides()+'0'; str[1] = 0; if(damage.getNumber() == 1 || strlen(sock->tempstr[3]) > 70) strcpy(sock->tempstr[3], str); else strcat(sock->tempstr[3], str); player->print("Click.\n"); if(player->getName() == "Bane") player->print("Combo so far: %s\n", sock->tempstr[3]); broadcast(sock, room, "%M presses %P^x.", player, this); if(strlen(sock->tempstr[3]) >= strlen(use_output)) { if(strcmp(sock->tempstr[3], use_output)) { dmg = mrand(20,40 + player->getLevel()); player->hp.decrease(dmg); player->printColor("You were zapped for %s%d^x damage!\n", player->customColorize("*CC:DAMAGE*").c_str(), dmg); broadcast(sock, room, "%M was zapped by %P^x!", player, this); sock->tempstr[3][0] = 0; if(player->hp.getCur() < 1) { player->print("You died.\n"); player->die(ZAPPED); } } else { Exit* toOpen = 0; i = 1; for(Exit* ext : room->exits) { if(i++ >= damage.getPlus()) toOpen = ext; } // for(i=1, xp = room->first_ext; // xp && i < damage.getPlus(); // i++, xp = xp->next_tag) // ; if(!toOpen) return(0); player->statistics.combo(); player->print("You opened the %s!\n", toOpen->getCName()); broadcast(player->getSock(), player->getParent(), "%M opened the %s!", player, toOpen->getCName()); toOpen->clearFlag(X_LOCKED); toOpen->clearFlag(X_CLOSED); toOpen->ltime.ltime = time(0); } } break; default: player->print("Nothing.\n"); break; } return(0); }