Example #1
0
InsertionNode MGADSMTrajectory::GetInsertion(int n) const
{
   int nodeIndex = GetInsertionIndex(n);
   OTL_ASSERT(nodeIndex >= 0, "Can't get Flyby node. Node not found.");

   auto insNode = dynamic_cast<InsertionNode*>(m_nodes[nodeIndex].get());
   OTL_ASSERT(insNode, "Failed to convert node to Insertion node.");
   return *insNode;  
}
void
CBShellEditor::HandleKeyPress
	(
	const int				key,
	const JXKeyModifiers&	modifiers
	)
{
	const JBoolean controlOn = modifiers.control();
	const JBoolean metaOn    = modifiers.meta();
	const JBoolean shiftOn   = modifiers.shift();
	if ((key == kJLeftArrow && metaOn && !controlOn && !shiftOn) ||
		(key == JXCtrl('A') && controlOn && !metaOn && !shiftOn))
		{
		const JIndex index            = GetInsertionIndex();
		const JRunArray<Font>& styles = GetStyles();
		if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
			{
			JIndex runIndex, firstIndexInRun;
			const JBoolean ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);
			SetCaretLocation(firstIndexInRun);
			return;
			}
		}

	if (key == kJReturnKey)
		{
		SetCurrentFont(itsInsertFont);
		}
	else
		{
		SetCurrentFont(GetDefaultFont());
		}

	JBoolean sentCmd = kJFalse;
	if (key == kJReturnKey && !modifiers.shift() && !HasSelection())
		{
		JIndex index;
		JBoolean ok = GetCaretLocation(&index);
		assert( ok );

		JString cmd;
		const JRunArray<Font>& styles = GetStyles();
		if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
			{
			JIndex runIndex, firstIndexInRun;
			ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);

			const JIndex endIndex = firstIndexInRun + styles.GetRunLength(runIndex);
			cmd = (GetText()).GetSubstring(firstIndexInRun, endIndex - 1);
			SetCaretLocation(endIndex);

			if (cmd.BeginsWith("man "))
				{
				cmd.ReplaceSubstring(1, 4, "jcc --man ");
				}
			else if (cmd.BeginsWith("apropos "))
				{
				cmd.ReplaceSubstring(1, 8, "jcc --apropos ");
				}
			else if (cmd.BeginsWith("vi "))
				{
				cmd.ReplaceSubstring(1, 3, "jcc ");
				}
			else if (cmd.BeginsWith("less ") || cmd.BeginsWith("more "))
				{
				cmd.ReplaceSubstring(1, 5, "jcc ");
				}
			else if (cmd == "more" || cmd == "less" || cmd == "vi")
				{
				cmd = "jcc";
				}
			}

		cmd += "\n";
		itsShellDoc->SendCommand(cmd);

		sentCmd = kJTrue;
		}

	CBTextEditor::HandleKeyPress(key, modifiers);

	if (sentCmd)
		{
		itsInsertIndex = GetInsertionIndex();
		}
}
Example #3
0
void MGADSMTrajectory::SetInsertion(int n, const InsertionNode& insertionNode)
{
   int index = GetInsertionIndex(n);
   SetNode(index, TrajectoryNodePtr(new InsertionNode(insertionNode)));
}