Пример #1
0
/* Try to get the number of columns in the current terminal, or assume 80
 * if it fails. */
static int getColumns(int ifd, int ofd) {
    struct winsize ws;

    if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
        /* ioctl() failed. Try to query the terminal itself. */
        int start, cols;

        /* Get the initial position so we can restore it later. */
        start = getCursorPosition(ifd,ofd);
        if (start == -1) goto failed;

        /* Go to right margin and get position. */
        if (write(ofd,"\x1b[999C",6) != 6) goto failed;
        cols = getCursorPosition(ifd,ofd);
        if (cols == -1) goto failed;

        /* Restore position. */
        if (cols > start) {
            char seq[32];
            snprintf(seq,32,"\x1b[%dD",cols-start);
            if (write(ofd,seq,strlen(seq)) == -1) {
                /* Can't recover... */
            }
        }
        return cols;
    } else {
        return ws.ws_col;
    }

failed:
    return 80;
}
Пример #2
0
Файл: kilo.c Проект: Ruk33/kilo
/* Try to get the number of columns in the current terminal. If the ioctl()
 * call fails the function will try to query the terminal itself.
 * Returns 0 on success, -1 on error. */
int getWindowSize(int ifd, int ofd, int *rows, int *cols) {
    struct winsize ws;

    if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
        /* ioctl() failed. Try to query the terminal itself. */
        int orig_row, orig_col, retval;

        /* Get the initial position so we can restore it later. */
        retval = getCursorPosition(ifd,ofd,&orig_row,&orig_col);
        if (retval == -1) goto failed;

        /* Go to right/bottom margin and get position. */
        if (write(ofd,"\x1b[999C\x1b[999B",12) != 12) goto failed;
        retval = getCursorPosition(ifd,ofd,rows,cols);
        if (retval == -1) goto failed;

        /* Restore position. */
        char seq[32];
        snprintf(seq,32,"\x1b[%d;%dH",orig_row,orig_col);
        if (write(ofd,seq,strlen(seq)) == -1) {
            /* Can't recover... */
        }
        return 0;
    } else {
        *cols = ws.ws_col;
        *rows = ws.ws_row;
        return 0;
    }

failed:
    return -1;
}
Пример #3
0
bool TextInputWidget::handleKey(int key) {
	bool handled(true);
	
	if (!_hasFocus) return false;
	std::wstring old_input(_input);
	
	int size = static_cast<int>(_input.size());
	
	switch (key) {
	
		case osgGA::GUIEventAdapter::KEY_Left: 
			setCursorPos(_cursorPos - 1);
			break;
		case osgGA::GUIEventAdapter::KEY_Right:
			setCursorPos(_cursorPos + 1);
			break;
		
		case osgGA::GUIEventAdapter::KEY_BackSpace:
			if ((_cursorPos >= size) && (size >=1)) 
			{
				// letztes Zeichen löschen
				_input = _input.substr(0, size - 2);
				setCursorPos(getCursorPosition()-1);
			}
			else if ((_cursorPos >= 0) &&  (_cursorPos < size)) 
			{
				//Zeichen links vom Cursor löschen
				_input = _input.substr(0,_cursorPos)+_input.substr(_cursorPos+1, size);
				setCursorPos(getCursorPosition()-1);
			}
			break;
		case osgGA::GUIEventAdapter::KEY_Delete:
		case osgGA::GUIEventAdapter::KEY_KP_Delete:
			if ((_cursorPos > 0) &&  (_cursorPos < size-1))
				_input = _input.substr(0,_cursorPos+1)+_input.substr(_cursorPos+2, size);
			break;
			
		default:
			if (key >= 0xff00) {
				handled = false;
			} else {
				// std::cout <<"key " << key << std::endl;
				// TODO hande utf?
				if (_cursorPos < size)
					_input.insert(_cursorPos+1, 1, static_cast<char>(key)); 
				else 
					_input += static_cast<char>(key);
				
				_cursorPos++;
			}
	}
	
	if (_input != old_input)
		informAttachedResponder(Actions::valueChanged());
	if (handled)
		update();
	return handled;
}
Пример #4
0
void SonicPiScintilla::moveLineOrSelection(int numLines) {
  beginUndoAction();

  int linenum, cursor, origLinenum, origCursor;
  getCursorPosition(&linenum, &cursor);
  origLinenum = linenum;
  origCursor = cursor;

  bool hadSelectedText = hasSelectedText();


  if(!hadSelectedText) {
    setSelection(linenum, 0, linenum + 1, 0);
  }

  int lineFrom, indexFrom, lineTo, indexTo, lineOffset;
  getSelection(&lineFrom, &indexFrom, &lineTo, &indexTo);
  lineOffset = lineTo - origLinenum;
  linenum = lineFrom;

  QString selection = selectedText();

  if(selection[selection.length()-1] != '\n') {
    selection = selection + "\n";
    lineTo += 1;
    lineOffset += 1;
    indexTo = 0;
    replaceSelectedText("");
    setCursorPosition(linenum, 0);
    SendScintilla(SCI_DELETEBACK);
  } else {
    replaceSelectedText("");
  }
  setCursorPosition(linenum, 0);

  moveLines(numLines);

  getCursorPosition(&linenum, &cursor);
  setCursorPosition(linenum, 0);
  insert(selection);

  setCursorPosition(linenum + lineOffset, origCursor);

  int diffLine = lineTo - lineFrom;
  int diffIndex = indexTo - indexFrom;

  setSelection(linenum + diffLine, diffIndex, linenum, 0);

  endUndoAction();
}
Пример #5
0
void EvaTextEdit::keyPressEvent(QKeyEvent *e)
{
	int para;
	int index;	
	getCursorPosition(&para,&index);
	if (isEnterSend && (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) && (e->state() != Qt::KeyButtonMask)) {
		if ((e->state() & Qt::ControlButton)==Qt::ControlButton) {
			KTextEdit::keyPressEvent(e);
			QString txt = text();
			txt.replace("</p>\n<p>", "<br />");
			setText(txt);
			setCursorPosition(para, index + 1);
		}
		emit keyPressed(e);
		return;
	}
	if (!isEnterSend && (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) && ((e->state() & Qt::ControlButton)==Qt::ControlButton)){
		emit keyPressed(e);
		return;
	}

	KTextEdit::keyPressEvent(e);	
	if((e->key() == Qt::Key_Enter) || (e->key() == Qt::Key_Return) ){
		QString txt = text();
		txt.replace("</p>\n<p>", "<br />");
		setText(txt);
		setCursorPosition(para, index + 1);
	}
	emit keyPressed(e);
}
Пример #6
0
QString KEdit::selectWordUnderCursor( )
{
    int parag;
    int pos;

    getCursorPosition(&parag, &pos);

    QString txt = text(parag);

    // Find start
    int start = pos;
    while( start > 0 )
    {
       const QChar &ch = txt[start-1];
       if (ch.isSpace() || ch.isPunct())
          break;
       start--;
    }

    // Find end
    int end = pos;
    int len = txt.length();
    while( end < len )
    {
       const QChar &ch = txt[end];
       if (ch.isSpace() || ch.isPunct())
          break;
       end++;
    }
    setSelection(parag, start, parag, end);
    return txt.mid(start, end-start);
}
Пример #7
0
void Editor::autoComplete( const QString& item )
{
    if( !d->autoCompleteEnabled || item.isEmpty() )
        return;

    int para = 0, curPos = 0;
    getCursorPosition( &para, &curPos );

    QString subtext = text().left( curPos );
    Tokens tokens = Evaluator::scan( subtext );

    if( !tokens.valid() || tokens.count() < 1 )
        return;

    Token lastToken = tokens[ tokens.count()-1 ];
    if( !lastToken.isIdentifier() )
        return;

    QStringList str = QStringList::split( ':', item );

    blockSignals( true );
    setSelection( 0, lastToken.pos(), 0, lastToken.pos()+lastToken.text().length() );
    insert( str[0] );
    blockSignals( false );
}
Пример #8
0
void Editor::uncommentSelection()
{
    int paragraphStart;
    int paragraphEnd;
    int indexStart;
    int indexEnd;
    getSelection(&paragraphStart, &indexStart, &paragraphEnd, &indexEnd);

    if (paragraphStart < 0) {
        getCursorPosition(&paragraphStart, &indexStart);
        paragraphEnd = paragraphStart;
    }

    if (paragraphStart >= 0 && paragraphEnd >= 0) {
        for (int i=paragraphStart; i<=paragraphEnd; ++i) {
            QString str = text(i);

            int whitespace = 0;
            while (str.startsWith("/") || (str.length() > 0 && str.at(0).isSpace())) {
                if (str.length() > 0 && str.at(0).isSpace()) ++whitespace;
                str.remove(0, 1);
            }

            if (whitespace > 0)
                str.prepend(QString().fill(QChar(' '), whitespace));

            insertParagraph(str, i);
            removeParagraph(i + 1);

        }

        repaintChanged();
        setModified(TRUE);       
    }
}
Пример #9
0
/**
 * Moves the cursor to the beginning of the current block.
 */
void Editor::gotoBlockBegin()
{
	int line, column, newline;
	getCursorPosition(&line, &column);
	newline = SendScintilla(QsciScintillaBase::SCI_GETFOLDPARENT, line);
	setCursorPosition(newline, 0);
}
Пример #10
0
/**
 * Paste in code and execute as new lines are encountered
 */
void CommandLineInterpreter::paste()
{
  const QClipboard *clipboard = QApplication::clipboard();
  m_pastedText = clipboard->text();
  if(m_pastedText.isEmpty()) return;

  const int lastLineIndex = indexOfLastLine();
  if(indexOfCursorLine() != lastLineIndex)
  {
    moveCursorToEnd();
  }

  int dummy(-1), offset(0);
  getCursorPosition(&dummy, &offset);

  if(containsNewlines(m_pastedText))
  {
    processPastedCodeWithNewlines(offset);
  }
  else
  {
    // If no newlines just insert the text at the current position
    setText(lastLineIndex,m_pastedText,offset);
  }
}
Пример #11
0
void SonicPiScintilla::toggleComment() {
  beginUndoAction();

  int linenum, cursor;
  getCursorPosition(&linenum, &cursor);

  //select the whole line
  setSelection(linenum, 0, linenum, cursor+1);

  QString selection = selectedText();

  // make sure we don't comment empty lines
  if (selection.length() > 0) {
      // if it's already commented, uncomment
      if (selection[0] == '#') {
          selection.remove(0, 1);
          replaceSelectedText(selection);
          if (cursor > 0) {
              setCursorPosition(linenum, cursor - 1);
          } else {
              setCursorPosition(linenum, cursor);
          }
      } else {
          selection.prepend('#');
          replaceSelectedText(selection);
          setCursorPosition(linenum, cursor + 1);
      }
  }
  deselect();
  endUndoAction();
}
Пример #12
0
/* set position if get=0, else get position */
qword sys_cursor(qword pos, qword get, qword rcx, qword r8, qword r9) {
	if (get) {
		int* p = (int*)pos;
		*p = getCursorPosition();
	} else setCursorPosition((int)pos);
	return 0;
}
Пример #13
0
/* special handling of keystorkes within the sbook editor.
 * If we hit return on the first line, just selected the second
 * line.
 */
void SBookEdit::keyPressEvent(QKeyEvent *event)
{
    int line,col;

    /* Special key processing */
    switch(event->key()){
	/* Pressing return on the first line takes you to the second line
	 * unless the Alt  key is down.
	 */
    case Key_Return:
	getCursorPosition(&line,&col);
	if(line==0 && numLines()>1 && ((event->state()&AltButton)==0)){
	    selectSecondLine();
	    return;
	}
	break;					  // no second row; just handle normally
    case Key_V:					  
	if(event->state() & ControlButton){	  // ^v does our special paste
	    paste();
	    return;
	}
	break;
    case Key_A:					  // ^a does a select all
	if(event->state() & ControlButton){
	    selectAll();
	    return;
	}
    }
    /* Default - just handle the event */
    QTextEdit::keyPressEvent(event);
    edited = true;				  // we have done something here
}
Пример #14
0
void SonicPiScintilla::transposeChars()
{
  int linenum, index;
  getCursorPosition(&linenum, &index);
  setSelection(linenum, 0, linenum + 1, 0);
  int lineLength = selectedText().size();

  //transpose chars
  if(index > 0){
    if(index < (lineLength - 1)){
      index = index + 1;
    }
    setSelection(linenum, index - 2, linenum, index);
    QString text = selectedText();
    QChar a, b;
    a = text.at(0);
    b = text.at(1);
    QString replacement  = "";
    replacement.append(b);
    replacement.append(a);
    replaceSelectedText(replacement);
  }

  setCursorPosition(linenum, index);
}
Пример #15
0
void MsgViewBase::addMessage(Message *msg)
{
    unsigned n = paragraphs() - 1;
    append(messageText(msg));
    if (!CorePlugin::m_plugin->getOwnColors())
        setBackground(n);
    if (!m_selectStr.isEmpty()){
        bool bStart = false;
        for (; n < (unsigned)paragraphs(); n++){
            QString s = text(n);
            if (s.find(MSG_HREF) >= 0){
                bStart = true;
                continue;
            }
            if (bStart)
                break;
        }
        if (n < (unsigned)paragraphs()){
            int savePara;
            int saveIndex;
            getCursorPosition(&savePara, &saveIndex);
            int para = n;
            int index = 0;
            while (find(m_selectStr, false, false, true, &para, &index)){
                setSelection(para, index, para, index + m_selectStr.length(), ++m_nSelection);
                setSelectionAttributes(m_nSelection, colorGroup().highlight(), true);
                index += m_selectStr.length();
            }
            setCursorPosition(savePara, saveIndex);
        }
    }
    sync();
}
Пример #16
0
void TextShow::search_slot()
{
    if (!srchdialog) return;
    int parag, index;
    getCursorPosition(&parag, &index);
    startSearch(parag, index);
}
Пример #17
0
void MsgViewBase::sync(unsigned n)
{
    if (!m_selectStr.isEmpty()){
        bool bStart = false;
        for (; n < (unsigned)paragraphs(); n++){
            QString s = text(n);
            if (s.find(MSG_ANCHOR) >= 0){
                bStart = true;
                continue;
            }
            if (bStart)
                break;
        }
        if (n < (unsigned)paragraphs()){
            int savePara;
            int saveIndex;
            getCursorPosition(&savePara, &saveIndex);
            int para = n;
            int index = 0;
            while (find(m_selectStr, false, false, true, &para, &index)){
                setSelection(para, index, para, index + m_selectStr.length(), ++m_nSelection);
                setSelectionAttributes(m_nSelection, colorGroup().highlight(), true);
                index += m_selectStr.length();
            }
            setCursorPosition(savePara, saveIndex);
            repaintChanged();
        }
    }
    TextShow::sync();
}
Пример #18
0
QString pEditor::currentLineText() const
{
    int line;
    int index;
    
    getCursorPosition( &line, &index );
    
    return text( line );
}
Пример #19
0
void KEdit::search_slot()
{

    int line, col;

    if(!srchdialog)
        return;

    QString to_find_string = srchdialog->getText();
    getCursorPosition(&line, &col);

    // srchdialog->get_direction() is true if searching backward

    if(last_search != NONE && srchdialog->get_direction())
    {
        col = col - pattern.length() - 1;
    }

again:
    int result = doSearch(to_find_string, srchdialog->case_sensitive(), false, (!srchdialog->get_direction()), line, col);

    if(!result)
    {
        if(!srchdialog->get_direction())
        { // forward search

            int query = KMessageBox::questionYesNo(srchdialog, i18n("End of document reached.\n"
                                                                    "Continue from the beginning?"),
                                                   i18n("Find"), KStdGuiItem::cont(), i18n("Stop"));
            if(query == KMessageBox::Yes)
            {
                line = 0;
                col = 0;
                goto again;
            }
        }
        else
        { // backward search

            int query = KMessageBox::questionYesNo(srchdialog, i18n("Beginning of document reached.\n"
                                                                    "Continue from the end?"),
                                                   i18n("Find"), KStdGuiItem::cont(), i18n("Stop"));
            if(query == KMessageBox::Yes)
            {
                QString string = textLine(numLines() - 1);
                line = numLines() - 1;
                col = string.length();
                last_search = BACKWARD;
                goto again;
            }
        }
    }
    else
    {
        emit CursorPositionChanged();
    }
}
Пример #20
0
void KisVisualEllipticalSelectorShape::drawCursor()
{
    //qDebug() << this << "KisVisualEllipticalSelectorShape::drawCursor: image needs update" << imagesNeedUpdate();
    QPointF cursorPoint = convertShapeCoordinateToWidgetCoordinate(getCursorPosition());
    QImage fullSelector = getImageMap();
    QColor col = getColorFromConverter(getCurrentColor());
    QPainter painter;
    painter.begin(&fullSelector);
    painter.setRenderHint(QPainter::Antialiasing);
    QRect innerRect(m_barWidth, m_barWidth, width()-(m_barWidth*2), height()-(m_barWidth*2));

    painter.save();
    painter.setCompositionMode(QPainter::CompositionMode_Clear);
    QPen pen;
    pen.setWidth(5);
    painter.setPen(pen);
    painter.drawEllipse(QRect(0,0,width(),height()));

    if (getDimensions()==KisVisualColorSelectorShape::onedimensional) {
        painter.setBrush(Qt::SolidPattern);
        painter.drawEllipse(innerRect);
    }
    painter.restore();

    QBrush fill;
    fill.setStyle(Qt::SolidPattern);

    int cursorwidth = 5;

    if (m_type==KisVisualEllipticalSelectorShape::borderMirrored) {
        painter.setPen(Qt::white);
        fill.setColor(Qt::white);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
        QPoint mirror(innerRect.center().x()+(innerRect.center().x()-cursorPoint.x()),cursorPoint.y());
        painter.drawEllipse(mirror, cursorwidth, cursorwidth);
        fill.setColor(col);
        painter.setPen(Qt::black);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth-1, cursorwidth-1);
        painter.drawEllipse(mirror, cursorwidth-1, cursorwidth-1);

    } else {
        painter.setPen(Qt::white);
        fill.setColor(Qt::white);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
        fill.setColor(col);
        painter.setPen(Qt::black);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0);
    }
    painter.end();
    setFullImage(fullSelector);
}
Пример #21
0
void Editor::selectTillNextParagraph()
{
    int lineTo, indexTo;
    if (selectionOrigin.line == -1)
    {
        // no previous selection, start from cursor
        getCursorPosition(&selectionOrigin.line, &selectionOrigin.index);
    }
    findNextParagraph(&lineTo, &indexTo);
    setSelection(selectionOrigin.line, selectionOrigin.index, lineTo, indexTo);
}
void Button::update(const sf::RenderWindow& screen, const float time, const sf::Vector2i& mouseOffset)
{
    auto position = getPosition();
    auto offset = getOffset();
    sf::IntRect buttonRect(static_cast<int>(position.x + offset.x + m_style.mouseRect.left - getSize().x / 2),
                           static_cast<int>(position.y + offset.y + m_style.mouseRect.top),
                           m_style.mouseRect.width,
                           m_style.mouseRect.height);
    auto mousePosition = getCursorPosition(screen);
    if(buttonRect.contains(mousePosition + mouseOffset) && isVisible())
    {
        if(!m_playHoverSound && m_style.hoverStyle.sound)
        {
            m_playHoverSound = true;
            m_style.hoverStyle.sound->play();
        }

        m_showToolTip = true;
        m_toolTip.setPosition(static_cast<const sf::Vector2f>(mousePosition), screen);
        
        if(utility::Mouse.leftButtonPressed())
        {
            m_sprite = &m_style.pressedStyle.sprite;
            m_label = &m_style.pressedStyle.label;
            onPositionChanged();

            if(!m_playPressedSound && m_style.pressedStyle.sound)
            {
                m_playPressedSound = true;
                m_style.pressedStyle.sound->play();
            }
        } 
        else
        {
            m_playPressedSound = false;
            m_sprite = &m_style.hoverStyle.sprite;
            m_label = &m_style.hoverStyle.label;
            onPositionChanged();

            if(m_isTriggering && utility::Mouse.leftButtonReleased() && m_callback != nullptr)
                m_callback(*this);
        }
    }
    else
    {
        m_playHoverSound = false;
        m_playPressedSound = false;
        m_sprite = &m_style.idleStyle.sprite;
        m_label = &m_style.idleStyle.label;
        onPositionChanged();
        m_showToolTip = false;
    }
}
Пример #23
0
void SonicPiScintilla::newlineAndIndent() {
  int point_line, point_index, first_line;
  getCursorPosition(&point_line, &point_index);
  first_line = firstVisibleLine();

  std::string code = text().toStdString();

  // TODO: fix this:
  std::string id = "foobar";

  oscSender->bufferNewlineAndIndent(point_line, point_index, first_line, code, fileName.toStdString(), id);
}
Пример #24
0
// Single clicked item in file list
long FileSelector::onCmdItemClicked(FXObject*,FXSelector,void* ptr)
{
	if (single_click != SINGLE_CLICK_NONE)
	{		
		FXint index=(FXint)(long)ptr;
		if(index<0)
			return 1;

		// In detailed mode, avoid single click when cursor is not over the first column
		FXint x, y;
		FXuint state;
		getCursorPosition(x,y,state);
		FXbool allow=TRUE;

		if (list->getListType() == IconList_ListType_Details && (x-list->getXPosition())>list->getHeaderSize(0)) {
			allow=FALSE;
		}

		// Single click with control or shift
		if (state&(CONTROLMASK|SHIFTMASK))
			return 1;
		
		// Single click without control or shift
		else
		{
			// If directory, open the directory
			if(single_click != SINGLE_CLICK_NONE && list->isItemDirectory(index) && allow)
			{
				FXString pathname=list->getItemPathname(index);

				// Does not have access
				if(!::isReadExecutable(pathname))
				{
					MessageBox::error(this,BOX_OK,_("Error"),_(" Permission to: %s denied."), pathname.text());
					return 0;
				}				
				setDirectory(pathname);
				pathlink->setPath(pathname);
				pathtext->setText(pathname);
				return 1;
			}
			else if((single_click==SINGLE_CLICK_DIR_FILE) && list->isItemFile(index) && allow)
			{
				FXObject *tgt=accept->getTarget();
				FXSelector sel=accept->getSelector();
				if(tgt)
					tgt->handle(accept,FXSEL(SEL_COMMAND,sel),(void*)1);
			}
		}
	}
    return 1;
}
Пример #25
0
/**
 * Prompts the user for a line number and moves the cursor to the selected line.
 */
void Editor::gotoLine()
{
	// Get the current line number.
	int line, column;
	getCursorPosition(&line, &column);

	// Prompt for a new line number.
	bool ok;
	line = QInputDialog::getInteger(this, tr("Enter Line Number"),
	                                tr("Line"), line + 1, 1, lines(), 1, &ok);
	if (ok)
		setCursorPosition(line - 1, 0);
}
Пример #26
0
void Editor::findPreviousParagraph(int *pLine, int *pIndex)
{
    int line, index;
    getCursorPosition(&line, &index);
    while (line > 0)
    {
        line--;
        if (text(line).trimmed().isEmpty())
            break;
    }
    *pLine = line;
    *pIndex = 0;
}
Пример #27
0
void SeparateChatWindow::sendMessage()
{
  if (m_edit->text().trimmed().isEmpty())
    return; // Empty message

  int cursor_position = getCursorPosition();
  m_abstract_chat_layer.sendMessageTo(m_protocol_name, m_account_name,
                                      m_item_name, m_edit->text(),
                                      cursor_position);
  m_edit->clear();
/*  m_edit->moveCursor(QTextCursor::Start);*/
  m_edit->setFocus();
}
Пример #28
0
/**
 * Fills a Location structure with information on the current file name, line
 * and column.
 * @param  loc  The structure to fill
 */
void Editor::getCurrentLocation(Core::Location& loc)
{
	int line, col;

	// Get the current cursor position.
	getCursorPosition(&line, &col);

	// Fill the structure.
	loc.file_ = path_;
	loc.line_ = line + 1;
	loc.column_ = col + 1;
	loc.text_ = text(line).trimmed();
}
Пример #29
0
void Editor::findNextParagraph(int *pLine, int *pIndex)
{
    int line, index;
    int lastLine = lines() - 1;
    getCursorPosition(&line, &index);
    while (line < lastLine)
    {
        line++;
        if (text(line).trimmed().isEmpty())
            break;
    }
    *pLine = line;
    *pIndex = 0;
}
Пример #30
0
void TextEdit::slotColorChanged(const QColor &c)
{
    if (c == curFG)
        return;
    int parag;
    int index;
    getCursorPosition(&parag, &index);
    if (QTextEdit::text(parag).isEmpty()){
        setColor(curFG);
        return;
    }
    if (c != curFG)
        setForeground(c, false);
}