// private void kpAbstractSelectionTool::endDrawMove () { d->RMBMoveUpdateGUITimer->stop (); // NOP drag? if (!d->currentMoveCommand) return; d->currentMoveCommand->finalize (); kpMacroCommand *renamedCmd = 0; #if DEBUG_KP_TOOL_SELECTION qCDebug(kpLogTools) << "\thave moveCommand"; #endif if (d->currentMoveCommandIsSmear) { renamedCmd = new kpMacroCommand (i18n ("%1: Smear", document ()->selection ()->name ()), environ ()->commandEnvironment ()); } else { renamedCmd = new kpMacroCommand ( /*virtual*/nonSmearMoveCommandName (), environ ()->commandEnvironment ()); } renamedCmd->addCommand (d->currentMoveCommand); d->currentMoveCommand = 0; addNeedingContentCommand (renamedCmd); }
// protected void kpAbstractImageSelectionTool::changeImageSelectionTransparency ( const QString &name, const kpImageSelectionTransparency &newTrans, const kpImageSelectionTransparency &oldTrans) { #if DEBUG_KP_TOOL_SELECTION qCDebug(kpLogTools) << "CALL(" << name << ")"; #endif kpSetOverrideCursorSaver cursorSaver (Qt::WaitCursor); if (hasBegunShape ()) endShapeInternal (); kpAbstractImageSelection *imageSel = document ()->imageSelection (); if (imageSel->hasContent () && newTrans.isTransparent ()) environ ()->flashColorSimilarityToolBarItem (); imageSel->setTransparency (newTrans); // We _must_ add the command even if kpAbstractImageSelection::setTransparency() // above did not change the selection transparency mask at all. // Consider the following case: // // 0. Ensure that selection transparency is opaque and any // color other than red is the background color. Ensure that // the color similarity setting is 0. // // 1. Select a solid red rectangle and pull it off. // // 2. Switch to transparent and set red as the background color. // [the selection is now invisible as red is the background // color, which is the same as the contents of the selection] // // 3. Invert Colors. // [the selection is now cyan, red is still the background color] // // 4. Change the background color to green. // [the selection transparency mask does not change so the // selection is still cyan; green is the background color] // // 5. Undo // // If no transparency command were added for Step 4., the Undo // in Step 5. would take us straight to the state after Step 2., // where we would expect the red selection to be invisible. However, // as the background color was changed to green in Step 4. and was not // undone, the red selection is not invisible when it should be -- Undo // has moved us to an incorrect state. // // KDE3: Copy this comment into the KDE 3 branch. commandHistory ()->addCommand (new kpToolImageSelectionTransparencyCommand ( name, newTrans, oldTrans, environ ()->commandEnvironment ()), false/*no exec*/); }
// public slot void kpToolText::slotFontFamilyChanged (const QString &fontFamily, const QString &oldFontFamily) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::slotFontFamilyChanged() new=" << fontFamily << " old=" << oldFontFamily << endl; #else (void) fontFamily; #endif if (!shouldChangeTextStyle ()) return; kpTextStyle newTextStyle = environ ()->textStyle (); // Figure out old text style. kpTextStyle oldTextStyle = newTextStyle; oldTextStyle.setFontFamily (oldFontFamily); changeTextStyle (i18n ("Text: Font"), newTextStyle, oldTextStyle); }
// public slot void kpToolText::slotFontSizeChanged (int fontSize, int oldFontSize) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::slotFontSizeChanged() new=" << fontSize << " old=" << oldFontSize << endl; #else (void) fontSize; #endif if (!shouldChangeTextStyle ()) return; kpTextStyle newTextStyle = environ ()->textStyle (); // Figure out old text style. kpTextStyle oldTextStyle = newTextStyle; oldTextStyle.setFontSize (oldFontSize); changeTextStyle (i18n ("Text: Font Size"), newTextStyle, oldTextStyle); }
// protected bool kpAbstractImageSelectionTool::shouldChangeImageSelectionTransparency () const { if (environ ()->settingImageSelectionTransparency ()) { #if DEBUG_KP_TOOL_SELECTION qCDebug(kpLogTools) << "\trecursion - abort setting selection transparency: " << environ ()->settingImageSelectionTransparency () << endl; #endif return false; } if (!document ()->imageSelection ()) return false; // TODO: Can probably return false if the selection transparency mode // is Opaque, since neither background color nor color similarity // would matter. return true; }
// protected bool kpToolText::shouldChangeTextStyle () const { if (environ ()->settingTextStyle ()) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "\trecursion - abort setting text style: " << environ ()->settingTextStyle () << endl; #endif return false; } if (!document ()->textSelection ()) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "\tno text selection - abort setting text style"; #endif return false; } return true; }
// protected slot virtual [base kpAbstractSelectionTool] void kpToolText::slotBackgroundColorChanged (const kpColor & /*color*/) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::slotBackgroundColorChanged()"; #endif if (!shouldChangeTextStyle ()) return; kpTextStyle newTextStyle = environ ()->textStyle (); kpTextStyle oldTextStyle = newTextStyle; oldTextStyle.setBackgroundColor (oldBackgroundColor ()); changeTextStyle (i18n ("Text: Background Color"), newTextStyle, oldTextStyle); }
// protected void kpToolText::changeTextStyle (const QString &name, const kpTextStyle &newTextStyle, const kpTextStyle &oldTextStyle) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::changeTextStyle(" << name << ")"; #endif if (hasBegunShape ()) endShape (currentPoint (), normalizedRect ()); commandHistory ()->addCommand ( new kpToolTextChangeStyleCommand ( name, newTextStyle, oldTextStyle, environ ()->commandEnvironment ())); }
// protected slot virtual [base kpTool] void kpAbstractImageSelectionTool::slotColorSimilarityChanged (double, int) { #if DEBUG_KP_TOOL_SELECTION qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotColorSimilarityChanged()"; #endif if (!shouldChangeImageSelectionTransparency ()) return; kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); kpImageSelectionTransparency oldST = st; oldST.setColorSimilarity (oldColorSimilarity ()); changeImageSelectionTransparency ( i18n ("Selection: Transparency Color Similarity"), st, oldST); }
// protected slot virtual [base kpTool] void kpAbstractImageSelectionTool::slotBackgroundColorChanged (const kpColor &) { #if DEBUG_KP_TOOL_SELECTION qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotBackgroundColorChanged()"; #endif if (!shouldChangeImageSelectionTransparency ()) return; kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); kpImageSelectionTransparency oldST = st; oldST.setTransparentColor (oldBackgroundColor ()); changeImageSelectionTransparency ( i18n ("Selection: Transparency Color"), st, oldST); }
// public slot void kpToolText::slotStrikeThruChanged (bool isStrikeThru) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::slotStrikeThruChanged(" << isStrikeThru << ")"; #endif if (!shouldChangeTextStyle ()) return; kpTextStyle newTextStyle = environ ()->textStyle (); // Figure out old text style. kpTextStyle oldTextStyle = newTextStyle; oldTextStyle.setStrikeThru (!isStrikeThru); changeTextStyle (i18n ("Text: Strike Through"), newTextStyle, oldTextStyle); }
// public slot void kpToolText::slotUnderlineChanged (bool isUnderline) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::slotUnderlineChanged(" << isUnderline << ")"; #endif if (!shouldChangeTextStyle ()) return; kpTextStyle newTextStyle = environ ()->textStyle (); // Figure out old text style. kpTextStyle oldTextStyle = newTextStyle; oldTextStyle.setUnderline (!isUnderline); changeTextStyle (i18n ("Text: Underline"), newTextStyle, oldTextStyle); }
// protected slot virtual [base kpAbstractSelectionTool] void kpToolText::slotIsOpaqueChanged (bool isOpaque) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::slotIsOpaqueChanged()"; #endif if (!shouldChangeTextStyle ()) return; kpTextStyle newTextStyle = environ ()->textStyle (); kpTextStyle oldTextStyle = newTextStyle; oldTextStyle.setBackgroundOpaque (!isOpaque); changeTextStyle (newTextStyle.isBackgroundOpaque () ? i18n ("Text: Opaque Background") : i18n ("Text: Transparent Background"), newTextStyle, oldTextStyle); }
// protected slot virtual [kpAbstractSelectionTool] void kpAbstractImageSelectionTool::slotIsOpaqueChanged (bool /*isOpaque*/) { #if DEBUG_KP_TOOL_SELECTION qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotIsOpaqueChanged()"; #endif if (!shouldChangeImageSelectionTransparency ()) return; kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); kpImageSelectionTransparency oldST = st; oldST.setOpaque (!oldST.isOpaque ()); changeImageSelectionTransparency ( st.isOpaque () ? i18n ("Selection: Opaque") : i18n ("Selection: Transparent"), st, oldST); }
// protected slot virtual [base kpTool] void kpToolText::slotColorsSwapped (const kpColor &newForegroundColor, const kpColor &newBackgroundColor) { #if DEBUG_KP_TOOL_TEXT qCDebug(kpLogTools) << "kpToolText::slotColorsSwapped()"; #endif if (!shouldChangeTextStyle ()) return; kpTextStyle newTextStyle = environ ()->textStyle (); kpTextStyle oldTextStyle = newTextStyle; oldTextStyle.setForegroundColor (newBackgroundColor); oldTextStyle.setBackgroundColor (newForegroundColor); changeTextStyle (i18n ("Text: Swap Colors"), newTextStyle, oldTextStyle); }
// public virtual [base kpCommand] void kpTransformAutoCropCommand::execute () { if (!d->contentsRect.isValid ()) d->contentsRect = contentsRect (); getUndoImages (); kpDocument *doc = document (); Q_ASSERT (doc); kpImage imageWithoutBorder = kpTool::neededPixmap (doc->image (d->actOnSelection), d->contentsRect); if (!d->actOnSelection) doc->setImage (imageWithoutBorder); else { d->oldSelectionPtr = doc->imageSelection ()->clone (); d->oldSelectionPtr->setBaseImage (kpImage ()); // d->contentsRect is relative to the top of the sel // while sel is relative to the top of the doc QRect rect = d->contentsRect; rect.translate (d->oldSelectionPtr->x (), d->oldSelectionPtr->y ()); kpRectangularImageSelection sel ( rect, imageWithoutBorder, d->oldSelectionPtr->transparency ()); doc->setSelection (sel); environ ()->somethingBelowTheCursorChanged (); } }
// private void kpAbstractSelectionTool::drawMove (const QPoint &thisPoint, const QRect &/*normalizedRect*/) { #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\tmoving selection"; #endif kpAbstractSelection *sel = document ()->selection (); QRect targetSelRect (thisPoint.x () - d->startMoveDragFromSelectionTopLeft.x (), thisPoint.y () - d->startMoveDragFromSelectionTopLeft.y (), sel->width (), sel->height ()); #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\t\tstartPoint=" << startPoint () << " thisPoint=" << thisPoint << " startDragFromSel=" << d->startMoveDragFromSelectionTopLeft << " targetSelRect=" << targetSelRect << endl; #endif // Try to make sure selection still intersects document so that it's // reachable. if (targetSelRect.right () < 0) targetSelRect.translate (-targetSelRect.right (), 0); else if (targetSelRect.left () >= document ()->width ()) targetSelRect.translate (document ()->width () - targetSelRect.left () - 1, 0); if (targetSelRect.bottom () < 0) targetSelRect.translate (0, -targetSelRect.bottom ()); else if (targetSelRect.top () >= document ()->height ()) targetSelRect.translate (0, document ()->height () - targetSelRect.top () - 1); #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\t\t\tafter ensure sel rect clickable=" << targetSelRect; #endif if (!d->dragAccepted && targetSelRect.topLeft () + d->startMoveDragFromSelectionTopLeft == startPoint ()) { #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogTools) << "\t\t\t\tnop"; #endif if (!d->RMBMoveUpdateGUITimer->isActive ()) { // (slotRMBMoveUpdateGUI() calls similar line) setUserShapePoints (sel->topLeft ()); } // Prevent both NOP drag-moves return; } if (d->RMBMoveUpdateGUITimer->isActive ()) { d->RMBMoveUpdateGUITimer->stop (); slotRMBMoveUpdateGUI (); } giveContentIfNeeded (); if (!d->currentMoveCommand) { d->currentMoveCommand = new kpToolSelectionMoveCommand ( QString()/*uninteresting child of macro cmd*/, environ ()->commandEnvironment ()); d->currentMoveCommandIsSmear = false; } //viewManager ()->setQueueUpdates (); //viewManager ()->setFastUpdates (); if (shiftPressed ()) d->currentMoveCommandIsSmear = true; if (!d->dragAccepted && (controlPressed () || shiftPressed ())) d->currentMoveCommand->copyOntoDocument (); d->currentMoveCommand->moveTo (targetSelRect.topLeft ()); if (shiftPressed ()) d->currentMoveCommand->copyOntoDocument (); //viewManager ()->restoreFastUpdates (); //viewManager ()->restoreQueueUpdates (); // REFACTOR: yuck, yuck kpAbstractSelection *orgSel = d->currentMoveCommand->originalSelectionClone (); QPoint start = orgSel->topLeft (); delete orgSel; QPoint end = targetSelRect.topLeft (); setUserShapePoints (start, end, false/*don't set size*/); setUserShapeSize (end.x () - start.x (), end.y () - start.y ()); d->dragAccepted = true; }
int main(int argc, char *argv[], char *env[]) { // Input buffer and and commands char buffer[BUFFER_LEN] = { 0 }; char command[BUFFER_LEN] = { 0 }; char arg[BUFFER_LEN] = { 0 }; char delim[BUFFER_LEN]; char* token = NULL; char* SHELL = NULL; setenv("SHELL", get_executable(SHELL), 1); free(SHELL); // Parse the commands provided using argc and argv FILE *in_stream = NULL; if(argc > 1){ in_stream = fopen(argv[1], "r"); if(in_stream == NULL){ printf("Could not open file %s", argv[1]); return EXIT_FAILURE; } } else { in_stream = stdin; printf("%s> ", get_cwd()); } // Perform an infinite loop getting command input from users while (fgets(buffer, BUFFER_LEN, in_stream) != NULL) { strcpy(arg, ""); // reset arg strcpy(command, ""); // reset command // Perform string tokenization to get // the command and argument strcpy(delim, " "); token = strtok(buffer, delim); // get first word // remove newline character if at end of string if (token[strlen(token)-1] == '\n') token[strlen(token)-1] = '\0'; strcpy(command, token); // copy token to command // loop to get second word in buffer while(token != NULL) { strcpy(delim, "\n"); token = strtok(NULL, delim); if (token == NULL) break; strcpy(arg, token); // store second word in arg } // Check command and execute operations for each command // cd command -- change the current directory if (strcmp(command, "cd") == 0) { if (strcmp(arg, " ") == 0 || strcmp(arg, "") == 0) printf("Error: cd: argument required\n"); cd(arg); } else if (strcmp(command, "clr") == 0) { clr(); } else if (strcmp(command, "dir") == 0) { dir(arg); } else if (strcmp(command, "environ") == 0) { environ(env); } else if (strcmp(command, "echo") == 0) { echo(arg); } else if (strcmp(command, "help") == 0) { help(); } else if (strcmp(command, "pause") == 0) { pauses(); } else if (strcmp(command, "") == 0) { } // quit command -- exit the shell else if (strcmp(command, "quit") == 0) { free(token), fclose(in_stream); return EXIT_SUCCESS; } // Unsupported command else { fputs("Unsupported command, use help to display the manual\n", stderr); } if(argc == 1) printf("%s> ", get_cwd()); } free(token), fclose(in_stream); // free the token pointer return EXIT_SUCCESS; }
// public virtual [base kpCommand] void kpTransformAutoCropCommand::unexecute () { #if DEBUG_KP_TOOL_AUTO_CROP && 1 qCDebug(kpLogImagelib) << "kpTransformAutoCropCommand::unexecute()"; #endif kpDocument *doc = document (); Q_ASSERT (doc); kpImage image (d->oldWidth, d->oldHeight, QImage::Format_ARGB32_Premultiplied); // restore the position of the center image kpPixmapFX::setPixmapAt (&image, d->contentsRect, doc->image (d->actOnSelection)); // draw the borders const kpTransformAutoCropBorder *borders [] = { &d->leftBorder, &d->rightBorder, &d->topBorder, &d->botBorder, 0 }; const kpImage *images [] = { d->leftImage, d->rightImage, d->topImage, d->botImage, 0 }; const kpImage **p = images; for (const kpTransformAutoCropBorder **b = borders; *b; b++, p++) { if (!(*b)->exists ()) continue; if ((*b)->isSingleColor ()) { kpColor col = (*b)->referenceColor (); #if DEBUG_KP_TOOL_AUTO_CROP && 1 qCDebug(kpLogImagelib) << "\tdrawing border " << (*b)->rect () << " rgb=" << (int *) col.toQRgb () /* %X hack */ << endl; #endif const QRect r = (*b)->rect (); kpPainter::fillRect (&image, r.x (), r.y (), r.width (), r.height (), col); } else { #if DEBUG_KP_TOOL_AUTO_CROP && 1 qCDebug(kpLogImagelib) << "\trestoring border image " << (*b)->rect (); #endif if (*p) { // REFACTOR: Add equivalent method to kpPainter and use. kpPixmapFX::setPixmapAt (&image, (*b)->rect (), **p); } } } if (!d->actOnSelection) doc->setImage (image); else { d->oldSelectionPtr->setBaseImage (image); doc->setSelection (*d->oldSelectionPtr); delete d->oldSelectionPtr; d->oldSelectionPtr = 0; environ ()->somethingBelowTheCursorChanged (); } deleteUndoImages (); }
QVariant TestItem::data(int role) const { switch(role) { case DurationRole: return duration(); case ChecksumRole: return checksum(); case DependsRole: return depends(); case TestNameRole: return testname(); case RequiresRole: return requires(); case DescriptionRole: return description(); case CommandRole: return command(); case EnvironRole: return environ(); case PluginRole: return plugin(); case TypeRole: return type(); case UserRole: return user(); case ViaRole: return via(); case GroupRole: return group(); case CheckRole: return check(); case ObjectPathRole: return objectpath(); case RunstatusRole: return runstatus(); case ElapsedtimeRole: return elapsedtime(); case GroupstatusRole: return groupstatus(); case ParentNameRole: break; case ParentIdRole: break; case DepthRole: return depth(); case BranchRole: return branch(); case RerunRole: return rerun(); default: return QVariant(); } // Prevents non-void return warning from the compiler return QVariant(); }
void applyToSource(Source &source, bool defines, bool incPaths) { std::lock_guard<std::mutex> lock(sMutex); Path cpath = source.compiler(); Compiler &compiler = sCompilers[cpath]; if (!compiler.inited) { compiler.inited = true; List<String> overrides; List<String> out, err; List<String> args; List<String> environ({"RTAGS_DISABLED=1"}); args << "-x" << "c++" << "-v" << "-E" << "-dM" << "-"; for (int i=0; i<4; /* see below */) { Process proc; proc.exec(cpath, args, environ); assert(proc.isFinished()); if (!proc.returnCode()) { out << proc.readAllStdOut().split('\n'); err << proc.readAllStdErr().split('\n'); // proc success. What's next? switch (i) { case 0: // C++ ok .. see which path is controlled by -nostdinc++ args.prepend("-nostdinc++"); err << "@@@@\n"; // magic separator i = 2; break; case 1: // "-x c++" not ok. Goto -nobuiltininc. err << "@@@@\n"; // magic separator args.prepend("-nobuiltininc"); i = 3; break; case 2: args.removeFirst(); // clear -nostdinc++ err << "@@@@\n"; // magic separator args.prepend("-nobuiltininc"); i = 3; break; default: err << "@@@@\n"; // magic separator i = 4; break; } } else if (i == 0) { // Strip -x c++ and try again args.removeFirst(); args.removeFirst(); i = 1; } else if (i == 3) { // GCC does not support -nobuiltininc flag. // Remove and retry args.removeFirst(); } else { error() << "CompilerManager: Cannot extract standard include paths.\n"; return; } } for (int i=0; i<out.size(); ++i) { const String &line = out.at(i); // error() << c << line; if (line.startsWith("#define ")) { Source::Define def; const int space = line.indexOf(' ', 8); if (space == -1) { def.define = line.mid(8); } else { def.define = line.mid(8, space - 8); def.value = line.mid(space + 1); } compiler.defines.insert(def); } } enum { eNormal, eNoStdInc, eNoBuiltin } mode = eNormal; List<Source::Include> copy; for (int i=0; i<err.size(); ++i) { const String &line = err.at(i); if (line.startsWith("@@@@")) // magic separator { if (mode == eNoStdInc) { // What's left in copy are the std c++ paths compiler.stdincxxPaths = copy; mode = eNoBuiltin; } else if (mode == eNoBuiltin) { // What's left in copy are the builtin paths compiler.builtinPaths = copy; // Set the includePaths exclusive of stdinc/builtin for (auto inc : compiler.stdincxxPaths) compiler.includePaths.remove(inc); for (auto inc : compiler.builtinPaths) compiler.includePaths.remove(inc); break; // we're done } else { mode = eNoStdInc; } copy = compiler.includePaths; } int j = 0; while (j < line.size() && isspace(line.at(j))) ++j; int end = line.lastIndexOf(" (framework directory)"); Source::Include::Type type = Source::Include::Type::Type_System; if (end != -1) { end = end - j; type = Source::Include::Type_SystemFramework; } Path path = line.mid(j, end); // error() << "looking at" << line << path << path.isDir(); if (path.isDir()) { path.resolve(); if (mode == eNormal) { compiler.includePaths.append(Source::Include(type, path)); } else { copy.remove(Source::Include(type, path)); } } } debug() << "[CompilerManager]" << cpath << "got includepaths\n" << compiler.includePaths; debug() << "StdInc++: " << compiler.stdincxxPaths << "\nBuiltin: " << compiler.builtinPaths; debug() << "[CompilerManager] returning.\n"; } if (defines) source.defines << compiler.defines; if (incPaths) { if (!source.arguments.contains("-nostdinc")) { source.includePaths << compiler.includePaths; if (!source.arguments.contains("-nostdinc++")) source.includePaths << compiler.stdincxxPaths; if (!source.arguments.contains("-nobuiltininc")) source.includePaths << compiler.builtinPaths; } else if (!strncmp("clang", cpath.fileName(), 5)) { // Module.map causes errors when -nostdinc is used, as it // can't find some mappings to compiler provided headers source.arguments.append("-fno-modules"); } } }
int main(int argc, char *argv[]) { // Input buffer and and commands char buffer[BUFFER_LEN] = { 0 }; char command[BUFFER_LEN] = { 0 }; char arg[BUFFER_LEN] = { 0 }; char fileN [256] = {0}; bool enterManual = true; // variable used to check pass bool check =false; // current working directory char cwd[PATH_MAX + 1]; // Get the argurment for the file. tokenize(argv[1]); // Checking through the files for the bat file check = foldercheck(tokens[0]); // copies the file into a tmp variable before we clear tokens strcpy(fileN, tokens[0]); clearTokens(); // If the file was found if(check) { // Load the file FILE *f; f=fopen(fileN, "r"); //sets it so you do not go into manual entry afterwords enterManual = false; if (getcwd(cwd, PATH_MAX + 1) != NULL) { printf("%s$ ", cwd); } // Enters a loop to get the inputs from the file while(fgets(buffer, BUFFER_LEN,f) != NULL) { // tokenizes the buffer tokenize(buffer); strcpy(command, tokens[0]); //Checks for commands if(strcmp(command, "dir") ==0) { directory(); } else if (strcmp(command, "cd") == 0) { changedir(tokens[1]); } else if(strcmp(command, "clr") ==0) { clear(); } else if(strcmp(command, "echo") == 0) { echo(tokens,i); } else if(strcmp(command, "pause") == 0) { pausing(); } else if(strcmp(command, "environ")==0) { environ(); } else if(strcmp(command, "help") ==0) { help(tokens[1]); } // quit command -- exit the shell else if (strcmp(command, "quit") == 0) { return EXIT_SUCCESS; } // If it is not a valid command checks if they are trying to start a program else { // Check if there is a file in the program check = false; check = foldercheck(command); // if program name is found if(check) { // create first part of program string char begin[250] = {"./"}; strcat (begin,tokens[0]); int count = 0; check = true; // Loops 7 times to get the max of seven parameter for(int i = 1; i < 7; i++) { // makes it so no blanks go into the checks if(strcmp(tokens[i]," ") != 0) { // checks for write symbol if(strcmp(tokens[i], ">") == 0) { // gets next token and sets it to write i++; freopen(tokens[i],"w",stdout); } // cbecks for append symbol else if (strcmp(tokens[i], ">>") == 0) { // gets next token and sets it to append i++; freopen(tokens[i],"a",stdout); } // checks for read input else if (strcmp(tokens[i], "<") == 0) { // gets next input for file name and checks if it is a file i++; if(foldercheck(tokens[i])) { // reads from file freopen(tokens[i],"r",stdin); }else { // not found sets it to terminal and writes i = 7; freopen("/dev/tty", "w", stdout); printf("Invalid file read entry \n"); check = false; } } // checks if two args have already pass else if(count < 2) { // appends the argument to the program call count++; char append [256] = {" "}; strcat (append,tokens[i]); strcat (begin, append); } // Invalid call has been passed else { freopen("/dev/tty", "w", stdout); printf("Invalid file program entry type \n"); check = false; i = 7; } } } // Runs if valid program call has been called if(check) { system(begin); } freopen("/dev/tty", "w", stdout); freopen("/dev/tty", "r", stdin); }// Command does not exist else { printf("Unsupported command, use help to display the manual. Please enter Manualy. %s \n", command); clearTokens(); enterManual = true; break; } } clearTokens(); // Fetches cwd and prints it out before input if (getcwd(cwd, PATH_MAX + 1) != NULL) { printf("%s$ ", cwd); } } } // Checks if the user has to enter manually for the shell if(enterManual) { if (getcwd(cwd, PATH_MAX + 1) != NULL) { printf("%s$ ", cwd); } while (fgets(buffer, BUFFER_LEN, stdin) != NULL) { // tokenizes the buffer tokenize(buffer); strcpy(command, tokens[0]); //Checks for commands if(strcmp(command, "dir") ==0) { directory(); } else if (strcmp(command, "cd") == 0) { changedir(tokens[1]); } else if(strcmp(command, "clr") ==0) { clear(); } else if(strcmp(command, "echo") == 0) { echo(tokens,i); } else if(strcmp(command, "pause") == 0) { pausing(); } else if(strcmp(command, "environ")==0) { environ(); } else if(strcmp(command, "help") ==0) { help(tokens[1]); } // quit command -- exit the shell else if (strcmp(command, "quit") == 0) { return EXIT_SUCCESS; } // If it is not a valid command checks if they are trying to start a program else { // Check if there is a file in the program check = false; check = foldercheck(command); // if the program is found if(check) { // create first part of program string char begin[250] = {"./"}; strcat (begin,tokens[0]); int count = 0; check = true; // Loops 7 times to get the max of seven parameter for(int i = 1; i < 7; i++) { // makes it so no blanks go into the checks if(strcmp(tokens[i]," ") != 0) { // checks for write symbol if(strcmp(tokens[i], ">") == 0) { // gets next token and sets it to write i++; freopen(tokens[i],"w",stdout); } // cbecks for append symbol else if (strcmp(tokens[i], ">>") == 0) { // gets next token and sets it to append i++; freopen(tokens[i],"a",stdout); } // checks for read input else if (strcmp(tokens[i], "<") == 0) { // gets next input for file name and checks if it is a file i++; if(foldercheck(tokens[i])) { // reads from file freopen(tokens[i],"r",stdin); }else { // not found sets it to terminal and writes i = 7; freopen("/dev/tty", "w", stdout); printf("Invalid file read entry \n"); check = false; } } // checks if two args have already pass else if(count < 2) { // appends the argument to the program call count++; char append [256] = {" "}; strcat (append,tokens[i]); strcat (begin, append); } // Invalid call has been passed else { freopen("/dev/tty", "w", stdout); printf("Invalid file program entry type \n"); check = false; i = 7; } } } // Runs if valid program call has been called if(check) { system(begin); } freopen("/dev/tty", "w", stdout); freopen("/dev/tty", "r", stdin); } else { printf("Unsupported command, use help to display the manual.%s \n", command); } } clearTokens(); // Fetches cwd and prints it out before input if (getcwd(cwd, PATH_MAX + 1) != NULL) { printf("%s$ ", cwd); } } } return EXIT_SUCCESS; }
// public virtual [base kpCommand] void kpToolTextGiveContentCommand::execute () { #if DEBUG_KP_TOOL_SELECTION && 1 qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::execute()"; #endif kpDocument *doc = document (); Q_ASSERT (doc); kpViewManager *vm = viewManager (); Q_ASSERT (vm); // See API Doc for kpViewManager::textCursorRow() & textCursorCol(). Q_ASSERT (vm->textCursorRow () == 0 && vm->textCursorCol () == 0); vm->setQueueUpdates (); { // // Recreate border // // The previously executed command is required to have been a // kpToolSelectionCreateCommand, which must have been given a text // selection with no content. // // However, there is a tricky case. Suppose we are called for the first // time, where the above precondition holds. We would add content // to the selection as expected. But the user then undoes (CTRL+Z) the // operation, calling unexecute(). There is now no content again. // Since selection is only a border, the user can freely deselect it // and/or select another region without changing the command history // or document modified state. Therefore, if they now call us again // by redoing (CTRL+Shift+Z), there is potentially no selection at all // or it is at an arbitrary location. // // This assertion covers all 3 possibilities: // // 1. First call: text selection with no content // 2. Later calls: // a) no text selection (due to deselection) // b) text selection with no content, at an arbitrary location Q_ASSERT (!textSelection () || !textSelection ()->hasContent ()); const kpTextSelection *originalTextSel = static_cast <const kpTextSelection *> (originalSelection ()); if (originalTextSel->textStyle () != environ ()->textStyle ()) environ ()->setTextStyle (originalTextSel->textStyle ()); doc->setSelection (*originalSelection ()); // // Add Content // QList <QString> listOfOneEmptyString; listOfOneEmptyString.append (QString ()); textSelection ()->setTextLines (listOfOneEmptyString); } vm->restoreQueueUpdates (); // This should not have changed from the start of the method. Q_ASSERT (vm->textCursorRow () == 0 && vm->textCursorCol () == 0); }