void CATextField::analyzeString(std::string str,int len) { for (int i=0; i<len; i++) { if (str[i]>0&& str[i]<127) { // if (str[i]!=32) { insertText(str.substr(i,1).c_str(), 1); } // else // { // continue; // } } else { std::string ss= str.substr(i,3); insertText(ss.c_str(), 3); i+=2; } } }
void WndText::caseMsg( af::Msg * i_msg) { switch (i_msg->type()) { case af::Msg::TDATA: { qTextEdit->setPlainText( afqt::dtoq( i_msg->data(), i_msg->int32())); break; } case af::Msg::TString: { std::string str; i_msg->getString( str); if( str.size() == 0) str = "An empty string recieved."; qTextEdit->setPlainText( afqt::stoq( str)); break; } case af::Msg::TStringList: { std::list<std::string> strlist; i_msg->getStringList( strlist); if( strlist.size() == 0) strlist.push_back("An empty list recieved."); for( std::list<std::string>::const_iterator it = strlist.begin(); it != strlist.end(); it++) qTextEdit->append( afqt::stoq(*it)); break; } default: insertText("WndText::WndText: Invalid message:\n"); insertText( i_msg->v_generateInfoString()); } }
bool QuasarDB::sqlCreateLines(const Slip& slip) { QString cmd = insertText("slip_item", "slip_id", "seq_num,item_id," "number,size_name,size_qty,quantity,ext_cost"); Stmt stmt(_connection, cmd); for (unsigned int i = 0; i < slip.items().size(); ++i) { const SlipItem& line = slip.items()[i]; stmtSetId(stmt, slip.id()); stmtSetInt(stmt, i); stmtSetId(stmt, line.item_id); stmtSetString(stmt, line.number); stmtSetString(stmt, line.size); stmtSetFixed(stmt, line.size_qty); stmtSetFixed(stmt, line.quantity); stmtSetFixed(stmt, line.ext_cost); if (!execute(stmt)) return false; } cmd = insertText("slip_orders", "slip_id", "seq_num,order_number"); stmt.setCommand(cmd); for (unsigned int i = 0; i < slip.orders().size(); ++i) { stmtSetId(stmt, slip.id()); stmtSetInt(stmt, i); stmtSetString(stmt, slip.orders()[i]); if (!execute(stmt)) return false; } return true; }
extern void __rw_url(LimitRewriter *_this,u32 begin,u32 length) { u8 ch ; u32 stop,isfull,cur,count; isfull = 0; count = 0; if( _this->string[begin] == '\'' || _this->string[begin] == '\"' ) { begin ++; length-=2; } stop = begin + length; cur = begin; ch = _this->string[cur++] ; switch(ch) { case '/': if(_this->string[cur++] == '/') { for(; cur < stop; cur++) { if(_this->string[cur] == '.') { count++; } } if(count >= 2) { isfull = 2 ; // //www.baidu.com ... } } else { isfull = 3; // /aaa/bbb } goto exit_for; case 'h' : if((0 == strncmp((const char *)(_this->string+begin),"https://",8)) || \ (0 == strncmp((const char *)(_this->string+begin),"http://",7))) { isfull = 1 ; // is full URL } case '?' : // s?... case '&' : // s&... goto exit_for; } exit_for: if( isfull ) { insertText(_this->rw_token,begin,0,(u8*)_this->path); if( isfull == 1 ) insertText(_this->rw_token,begin,1,(u8*)"/"); else if (isfull == 2) insertText(_this->rw_token,begin,1,(u8*)"/http:"); } }
void TEditor::newLine() { const char crlf[] = "\x0D\x0A"; ushort p = lineStart(curPtr); ushort i = p; while( i < curPtr && ( (buffer[i] == ' ') || (buffer[i] == '\x9')) ) i++; insertText(crlf, 2, False); if( autoIndent == True ) insertText( &buffer[p], i - p, False); }
// Create a Cheque bool QuasarDB::create(Cheque& cheque) { if (!validate(cheque)) return false; if (!create((Gltx&)cheque)) return false; QString cmd = insertText("cheque", "cheque_id", "cheque_type," "account_id,disc_id,address"); Stmt stmt(_connection, cmd); stmtSetId(stmt, cheque.id()); stmtSetInt(stmt, cheque.type()); stmtSetId(stmt, cheque.accountId()); stmtSetId(stmt, cheque.discountId()); stmtSetString(stmt, cheque.address()); if (!execute(stmt)) return false; // Set next number in account cmd = "update account set next_number = ? where account_id = ?"; stmt.setCommand(cmd); stmtSetInt(stmt, cheque.number().toInt() + 1); stmtSetId(stmt, cheque.accountId()); if (!execute(stmt)) return false; commit(); dataSignal(DataEvent::Insert, cheque); return true; }
void TEditor::doSearchReplace() { int i; do { i = cmCancel; if( search(findStr, editorFlags) == False ) { if( (editorFlags & (efReplaceAll | efDoReplace)) != (efReplaceAll | efDoReplace) ) editorDialog( edSearchFailed ); } else if( (editorFlags & efDoReplace) != 0 ) { i = cmYes; if( (editorFlags & efPromptOnReplace) != 0 ) { TPoint c = makeGlobal( cursor ); i = editorDialog( edReplacePrompt, &c ); } if( i == cmYes ) { lock(); insertText( replaceStr, strlen(replaceStr), False); trackCursor(False); unlock(); } } } while( i != cmCancel && (editorFlags & efReplaceAll) != 0 ); }
bool Editor::handleEditingKeyboardEvent(KeyboardEvent* evt) { const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); // do not treat this as text input if it's a system key event if (!keyEvent || keyEvent->isSystemKey()) return false; String commandName = behavior().interpretKeyEvent(*evt); Command command = this->createCommand(commandName); if (keyEvent->type() == PlatformEvent::RawKeyDown) { // WebKit doesn't have enough information about mode to decide how // commands that just insert text if executed via Editor should be treated, // so we leave it upon WebCore to either handle them immediately // (e.g. Tab that changes focus) or let a keypress event be generated // (e.g. Tab that inserts a Tab character, or Enter). if (command.isTextInsertion() || commandName.isEmpty()) return false; return command.execute(evt); } if (command.execute(evt)) return true; if (!behavior().shouldInsertCharacter(*evt) || !canEdit()) return false; // Return true to prevent default action. e.g. Space key scroll. if (dispatchBeforeInputInsertText(evt->target(), evt->keyEvent()->text()) != DispatchEventResult::NotCanceled) return true; return insertText(evt->keyEvent()->text(), evt); }
void MgCommandLine::keyPressEvent(QKeyEvent * e) { if(e->key() == Qt::Key_Escape ) clear(); else if((e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) && m_scriptEngine && m_completer->popup()->isVisible()) { insertText(m_completer->popup()->currentIndex().data().toString()); m_completer->popup()->hide(); } else if((e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) && m_scriptEngine) { m_scriptEngine->execCommand(text()); clear(); } else if(e->key() == Qt::Key_Space && e->modifiers().testFlag(Qt::ControlModifier)) { if(!m_completer->popup()->isVisible()) { MgCommandCompleter completer(m_scriptEngine); MgCommandCompleter::CompletionResult result = completer.completionOf(text(),cursorPosition()); m_completer->setCompletionPrefix(""); m_prefix = result.prefix; m_completionModel->setStringList(result.completion); m_completer->complete(); } else { m_completer->popup()->hide(); } } else QLineEdit::keyPressEvent(e); }
MgCommandLine::MgCommandLine(QWidget * parent) :QLineEdit(parent),m_scriptEngine(0) { setStyleSheet(" " "QLineEdit {" "border: 1px solid darkgray;" "border-radius: 2px;" "padding: 0 8px;" "background: rgb(45,45,45);" "color: rgb(210,210,210);" "selection-background-color: darkgray;" "}"); m_completionModel = new QStringListModel(this); m_completionModel->setStringList(QStringList()); m_completer = new QCompleter(m_completionModel,this); m_completer->setCompletionMode(QCompleter::PopupCompletion); setCompleter(m_completer); disconnect(m_completer, 0, this, 0); connect(m_completer, SIGNAL(activated(QString)),this,SLOT(insertText(QString))); QPalette p = m_completer->popup()->palette(); p.setColor(QPalette::Base,QColor(45,45,45)); p.setColor(QPalette::Text,QColor(210,210,210)); m_completer->popup()->setPalette(p); m_completer->popup()->setWindowOpacity(.8); connect(this,SIGNAL(textChanged(QString)),this,SLOT(updateCompletion())); }
void View::commitPreeditHolder(QInputMethodEvent *e) { Q_D(View); QString newText = d->preeditHolder->text().replace(e->commitString(), ""); d->preeditHolder->setText(newText); insertText(e->commitString()); }
void KTextCursor::insertFragment( QList<QPair<QString,QTextCharFormat>>& frags ) { for(QList<QPair<QString,QTextCharFormat>>::iterator iter = frags.begin(); iter != frags.end(); iter++) { QPair<QString,QTextCharFormat>& item = *iter; QString text = item.first; QTextCharFormat fmt = item.second; if(text.at(0) == QChar::ObjectReplacementCharacter) { //图片 QTextImageFormat imgFmt = fmt.toImageFormat(); QString file = imgFmt.name(); if(!file.isEmpty()) { if(moviePool()->insertMovie(file, file)) { fmt.setProperty(KAnimationImage, true); document()->addResource(QTextDocument::ImageResource, QUrl(file), moviePool()->currentImage(file)); } else { QImage image(file); if(!image.isNull()) { document()->addResource(QTextDocument::ImageResource, QUrl(file), image); } } } } insertText(text, fmt); } }
Stack::Stack(QWidget* parent) : QWidget(parent), m_symbols_dialog(0), m_printer(0), m_current_document(0), m_footer_margin(0), m_header_margin(0), m_footer_visible(0), m_header_visible(0) { setMouseTracking(true); m_contents = new QStackedWidget(this); m_alerts = new AlertLayer(this); m_scenes = new SceneList(this); setScenesVisible(false); m_menu = new QMenu(this); m_menu_group = new QActionGroup(this); m_menu_group->setExclusive(true); connect(m_menu_group, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*))); m_find_dialog = new FindDialog(this); connect(m_find_dialog, SIGNAL(findNextAvailable(bool)), this, SIGNAL(findNextAvailable(bool))); connect(ActionManager::instance(), SIGNAL(insertText(QString)), this, SLOT(insertSymbol(QString))); m_layout = new QGridLayout(this); m_layout->setMargin(0); m_layout->setSpacing(0); m_layout->setRowMinimumHeight(1, 6); m_layout->setRowMinimumHeight(4, 6); m_layout->setRowStretch(2, 1); m_layout->setColumnMinimumWidth(1, 6); m_layout->setColumnMinimumWidth(4, 6); m_layout->setColumnStretch(1, 1); m_layout->setColumnStretch(2, 1); m_layout->setColumnStretch(3, 1); m_layout->addWidget(m_contents, 1, 0, 4, 6); m_layout->addWidget(m_scenes, 1, 0, 4, 3); m_layout->addWidget(m_alerts, 3, 3); m_resize_timer = new QTimer(this); m_resize_timer->setInterval(50); m_resize_timer->setSingleShot(true); connect(m_resize_timer, SIGNAL(timeout()), this, SLOT(updateBackground())); m_theme_renderer = new ThemeRenderer(this); connect(m_theme_renderer, SIGNAL(rendered(QImage,QRect,Theme)), this, SLOT(updateBackground(QImage,QRect))); setHeaderVisible(Preferences::instance().alwaysShowHeader()); setFooterVisible(Preferences::instance().alwaysShowFooter()); // Always draw background setAttribute(Qt::WA_OpaquePaintEvent); setAutoFillBackground(false); updateBackground(); }
void TypingCommand::doApply() { if (endingSelection().isNone()) return; if (m_commandType == DeleteKey) if (m_commands.isEmpty()) m_openedByBackwardDelete = true; switch (m_commandType) { case DeleteSelection: deleteSelection(m_smartDelete); return; case DeleteKey: deleteKeyPressed(m_granularity); return; case ForwardDeleteKey: forwardDeleteKeyPressed(m_granularity); return; case InsertLineBreak: insertLineBreak(); return; case InsertParagraphSeparator: insertParagraphSeparator(); return; case InsertParagraphSeparatorInQuotedContent: insertParagraphSeparatorInQuotedContent(); return; case InsertText: insertText(m_textToInsert, m_selectInsertedText); return; } ASSERT_NOT_REACHED(); }
void TextDocumentManipulator::replaceWithoutCheck(int position, int length, const QString &text) { auto cursor = m_textEditorWidget->textCursor(); cursor.setPosition(position); cursor.setPosition(position + length, QTextCursor::KeepAnchor); cursor.insertText(text); }
void CATextField::AndroidWillInsertText(int start,const char* str,int before,int count) { CCAssert(str != NULL, ""); CCAssert(count > 0, ""); insertText(str, (int)strlen(str)); }
void View::paste() { if (!isConnected()) return; const QMimeData *data = QApplication::clipboard()->mimeData(); if (data->hasText()) insertText(data->text(), 1); }
void CATextView::willInsertText(const char* text, int len) { execCurSelCharRange(); int iOldCurPos = m_iCurPos; insertText(text, len); m_curSelCharRange = std::make_pair(iOldCurPos, m_iCurPos); m_pTextSelView->showTextViewMark(getZZCRect()); }
void TextBase::inputTransition(EditData& ed, QInputMethodEvent* ie) { TextEditData* ted = static_cast<TextEditData*>(ed.getData(this)); TextCursor* _cursor = &ted->cursor; // remove preedit string int n = preEdit.size(); while (n--) { if (_cursor->movePosition(QTextCursor::Left)) { TextBlock& l = _cursor->curLine(); l.remove(_cursor->column()); _cursor->text()->triggerLayout(); _cursor->text()->setTextInvalid(); } } qDebug("<%s><%s> len %d start %d, preEdit size %d", qPrintable(ie->commitString()), qPrintable(ie->preeditString()), ie->replacementLength(), ie->replacementStart(), preEdit.size()); if (!ie->commitString().isEmpty()) { _cursor->format()->setPreedit(false); score()->startCmd(); insertText(ed, ie->commitString()); score()->endCmd(); preEdit.clear(); } else { preEdit = ie->preeditString(); if (!preEdit.isEmpty()) { #if 0 for (auto a : ie->attributes()) { switch(a.type) { case QInputMethodEvent::TextFormat: { qDebug(" attribute TextFormat: %d-%d", a.start, a.length); QTextFormat tf = a.value.value<QTextFormat>(); } break; case QInputMethodEvent::Cursor: qDebug(" attribute Cursor at %d", a.start); break; default: qDebug(" attribute %d", a.type); } } #endif _cursor->format()->setPreedit(true); _cursor->updateCursorFormat(); editInsertText(_cursor, preEdit); setTextInvalid(); layout1(); score()->update(); } } ie->accept(); }
void SciDoc::replaceSelectedText(const QString& text, bool cursorToTheEnd) { if ( int_->curEdit_ == NULL ) return; int line1, col1, line2, col2; if ( !int_->curEdit_->hasSelectedText() ) { // no selected text - just insert the text we have if ( !text.isEmpty() ) { getCursorPos(line1, col1); int_->curEdit_->beginUndoAction(); insertText(text); if ( cursorToTheEnd ) { moveCursorToTheEnd(line1, col1, text); } int_->curEdit_->endUndoAction(); } } else { int_->curEdit_->getSelection(&line1, &col1, &line2, &col2); int_->curEdit_->beginUndoAction(); // hack! hack! hack! disconnect(int_->edit1_, SIGNAL(textChanged()), this, SIGNAL(textChanged())); removeSelectedText(); // hack! hack! hack! connect(int_->edit1_, SIGNAL(textChanged()), this, SIGNAL(textChanged())); if ( text.isEmpty() ) { // need to emit the signal manually emit textChanged(); } else { insertText(text); } if ( cursorToTheEnd ) { moveCursorToTheEnd(line1, col1, text); } else { int_->curEdit_->setCursorPosition(line1, col1); } int_->curEdit_->endUndoAction(); } }
void TypingCommand::insertText(Document* document, const String& text, bool selectInsertedText, bool insertedTextIsComposition) { ASSERT(document); Frame* frame = document->frame(); ASSERT(frame); insertText(document, text, frame->selection()->selection(), selectInsertedText, insertedTextIsComposition); }
void LiveDataWidget::insertNewItem(const QString shortName, const QString &catalog, const QString &lang, QSqlDatabase &db) { _isAddNew = false; QSqlQuery query(db); if (!query.prepare(QString("SELECT max(ID) from [LiveData") + lang + QString("]"))) { return; } if (!query.exec()) { return; } if (!query.next()) { return; } int count = query.value(0).toInt() + 1; QString cmdID = _commandIDBox->currentText(); QString algID = _algorithmIDBox->currentText(); //QString insertText("INSERT INTO [LiveData"); //insertText += lang; //insertText += QString("] VALUES(%1, '%2', '%3', '%4', '%5', %6, %7, '%8')") // .arg(count).arg(shortName).arg(_contentEdits.value(lang)->toPlainText()) // .arg(_defEdits.value(lang)->text()) // .arg(_unitEdit->text()) // .arg(cmdID.isEmpty() ? "-1" : cmdID) // .arg(algID.isEmpty() ? "-1" : algID) // .arg(catalog); QString insertText("INSERT INTO [LiveData"); insertText.append(lang); insertText.append(QString("] VALUES(:id, :shortName, :content, :defaultValue, :unit, :cmdID, :algID, :catalog)")); if (!query.prepare(insertText)) { QString str = query.lastError().databaseText(); return; } query.bindValue(":id", count); query.bindValue(":shortName", shortName); query.bindValue(":content", _contentEdits.value(lang)->toPlainText()); query.bindValue(":defaultValue", _defEdits.value(lang)->text()); query.bindValue(":unit", _unitEdit->text()); query.bindValue(":cmdID", cmdID.isEmpty() ? -1 : cmdID.toInt()); query.bindValue(":algID", algID.isEmpty() ? -1 : algID.toInt()); query.bindValue(":catalog", catalog); query.exec(); }
void telnetText(char *text){ static guchar tbuffer[BUFFER_SIZE]; static gboolean vtSeq=FALSE; static gchar vtBuf[16]; static gint vtPos=0; gint pos=0; gint pos2=4; if ((gboolean) MW_GET("TELNET_SILENT")) return; // interne Meldung ausgeben. if (text[pos]=='<' && text[pos+1]=='c' && text[pos+3]=='>'){ insertText(MW_GET("TELNET_VIEW"), txtIn(text), TRUE); return; } // externe Meldung ausgeben. tbuffer[0]='<'; tbuffer[1]='c';tbuffer[2]='0';tbuffer[3]='>'; while(text[pos]){ if (text[pos]==27){ vtSeq=TRUE; tbuffer[pos2]=0; pos2=4; insertText(MW_GET("TELNET_VIEW"), txtIn(tbuffer), TRUE); } if (vtSeq==TRUE){ if (text[pos]==109){ vtSeq=FALSE; vtPos=0; tbuffer[2]='0'; if (!strncmp(vtBuf, "133", 3)) tbuffer[2]='1'; if (!strncmp(vtBuf, "134", 3)) tbuffer[2]='2'; if (!strncmp(vtBuf, "135", 3)) tbuffer[2]='3'; if (!strncmp(vtBuf, "136", 3)) tbuffer[2]='4'; if (!strncmp(vtBuf, "137", 3)) tbuffer[2]='5'; } if ((text[pos]>='0') && (text[pos]<='9')) vtBuf[vtPos++]=text[pos]; pos++; } else tbuffer[pos2++] = text[pos++]; } tbuffer[pos2]=0; insertText(MW_GET("TELNET_VIEW"), txtIn(tbuffer), TRUE); }
void QConsoleWidget::setPrompt(const QString &v) { auto __insertText=[ this]( const QString & t, const QTextCharFormat & f ) { { auto tc = this->textCursor(); tc.clearSelection(); this ->setTextCursor(tc); } auto tc = this->textCursor(); tc.insertText(t, f); this->setTextCursor(tc); }; //TODO: QConsoleWidget::setPrompt { prompt_ = v.simplified(); _pf<void, MoveToEnd>(this); { auto * document_ = this->document(); auto tc_ = this->textCursor(); QChar current_char_ = document_->characterAt(tc_.position()); //QChar::LineSeparator; ; if ( (tc_.columnNumber()==0) && ( (current_char_ == QChar::ParagraphSeparator) ) ){ /* 如果以换行符开头就不必添加新行 */ promptBeginPos_ = this->textCursor().position(); __insertText(prompt_, thisp->textCharFormat); promptEndPos_ = this->textCursor().position(); _pf<void, UpdatePromptWidget>(this); _pf<void, MoveToEnd>(this); } else { /* 添加新行 */ __insertText("\n", thisp->textCharFormat); __insertText(prompt_, thisp->textCharFormat); promptEndPos_ = this->textCursor().position(); promptBeginPos_ = promptEndPos_ - prompt_.size(); _pf<void, UpdatePromptWidget>(this); _pf<void, MoveToEnd>(this); } } } }
void QSvgText::insertLineBreak() { if (m_type == TEXTAREA) { if (m_paragraphs.back().isEmpty()) insertText(QLatin1String(" "), Preserve); m_appendSpace = false; m_paragraphs.push_back(QString()); m_formatRanges.push_back(QList<QTextLayout::FormatRange>()); } }
///////////////// Report Builder - INTERNAL /////////////////// // These functions build the different sections of the report /////////////////////////////////////////////////////////////// void MediationProcess::TextToCell(QTextTable* table, int row, int col, QString txt, QTextCharFormat* textFormat, QTextTableCellFormat* cellFormat) { if(!textFormat) textFormat = &_tableTextFormat; auto cell = table->cellAt(row, col); if(cellFormat) cell.setFormat(*cellFormat); auto cellCursor = cell.firstCursorPosition(); cellCursor.insertText(txt, *textFormat); }
void CATextView::setText(const std::string& var) { CATextViewDelegate* pTemp = m_pTextViewDelegate; m_pTextViewDelegate = NULL; m_szText.clear(); m_iCurPos = 0; m_vLinesTextView.clear(); insertText(var.c_str(), var.length()); m_pTextViewDelegate = pTemp; }
void CATextView::pasteFromClipboard() { std::string cszText = CAClipboard::getText(); insertText(cszText.c_str(), (int)cszText.size()); #if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView(); pGlView->setIMECursorPos(getCursorPos(), getContentText()); #endif }
void Lyrics::paste(MuseScoreView* scoreview) { #if defined(Q_OS_MAC) || defined(Q_OS_WIN) QClipboard::Mode mode = QClipboard::Clipboard; #else QClipboard::Mode mode = QClipboard::Selection; #endif QString txt = QApplication::clipboard()->text(mode); QStringList sl = txt.split(QRegExp("\\s+"), QString::SkipEmptyParts); if (sl.isEmpty()) return; QStringList hyph = sl[0].split("-"); bool minus = false; if(hyph.length() > 1) { insertText(hyph[0]); hyph.removeFirst(); sl[0] = hyph.join("-"); minus = true; } else if (sl.length() > 1 && sl[1] == "-") { insertText(sl[0]); sl.removeFirst(); sl.removeFirst(); minus = true; } else { insertText(sl[0]); sl.removeFirst(); } layout(); score()->setLayoutAll(true); score()->end(); txt = sl.join(" "); QApplication::clipboard()->setText(txt, mode); if (minus) scoreview->lyricsMinus(); else scoreview->lyricsTab(false, false, true); }
void KTextCursor::insertText( const QString &displayName, const QColor &color, const QString &linkValue, const QString &linkKey, bool bUnderLine ) { Q_D(KTextCursor); QTextCharFormat linkFormat; linkFormat.setFontUnderline(bUnderLine); linkFormat.setForeground(color); insertText(displayName, linkFormat, linkValue, linkKey); }