Example #1
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();
}
Example #2
0
static void updateBootArgs( int key )
{
    key &= kASCIIKeyMask;

    switch ( key )
    {
        case kBackspaceKey:
            if ( gBootArgsPtr > gBootArgs )
            {
                int x, y, t;
                getCursorPositionAndType( &x, &y, &t );
                if ( x == 0 && y )
                {
                    x = 80; y--;
                }
                if (x) x--;
                setCursorPosition( x, y, 0 );
                putca(' ', 0x07, 1);
                *gBootArgsPtr-- = '\0';
            }
            break;

        default:
            if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd)
            {
                putchar(key);  // echo to screen
                *gBootArgsPtr++ = key;
            }
            break;
    }
}
Example #3
0
void LocationBar::webViewUrlChanged(const QUrl &url)
{
    if (hasFocus())
        return;
    setText(url.toString());
    setCursorPosition(0);
}
Example #4
0
 void PropertyLineEdit::insertText(const QString &text) {
     // position cursor after new text and grab focus
     const int oldCursorPosition = cursorPosition ();
     insert(text);
     setCursorPosition (oldCursorPosition + text.length());
     setFocus(Qt::OtherFocusReason);
 }
Example #5
0
void NumberEdit::texttChanged(const QString& text) {
    QString in=text;
    if (!suffix.isEmpty()) {
        if (text.endsWith(suffix)) {
            in=in.remove(text.size()-suffix.size(), suffix.size());
        }
    }
    double d=extractVal(text);
    setViewOK();
    if ((checkMax) && (d>max)) {
        d=max;
        setViewError();
    }//setValue(d);}
    if ((checkMin) && (d<min)) {
        d=min;
        setViewError();
    }//setValue(d); }

    //std::cout<<d<<std::endl;
    //QMessageBox::information(this, "", QString("value is %1").arg(d));
    else emit valueChanged(d);
    if ((!suffix.isEmpty()) && (!text.contains(suffix))) {
        int cp=cursorPosition();
        setText(text+suffix);
        setCursorPosition(cp);
    }
}
Example #6
0
void QHexEdit::setAddressArea(bool addressArea)
{
    _addressArea = addressArea;
    adjust();
    setCursorPosition(_cursorPosition);
    viewport()->update();
}
Example #7
0
void refreshKernelVideo(void) {
    int i;
    for (i = 0; i < VIDEO_ROWS; i++) {
        __write(1, video[i], VIDEO_COLUMNS);
    }
    setCursorPosition(0);
}
Example #8
0
bool Slider::touchMoveHandler(ofTouchEventArgs &touch){
    if (touch.id == currentTouchId){
        setCursorPosition(globalToLocal(touch.x, touch.y));
        return true;
    }
    return false;
}
Example #9
0
void KTextBox::fitText()
{
  int startindex, endindex, countindex, testlength, line, column;
  
  // Map the text to the width of the widget
  cursorPosition( &line, &column );
  countindex =-1;
  QString testText = text().simplifyWhiteSpace() + " ";
  startindex = 0;
  testlength = testText.length();
  countindex = testText.find(" ", 0);
  while ((endindex = testText.find(" ", countindex+1)) > -1) {
    QString middle;
    int len;
    len = endindex - startindex;
    middle = testText.mid( startindex, len );

    if (textWidth( &middle ) > width()) {
      testText.replace( countindex, 1, "\n" );
      startindex = countindex;
    }
    countindex = endindex;
  }

  setText( testText.stripWhiteSpace() );

  setCursorPosition( line, column );
}
Example #10
0
 void LCD4884::writeCharBig(unsigned char x, unsigned char y, unsigned char ch, char mode)
 {
   unsigned char i, j;
   unsigned char *pFont;
   unsigned char ch_dat;
   
   pFont = (unsigned char*) big_number;
   
   if(ch == '.')
   {
     ch = 10;
   } else if(ch == '+')
   {
     ch = 11;
   } else if(ch == '-')
   {
     ch = 12;
   } else
   {
     ch = ch & 0x0F;
   }
   
   for(i=0; i < 3; i++)
   {
     setCursorPosition(x, y+i);
     
     for(j=0; j < 16; j++)
     {
       ch_dat = pgm_read_byte(pFont + ch * 48 + i * 16 + j);
       writeByte( (mode == MENU_NORMAL) ? ch_dat : (ch_dat ^ 0xFF), 1);
     }
   }
 }
Example #11
0
void QHexEdit::setAddressOffset(qint64 addressOffset)
{
    _addressOffset = addressOffset;
    adjust();
    setCursorPosition(_cursorPosition);
    viewport()->update();
}
Example #12
0
void QHexEdit::setEditorSize(qint64 size)
{
    _editorSize = size;
    adjust();
    setCursorPosition(_cursorPosition);
    viewport()->update();
}
Example #13
0
void QHexEdit::adjust()
{
    // recalc Graphics
    if (_addressArea)
    {
        _addrDigits = addressWidth();
        _pxPosHexX = _pxGapAdr + _addrDigits*_pxCharWidth + _pxGapAdrHex;
    }
    else
        _pxPosHexX = _pxGapAdrHex;
    _pxPosAdrX = _pxGapAdr;
    _pxPosAsciiX = _pxPosHexX + HEXCHARS_IN_LINE * _pxCharWidth + _pxGapHexAscii;

    // set horizontalScrollBar()
    int pxWidth = _pxPosAsciiX;
    if (_asciiArea)
        pxWidth += BYTES_PER_LINE*_pxCharWidth;
    horizontalScrollBar()->setRange(0, pxWidth - viewport()->width());
    horizontalScrollBar()->setPageStep(viewport()->width());

    // set verticalScrollbar()
    _rowsShown = ((viewport()->height()-4)/_pxCharHeight);
    int lineCount = (int)(_editorSize / (qint64)BYTES_PER_LINE) + 1;
    verticalScrollBar()->setRange(0, lineCount - _rowsShown);
    verticalScrollBar()->setPageStep(_rowsShown);

    int value = verticalScrollBar()->value();
    _bPosFirst = (qint64)value * BYTES_PER_LINE;
    _bPosLast = _bPosFirst + (qint64)(_rowsShown * BYTES_PER_LINE) - 1;
    if (_bPosLast >= _editorSize)
        _bPosLast = _editorSize - 1;
    readBuffers();
    setCursorPosition(_cursorPosition);
}
Example #14
0
void ScrollLine::mouseReleaseEvent( QMouseEvent *event )
{
   mClicked = false;
   GlobalConfigWidget::setClipboard( selectedText() );
   setCursorPosition( cursorPositionAt( event->pos() ) );
   QLineEdit::mouseReleaseEvent( event );
}
Example #15
0
void LocationBar::webViewUrlChanged(const QUrl &url)
{
    if (hasFocus())
        return;
    setText(QString::fromUtf8(url.toEncoded()));
    setCursorPosition(0);
}
Example #16
0
void printMemoryInfo(void)
{
    int line;
    unsigned long i;
    MemoryRange *mp = (MemoryRange*)(uint32_t)get_env(envMemoryMap);
	
    // Activate and clear page 1
    setActiveDisplayPage(1);
    clearScreenRows(0, 24);
    setCursorPosition( 0, 0, 1 );
	
    printf("BIOS reported memory ranges:\n");
    line = 1;
	
	int memoryMapCount = (int)get_env(envMemoryMapCnt);
    for (i=0; i<memoryMapCount; i++) {
        printf("Base 0x%08x%08x, ",
               (unsigned long)(mp->base >> 32),
               (unsigned long)(mp->base));
        printf("length 0x%08x%08x, type %d\n",
               (unsigned long)(mp->length >> 32),
               (unsigned long)(mp->length),
               mp->type);
        if (line++ > 20) {
            pause();
            line = 0;
        }
        mp++;
    }
    if (line > 0) {
        pause();
    }
    
    setActiveDisplayPage(0);
}
Example #17
0
void EvaTextEdit::keyPressEvent(TQKeyEvent *e)
{

    int para;
    int index;	
    getCursorPosition(&para,&index);
    if ( (e->key() == TQt::Key_Enter) || (e->key() == TQt::Key_Return) ) {
	if ( (e->state() & TQt::ControlButton)==TQt::ControlButton)
        {
    	    if ( !isEnterSend )
    	    {
        	emit keyPressed(e);
        	return;
    	    }
    	}
	else if ( (e->state() | TQt::KeyButtonMask) ) {
    	    if (isEnterSend )
    	    {
        	emit keyPressed(e);
        	return;
    	    }
	}
    }
    KTextEdit::keyPressEvent(e);
    if((e->key() == TQt::Key_Enter) || (e->key() == TQt::Key_Return) ){	
        TQString txt = text();
        txt.replace("</p>\n<p>", "<br />");
        setText(txt);
        setCursorPosition(para, index + 1);
    }
    emit keyPressed(e);
}
Example #18
0
void QHexEdit::setAddressWidth(int addressWidth)
{
    _addressWidth = addressWidth;
    adjust();
    setCursorPosition(_cursorPosition);
    viewport()->update();
}
Example #19
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);
}
Example #20
0
void MsgViewBase::addMessage(Message *msg)
{
    unsigned n = paragraphs() - 1;
    append(messageText(msg));
    if (!CorePlugin::m_plugin->getOwnColors()) {
        // set all Backgrounds to the right colors
        setBackground(0);
    }
    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();
}
Example #21
0
void BaseValidatingLineEdit::slotChanged(const QString &t)
{
    m_bd->m_errorMessage.clear();
    // Are we displaying the initial text?
    const bool isDisplayingInitialText = !m_bd->m_initialText.isEmpty() && t == m_bd->m_initialText;
    const State newState = isDisplayingInitialText ?
                               DisplayingInitialText :
                               (validate(t, &m_bd->m_errorMessage) ? Valid : Invalid);
    setToolTip(m_bd->m_errorMessage);
    if (debug)
        qDebug() << Q_FUNC_INFO << t << "State" <<  m_bd->m_state << "->" << newState << m_bd->m_errorMessage;
    // Changed..figure out if valid changed. DisplayingInitialText is not valid,
    // but should not show error color. Also trigger on the first change.
    if (newState != m_bd->m_state || m_bd->m_firstChange) {
        const bool validHasChanged = (m_bd->m_state == Valid) != (newState == Valid);
        m_bd->m_state = newState;
        m_bd->m_firstChange = false;
        setTextColor(this, newState == Invalid ? m_bd->m_errorTextColor : m_bd->m_okTextColor);
        if (validHasChanged) {
            emit validChanged(newState == Valid);
            emit validChanged();
        }
    }
    bool block = blockSignals(true);
    const QString fixedString = fixInputString(t);
    if (t != fixedString) {
        const int cursorPos = cursorPosition();
        setText(fixedString);
        setCursorPosition(qMin(cursorPos, fixedString.length()));
    }
    blockSignals(block);
}
Example #22
0
int selectAlternateBootDevice(int bootdevice)
{
	int key;
	int newbootdevice;
	int digitsI = 0;
	char *end;
	char digits[3] = {0,0,0};

	// We've already printed the current boot device so user knows what it is
	printf("Typical boot devices are 80 (First HD), 81 (Second HD)\n");
	printf("Enter two-digit hexadecimal boot device [%02x]: ", bootdevice);
	do {
		key = getc();
		switch (key & kASCIIKeyMask) {
		case kBackspaceKey:
			if (digitsI > 0) {
				int x, y, t;
				getCursorPositionAndType(&x, &y, &t);
				// Assume x is not 0;
				x--;
				setCursorPosition(x,y,0); // back up one char
				// Overwrite with space without moving cursor position
				putca(' ', 0x07, 1);
				digitsI--;
			} else {
				// TODO: Beep or something
			}
			break;

		case kReturnKey:
			digits[digitsI] = '\0';
			newbootdevice = strtol(digits, &end, 16);
			if (end == digits && *end == '\0') {
				// User entered empty string
				printf("\nUsing default boot device %x\n", bootdevice);
				key = 0;
			} else if(end != digits && *end == '\0') {
				bootdevice = newbootdevice;
				printf("\n");
				key = 0; // We gots da boot device
			} else {
				printf("\nCouldn't parse. try again: ");
				digitsI = 0;
			}
			break;

		default:
			if (isxdigit(key & kASCIIKeyMask) && digitsI < 2) {
				putc(key & kASCIIKeyMask);
				digits[digitsI++] = key & kASCIIKeyMask;
			} else {
				// TODO: Beep or something
			}
			break;
		};
	} while (key != 0);

	return bootdevice;
}
Example #23
0
void PhoneInput::addedToNumber(const QString &added) {
    setFocus();
    QString was(text());
    setText(added + text());
    setCursorPosition(added.length());
    correctValue(0, was);
    updatePlaceholder();
}
Example #24
0
void aHistLineEdit::slot_insert( QString str )
{
  QString s = text();
  int curPos = cursorPosition();
  s.insert(curPos, str);
  setText(s);
  setCursorPosition(curPos + str.length());
}
Example #25
0
void consoleFill(int rows, int columns)
{
    int i, curRow;
    for(i = 0, curRow = 0; curRow<rows; i++, curRow = (i/columns))
    {
        int left = curRow %2 ? 0 : 1;
        int curColumn = left ? (columns-1)-i%columns : i%columns;
        int curColorPos = abs( (curColumn - curRow) % 3);
        if(curRow > curColumn)
            curColorPos = 2 - abs( (curColumn - curRow - 2) % 3);
        setCursorPosition(curColumn, curRow);
        setConsoleColor(curColorPos);
        printf("*"); /* " " is more beautiful */
        Sleep(1);
    }
    setCursorPosition(0, 0);
}
Example #26
0
/**
 * Updates display with a new temperature
 */
void Lcd::updateTemp(double temp)
{
	setCursorPosition(LCD_CURSOR_POS_TEMP_START);

	// Send temp to LCD
	lcdPort.print( temp, 2 );

} // end updateTemp
Example #27
0
void ScrollLine::setText( const QString &text )
{
   QLineEdit::setText( text );
   mDirection = 1;
   mPosition = 0;
   setCursorPosition( mPosition );
   clearFocus();
}
Example #28
0
void DocumentEditor::nextBookmark() {
	int line, index;
	getCursorPosition(&line, &index);

	line = markerFindNext(line+1, MARKER_BOOK_MASK);
	if (line >= 0) {
		setCursorPosition(line, 0);
		ensureLineVisible(line);
	} else {
		// check from start
		line = markerFindNext(0, MARKER_BOOK_MASK);
		if (line >= 0) {
			setCursorPosition(line, 0);
			ensureLineVisible(line);
		}
	}
}
Example #29
0
void DocumentEditor::prevBookmark() {
	int line, index;
	getCursorPosition(&line, &index);

	line = markerFindPrevious(line-1, MARKER_BOOK_MASK);
	if (line >= 0) {
		setCursorPosition(line, 0);
		ensureLineVisible(line);
	} else {
		// check from end
		line = markerFindPrevious(lines(), MARKER_BOOK_MASK);
		if (line >= 0) {
			setCursorPosition(line, 0);
			ensureLineVisible(line);
		}
	}
}
Example #30
0
/**
 * Set the text on the given line, something I feel is missing from the QScintilla API. Note
 * that like QScintilla line numbers start from 0
 * @param lineno :: A zero-based index representing the linenumber, 
 * @param txt :: The text to insert at the given line
 * @param index :: The position of text in a line number,default value is zero
 */
void ScriptEditor::setText(int lineno, const QString& txt,int index)
{
  int line_length = txt.length();
  // Index is max of the length of current/new text
  setSelection(lineno, index, lineno, qMax(line_length, this->text(lineno).length()));
  removeSelectedText();
  insertAt(txt, lineno, index);
  setCursorPosition(lineno, line_length);
}