当前位置: 首页>>代码示例>>C++>>正文


C++ Position::getIndexInLine方法代码示例

本文整理汇总了C++中codedocument::Position::getIndexInLine方法的典型用法代码示例。如果您正苦于以下问题:C++ Position::getIndexInLine方法的具体用法?C++ Position::getIndexInLine怎么用?C++ Position::getIndexInLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在codedocument::Position的用法示例。


在下文中一共展示了Position::getIndexInLine方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mouseDoubleClick

void CodeEditorComponent::mouseDoubleClick (const MouseEvent& e)
{
    CodeDocument::Position tokenStart (getPositionAt (e.x, e.y));
    CodeDocument::Position tokenEnd (tokenStart);

    if (e.getNumberOfClicks() > 2)
    {
        tokenStart.setLineAndIndex (tokenStart.getLineNumber(), 0);
        tokenEnd.setLineAndIndex (tokenStart.getLineNumber() + 1, 0);
    }
    else
    {
        while (CharacterFunctions::isLetterOrDigit (tokenEnd.getCharacter()))
            tokenEnd.moveBy (1);

        tokenStart = tokenEnd;

        while (tokenStart.getIndexInLine() > 0
                && CharacterFunctions::isLetterOrDigit (tokenStart.movedBy (-1).getCharacter()))
            tokenStart.moveBy (-1);
    }

    moveCaretTo (tokenEnd, false);
    moveCaretTo (tokenStart, true);
}
开发者ID:alessandropetrolati,项目名称:juced,代码行数:25,代码来源:juce_CodeEditorComponent.cpp

示例2: findNext

void GenericCodeEditorComponent::findNext (bool forwards, bool skipCurrentSelection)
{
	const Range<int> highlight (getHighlightedRegion());
	const CodeDocument::Position startPos (getDocument(), skipCurrentSelection ? highlight.getEnd()
		: highlight.getStart());
	int lineNum = startPos.getLineNumber();
	int linePos = startPos.getIndexInLine();

	const int totalLines = getDocument().getNumLines();
	const String searchText (getSearchString());
	const bool caseSensitive = isCaseSensitiveSearch();

	for (int linesToSearch = totalLines; --linesToSearch >= 0;)
	{
		String line (getDocument().getLine (lineNum));
		int index;

		if (forwards)
		{
			index = caseSensitive ? line.indexOf (linePos, searchText)
				: line.indexOfIgnoreCase (linePos, searchText);
		}
		else
		{
			if (linePos >= 0)
				line = line.substring (0, linePos);

			index = caseSensitive ? line.lastIndexOf (searchText)
				: line.lastIndexOfIgnoreCase (searchText);
		}

		if (index >= 0)
		{
			const CodeDocument::Position p (getDocument(), lineNum, index);
			selectRegion (p, p.movedBy (searchText.length()));
			break;
		}

		if (forwards)
		{
			linePos = 0;
			lineNum = (lineNum + 1) % totalLines;
		}
		else
		{
			if (--lineNum < 0)
				lineNum = totalLines - 1;

			linePos = -1;
		}
	}
}
开发者ID:grimtraveller,项目名称:ctrlr,代码行数:52,代码来源:CtrlrLuaMethodCodeEditor.cpp

示例3: moveLineDelta

void CodeEditorComponent::moveLineDelta (const int delta, const bool selecting)
{
    CodeDocument::Position pos (caretPos);
    const int newLineNum = pos.getLineNumber() + delta;

    if (columnToTryToMaintain < 0)
        columnToTryToMaintain = indexToColumn (pos.getLineNumber(), pos.getIndexInLine());

    pos.setLineAndIndex (newLineNum, columnToIndex (newLineNum, columnToTryToMaintain));

    const int colToMaintain = columnToTryToMaintain;
    moveCaretTo (pos, selecting);
    columnToTryToMaintain = colToMaintain;
}
开发者ID:SonicPotions,项目名称:editor,代码行数:14,代码来源:juce_CodeEditorComponent.cpp

示例4: getCharacterBounds

const Rectangle CodeEditorComponent::getCharacterBounds (const CodeDocument::Position& pos) const throw()
{
    return Rectangle (roundToInt ((gutter - xOffset * charWidth) + indexToColumn (pos.getLineNumber(), pos.getIndexInLine()) * charWidth),
                      (pos.getLineNumber() - firstLineOnScreen) * lineHeight,
                      roundToInt (charWidth),
                      lineHeight);
}
开发者ID:alessandropetrolati,项目名称:juced,代码行数:7,代码来源:juce_CodeEditorComponent.cpp

示例5: keyPressed

bool CtrlrLuaMethodCodeEditor::keyPressed (const KeyPress &key, Component *originatingComponent)
{
    if (key.getModifiers().isCommandDown() )
	{
		if(key.getKeyCode() == 9)
		{
			owner.keyPressed (key, originatingComponent);
			return (true);
		}
		if (key.getKeyCode() == 83) // CTRL + S
		{
			saveDocument();
			return (true);
		}
		if (CharacterFunctions::toUpperCase ((juce_wchar) (key.getKeyCode())) == 70) // CTRL + F
		{
			// Show search Dialog
			editorComponent->showFindPanel();
			return (true);
		}
		if (CharacterFunctions::toUpperCase ((juce_wchar) (key.getKeyCode())) == 71) // CTRL + G
		{
			// Show Go To Dialog
			editorComponent->showGoTOPanel();
			return (true);
		}
		if (CharacterFunctions::toUpperCase ((juce_wchar) (key.getKeyCode())) == 72) // CTRL + H
		{
			// Show search Dialog
			editorComponent->showFindPanel(true);
			return (true);
		}

		if (key.getKeyCode() == KeyPress::deleteKey) // CTRL + Delete
		{
			owner.keyPressed(key, originatingComponent);
			return (true);
		}

		// search selected previous in current
		if (key.getModifiers().isShiftDown()
			&& key.getKeyCode() == KeyPress::F3Key) // CTRL + SHIFT + F3
		{
			editorComponent->findSelection(false);
			return (true);
		}
	}

	// search selected next in current
	if (key.getModifiers().isShiftDown() && key.getKeyCode() == KeyPress::F3Key) // SHIFT + F3
	{
		editorComponent->findSelection(true);
		return (true);
	}

	if (key.getKeyCode() == KeyPress::F7Key)
	{
		saveAndCompileDocument();
		return (true);
	}

	if (key.getKeyCode() == KeyPress::F8Key)
	{
		owner.saveAndCompilAllMethods();
		return (true);
	}

	CodeDocument::Position pos = editorComponent->getCaretPos();
	owner.setPositionLabelText ("Line:  " + String(pos.getLineNumber()+1) + " Column: " + String(pos.getIndexInLine()));
	return (false);
}
开发者ID:grimtraveller,项目名称:ctrlr,代码行数:71,代码来源:CtrlrLuaMethodCodeEditor.cpp

示例6: keyStateChanged

bool CtrlrLuaMethodCodeEditor::keyStateChanged (bool isKeyDown, Component *originatingComponent)
{
	CodeDocument::Position pos = editorComponent->getCaretPos();
	owner.setPositionLabelText ("Line:  " + String(pos.getLineNumber()+1) + " Column: " + String(pos.getIndexInLine()));
	return (false);
}
开发者ID:grimtraveller,项目名称:ctrlr,代码行数:6,代码来源:CtrlrLuaMethodCodeEditor.cpp

示例7: mouseDown

void CtrlrLuaMethodCodeEditor::mouseDown (const MouseEvent &e)
{
	CodeDocument::Position pos = editorComponent->getCaretPos();
	String url;
	if (isMouseOverUrl (pos, &url))
	{
		URL(url).launchInDefaultBrowser();
	}
	owner.setPositionLabelText ("Line:  " + String(pos.getLineNumber()+1) + " Column: " + String(pos.getIndexInLine()));
}
开发者ID:grimtraveller,项目名称:ctrlr,代码行数:10,代码来源:CtrlrLuaMethodCodeEditor.cpp


注:本文中的codedocument::Position::getIndexInLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。