Example #1
0
void EpsonPaperSpace::moveTo( Pos newPos )
{
	if( convertToPUnits( newPos.x ) < pos.x )
		carriageReturn();

	int oldFont = font;
	setFont( moveToFont );

	PrecPos character = getCharMetrics( font );
	int lines = (convertToPUnits( newPos.y ) - pos.y) / character.y;

	while( lines )
		{
		lineFeed();
		lines--;
		}

	lineFeed180th( (convertToPUnits( newPos.y ) - pos.y) / 2 );

	int tabPos = (convertToPUnits( newPos.x ) - pos.x) / character.x;
	setHTabulator( tabPos );
	hTabulator();

	setFont( oldFont );
}
Example #2
0
void Cursor::replaceAtCursor(const QByteArray &data)
{
    //if (m_selection_valid ) {
    //    if (current_cursor_new_y() >= m_selection_start.new_y() && current_cursor_new_y() <= m_selection_end.new_y())
    //        //don't need to schedule as event since it will only happen once
    //        setSelectionEnabled(false);
    //}

    const QString text = m_gl_text_codec->toUnicode(data);

    if (new_x() + text.size() <= m_screen->width()) {
        Block *block = screen_data()->blockContainingLine(new_y());
        block->replaceAtPos(new_x(), text, m_current_text_style);
        new_rx() += text.size();
    } else if (m_wrap_around) {
        Block *block = screen_data()->blockContainingLine(new_y());
        block->replaceAtPos(new_x(), text, m_current_text_style);
        int line_feeds = (new_x() + text.size()) / m_screen->width();
        new_rx() = (new_x() + text.size()) % m_screen->width();
        for (int i = 0; i < line_feeds; i++) {
            lineFeed();
        }
    }else {
        const int size = m_document_width - new_x();
        QString toBlock = text.mid(0,size);
        toBlock.replace(toBlock.size() - 1, 1, text.at(text.size()-1));
        Block *block = screen_data()->blockContainingLine(new_y());
        block->replaceAtPos(new_x(),toBlock, m_current_text_style);
        new_rx() += toBlock.size();
    }
    if (new_x() >= m_document_width)
        new_rx() = m_document_width - 1;
    notifyChanged();
}
Example #3
0
 void lineFeed() { FOREACH lineFeed(); }