Пример #1
0
NS_IMETHODIMP
nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsAString &aAttribute)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    nsAutoString propStr;

    aProperty->ToString(propStr);

    PrintSelection();
    Write("atomService = Components.classes[\"@mozilla.org/atom-service;1\"].getService(Components.interfaces.nsIAtomService);\n");
    Write("propAtom = atomService.getAtom(\"");
    PrintUnicode(propStr);
    Write("\");\n");
    Write("GetCurrentEditor().removeInlineProperty(propAtom, \"");
    if (aAttribute.Length())
      PrintUnicode(aAttribute);
    Write("\");\n");

    Flush();
  }

  return nsHTMLEditor::RemoveInlineProperty(aProperty, aAttribute);
}
Пример #2
0
bool CPatchUndoTest::SelectRandomParts(CString& SelStr)
{
    CIntArrayEx	sel;
    if (!GetRandomSelection(sel))
        return(FALSE);
    m_Main->GetPartsBar().SetSelection(sel);
    if (m_MakeSnapshots)
        m_Snapshot[m_EditsDone] = GetSnapshot();	// update snapshot
    SelStr = PrintSelection(sel);
    return(TRUE);
}
Пример #3
0
NS_IMETHODIMP
nsHTMLEditorLog::Copy()
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();
    Write("GetCurrentEditor().copy();\n");
    Flush();
  }

  return nsHTMLEditor::Copy();
}
Пример #4
0
NS_IMETHODIMP
nsHTMLEditorLog::PasteAsPlaintextQuotation(int32_t aClipboardType)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();
    Write("GetCurrentEditor().pasteAsQuotation(");
    WriteInt(aClipboardType);
    Write(");\n");
    Flush();
  }

  return nsHTMLEditor::PasteAsPlaintextQuotation(aClipboardType);
}
Пример #5
0
NS_IMETHODIMP
nsHTMLEditorLog::Align(const nsAString& aAlign)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();

    Write("GetCurrentEditor().align(\"");
    PrintUnicode(aAlign);
    Write("\");\n");
    Flush();
  }

  return nsHTMLEditor::Align(aAlign);
}
Пример #6
0
NS_IMETHODIMP
nsHTMLEditorLog::SetParagraphFormat(const nsAString& aParagraphFormat)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();
    Write("GetCurrentEditor().setParagraphFormat(\"");
    PrintUnicode(aParagraphFormat);
    Write("\");\n");

    Flush();
  }

  return nsHTMLEditor::SetParagraphFormat(aParagraphFormat);
}
Пример #7
0
NS_IMETHODIMP
nsHTMLEditorLog::InsertAsQuotation(const nsAString& aQuotedText,
                                   nsIDOMNode **aNodeInserted)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();
    Write("GetCurrentEditor().insertAsQuotation(\"");
    PrintUnicode(aQuotedText);
    Write("\");\n");
    Flush();
  }

  return nsHTMLEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
}
Пример #8
0
NS_IMETHODIMP
nsHTMLEditorLog::SetDocumentTitle(const nsAString& aTitle)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();

    Write("GetCurrentEditor().setDocumentTitle(\"");
    nsAutoString str(aTitle);
    PrintUnicode(str);
    Write("\");\n");
    Flush();
  }

  return nsHTMLEditor::SetDocumentTitle(aTitle);
}
Пример #9
0
NS_IMETHODIMP
nsHTMLEditorLog::DeleteSelection(nsIEditor::EDirection aAction,
                                 nsIEditor::EStripWrappers aStripWrappers)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();
    Write("GetCurrentEditor().deleteSelection(");
    WriteInt(aAction);
    Write(");\n");

    Flush();
  }

  return nsHTMLEditor::DeleteSelection(aAction, aStripWrappers);
}
Пример #10
0
NS_IMETHODIMP
nsHTMLEditorLog::PasteAsCitedQuotation(const nsAString& aCitation,
                                       int32_t aClipboardType)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();
    Write("GetCurrentEditor().pasteAsCitedQuotation(\"");
    PrintUnicode(aCitation);
    Write("\", ");
    WriteInt(aClipboardType);
    Write(");\n");
    Flush();
  }

  return nsHTMLEditor::PasteAsCitedQuotation(aCitation, aClipboardType);
}
Пример #11
0
NS_IMETHODIMP
nsHTMLEditorLog::InsertText(const nsAString& aStringToInsert)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();

    Write("GetCurrentEditor().insertText(\"");
    nsAutoString str(aStringToInsert);
    PrintUnicode(str);
    Write("\");\n");

    Flush();
  }

  return nsHTMLEditor::InsertText(aStringToInsert);
}
Пример #12
0
NS_IMETHODIMP
nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    NS_ENSURE_TRUE(aAnchorElement, NS_ERROR_NULL_POINTER);

    nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aAnchorElement);

    NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);

    PrintSelection();
    PrintNode(node, 0);
    Write("GetCurrentEditor().insertLinkAroundSelection(n0);\n");
    Flush();
  }

  return nsHTMLEditor::InsertLinkAroundSelection(aAnchorElement);
}
Пример #13
0
NS_IMETHODIMP
nsHTMLEditorLog::MakeOrChangeList(const nsAString& aListType, bool entireList, const nsAString& aBulletType)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    PrintSelection();

    Write("GetCurrentEditor().makeOrChangeList(\"");
    PrintUnicode(aListType);
    Write("\", ");
    Write(entireList ? "true" : "false");
    Write(", \"");
    PrintUnicode(aBulletType);
    Write("\");\n");
    Flush();
  }

  return nsHTMLEditor::MakeOrChangeList(aListType, entireList, aBulletType);
}
Пример #14
0
NS_IMETHODIMP
nsHTMLEditorLog::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSelection)
{
  nsAutoHTMLEditorLogLock logLock(this);

  if (!mLocked && mFileStream)
  {
    NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);

    nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);

    NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);

    PrintSelection();
    PrintNode(node, 0);
    Write("GetCurrentEditor().insertElementAtSelection(n0, ");
    Write(aDeleteSelection ? "true" : "false");
    Write(");\n");
    Flush();
  }

  return nsHTMLEditor::InsertElementAtSelection(aElement, aDeleteSelection);
}
Пример #15
0
void DisplayTrip(const int BORDER,
				  string username,
			      Trip &trip)
{
	const int NUM_OF_OPTIONS = trip.getDestinations().size();

	//Data Structures
	ListNode<tripNode>* 	   selected[NUM_OF_OPTIONS];
	int            parentAr   [NUM_OF_OPTIONS];
	int            dist       [NUM_OF_OPTIONS];

	List<tripNode> destinations;
	avltree<User>  users;

	//Input-Output
	stringstream   ss;
	stringstream   ss2;

	//Variables
	int input;
	int option;
	int index;
	int distance;
	int totalDistance;

	string tripStr;
	string tripName;

	ifstream inFile;
	ofstream outFile;
	User     tempUser;

	tripNode tempTrip;
	tripNode lastTrip;
	tripNode source;
	ListNode<tripNode> *node;

	DWORD mode;

	//Initialize Variables
	input         = 0;
	option        = 1;
	index         = 0;
	distance      = 0;
	totalDistance = 0;

	destinations = trip.getDestinations();
	destinations.to_front();

	CenterStrings(ss, "Press Enter to Select a Trip", BORDER);
	CenterStrings(ss, "Use Up or Down Arrow Keys to Navigate list", BORDER);
	CenterStrings(ss, "Press Ctrl-S to Save and Exit \n\n", BORDER);

	if(destinations.currentNode(source)){
		destinations.to_front();
		source = trip.getSource();
		fastRoute(destinations,
				  source,
				  parentAr,
				  dist,
				  NUM_OF_OPTIONS);
	}

	//Initialize all indices of currentTrip[] to 0 (All options unselected)
	for(int pos = 0; pos < NUM_OF_OPTIONS; pos++){
		selected[pos] = NULL;
	}


	//Main Loop
	while(input != -1)
	{
		// Clear Console.
		system("CLS");

		//Reset Index
		index = 0;
		//PrintInput("MainMenu.txt");
		cout << (MenuString());
		cout << ss.str() << '\n';

		destinations.to_front();

		// Prints Selection.  Passes parameter based on
		// current value of option.
		node = destinations.currentNode();
		while(node != NULL){
			if(index == 0)
			{
				distance = 0;
			}
			else
			{
				distance = node->getData().s.getLocation().distanceTo
													(lastTrip.s.getLocation());
			}
			totalDistance += distance;
			lastTrip = node->getData();

			ss2 << node->getData().s.getStadiumName().str
				<< " | "
				<< node->getData().s.getCity()
				<< ", "
			    << node->getData().s.getState()
				<< " | "
				<< distance
				<< " miles";

			tripStr = NumberedLine(ss2.str(), 5, index + 1, BORDER);
			tripStr += '\n';

			if(selected[index] != NULL || index == option - 1)
			{
					PrintSelection(tripStr);
			}
			else
			{
				cout << tripStr;
			}
			destinations.next(tempTrip);
			node = destinations.currentNode();
			index++;
			ss2.str("");
		}
		cout << "TOTAL DISTANCE: " << totalDistance << " miles\n";
		totalDistance = 0;

		// Get user's key stroke.
		input = PressAnyKey("", mode);


		// If user makes selection (Presses Enter Key)
		tripNode newStop;
		if(input == VK_RETURN)
		{
			if(selected[option - 1] == NULL){
				selected[option - 1] = node;
			}
			else{
				selected[option - 1] = NULL;
			}

		}else if((input == 0x53 && (mode & LEFT_CTRL_PRESSED)) ||
				(input == 0x53 && (mode & RIGHT_CTRL_PRESSED)))
		{
				input = -1;
		}
		else
		{
			if(input == VK_UP){
				ChangeSelection(VK_LEFT, option, NUM_OF_OPTIONS);
			}
			else if(input == VK_DOWN){
				ChangeSelection(VK_RIGHT, option, NUM_OF_OPTIONS);
			}
		}
	}
}
Пример #16
0
void PrintPacketInfo(ubyte *packet,udword size)
{
    ubyte *curpacket;
    udword numberOfCommandsLeft;
    uword commandType;

#define hwpacket ((HWPacketHeader *)packet)

    numberOfCommandsLeft = (udword)(hwpacket)->numberOfCommands;

    if (verbose)
    {       
        print("\n%x Pkt %d F: %d S: %d #= %d (PktNum %d Rand %d Univ %f Blob %f)",
                hwpacket->type,hwpacket->frame,hwpacket->from,size,numberOfCommandsLeft,
                hwpacket->checksums.packetnum,hwpacket->checksums.randcheck,hwpacket->checksums.univcheck,hwpacket->checksums.blobcheck);       

        if (hwpacket->type != PACKETTYPE_SYNC)
            return;
    }
    else
    {
        if (hwpacket->type == PACKETTYPE_SYNC)
        {
            if (numberOfCommandsLeft == 0)
                print(".");
            else
                print("\nPkt %d: F: %d S: %d #= %d",hwpacket->frame,hwpacket->from,size,numberOfCommandsLeft);
        }
        else
        {
            print("\nUnknown Pkt Size %d:",size);
            return;
        }
    }

    curpacket = packet + sizeof(HWPacketHeader);

    while (numberOfCommandsLeft > 0)
    {
        commandType = ((HWCommandHeader *)curpacket)->commandType & 255;
        curpacket += sizeof(HWCommandHeader);

        switch (commandType)
        {
            case COMMANDTYPE_MOVE:
            {
                NetMoveCommand *movecom = (NetMoveCommand *)curpacket;
                print("\n\tMOVE: From: %f %f %f To: %f %f %f Selection: ",movecom->from.x,movecom->from.y,movecom->from.z,
                                                                         movecom->to.x,movecom->to.y,movecom->to.z);
                PrintSelection(&movecom->selection);
                curpacket += sizeofNetMoveCommand(movecom->selection.numShips);
            }
            break;

            case COMMANDTYPE_MP_HYPERSPACE:
            {
                NetMoveCommand *movecom = (NetMoveCommand *)curpacket;
                print("\n\tMOVEHP: From: %f %f %f To: %f %f %f Selection: ",movecom->from.x,movecom->from.y,movecom->from.z,
                                                                         movecom->to.x,movecom->to.y,movecom->to.z);
                PrintSelection(&movecom->selection);
                curpacket += sizeofNetMoveCommand(movecom->selection.numShips);
            }
            break;

            case COMMANDTYPE_ATTACK:
            {
                NetAttackSelection *netattackselection = (NetAttackSelection *)curpacket;
                NetSelection *netselection = (NetSelection *)(curpacket + sizeofNetAttackSelection(netattackselection->numTargets));
                print("\n\tATTACK: Selection: ");
                PrintSelection(netselection);
                print("attacks Targets: ");
                PrintTargets(netattackselection);
                curpacket += sizeofNetAttackCommand(netattackselection->numTargets,netselection->numShips);
            }
            break;

            case COMMANDTYPE_SPECIAL:
            {
                NetTargetsSelection *nettargetsselection = (NetTargetsSelection *)curpacket;
                sdword nettargetsselectionNumShips = nettargetsselection->numTargets;
                NetSelection *netselection = (NetSelection *)(curpacket + sizeofNetTargetsSelection(nettargetsselectionNumShips));
                print("\n\tSPECIAL: Selection: ");
                PrintSelection(netselection);
                if (nettargetsselectionNumShips > 0)
                {
                    print("targets: ");
                    PrintTargets(nettargetsselection);
                }
                else
                {
                    print("No Targets Present");
                }
                curpacket += sizeofNetSpecialCommand(nettargetsselectionNumShips,netselection->numShips);
            }
            break;

            case COMMANDTYPE_FORMATION:
            {
                NetFormationCommand *formationcom = (NetFormationCommand *)curpacket;
                print("\n\tFORMATION %d: Selection: ",formationcom->typeOfFormation);
                PrintSelection(&formationcom->selection);
                curpacket += sizeofNetFormationCommand(formationcom->selection.numShips);
            }
            break;

            case COMMANDTYPE_DOCK:
            {
                NetDockCommand *dockcom = (NetDockCommand *)curpacket;
                print("\n\tDOCK Type:%d Dockwith: %d",dockcom->dockType,dockcom->dockwithID);
                print("Selection: ");
                PrintSelection(&dockcom->selection);
                curpacket += sizeofNetDockCommand(dockcom->selection.numShips);
            }
            break;

            case COMMANDTYPE_LAUNCHMULTIPLE:
            {
                NetLaunchMultipleCommand *launchcom = (NetLaunchMultipleCommand *)curpacket;
                print("\n\tLAUNCH: From: %d Selection: ",launchcom->launchfromID.shipNumber);
                PrintSelection(&launchcom->selection);
                curpacket += sizeofNetLaunchMultipleCommand(launchcom->selection.numShips);
            }
            break;

            case COMMANDTYPE_MISC:
            {
                NetMiscCommand *misccom = (NetMiscCommand *)curpacket;
                switch (misccom->miscCommand)
                {
                    case MISCCOMMAND_HALT:
                        print("\n\tHALT: ");
                        break;

                    case MISCCOMMAND_SCUTTLE:
                        print("\n\tSCUTTLE: ");
                        break;

                    case MISCCOMMAND_TACTICS:
                        print("\n\tTACTICS: %d ",misccom->miscData);
                        break;

                    case MISCCOMMAND_KAMIKAZE:
                        print("\n\tKAMIKAZE: ");
                        break;

                    case MISCCOMMAND_PARADE:
                        print("\n\tMILITARY PARADE");
                        break;

                    default:
                        print("\n\tUNKNOWN MISC COMMAND %d: ",misccom->miscCommand);
                        break;
                }
                print("Selection: ");
                PrintSelection(&misccom->selection);
                curpacket += sizeofNetMiscCommand(misccom->selection.numShips);
            }
            break;

            case COMMANDTYPE_AUTOLAUNCH:
            {
                NetAutolaunchCommand *launchcom = (NetAutolaunchCommand *)curpacket;
                print("\n\tAUTOLAUNCH: Player %d turns on %d",launchcom->playerIndex,launchcom->OnOff);
                curpacket += sizeofNetAutolaunchCommand;
            }
            break;

            case COMMANDTYPE_ALLIANCEINFO:
            {
                NetAllianceCommand *alliancecom = (NetAllianceCommand *)curpacket;
                print("\n\tALLIANCE: Msg: %d Cur: %d New: %d",alliancecom->AllianceMsgType, alliancecom->CurAlliance, alliancecom->NewAlliance);
                curpacket += sizeofNetAllianceCommand;
            }
            break;

            case COMMANDTYPE_CREATESHIP:
            {
                NetCreateShipCommand *createcom = (NetCreateShipCommand *)curpacket;
                print("\n\tCREATESHIP: %d %d of Player %d Built by Ship: %d",createcom->shipType,createcom->shipRace,createcom->playerIndex,createcom->creatorID.shipNumber);
                curpacket += sizeofNetCreateShipCommand;
            }
            break;

            case COMMANDTYPE_BUILDSHIP:
            {
                NetCreateShipCommand *createcom = (NetCreateShipCommand *)curpacket;
                print("\n\tBUILDSHIP: %d %d of Player %d Built by Ship: %d",createcom->shipType,createcom->shipRace,createcom->playerIndex,createcom->creatorID.shipNumber);
                curpacket += sizeofNetCreateShipCommand;
            }
            break;

            case COMMANDTYPE_COLLECTRESOURCE:
            {
                NetCollectResourceCommand *collectcom = (NetCollectResourceCommand *)curpacket;
                print("\n\tHARVEST: Selection: ");
                PrintSelection(&collectcom->selection);
                print("Resouce: %d",collectcom->resourceID.resourceNumber);
                curpacket += sizeofNetCollectResourceCommand(collectcom->selection.numShips);
            }
            break;

            case COMMANDTYPE_PROTECT:
            {
                NetProtectSelection *netprotectselection = (NetProtectSelection *)curpacket;
                NetSelection *netselection = (NetSelection *)(curpacket + sizeofNetProtectSelection(netprotectselection->numShips));
                print("\n\tGUARD: Selection: ");
                PrintSelection(netselection);
                print("Protecting: ",netprotectselection);
                curpacket += sizeofNetProtectCommand(netprotectselection->numShips,netselection->numShips);
            }
            break;

            case COMMANDTYPE_RUTRANSFER:
            {
                NetRUTransferferCommand *rucommand = (NetRUTransferferCommand *)curpacket;
                print("\n\tRUTransfer: from %d to %d RU %d Flags %d",rucommand->from,rucommand->to,rucommand->resourceUnits,rucommand->flags);
                curpacket+=sizeof(NetRUTransferferCommand);
            }
            break;

            case COMMANDTYPE_GODSYNC:
            {
                print("\n\tSYNCCHECK");
                curpacket += sizeof(GodSyncCommand);
            }
            break;

            case COMMANDTYPE_DETERMINISTICBUILD:
            {
                NetDeterministicBuildCommand* buildcom = (NetDeterministicBuildCommand*)curpacket;
                print("\n\tDBUILD: %d #:%d (%d %d) Player %d by Ship %d",buildcom->subCommand,buildcom->numShips,
                      buildcom->shipType,buildcom->shipRace,buildcom->playerIndex,buildcom->creatorID.shipNumber);
                curpacket += sizeofNetDeterministicBuildCommand;
            }
            break;

            case COMMANDTYPE_RESEARCHINFO:
            {
                NetResearchCommand *researchcommand = (NetResearchCommand *)curpacket;
                print("\n\tRESEARCH: %d %d %d %d",(udword)researchcommand->ResearchMsgType, (udword)researchcommand->playerindex,
                      (udword)researchcommand->labnum, (udword)researchcommand->tech);
                curpacket+=sizeofNetResearchCommand;
            }
            break;

            default:
                print("\n\tUNKNOWN COMMAND %d",commandType);
                return;
        }

        numberOfCommandsLeft--;
    }
}