コード例 #1
0
int CodeEditorComponent::indexToColumn (int lineNum, int index) const throw()
{
    const String line (document.getLine (lineNum));
    jassert (index <= line.length());

    int col = 0;
    for (int i = 0; i < index; ++i)
    {
        if (line[i] != T('\t'))
            ++col;
        else
            col += getTabSize() - (col % getTabSize());
    }

    return col;
}
コード例 #2
0
int CodeEditorComponent::columnToIndex (int lineNum, int column) const throw()
{
    const String line (document.getLine (lineNum));
    const int lineLength = line.length();

    int i, col = 0;
    for (i = 0; i < lineLength; ++i)
    {
        if (line[i] != T('\t'))
            ++col;
        else
            col += getTabSize() - (col % getTabSize());

        if (col > column)
            break;
    }

    return i;
}
コード例 #3
0
int CodeEditorComponent::columnToIndex (int lineNum, int column) const noexcept
{
    String::CharPointerType t (document.getLine (lineNum).getCharPointer());

    int i = 0, col = 0;

    while (! t.isEmpty())
    {
        if (t.getAndAdvance() != '\t')
            ++col;
        else
            col += getTabSize() - (col % getTabSize());

        if (col > column)
            break;

        ++i;
    }

    return i;
}
コード例 #4
0
int CodeEditorComponent::indexToColumn (int lineNum, int index) const noexcept
{
    String::CharPointerType t (document.getLine (lineNum).getCharPointer());

    int col = 0;
    for (int i = 0; i < index; ++i)
    {
        if (t.isEmpty())
        {
            jassertfalse;
            break;
        }

        if (t.getAndAdvance() != '\t')
            ++col;
        else
            col += getTabSize() - (col % getTabSize());
    }

    return col;
}
コード例 #5
0
ファイル: token.c プロジェクト: ABratovic/open-watcom-v2
static int skipBlank(void)
{
    int count = 0;

    while (NEXT_CHAR == ' ' || NEXT_CHAR == '\t') {
        if (NEXT_CHAR == ' ') {
            count++;
        } else {
            count += getTabSize(COL_NUM);
        }
        getNextChar();
    }

    return count;
}
コード例 #6
0
ファイル: token.c プロジェクト: ABratovic/open-watcom-v2
static void getNextChar(void)
{
    static unsigned long counter = 0;
    enum { COUNTER_STEP = 1024 };

    if (counter++ % COUNTER_STEP == 0) {
        dribble();
    }

    if ((char) NEXT_CHAR == (char) EOF){
        printf("INTERNAL ERROR in getNextChar: Attempted to read beyond EOF!\n");
        return;
    }

    if (NEXT_CHAR == '\t'){
        COL_NUM += getTabSize(COL_NUM);
    } else if (NEXT_CHAR != '\n') {
        COL_NUM++;
    } else {
        g_totalNumLines++;
        LINE_NUM++;
        orderLineNum++;
        COL_NUM = 0;
        TOK_NUM_AFTER_NEW_LINE = 0;
    }

    NEXT_CHAR = _NEXT_NEXT_CHAR;
    if ((char) NEXT_CHAR != (char) EOF){
        _NEXT_NEXT_CHAR = fgetc(TOK_FILE);
        if (STATE != TS_COMMENT) {
            while (_NEXT_NEXT_CHAR == '\n' && NEXT_CHAR == '\\'){
                g_totalNumLines++;
                NEXT_CHAR = fgetc(TOK_FILE);
                _NEXT_NEXT_CHAR = fgetc(TOK_FILE);
                LINE_NUM++;
                COL_NUM = 0;
            }
        }
        if ((char) _NEXT_NEXT_CHAR == (char) EOF && NEXT_CHAR == '\\'){
            NEXT_CHAR = (char) EOF;
        }
    }
}
コード例 #7
0
void TextDomArea::tabHandler(bool isShiftPressed)
{
	UInt32 lesserLine,greaterLine,lesserIndex;
	DocumentElementAttribute temp;
	UInt32 oldHSI = getLayoutManager()->getHSI();
	UInt32 oldHSL = getLayoutManager()->getHSL();
	UInt32 oldHEI = getLayoutManager()->getHEI();
	UInt32 oldHEL = getLayoutManager()->getHEL();

	PlainDocumentLeafElementRefPtr theElement;
	if(getLayoutManager()->getHSL() <= getLayoutManager()->getHEL())
	{
		lesserLine = getLayoutManager()->getHSL();
		lesserIndex = getLayoutManager()->getHSI();
		greaterLine = getLayoutManager()->getHEL();
	}
	else
	{
		lesserLine = getLayoutManager()->getHEL();
		lesserIndex = getLayoutManager()->getHEI();
		greaterLine = getLayoutManager()->getHSL();
	}

	UInt32 count=0;
	if(getLayoutManager()->isSomethingSelected())
	{
		if(!isShiftPressed)
		{
			for(UInt32 caretLine = lesserLine;caretLine<=greaterLine;caretLine++)
			{
				for(UInt32 i=0;i<getTabSize();i++)
				{
					//getDocumentModel()->insertCharacter(0,caretLine,' ',temp);
					insertCharacterUsingCommandManager(' ',caretLine,0);
				}
				//getLayoutManager()->DoIfLineLongerThanPreferredSize();
			}
		
		}
		else
		{
			for(UInt32 caretLine = lesserLine;caretLine<=greaterLine;caretLine++)
			{
				theElement = dynamic_cast<PlainDocumentLeafElement*>(getLayoutManager()->getRootElement()->getElement(caretLine));
				std::string theString = theElement->getText();
				Int32 i;
				for(i=0;i<theElement->getTextLength()-2,i<getTabSize();i++)
				{
					if(theString[i]!=' ')break;
					if(caretLine == getLayoutManager()->getCaretLine())getLayoutManager()->moveTheCaret(LEFT,false,false);
					if(caretLine == lesserLine)count--;
				}
				theString = theString.substr(i);
				setTextUsingCommandManager(theElement,theString);
				//theElement->setText(theString);
				
			}
			getLayoutManager()->setHSI(0);
			getLayoutManager()->setHSL(lesserLine);
			getLayoutManager()->setHEI(0);
			getLayoutManager()->setHEL(greaterLine);
		}
	}
	else
	{
		if(!isShiftPressed)
		{
			for(UInt32 i=0;i<getTabSize();i++)
			{
				//getDocumentModel()->insertCharacter(getLayoutManager()->getCaretIndex(),getLayoutManager()->getCaretLine(),' ',temp);
				insertCharacterUsingCommandManager(' ',-1,-1);
				//getLayoutManager()->moveTheCaret(RIGHT,false,false);
			}
			//getLayoutManager()->DoIfLineLongerThanPreferredSize();	
		}
		else
		{
			theElement = dynamic_cast<PlainDocumentLeafElement*>(getLayoutManager()->getRootElement()->getElement(getLayoutManager()->getCaretLine()));
			std::string theString = theElement->getText();
			Int32 i,count=0;
			Int32 initIndex = getLayoutManager()->getCaretIndex();
			for(i=getLayoutManager()->getCaretIndex()-1;i>=0,count<getTabSize();i--,count++)
			{
				if(i<0 || theString[i]!=' ')break;
				getLayoutManager()->moveTheCaret(LEFT,false,false);
			}
			theString = theString.substr(0,getLayoutManager()->getCaretIndex())+theString.substr(initIndex);
			setTextUsingCommandManager(theElement,theString);
			//theElement->setText(theString);
		}
	}
}